looking for way to include many times some .py code from anotherpython code

Peter Hansen peter at engcorp.com
Tue Mar 8 16:59:08 CET 2005


Martin MOKREJŠ wrote:
> Am I so deperately fighting the language? No-one here on the list needs 
> to set hundreds variables at once somewhere in their code? 

Nobody needs to do that.  As others have pointed out, creating variables
implies wanting to access them distinctly, not as a whole group.  If
you are just going to access them as a group, use contain objects such
as lists or dicts or a custom class, not individual variables.

> Now have to figure out how to assign them easily into the XML tree.

This might be the hint that others were hoping for, about your
real requirements.  Do you mean to say that the whole reason
you have for assigning hundreds of variables is to go and
shove the values right back into another data structure such
as an XML document?  If so, trust us, you very likely don't
want to do it by assigning and then referencing hundreds of
variables.

-Peter



More information about the Python-list mailing list