> Also see PEP 299 for a slightly different approach.
Indeed. This proposal is more limited in scope than PEP 299, and appears
better from a backwards compatibility perspective.
> there's going to be two ways to spell the exact same thing. Both are
> still going to have to be memorized
Sure - th
Hello,
On Thu, 12 Nov 2020 18:33:52 +
Rob Cliffe via Python-ideas wrote:
[]
> > But that's absolutely great! A novice can first memorize the 'if
> > __name__ == "__main__":' idiom, but it will plant seed for them to
> > explore Python module and module loading systems. Such ways of
> > lear
On 12/11/2020 16:37, Paul Sokolovsky wrote:
Hello,
On Thu, 12 Nov 2020 07:56:17 -
"Matt Wozniski" wrote:
Currently, the simplest and most idiomatic way to check whether a
module was run as a script rather than imported is:
if __name__ == "__main__":
People generally learn this by
This gets discussed every now and again, and has thus far been rejected. Also
see PEP 299 for a slightly different approach.
--
Eric V. Smith
> On Nov 12, 2020, at 8:45 AM, Matt Wozniski wrote:
>
> Currently, the simplest and most idiomatic way to check whether a module was
> run as a script
Hello,
On Thu, 12 Nov 2020 07:56:17 -
"Matt Wozniski" wrote:
> Currently, the simplest and most idiomatic way to check whether a
> module was run as a script rather than imported is:
>
> if __name__ == "__main__":
>
> People generally learn this by rote memorization, because users ofte
I kinda like it. Definitely +0.0, maybe +0.5.
On Thu, Nov 12, 2020 at 2:46 PM Matt Wozniski wrote:
> if __main__:
>
> It would behave as though
>
> __main__ = (__name__ == "__main__")
>
> is executed in each module's namespace before executing it.
>
Some other commenters say they rarel
On 11/12/20, Chris Angelico wrote:
>
> I actually don't use the "if name is main" idiom all that often. The
> need to have a script be both a module and an executable is less
> important than you might think. In a huge number of cases, it's
> actually better to separate out the library-like and sc
On Fri, Nov 13, 2020 at 12:47 AM Matt Wozniski wrote:
>
> Currently, the simplest and most idiomatic way to check whether a module was
> run as a script rather than imported is:
>
> if __name__ == "__main__":
>
> People generally learn this by rote memorization, because users often want the
>
Currently, the simplest and most idiomatic way to check whether a module was
run as a script rather than imported is:
if __name__ == "__main__":
People generally learn this by rote memorization, because users often want the
ability to add testing code or command line interfaces to their modul