Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Alan Gauld
On 08/09/14 03:31, Juan Christian wrote: @property def steamid(self): return self._steamid Unless you specifically *need* these fields to be read-only you don't need the property declarations. Just use the _XXX convention to signal that they are *intended* to be private and allow clien

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Danny Yoo
@property def _avatar(self): return self._avatar >> >> Hi Joel, >> >> The above code looks strange to me. The method and the field name >> should not use the same name. > > ah! good catch Danny. I didn't write it, I was commenting on the OP code. > > But (and maybe this was discuss

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Joel Goldstick
On Sun, Sep 7, 2014 at 11:01 PM, Danny Yoo wrote: >>> @property >>> def _avatar(self): >>> return self._avatar > > Hi Joel, > > The above code looks strange to me. The method and the field name > should not use the same name. ah! good catch Danny. I didn't write it, I was commenting on the OP c

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Danny Yoo
>> @property >> def _avatar(self): >> return self._avatar Hi Joel, The above code looks strange to me. The method and the field name should not use the same name. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: ht

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Joel Goldstick
On Sun, Sep 7, 2014 at 10:31 PM, Juan Christian wrote: > So... I tried to follow all what you guys said: > > user.py module: > > import urllib.request > import json > > class User(): > > def __init__(self, steamid, personaname, lastlogoff, profileurl, avatar, > timecreated, loccountrycode): > self

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Juan Christian
So... I tried to follow all what you guys said: user.py module: import urllib.request import json class User(): def __init__(self, steamid, personaname, lastlogoff, profileurl, avatar, timecreated, loccountrycode): self._steamid = steamid self._personaname = personaname self._lastlogoff = lastl

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Steven D'Aprano
On Mon, Sep 08, 2014 at 04:01:01AM +1000, Steven D'Aprano wrote a bunch of stuff about the User class... Ah, sorry guys, I did *not* intend to send that post. It's probably a bit incoherent, and certainly unfinished. I hit the wrong key and my mail program sent it. If I get time to finish it

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Steven D'Aprano
On Sun, Sep 07, 2014 at 12:00:15AM -0300, Juan Christian wrote: > I'm writing a program that have a 'User' class. This class will have the > following attributes: > > 1. id > 2. personaname > 3. lastlogoff > 4. profileurl > 5. avatar > 6. realname > 7. timecreated > 8. loccountrycode > > I'm thin

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Juan Christian
> > > On Sun, Sep 7, 2014 at 5:04 AM, Peter Otten <__pete...@web.de> wrote: > > > I would call it with ID only and them the API server would return me > > all the info, and then I would set them. I didn't learn '@classmethod' > > decoration yet, but I presume it would work as a 'get()', right? The

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Peter Otten
Juan Christian wrote: > On Sun, Sep 7, 2014 at 5:04 AM, Peter Otten <__pete...@web.de> wrote: >> >> It's not a good approach and it's not pythonic. >> >> In Python you should avoid accessor functions and (pseudo-)private >> __attributes ("Python is not Java"). So >> >> class User: >> def __ini

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Juan Christian
On Sun, Sep 7, 2014 at 5:04 AM, Peter Otten <__pete...@web.de> wrote: > > It's not a good approach and it's not pythonic. > > In Python you should avoid accessor functions and (pseudo-)private > __attributes ("Python is not Java"). So > > class User: > def __init__(self, id): > self.id

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Peter Otten
Juan Christian wrote: > I'm writing a program that have a 'User' class. This class will have the > following attributes: > > 1. id > 2. personaname > 3. lastlogoff > 4. profileurl > 5. avatar > 6. realname > 7. timecreated > 8. loccountrycode > > I'm thinking about writing something like that:

Re: [Tutor] Good approach regarding classes attributes

2014-09-07 Thread Alan Gauld
On 07/09/14 04:00, Juan Christian wrote: I'm writing a program that have a 'User' class. This class will have the following attributes: 1. id 2. personaname 3. lastlogoff 4. profileurl 5. avatar 6. realname 7. timecreated 8. loccountrycode I'm thinking about writing something like that: http://

[Tutor] Programming for Everybody (Python) - Oct 6, University of Michigan

2014-09-07 Thread Mario Py
Here is another Python course that starts October 6 2014: https://www.coursera.org/course/pythonlearn ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor