Martin MOKREJŠ wrote:
Peter Hansen wrote:

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.


I understand, but this is unfortunately not my case now. It's really
about assigning data from mysql to some variables and getting them later
checked. The checks will be different for most variables and will even
differ if I read from sql or alternatively I instantiate first new data
obtained from web interface and write subsequently into sql (for example,
all row ID's won't be known while instantiating the objects).

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


No, the xml is another reason why I wanted to walk over the __dict__
of some object and let something magically constrcut the XML tree for me.
But this is really another, distinct problem from teh one I posted originally.


want to do it by assigning and then referencing hundreds of
variables.


I need to test almost every for it's content. Some tests
are just that the value is non-empty (few cases), but in most cases
a lot more checks (only certain values allowed, or only int type allowed,
or only \w is allowed ...).

FYI: The program/database runs at the moment under php + mysql.

I will be *very* surprised if you can't get a much better (i.e. easier and more efficient) solution by stepping back from the programming details for a moment and explaining what it is you are actually trying to achieve in user-space.

Can you describe the problem you are trying to solve, rather than the solution you are hoping to adopt?

regards
 Steve

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to