Nick Vatamaniuc wrote: > Dave, > > Sometimes generating classes from .ini or XML files is not the best > way. You are just translating one language into another and are making > bigger headaches for your self. It is certainly cool and bragable to > say that "my classes get generated on the fly from XML" but Python is > terse and reasonable enough to just write it in Python. In other words > instead of saying <turbine> <power>2MW</power></turbine> just write > some Python code that instantiates a turbine with a 2MW power based on > your class. Then you can evaluate Python code in Python and you even > got your on-the-fly generation. > As a general rule, I would say to think 3 times before touching XML in > Python unless you are absolutely forced to. Config .ini files can be > more acceptable but Python is still best. Why write > ;;My turbine class > [turbine] > power=2MW > speed=800rpm > ... > when you can just say: > #my turbine class > t=Turbine( power="2MW", \ > speed="800rpm", \ > ... > First case is a little shorter but then you have to use a parser for it
There's one builtin. > while in the second case you just execute the file, and besides, you > can edit it with any Python editor. > This is certainly nice when the users are able to write python code, but that's not always the case. Also, it can be dangerous to directly execute user's python code... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list