This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年06月12日 01:04 by bcward, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg107620 - (view) | Author: Bryan Ward (bcward) | Date: 2010年06月12日 01:04 | |
It would be convenient to be able to access the resultant options from optparse using the syntax options['some_option'] instead of options.some_option Or additionally it would be nice to have a way to produce a dictionary of the options. This would be nice to have to do something to the effect of dictOptions = options.to_dict() obj = SomeObject(**dictOptions) |
|||
| msg107635 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年06月12日 08:38 | |
Thanks for your report and your ideas for Python :) Some remarks: 1) New features have to target 3.2; 2.6 is the current stable version (only security and documentation fixes) and 2.7 is to be released really soon (end of the 2.x line); 2) Can you explain why options['thing'] would be more convenient than options.thing? 3) You can get a dict today with vars(options). (By the way, please open two reports for two requests in the futures.) 4) optparse is superseded by argparse, I don’t know if new features will be added to optparse. |
|||
| msg107694 - (view) | Author: Steven Bethard (bethard) * (Python committer) | Date: 2010年06月12日 20:27 | |
Given that the one obvious way of using dict-style syntax given a Python object is to call vars(), I thing adding a __getitem__ is probably a bad idea. |
|||
| msg107697 - (view) | Author: Bryan Ward (bcward) | Date: 2010年06月12日 20:40 | |
Thanks for your help and I apologize for the unnecessary ticket. I was unfamiliar with vars() which seems to accomplish what I wanted. |
|||
| msg107698 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年06月12日 20:43 | |
Don’t hesitate to propose future ideas to the python-ideas mailing list http://mail.python.org/mailman/listinfo/python-ideas |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:02 | admin | set | github: 53225 |
| 2010年06月12日 20:43:10 | eric.araujo | set | resolution: rejected messages: + msg107698 stage: resolved |
| 2010年06月12日 20:40:26 | bcward | set | status: open -> closed messages: + msg107697 |
| 2010年06月12日 20:27:52 | bethard | set | messages: + msg107694 |
| 2010年06月12日 13:45:53 | r.david.murray | set | nosy:
+ bethard |
| 2010年06月12日 08:38:47 | eric.araujo | set | nosy:
+ eric.araujo messages: + msg107635 |
| 2010年06月12日 01:04:22 | bcward | create | |