[Python-Dev] functools additions (original) (raw)
SevenInchBread adamadamadamamiadam at gmail.com
Mon Apr 16 00🔞16 CEST 2007
- Previous message: [Python-Dev] Python 2.5.1c1 pickle problem
- Next message: [Python-Dev] functools additions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Do you have commit access? What's your real name? I prefer to remain pseudonymous, and I don't have commit access.
Yeah... they're not terribly useful - more or less there for the sake of being there. Batteries included and all that
...but now I've got a more useful idea for a function wrapper around predicate functions to make them a little more functionally inclined. Something like.......
@predicate def hasnext(x): return hasattr(x, "next")
@predicate def hasiter(x): return hasattr(x, "iter")
isiterable = hasnext or hasiter #or/and/not operators construct new predicate functions
isEmptyIterable = isiterable and not predicate(bool)
isgenerator = isiterable and (lambda x: hasattr(x, "send") and hasattr(x, "throw"))
filter(isgenerator or callable, SomeSequence)
-- "What's money? A man is a success if he gets up in the morning and goes to bed at night and in between does what he wants to do." ~ Bob Dylan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20070415/2f20f155/attachment.htm
- Previous message: [Python-Dev] Python 2.5.1c1 pickle problem
- Next message: [Python-Dev] functools additions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]