Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79968 > unrolled thread

Classes

Started bySeymore4Head <Seymore4Head@Hotmail.invalid>
First post2014-10-30 16:16 -0400
Last post2014-10-31 14:56 -0400
Articles 20 on this page of 68 — 20 participants

Back to article view | Back to comp.lang.python


Contents

  Classes   Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-30 16:16 -0400
    Re: Classes sohcahtoa82@gmail.com - 2014-10-30 13:33 -0700
      Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-30 17:00 -0400
    Re: Classes Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-10-30 13:34 -0700
      Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-30 17:00 -0400
    Re: Classes Larry Hudson <orgnut@yahoo.com> - 2014-10-30 14:28 -0700
      Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-30 17:34 -0400
        Re: Classes sohcahtoa82@gmail.com - 2014-10-30 18:21 -0700
        Re: Classes alister <alister.nospam.ware@ntlworld.com> - 2014-10-31 09:59 +0000
          Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 10:07 -0400
    Re: Classes   "ast" <nomail@invalid.com> - 2014-10-31 10:05 +0100
      Re: Classes   "ast" <nomail@invalid.com> - 2014-10-31 10:18 +0100
        Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-10-31 20:21 +1100
      Re: Classes   Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 10:05 -0400
        Re: Classes Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-31 08:47 -0600
          Re: Classes Grant Edwards <invalid@invalid.invalid> - 2014-10-31 15:49 +0000
            Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 12:31 -0400
              Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 03:37 +1100
                Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 12:47 -0400
                  Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 04:02 +1100
                    Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 13:31 -0400
                      Re: Classes Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-31 12:39 -0500
                        Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 13:57 -0400
                      Re: Classes Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-10-31 10:40 -0700
                  Re: Classes Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-01 11:17 +1300
                    Re: Classes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-01 12:06 +1100
                      Re: Classes Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-01 00:12 -0600
                      Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 17:32 +1100
                      Re: Classes Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-03 00:32 +1300
              Re: Classes Dave Angel <davea@davea.name> - 2014-10-31 13:20 -0400
              Re: Classes Marko Rauhamaa <marko@pacujo.net> - 2014-10-31 19:35 +0200
              Re: Classes Grant Edwards <invalid@invalid.invalid> - 2014-10-31 17:40 +0000
              Re: Classes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-31 18:26 -0400
                Re: Classes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-01 12:09 +1100
        Re: Classes   Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-01 04:06 +1100
          Re: Classes   Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 13:18 -0400
            Re: Classes Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-10-31 10:43 -0700
              Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 14:18 -0400
                Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 14:42 -0400
                Re: Classes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-31 18:57 -0400
                  Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 19:22 -0400
                    Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 19:32 -0400
                      Re: Classes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-01 12:00 -0400
                        Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-01 12:42 -0400
                          Re: Classes Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-02 09:50 +0000
                            Re: Classes Tim Delaney <timothy.c.delaney@gmail.com> - 2014-11-02 21:32 +1100
                              Re: Classes Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-02 12:27 +0000
                                Re: Classes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-02 11:31 -0500
                                  Re: Classes Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-03 03:12 +0000
                                    Re: Classes Dan Sommers <dan@tombstonezero.net> - 2014-11-03 06:29 +0000
                                      Re: Classes Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-04 01:10 +0000
                                        Re: Classes Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-04 18:30 +1300
                                    Re: Classes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-03 08:50 -0500
                                    Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-04 02:34 +1100
                                Re: Classes Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-03 07:47 -0700
                            Re: Classes Larry Hudson <orgnut@yahoo.com> - 2014-11-02 14:03 -0800
              Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 07:51 +1100
                Re: Classes sohcahtoa82@gmail.com - 2014-10-31 14:24 -0700
                  Re: Classes Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-10-31 14:40 -0700
                    Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 08:56 +1100
                  Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 08:36 +1100
            Re: Classes Grant Edwards <invalid@invalid.invalid> - 2014-10-31 17:43 +0000
      Re: Classes Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-10-31 14:11 +0000
      Re: Classes   Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 12:49 -0400
        Re: Classes   "ast" <nomail@invalid.com> - 2014-10-31 19:31 +0100
          Re: Classes   Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 14:36 -0400
          Re: Classes Joel Goldstick <joel.goldstick@gmail.com> - 2014-10-31 14:41 -0400
            Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 14:56 -0400

Page 1 of 4  [1] 2 3 4  Next page →


#79968 — Classes

FromSeymore4Head <Seymore4Head@Hotmail.invalid>
Date2014-10-30 16:16 -0400
SubjectClasses
Message-ID<51755at03r0bidjqh3qf0hhpvjr8756ill@4ax.com>
class pet: 
    def set_age(self,age):
        self.age=age
    def get_age(self):
        return self.age
pax=pet
pax.set_age(4)

Traceback (most recent call last):
  File "C:\Functions\test.py", line 18, in <module>
    pax.set_age(4)
TypeError: set_age() missing 1 required positional argument: 'age'

I am trying to pass 4 as the age.  Obviously I am doing it wrong.

[toc] | [next] | [standalone]


#79969

Fromsohcahtoa82@gmail.com
Date2014-10-30 13:33 -0700
Message-ID<7337e0d9-19cd-4a42-907d-9bc676327ae8@googlegroups.com>
In reply to#79968
On Thursday, October 30, 2014 1:19:57 PM UTC-7, Seymore4Head wrote:
> class pet: 
>     def set_age(self,age):
>         self.age=age
>     def get_age(self):
>         return self.age
> pax=pet
> pax.set_age(4)
> 
> Traceback (most recent call last):
>   File "C:\Functions\test.py", line 18, in <module>
>     pax.set_age(4)
> TypeError: set_age() missing 1 required positional argument: 'age'
> 
> I am trying to pass 4 as the age.  Obviously I am doing it wrong.

The line `pax=pet` doesn't create an instance of your pet class, it creates essentially a copy of the class definition.

You need `pax=pet()`

Or preferably, `pax = pet()`.  The spaces are optional, but they make it more readable.

[toc] | [prev] | [next] | [standalone]


#79971

FromSeymore4Head <Seymore4Head@Hotmail.invalid>
Date2014-10-30 17:00 -0400
Message-ID<im955apfpjj92ojfn81tv75c4j6k9id89q@4ax.com>
In reply to#79969
On Thu, 30 Oct 2014 13:33:01 -0700 (PDT), sohcahtoa82@gmail.com wrote:

>On Thursday, October 30, 2014 1:19:57 PM UTC-7, Seymore4Head wrote:
>> class pet: 
>>     def set_age(self,age):
>>         self.age=age
>>     def get_age(self):
>>         return self.age
>> pax=pet
>> pax.set_age(4)
>> 
>> Traceback (most recent call last):
>>   File "C:\Functions\test.py", line 18, in <module>
>>     pax.set_age(4)
>> TypeError: set_age() missing 1 required positional argument: 'age'
>> 
>> I am trying to pass 4 as the age.  Obviously I am doing it wrong.
>
>The line `pax=pet` doesn't create an instance of your pet class, it creates essentially a copy of the class definition.
>
>You need `pax=pet()`
>
>Or preferably, `pax = pet()`.  The spaces are optional, but they make it more readable.

Thanks

[toc] | [prev] | [next] | [standalone]


#79970

FromRob Gaddi <rgaddi@technologyhighland.invalid>
Date2014-10-30 13:34 -0700
Message-ID<20141030133404.44c0875e@rg.highlandtechnology.com>
In reply to#79968
On Thu, 30 Oct 2014 16:16:51 -0400
Seymore4Head <Seymore4Head@Hotmail.invalid> wrote:

> class pet: 
>     def set_age(self,age):
>         self.age=age
>     def get_age(self):
>         return self.age
> pax=pet
> pax.set_age(4)
> 
> Traceback (most recent call last):
>   File "C:\Functions\test.py", line 18, in <module>
>     pax.set_age(4)
> TypeError: set_age() missing 1 required positional argument: 'age'
> 
> I am trying to pass 4 as the age.  Obviously I am doing it wrong.
> 

The reason your call is missing the positional argument is that 4 is
being assigned to self, rather than to age, so there is no age.  This is
because you are trying to call a function of the class object, rather
than a function of an instance of the class.

pax=pet()

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.

[toc] | [prev] | [next] | [standalone]


#79972

FromSeymore4Head <Seymore4Head@Hotmail.invalid>
Date2014-10-30 17:00 -0400
Message-ID<pn955apeatfhmkjbjiidotluuaa1qg9i3b@4ax.com>
In reply to#79970
On Thu, 30 Oct 2014 13:34:04 -0700, Rob Gaddi
<rgaddi@technologyhighland.invalid> wrote:

>On Thu, 30 Oct 2014 16:16:51 -0400
>Seymore4Head <Seymore4Head@Hotmail.invalid> wrote:
>
>> class pet: 
>>     def set_age(self,age):
>>         self.age=age
>>     def get_age(self):
>>         return self.age
>> pax=pet
>> pax.set_age(4)
>> 
>> Traceback (most recent call last):
>>   File "C:\Functions\test.py", line 18, in <module>
>>     pax.set_age(4)
>> TypeError: set_age() missing 1 required positional argument: 'age'
>> 
>> I am trying to pass 4 as the age.  Obviously I am doing it wrong.
>> 
>
>The reason your call is missing the positional argument is that 4 is
>being assigned to self, rather than to age, so there is no age.  This is
>because you are trying to call a function of the class object, rather
>than a function of an instance of the class.
>
>pax=pet()
Thanks

[toc] | [prev] | [next] | [standalone]


#79973

FromLarry Hudson <orgnut@yahoo.com>
Date2014-10-30 14:28 -0700
Message-ID<ctCdnVN2I5HoMM_JnZ2dnUU7-N2dnZ2d@giganews.com>
In reply to#79968
On 10/30/2014 01:16 PM, Seymore4Head wrote:
> class pet:
>      def set_age(self,age):
>          self.age=age
>      def get_age(self):
>          return self.age
> pax=pet
> pax.set_age(4)
>
> Traceback (most recent call last):
>    File "C:\Functions\test.py", line 18, in <module>
>      pax.set_age(4)
> TypeError: set_age() missing 1 required positional argument: 'age'
>
> I am trying to pass 4 as the age.  Obviously I am doing it wrong.
>
You have already received the answer -- pax=pet should be pax=pet(), but I have a simple 
side-comment about style.  It is common Python convention to capitalize class names, IOW make 
this class Pet instead of class pet.  This is convention not a requirement, but it does help 
distinguish class names from ordinary variable names -- especially to others reading your code 
(as well as yourself a few days later).   ;-)

      -=- Larry -=-

[toc] | [prev] | [next] | [standalone]


#79974

FromSeymore4Head <Seymore4Head@Hotmail.invalid>
Date2014-10-30 17:34 -0400
Message-ID<ukb55adn593v64in8c3aleghdfl1av5af1@4ax.com>
In reply to#79973
On Thu, 30 Oct 2014 14:28:19 -0700, Larry Hudson <orgnut@yahoo.com>
wrote:

>On 10/30/2014 01:16 PM, Seymore4Head wrote:
>> class pet:
>>      def set_age(self,age):
>>          self.age=age
>>      def get_age(self):
>>          return self.age
>> pax=pet
>> pax.set_age(4)
>>
>> Traceback (most recent call last):
>>    File "C:\Functions\test.py", line 18, in <module>
>>      pax.set_age(4)
>> TypeError: set_age() missing 1 required positional argument: 'age'
>>
>> I am trying to pass 4 as the age.  Obviously I am doing it wrong.
>>
>You have already received the answer -- pax=pet should be pax=pet(), but I have a simple 
>side-comment about style.  It is common Python convention to capitalize class names, IOW make 
>this class Pet instead of class pet.  This is convention not a requirement, but it does help 
>distinguish class names from ordinary variable names -- especially to others reading your code 
>(as well as yourself a few days later).   ;-)
>
>      -=- Larry -=-

I try to take typing shortcuts and it bites me in the behind.
Good suggestion
Thanks

[toc] | [prev] | [next] | [standalone]


#79983

Fromsohcahtoa82@gmail.com
Date2014-10-30 18:21 -0700
Message-ID<9b71b42d-220f-4d08-990f-d3873d87245a@googlegroups.com>
In reply to#79974
On Thursday, October 30, 2014 2:37:54 PM UTC-7, Seymore4Head wrote:
> On Thu, 30 Oct 2014 14:28:19 -0700, Larry Hudson <orgnut@yahoo.com>
> wrote:
> 
> >On 10/30/2014 01:16 PM, Seymore4Head wrote:
> >> class pet:
> >>      def set_age(self,age):
> >>          self.age=age
> >>      def get_age(self):
> >>          return self.age
> >> pax=pet
> >> pax.set_age(4)
> >>
> >> Traceback (most recent call last):
> >>    File "C:\Functions\test.py", line 18, in <module>
> >>      pax.set_age(4)
> >> TypeError: set_age() missing 1 required positional argument: 'age'
> >>
> >> I am trying to pass 4 as the age.  Obviously I am doing it wrong.
> >>
> >You have already received the answer -- pax=pet should be pax=pet(), but I have a simple 
> >side-comment about style.  It is common Python convention to capitalize class names, IOW make 
> >this class Pet instead of class pet.  This is convention not a requirement, but it does help 
> >distinguish class names from ordinary variable names -- especially to others reading your code 
> >(as well as yourself a few days later).   ;-)
> >
> >      -=- Larry -=-
> 
> I try to take typing shortcuts and it bites me in the behind.
> Good suggestion
> Thanks

A shortcut is the fastest way to get somewhere you weren't going.

Python makes programming very easy (Compared to C/C++ and many other languages), but there are still a lot of shortcuts you can't make.

[toc] | [prev] | [next] | [standalone]


#80004

Fromalister <alister.nospam.ware@ntlworld.com>
Date2014-10-31 09:59 +0000
Message-ID<64J4w.766648$dz3.103993@fx20.am4>
In reply to#79974
On Thu, 30 Oct 2014 17:34:57 -0400, Seymore4Head wrote:

> On Thu, 30 Oct 2014 14:28:19 -0700, Larry Hudson <orgnut@yahoo.com>
> wrote:
> 
>>On 10/30/2014 01:16 PM, Seymore4Head wrote:
>>> class pet:
>>>      def set_age(self,age):
>>>          self.age=age
>>>      def get_age(self):
>>>          return self.age
>>> pax=pet pax.set_age(4)
>>>
>>> Traceback (most recent call last):
>>>    File "C:\Functions\test.py", line 18, in <module>
>>>      pax.set_age(4)
>>> TypeError: set_age() missing 1 required positional argument: 'age'
>>>
>>> I am trying to pass 4 as the age.  Obviously I am doing it wrong.
>>>
>>You have already received the answer -- pax=pet should be pax=pet(), but
>>I have a simple side-comment about style.  It is common Python
>>convention to capitalize class names, IOW make this class Pet instead of
>>class pet.  This is convention not a requirement, but it does help
>>distinguish class names from ordinary variable names -- especially to
>>others reading your code (as well as yourself a few days later).   ;-)
>>
>>      -=- Larry -=-
> 
> I try to take typing shortcuts and it bites me in the behind.
> Good suggestion Thanks

If shortcuts were safe and easy they would not be shortcuts they would be 
the way.

It is best to avoid shortcuts whilst learning untill you know the full 
implications. you will find your learning goes much smother & faster.




-- 
We are all in the gutter, but some of us are looking at the stars.
		-- Oscar Wilde

[toc] | [prev] | [next] | [standalone]


#80016

FromSeymore4Head <Seymore4Head@Hotmail.invalid>
Date2014-10-31 10:07 -0400
Message-ID<9r575a55lsmns61lnbucauuk6vs1p74l16@4ax.com>
In reply to#80004
On Fri, 31 Oct 2014 09:59:30 GMT, alister
<alister.nospam.ware@ntlworld.com> wrote:

>On Thu, 30 Oct 2014 17:34:57 -0400, Seymore4Head wrote:
>
>> On Thu, 30 Oct 2014 14:28:19 -0700, Larry Hudson <orgnut@yahoo.com>
>> wrote:
>> 
>>>On 10/30/2014 01:16 PM, Seymore4Head wrote:
>>>> class pet:
>>>>      def set_age(self,age):
>>>>          self.age=age
>>>>      def get_age(self):
>>>>          return self.age
>>>> pax=pet pax.set_age(4)
>>>>
>>>> Traceback (most recent call last):
>>>>    File "C:\Functions\test.py", line 18, in <module>
>>>>      pax.set_age(4)
>>>> TypeError: set_age() missing 1 required positional argument: 'age'
>>>>
>>>> I am trying to pass 4 as the age.  Obviously I am doing it wrong.
>>>>
>>>You have already received the answer -- pax=pet should be pax=pet(), but
>>>I have a simple side-comment about style.  It is common Python
>>>convention to capitalize class names, IOW make this class Pet instead of
>>>class pet.  This is convention not a requirement, but it does help
>>>distinguish class names from ordinary variable names -- especially to
>>>others reading your code (as well as yourself a few days later).   ;-)
>>>
>>>      -=- Larry -=-
>> 
>> I try to take typing shortcuts and it bites me in the behind.
>> Good suggestion Thanks
>
>If shortcuts were safe and easy they would not be shortcuts they would be 
>the way.
>
>It is best to avoid shortcuts whilst learning untill you know the full 
>implications. you will find your learning goes much smother & faster.

Good advice.

[toc] | [prev] | [next] | [standalone]


#80001

From"ast" <nomail@invalid.com>
Date2014-10-31 10:05 +0100
Message-ID<545350c3$0$23449$426a74cc@news.free.fr>
In reply to#79968
"Seymore4Head" <Seymore4Head@Hotmail.invalid> a écrit dans le message de 
news:51755at03r0bidjqh3qf0hhpvjr8756ill@4ax.com...
> class pet:
>    def set_age(self,age):
>        self.age=age
>    def get_age(self):
>        return self.age
> pax=pet
> pax.set_age(4)
>
> Traceback (most recent call last):
>  File "C:\Functions\test.py", line 18, in <module>
>    pax.set_age(4)
> TypeError: set_age() missing 1 required positional argument: 'age'
>
> I am trying to pass 4 as the age.  Obviously I am doing it wrong.
>

Hi

I am a beginner too, but I find it strange that your
pet class has no __init__ method to construct
instances 

[toc] | [prev] | [next] | [standalone]


#80002

From"ast" <nomail@invalid.com>
Date2014-10-31 10:18 +0100
Message-ID<545353dd$0$2326$426a74cc@news.free.fr>
In reply to#80001
"ast" <nomail@invalid.com> a écrit dans le message de news:545350c3$0$23449$426a74cc@news.free.fr...

> I am a beginner too, but I find it strange that your
> pet class has no __init__ method to construct
> instances

It works anyway because __init__ is taken in the
parent Class, probably Object.

But this means that a method can create a new
attribute not previously created with __init__.
Is that correct ? 

[toc] | [prev] | [next] | [standalone]


#80003

FromChris Angelico <rosuav@gmail.com>
Date2014-10-31 20:21 +1100
Message-ID<mailman.15347.1414747313.18130.python-list@python.org>
In reply to#80002
On Fri, Oct 31, 2014 at 8:18 PM, ast <nomail@invalid.com> wrote:
>
> But this means that a method can create a new
> attribute not previously created with __init__.
> Is that correct ?

That's always the case. There's nothing special about __init__ for
creating attributes.

ChrisA

[toc] | [prev] | [next] | [standalone]


#80015

FromSeymore4Head <Seymore4Head@Hotmail.invalid>
Date2014-10-31 10:05 -0400
Message-ID<bj575ahusmihp1fpm58gmcr2eg0g8k21o6@4ax.com>
In reply to#80001
On Fri, 31 Oct 2014 10:05:03 +0100, "ast" <nomail@invalid.com> wrote:

>
>"Seymore4Head" <Seymore4Head@Hotmail.invalid> a écrit dans le message de 
>news:51755at03r0bidjqh3qf0hhpvjr8756ill@4ax.com...
>> class pet:
>>    def set_age(self,age):
>>        self.age=age
>>    def get_age(self):
>>        return self.age
>> pax=pet
>> pax.set_age(4)
>>
>> Traceback (most recent call last):
>>  File "C:\Functions\test.py", line 18, in <module>
>>    pax.set_age(4)
>> TypeError: set_age() missing 1 required positional argument: 'age'
>>
>> I am trying to pass 4 as the age.  Obviously I am doing it wrong.
>>
>
>Hi
>
>I am a beginner too, but I find it strange that your
>pet class has no __init__ method to construct
>instances 

Because the topic of that lesson was getter setter.
I can construct an __init___  but I was practicing get/set.
This stuff is coming to me slowly.  I need to rinse and repeat quite a
few more times, before I follow what is going on.

[toc] | [prev] | [next] | [standalone]


#80020

FromIan Kelly <ian.g.kelly@gmail.com>
Date2014-10-31 08:47 -0600
Message-ID<mailman.15358.1414766892.18130.python-list@python.org>
In reply to#80015
On Fri, Oct 31, 2014 at 8:05 AM, Seymore4Head
<Seymore4Head@hotmail.invalid> wrote:
> Because the topic of that lesson was getter setter.
> I can construct an __init___  but I was practicing get/set.

Doesn't sound like a very good lesson to me. Getters and setters are
the Java way of doing things. The Pythonic way is to just use an
attribute, and then replace it with a property in the unlikely event
that getter/setter logic needs to be added.

[toc] | [prev] | [next] | [standalone]


#80021

FromGrant Edwards <invalid@invalid.invalid>
Date2014-10-31 15:49 +0000
Message-ID<m30b2n$gpu$1@reader2.panix.com>
In reply to#80020
On 2014-10-31, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Fri, Oct 31, 2014 at 8:05 AM, Seymore4Head
><Seymore4Head@hotmail.invalid> wrote:
>> Because the topic of that lesson was getter setter.
>> I can construct an __init___  but I was practicing get/set.
>
> Doesn't sound like a very good lesson to me.

It's not.  It's teaching java or C++ or some other language while
using a Python compiler.

> Getters and setters are the Java way of doing things. The Pythonic
> way is to just use an attribute, and then replace it with a property
> in the unlikely event that getter/setter logic needs to be added.

Exactly.

-- 
Grant Edwards               grant.b.edwards        Yow! I have the power to
                                  at               HALT PRODUCTION on all
                              gmail.com            TEENAGE SEX COMEDIES!!

[toc] | [prev] | [next] | [standalone]


#80022

FromSeymore4Head <Seymore4Head@Hotmail.invalid>
Date2014-10-31 12:31 -0400
Message-ID<iae75a5j9ec1qv8as3n5bipl2milv6kolm@4ax.com>
In reply to#80021
On Fri, 31 Oct 2014 15:49:43 +0000 (UTC), Grant Edwards
<invalid@invalid.invalid> wrote:

>On 2014-10-31, Ian Kelly <ian.g.kelly@gmail.com> wrote:
>> On Fri, Oct 31, 2014 at 8:05 AM, Seymore4Head
>><Seymore4Head@hotmail.invalid> wrote:
>>> Because the topic of that lesson was getter setter.
>>> I can construct an __init___  but I was practicing get/set.
>>
>> Doesn't sound like a very good lesson to me.
>
>It's not.  It's teaching java or C++ or some other language while
>using a Python compiler.
>
>> Getters and setters are the Java way of doing things. The Pythonic
>> way is to just use an attribute, and then replace it with a property
>> in the unlikely event that getter/setter logic needs to be added.
>
>Exactly.

In this class, we will follow the practice of accessing the contents
of objects using methods known as getters and setters. While not
required by Python, this practice encourages the user of the class to
manipulates class objects solely via class methods. The advantage of
following this practice is that the implementer of the class
definition (often someone other than the user of the class) may
restructure the organization of the data fields associated with the
object while avoiding the need to rewrite code that uses the class.

[toc] | [prev] | [next] | [standalone]


#80023

FromChris Angelico <rosuav@gmail.com>
Date2014-11-01 03:37 +1100
Message-ID<mailman.15359.1414773458.18130.python-list@python.org>
In reply to#80022
On Sat, Nov 1, 2014 at 3:31 AM, Seymore4Head
<Seymore4Head@hotmail.invalid> wrote:
[presumably quoting his course material]
> In this class, we will follow the practice of accessing the contents
> of objects using methods known as getters and setters. While not
> required by Python, this practice encourages the user of the class to
> manipulates class objects solely via class methods. The advantage of
> following this practice is that the implementer of the class
> definition (often someone other than the user of the class) may
> restructure the organization of the data fields associated with the
> object while avoiding the need to rewrite code that uses the class.

Yep, that's teaching C++/Java coding using Python. Isn't it time you
got onto a better course? Time and time again you've been going down
inadvisable paths, and it seems to me you could do better with the
inbuilt tutorial rather than this kind of course.

ChrisA

[toc] | [prev] | [next] | [standalone]


#80025

FromSeymore4Head <Seymore4Head@Hotmail.invalid>
Date2014-10-31 12:47 -0400
Message-ID<q3f75adqkbhvq4nek8h35qq5sti04l0o4t@4ax.com>
In reply to#80023
On Sat, 1 Nov 2014 03:37:29 +1100, Chris Angelico <rosuav@gmail.com>
wrote:

>On Sat, Nov 1, 2014 at 3:31 AM, Seymore4Head
><Seymore4Head@hotmail.invalid> wrote:
>[presumably quoting his course material]
>> In this class, we will follow the practice of accessing the contents
>> of objects using methods known as getters and setters. While not
>> required by Python, this practice encourages the user of the class to
>> manipulates class objects solely via class methods. The advantage of
>> following this practice is that the implementer of the class
>> definition (often someone other than the user of the class) may
>> restructure the organization of the data fields associated with the
>> object while avoiding the need to rewrite code that uses the class.
>
>Yep, that's teaching C++/Java coding using Python. Isn't it time you
>got onto a better course? Time and time again you've been going down
>inadvisable paths, and it seems to me you could do better with the
>inbuilt tutorial rather than this kind of course.
>
>ChrisA
inbuilt tutorial?

The course is free.  You can't beat the price.  It is only for a few
more weeks.

Trying to learn from reading the Internet has no set direction.  I
need a little nudge.  More like a shove.

[toc] | [prev] | [next] | [standalone]


#80028

FromChris Angelico <rosuav@gmail.com>
Date2014-11-01 04:02 +1100
Message-ID<mailman.15361.1414774962.18130.python-list@python.org>
In reply to#80025
On Sat, Nov 1, 2014 at 3:47 AM, Seymore4Head
<Seymore4Head@hotmail.invalid> wrote:
> inbuilt tutorial?
>
> The course is free.  You can't beat the price.  It is only for a few
> more weeks.
>
> Trying to learn from reading the Internet has no set direction.  I
> need a little nudge.  More like a shove.

https://docs.python.org/3/tutorial/

Same price.

ChrisA

[toc] | [prev] | [next] | [standalone]


Page 1 of 4  [1] 2 3 4  Next page →

Back to top | Article view | comp.lang.python


csiph-web