Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46398 > unrolled thread
| Started by | andrea crotti <andrea.crotti.0@gmail.com> |
|---|---|
| First post | 2013-05-29 18:55 +0100 |
| Last post | 2013-05-29 18:55 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Getting a callable for any value? andrea crotti <andrea.crotti.0@gmail.com> - 2013-05-29 18:55 +0100
| From | andrea crotti <andrea.crotti.0@gmail.com> |
|---|---|
| Date | 2013-05-29 18:55 +0100 |
| Subject | Re: Getting a callable for any value? |
| Message-ID | <mailman.2368.1369850161.3114.python-list@python.org> |
[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 top | Article view | comp.lang.python
csiph-web