On 2021-05-26 at 12:53:32 -0000,
Shreyan Avigyan <pythonshreya...@gmail.com> wrote:

> I've already given one. Since Python is dynamically typed changing a
> critical variable can cause huge instability. Want a demonstration?
> Here we go,
> 
> import sys
> sys.stdout = None
> 
> Now what? Now how can we print anything? Isn't this a bug? There are
> lots of code out there where we need to protect things from being
> overwritten. Though I'm never telling to use constants in Python
> stdlib or else I could have never done this demonstration. :)

In C:

    fclose(stdout);

Now what?  Now how can we print anything?

(I'm sure other languages allow programs to close stdout, but C has come
up in this thread before.)

There are a handful of real use cases for closing (or otherwise
changing) stdout; e.g., background/daemon processes, programs that
operate exclusively in a graphical environment.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/WJP6SHVNHCX35T4M5VRR2FOFIKYHH2TG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to