Mailing List Archive

0xfor 3. Parser bug?
This was just posted on SO

https://stackoverflow.com/questions/67083039/why-does-python-return-15-for-0xfor-x-in-1-2-3

I can reproduce it with a simpler example

>>> 0xfor 3
15

Is it a bug in the parser, or working as intended? It's not only for
hex. This works to

>>> 3or 50
3



--
Kind regards,

Stefano Borini
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/V6HMVBY4DO7IB7MQO2CAZFY7RJWAV7BB/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: 0xfor 3. Parser bug? [ In reply to ]
14.04.21 13:22, Stefano Borini ????:
> This was just posted on SO
>
> https://stackoverflow.com/questions/67083039/why-does-python-return-15-for-0xfor-x-in-1-2-3
>
> I can reproduce it with a simpler example
>
>>>> 0xfor 3
> 15
>
> Is it a bug in the parser, or working as intended? It's not only for
> hex. This works to
>
>>>> 3or 50
> 3
>
>
>

It is already discussed in thread >
https://mail.python.org/archives/list/python-dev@python.org/thread/D2WPCITHG2LBQAP7DBTC6CY26WQUBAKP/

It does not contradict specification, but looks pretty confusing, so we
will likely change specification and implementation to prevent confusion.

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/QODMSOOHZFGL7HL4VDAKZMZ23RPYTIQO/
Code of Conduct: http://python.org/psf/codeofconduct/