[Python-ideas] without(str(bytes))

Brett Cannon brett at python.org
Wed Jun 5 19:10:52 CEST 2013


On Wed, Jun 5, 2013 at 12:33 PM, Serhiy Storchaka <storchaka at gmail.com>wrote:

> 05.06.13 18:54, Daniel Holth написав(ла):
>
>  Can I have a context manager that disables str(bytes) just for part of
>> my code, the same as python -bb?
>>
>> with bb:
>>      serialize_something()
>>
>
> No, you can't.
>
> But it looks as interesting idea. Perhaps it should be a function in the
> sys module.
>
> with sys.alter_flags(bytes_warning=**2, dont_write_bytecode=1):
>     ...


Future statements affect the parser, so by the time the code is executed
there's nothing you could affect. If you really want this sort of thing you
can use compile() and it's flag argument.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130605/4107cefe/attachment.html>


More information about the Python-ideas mailing list