Class extension confusion :(

r0g at
Thu Nov 11 22:17:56 CET 2010

On 11/11/10 19:34, r0g wrote:
> On 11/11/10 09:34, Peter Otten wrote:
>> r0g wrote:
> If I understand correctly it may also be possible
> (and more efficient) to use setattr() to inject the parameters I want
> into the class as class attributes before use, rather than assigning
> them to data attributes every time I instantiate an new instance.

Ah, it's even simpler than that, turns out I've been significantly 
overcomplicating things, I can just set the class attributes by calling 
classname.attributename = whatever once at the start of my script. The 
one thing I might need to change as the server runs is the paths 
dictionary but dicts are mutable so that's no problem and I don't need 
to inject any data into the instances at all. I'm guessing I can 
subclass that easily now too - happy days!

Well, far from wasted time it's been a very educational diversion, cheers :)


More information about the Python-list mailing list