in statement and namespace type ideas
Bjorn Pettersen
BPettersen at NAREX.com
Sat Jun 16 17:02:10 EDT 2001
More information about the Python-list mailing list
Sat Jun 16 17:02:10 EDT 2001
- Previous message (by thread): Slightly Off Topic : restrictions on the response part in a SOAP-response
- Next message (by thread): in statement and namespace type ideas
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> From: Roman Suzi [mailto:rnd at onego.ru] > > Hello, > > right now namespace handling in Python uses dicts, > however, docs say it could change. > > I can't be sure that my code which uses globals() to merge, > for example, > cgi-form variables with globals namespace will work with future Python I think this is a Perl'ism which we shouldn't repeat here (it only works if the cgi vars are valid Python vars, otherwise it will blow up rather ungracefully). > versions. There are other examples where I need to transfer some > variables from one namespace to another. Dict is good type > for namespace, > but maybe it's time to propose new mapping type - namespace - > to do things I described? > > I also thought about absent "with" operator and how it could be used > in Python. Maybe it is beneficial to have "with" syntax like in the > followin example: [snip example] > Are these ideas worth serious consideration? Perhaps, although I didn't find anything particularly compelling in your argument. Moving values from one namespace to another is easily handled by return values and assignment -- or if you're returning a large number of variables, by wrapping them in an object or a dictionary. The "with" keyword leads to a lot of implied context (especially when nested). While it may make code easier to write for a "lazy" programmer, readability and maintainability suffers. I think "explicit is better than implicit" is the better alternative here. -- bjorn
- Previous message (by thread): Slightly Off Topic : restrictions on the response part in a SOAP-response
- Next message (by thread): in statement and namespace type ideas
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list