Re: Over my head with descriptors

2006-12-18 Thread Sarcastic Zombie
> > Is there a reason you don't just use __init__ instead of __new__, and use > > "self.age" and "self.weight" and so on?I was asking myself the same thing... > > Chris "A lack of understanding," he answered sheepishly. There are attributes (ie, question._qtext) that I do want to be the same for

Over my head with descriptors

2006-12-14 Thread Sarcastic Zombie
Code included below. Basically, I've created a series of "question" descriptors, which each hold a managed value. This is so I can implement validation, and render each field into html automatically for forms. My problem is this: every instance of my "wizard" class has unique self values, but the

Re: Overloading "if object" unary operator

2006-11-29 Thread Sarcastic Zombie
On Nov 29, 11:26 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Sarcastic Zombie wrote: > > is there any way to overload the 'if' unary usage to detect if a > > variable has a value?Define a __nonzero__() or __len__() method. > > Peter Thanks to both of

Overloading "if object" unary operator

2006-11-29 Thread Sarcastic Zombie
Good morning, If I have a class class A: __init__(id) self.id = id is there any way to overload the 'if' unary usage to detect if a variable has a value? For example, in the code: a = A(56) if a: print "Hoo hah!" how can I insure that the if will come back true and fire off th