Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46398 > unrolled thread

Re: Getting a callable for any value?

Started byandrea crotti <andrea.crotti.0@gmail.com>
First post2013-05-29 18:55 +0100
Last post2013-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.


Contents

  Re: Getting a callable for any value? andrea crotti <andrea.crotti.0@gmail.com> - 2013-05-29 18:55 +0100

#46398 — Re: Getting a callable for any value?

Fromandrea crotti <andrea.crotti.0@gmail.com>
Date2013-05-29 18:55 +0100
SubjectRe: 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web