A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/039703.html below:

[Python-Dev] Alternate notation for global variable assignments

[Python-Dev] Alternate notation for global variable assignments [Python-Dev] Alternate notation for global variable assignmentsGuido van Rossum guido at python.org
Tue Oct 28 10:36:23 EST 2003
> Why not just:
> 
> import whatevermynameis
> 
> whatevermynameis.foo = bar
> 
> This would be even *more* maximally obvious, as you wouldn't need to
> know what '__me__' means.  :) And how often do you write a module
> without knowing what its name is, or change the name after you've
> written it?  Plus, thanks to the time machine, it already works.  :)

Doesn't work when your module may either be called __main__ or
rumpelstiltkin.  It would then become

  if __name__ == "__main__":
      import __main__ as me
  else:
      import rumpelstiltkin as me

which loses the "aha!" effect of a cool solution.  It also IMO
requires too much explanation to the unsuspecting reader who doesn't
understand right away *why* rumpelstiltkin imports itself.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4