Does Python need a semantics for and/or over generators ? was : 'xor' operator?
Andrae Muys
amuys at shortech.com.au
Mon Apr 15 20:08:36 EDT 2002
More information about the Python-list mailing list
Mon Apr 15 20:08:36 EDT 2002
- Previous message (by thread): Does Python need a semantics for and/or over generators ? was : 'xor' operator?
- Next message (by thread): Does Python need a semantics for and/or over generators ? was : 'xor' operator?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Boris Borcic <borcis at geneva-link.ch> wrote in message news:<3CBABA71.3040909 at geneva-link.ch>... > Indeed, shouldn't two generators g1 and g2, when combined > in an expression of the form e.g. "g1 and g2" or "g1 or g2", > combine meaningfully to become a third generator ? Respectively > one that returns a successive value of g2 for every value that > g1 returns, until one of them returns IterationError, Ahh you would mean [yield elem for tupl in xzip(g1, g2) for elem in tupl] > and one > that concatenates the values of g1 with the values of g2 ? [yield elem for tupl in (g1, g2) for elem in tupl] I personally don't see these as being natural applications of and/or to lists. As far as concatenation is concerned, I remain a little surprised that '+' isn't defined for generators, after all it is for lists and has a well defined semantic that is obvious. I have always found the absense of a multiply method on lists strange, I personally would have expected it to perform a cartesian product. Still it's easy enough to do long hand, so it doesn't really bother me, especially given the non-intuitive ordering required if you want to handle infintate generators at all gracefully. Andrae Muys
- Previous message (by thread): Does Python need a semantics for and/or over generators ? was : 'xor' operator?
- Next message (by thread): Does Python need a semantics for and/or over generators ? was : 'xor' operator?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list