Joachim Saul, 25.11.2009 11:07:
> Joachim Saul:
>> I would assume that in addition to None, any value that is acceptable as
>> argument to bytes() should also be acceptable as a default value for a
>> bytes-type parameter, following the Rule of Least Surprizeā¢. This would
>> consequently also allow code such as
>>
>> def foo(bytes bar=5):
If you want bytes(5), use bytes(5) as default value. The literal 5 is a
number, not a bytes string, and thus not a valid value for a variable typed
as bytes.
>> unless forbidden in Python 3.
>
> Read: Unless 'bytes(5)' etc. is forbidden in Python 3. ;)
I hope you are aware that bytes(5) is not str(5):
Python 3.1.1 (r311:74480, Oct 22 2009, 19:34:26)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> bytes(5)
b'\x00\x00\x00\x00\x00'
>>> str(5)
'5'
That's one of the differences between the Py2.6 bytes/str type and the
'real' Py3.x bytes type, BTW.
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev