Python is confusing

>>> def simple(): yield 'a'
...
>>> ', '.join(simple())
'a'
>>> def horrible():
...     if ' ' not in False: yield 'a'
...
>>> ', '.join(horrible())
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: sequence expected, generator found
>>>
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: sequence expected, generator found

But it does accept generators!

(Yes, I know what triggers it to say that. It's still horribly misleading.)

Tags:
  • python
  • programming
2005-11-02T14:40+02:00