Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46403
| References | <CAA=1kxRDu5CCL-MNj-K4hG2Xrex5tM6x-C=U+h5-Mwy3dqDuOw@mail.gmail.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2013-05-29 12:24 -0600 |
| Subject | Re: Getting a callable for any value? |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2373.1369851922.3114.python-list@python.org> (permalink) |
On Wed, May 29, 2013 at 12:19 PM, Fábio Santos <fabiosantosart@gmail.com> wrote: > Are you sure you don't want to use a lambda expression? They are pretty > pythonic. > > none_factory = lambda: None > defaultdict_none_factory = lambda: defaultdict(none_factory) > > collections.defaultdict(defaultdict_none_factory) Gah. If you're going to go to the trouble of assigning a name to the lambda, then just use a def statement: def none_factory: return None def defaultdict_none_factory: return defaultdict(none_factory) collections.defaultdict(defaultdict_none_factory)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Getting a callable for any value? Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-29 12:24 -0600
csiph-web