kachayev / fn.py

Functional programming in Python: implementation of missing features to enjoy FP
Other
3.35k stars 203 forks source link

Fix error with __repl__ calculation for _ with getattr #22

Closed kachayev closed 11 years ago

kachayev commented 11 years ago
>>> from fn import _ as XXX
>>> from fn.op import flip
>>> print flip(XXX + XXX)
(x1, x2, x3, x4, x5, x6) => getattr((x1 + x2), x3x4flipbackx5x6)
KangOl commented 11 years ago

I don't have the same output.

>>> from fn.op import flip
>>> from fn import _ as X
>>> flip(X+X)
<function _flipper at 0x10f789758>
>>> str(flip(X+X))
'<function _flipper at 0x10f78d488>'
kachayev commented 11 years ago

Oh, this was another issue, that I have already fixed today (#23). Another example:

>>> from fn import _ as X
>>> X + X
(_ + _)
>>> (X + X).now
getattr((_ + _), now)
>>> str(_)
'(x1, x2) => getattr((x1 + x2), now)'
>>> (X + X).__and_now__
getattr((_ + _), __and_now__)
>>> str(_)
'(x1, x2, x3, x4, x5, x6, x7) => getattr((x1 + x2), x3x4andx5nowx6x7)'
KangOl commented 11 years ago

Ok, I see what the error is. I have a patch for it. Pull request soon (but will depend on another one)