Ryan,
> So if you don't care about portability or about that dirty feeling you get
> from messing with the Python internals, then have at it :-)
Warnings aside, its very clever code. Thanks for sharing!
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 2010-04-21 at 19:43 -0400, pyt...@bdurham.com wrote:
> Ryan,
>
> Your withhacks module looks very interesting.
> http://pypi.python.org/pypi/withhacks
>
> What are your specific concerns about its use? Are there portability
> concerns?
It combines two things you just don't see in respec
Ryan,
Your withhacks module looks very interesting.
http://pypi.python.org/pypi/withhacks
What are your specific concerns about its use? Are there portability
concerns?
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Ryan Kelly wrote:
On Tue, 2010-04-20 at 14:43 +0100, 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 wi
On Tue, 2010-04-20 at 14:43 +0100, 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 wit
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
You can do something like this:
>>> class A(): pass
>>> inst=A()
>>> exec("""
... a=1
... 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 is not recommended. If you mess
w
Alan Harris-Reid wrote:
Jean-Michel Pichavant 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 with
Ethan Furman wrote:
Alan Harris-Reid wrote:
The code is not usually in class.__init__ (otherwise I would have
used the self. prefix), but I like your self.__dict__.update(...)
solution and I'll try and remember it.
The code I was thinking of goes something like as follows (don't have
a speci
Chris Rebert wrote:
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
clas
Xavier Ho wrote:
On Wed, Apr 21, 2010 at 7:59 AM, Alan Harris-Reid
mailto: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
Alan Harris-Reid wrote:
The code is not usually in class.__init__ (otherwise I would have used
the self. prefix), but I like your self.__dict__.update(...) solution
and I'll try and remember it.
The code I was thinking of goes something like as follows (don't have a
specific example to hand,
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
Jean-Michel Pichavant 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
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 prefix? Before Python
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
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 = 1
> class1.attr2 = 2
> class1.attr3 = 3
> class1.attr4 = 4
> etc.
>
> Is there any way to achieve the same result without having to rep
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
class1 prefix? Before Pyt
22 matches
Mail list logo