> > > If you need this for **kw arguments maybe you're not using them right; > why not name your arguments if you're going to reference them by name? > Good point. > > The JSON use case seems to be driven because this is the way > JavaScript does things -- they don't distinguish between dicts and > objects. I personally think that's a poor language feature: it blurs a > line that should be clear, between data (dict keys) and program > variables (attributes). > > OK. So if this is a json-only issue, it can be done using a wrapper and object_hook in the json library. I believe that, since all the magic functions are pulled from the class, not the instance, you should even be able to use "if 'a' in wrapped_dict:" and "for a in wrapped_dict:" if your wrapper class delegates __contains__ and __iter__ to the underlying dict. Anyway, you can use hasattr for the former. So my overarching proposal has shrunk to a suggestion that I should go and make a attrlyjson module which does this by default. I certainly think that I can get it right, and I know that there are several easy ways to get it wrong, so it's worth saving people the headache. Jameson -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20110324/4dab1b40/attachment-0001.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4