Andreas Löscher wrote:
You can do something like this:
class A(): pass
inst=)
exec("""
... a=
... b=2
... c=3
... d=4
... """) in inst.__dict__
inst.a
1
This executes the Statement in the exec function and uses inst.__dict__
as namespace. But be aware, that this
On Tue, Apr 20, 2010 at 2:59 PM, Alan Harris-Reid
wrote:
> Stefan Behnel wrote:
>> Alan Harris-Reid, 20.04.2010 15:43:
>>> During my Python (3.1) programming I often find myself having to repeat
>>> code such as...
>>>
>>> class1.attr1 = 1
>>> class1.attr2 = 2
>>> class1.attr3 = 3
>>> class1.attr4
On Wed, Apr 21, 2010 at 7:59 AM, Alan Harris-Reid <
aharrisr...@googlemail.com> wrote:
> The code is not usually in class.__init__ (otherwise I would have used the
> self. prefix)
Alan, if your variables are not usually in __init__, what's preventing you
from using class variables like this:
>>
Stefan Behnel wrote:
Alan Harris-Reid, 20.04.2010 15:43:
During my Python (3.1) programming I often find myself having to repeat
code such as...
class1.attr1 = 1
class1.attr2 = 2
class1.attr3 = 3
class1.attr4 = 4
etc.
Is there any way to achieve the same result without having to repeat the
cla
Iain King wrote:
On Apr 20, 2:43 pm, Alan Harris-Reid
wrote:
Hi,
During my Python (3.1) programming I often find myself having to repeat
code such as...
class1.attr1 =
class1.attr2 =
class1.attr3 =
class1.attr4 =
etc.
Is there any way to achieve the same result without having to repeat th
Peter Otten wrote:
Alan Harris-Reid wrote:
Hi,
During my Python (3.1) programming I often find myself having to repeat
code such as...
class1.attr1 = 1
class1.attr2 = 2
class1.attr3 = 3
class1.attr4 = 4
etc.
Is there any way to achieve the same result without having to repeat the
class1 p