<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 5, 2013 at 12:33 PM, Serhiy Storchaka <span dir="ltr"><<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">05.06.13 18:54, Daniel Holth написав(ла):<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Can I have a context manager that disables str(bytes) just for part of<br>
my code, the same as python -bb?<br>
<br>
with bb:<br>
serialize_something()<br>
</blockquote>
<br></div>
No, you can't.<br>
<br>
But it looks as interesting idea. Perhaps it should be a function in the sys module.<br>
<br>
with sys.alter_flags(bytes_warning=<u></u>2, dont_write_bytecode=1):<br>
...</blockquote><div><br></div><div>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. </div>
</div></div></div>