Re: class attribute

2016-01-28 Thread Joel Goldstick
On Thu, Jan 28, 2016 at 9:56 AM, Chris Angelico wrote: > On Fri, Jan 29, 2016 at 12:56 AM, jmp wrote: > > My guess is that models.Model has a metclass. Without going too much int > > details, the metaclass may change the class structure when it's created. > > > > django is very specific and very

Re: class attribute

2016-01-28 Thread Todd Dembrey
On 28/01/16 13:15, ast wrote: hello Here is a class from django framework from django.db import models class Article(models.Model): titre = models.CharField(max_length=100) auteur = models.CharField(max_length=42) contenu = models.TextField(null=True) date = models.DateTimeField(

Re: class attribute

2016-01-28 Thread Chris Angelico
On Fri, Jan 29, 2016 at 12:56 AM, jmp wrote: > My guess is that models.Model has a metclass. Without going too much int > details, the metaclass may change the class structure when it's created. > > django is very specific and very database oriented. > > " > article = Article(titre="Bonjour", aute

Re: class attribute

2016-01-28 Thread ast
"ast" a écrit dans le message de news:56aa1474$0$27833$426a7...@news.free.fr... OK, thank you for answer I didn't studied metaclass yet that's why it is not clear for me. I have to take a look at that concept first -- https://mail.python.org/mailman/listinfo/python-list

Re: class attribute

2016-01-28 Thread jmp
On 01/28/2016 02:15 PM, ast wrote: hello Here is a class from django framework from django.db import models class Article(models.Model): titre = models.CharField(max_length=100) auteur = models.CharField(max_length=42) contenu = models.TextField(null=True) date = models.DateT

Re: class attribute confusion

2010-12-05 Thread Steve Holden
On 12/3/2010 11:58 PM, Steven D'Aprano wrote: > Right. If you define a *class* attribute, it lives in the class, not the > instance, and so all instances share the same value. Unless, of course, an instance binds the same name in its namespace, in which case it will (usually) mask the class attri

Re: class attribute confusion

2010-12-04 Thread Steven D'Aprano
On Sat, 04 Dec 2010 15:00:43 +0100, Omar Abo-Namous wrote: >>> I think this behaviour is totally wrong, since it seems >>> A.__init__(self) is changing the value inside of A() not inside of the >>> object variable 'self' (that should be x or y)!! >> It's not wrong at all. You expect "mylist" to b

Re: class attribute confusion

2010-12-04 Thread Omar Abo-Namous
Am 03.12.2010 23:11, schrieb Arnaud Delobelle: OAN writes: Hi, i was having a problem with class attributes initiated outside of __init__. This code is a demonstration of what i mean: class A(): mylist = [] def __init__(self): self.mylist.append(1) pass class B(A

Re: class attribute confusion

2010-12-03 Thread Steven D'Aprano
On Fri, 03 Dec 2010 22:54:19 +0100, OAN wrote: > Hi, > > i was having a problem with class attributes initiated outside of > __init__. This code is a demonstration of what i mean: [...] > I would expect the following result: > > v: [1] > x: [1, 2] > y: [1, 2] > z: [1] > v: [1] > > Who wouldn't,

Re: class attribute confusion

2010-12-03 Thread Arnaud Delobelle
OAN writes: > Hi, > > i was having a problem with class attributes initiated outside of > __init__. This code is a demonstration of what i mean: > > class A(): > mylist = [] > def __init__(self): > self.mylist.append(1) > pass > > class B(A): > def __init__(self): >

Re: class attribute to instance attribute

2005-07-05 Thread Greg Ewing
Donnal Walter wrote: > Each "presenter" (instance) needs its own "view" (instance). The class > attribute references a wxPython class. The resulting instance attribute > references a wxPython object (widget or container). This is a reasonable idea, but it would be less confusing to give the cla

Re: class attribute to instance attribute

2005-07-01 Thread Devan L
Well, I've never heard of a method like that for assigning variables. I'd rather put it in the __init__ method. -- http://mail.python.org/mailman/listinfo/python-list

Re: class attribute to instance attribute

2005-07-01 Thread Donnal Walter
Devan L wrote: > Why make it an instance attribute? Couldn't you just look at > the class attribute? Each "presenter" (instance) needs its own "view" (instance). The class attribute references a wxPython class. The resulting instance attribute references a wxPython object (widget or container)

Re: class attribute to instance attribute

2005-06-30 Thread Devan L
Why make it an instance attribute? Couldn't you just look at the class attribute? If its something that depends on each instance's value assigned to the attribute, why not make it an instance attribute to start with? -- http://mail.python.org/mailman/listinfo/python-list