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
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
with __dict__, you
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 is
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 without having
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
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
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 respectable
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
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 my previous main
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
On Apr 20, 2:43 pm, Alan Harris-Reid aharrisr...@googlemail.com
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
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?
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
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
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
Iain King wrote:
On Apr 20, 2:43 pm, Alan Harris-Reid aharrisr...@googlemail.com
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
Stefan Behnel wrote:
div class=moz-text-flowedAlan 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
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:
On Tue, Apr 20, 2010 at 2:59 PM, Alan Harris-Reid
aharrisr...@googlemail.com 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
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,
Xavier Ho wrote:
On Wed, Apr 21, 2010 at 7:59 AM, Alan Harris-Reid
aharrisr...@googlemail.com 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
Chris Rebert wrote:
On Tue, Apr 20, 2010 at 2:59 PM, Alan Harris-Reid
aharrisr...@googlemail.com 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
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
There is the following source structure:
/packages/...
/packages/global_settings.py # this is the global settings file
imported from each client settings file
/clients/...
/clients/client1/settings.py # client specific settings file (see code
above), each client is running in its own process so
My settings file
---
from global_settings import *
SITE_FOLDER = 'mypipe'
SITE_DOMAIN = 'localhost'
SITE_NAME = 'My Pipe'
SITE_ID = 1
TEMPLATE_DIRS = (/clients/+SITE_FOLDER+/templates, /packages/apps/
templates)
MEDIA_FILES_PREFIX = 'http://'+SITE_DOMAIN+'/media/'
for cfg in settings_modules:
cfg.TEMPLATE_DIRS = (/clients/+ cfg.SITE_FOLDER+/templates,
/packages/apps/templates)
cfg.MEDIA_FILES_PREFIX = 'http://'+ cfg.SITE_DOMAIN+'/media/'
cfg.VIDEO_FILES_URL = 'http://'+ cfg.SITE_DOMAIN+'/video/'
cfg.VIDEO_FILES_ROOT = '/clients/'+
26 matches
Mail list logo