santinic / pampy

Pampy: The Pattern Matching for Python you always dreamed of.
MIT License
3.52k stars 125 forks source link

Weird behavior with the default match operator #23

Open JGailor opened 5 years ago

JGailor commented 5 years ago
>>> from pampy import match, _

>>> _
_

>>> def matcher(val):
...     return match(val, int, "int", _, "something else",)

>>> matcher("hi")
'something else'

>>> matcher(1)
'int'

>>> matcher("hi")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in matcher
  File "/usr/local/lib/python3.7/site-packages/pampy/pampy.py", line 186, in match
    raise MatchError("'_' not provided. This case is not handled:\n%s" % str(var))
pampy.pampy.MatchError: '_' not provided. This case is not handled:
hi

'_' not provided. This case is not handled:
hi
santinic commented 5 years ago

Weird, this doesn't happen in scripts. I think it's an artifact of python shells, because you call "_" before using it. I really don't know why.

catethos commented 5 years ago

I think this is due to a bug in ipython: ipython/ipython#11325