Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46398
| Date | 2013-05-29 18:55 +0100 |
|---|---|
| From | andrea crotti <andrea.crotti.0@gmail.com> |
| Subject | Re: Getting a callable for any value? |
| References | <CANm61jeHSZL1FQvTr9FS0QKEhFPXug0fibXBEA-4guYF1Lf7UQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2368.1369850161.3114.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On 05/29/2013 06:46 PM, Croepha wrote: > Is there anything like this in the standard library? > > class AnyFactory(object): > def __init__(self, anything): > self.product = anything > def __call__(self): > return self.product > def __repr__(self): > return "%s.%s(%r)" % (self.__class__.__module__, > self.__class__.__name__, self.product) > > my use case is: > collections.defaultdict(AnyFactory(collections.defaultdict(AnyFactory(None)))) > I think I would scratch my head for a good half an hour if I see a string like this, so I hope there isn't anything in the standard library to do that :D
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Getting a callable for any value? andrea crotti <andrea.crotti.0@gmail.com> - 2013-05-29 18:55 +0100
csiph-web