Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Third iteration. Fixed the weird syntax highlighting (as a result, the diff looks more extensive than it really is - use view "Side-by-side Markdown" to compare).
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134
python2 lib.foo
python2 lib.foo
python3 lib.foo
python3 lib.foo
Package named 'lib'; __name__ is '__main__'
Package named 'lib'; __name__ is '__main__'
python2 lib.foo
python2 lib.foo
Package named 'lib'; __name__ is 'lib.foo'
Package named 'lib'; __name__ is '__main__'
Package named 'lib'; __name__ is 'lib.foo'
Package named 'lib'; __name__ is '__main__'
python3 lib.routine
python3 lib.routine
Package named 'lib'; __name__ is 'lib.foo'
[...]/runpy.py:125: RuntimeWarning: 'lib.foo' found in sys.modules
after import of package 'lib', but prior to execution of 'lib.foo';
this may result in unpredictable behaviour
 warn(RuntimeWarning(msg))
Package named 'lib'; __name__ is '__main__'
Package named 'lib'; __name__ is 'lib.foo'
[...]/runpy.py:125: RuntimeWarning: 'lib.foo' found in sys.modules
after import of package 'lib', but prior to execution of 'lib.foo';
this may result in unpredictable behaviour
 warn(RuntimeWarning(msg))
Package named 'lib'; __name__ is '__main__'
python2 lib.foo
python3 lib.foo
Package named 'lib'; __name__ is '__main__'
python2 lib.foo
Package named 'lib'; __name__ is 'lib.foo'
Package named 'lib'; __name__ is '__main__'
python3 lib.routine
Package named 'lib'; __name__ is 'lib.foo'
[...]/runpy.py:125: RuntimeWarning: 'lib.foo' found in sys.modules
after import of package 'lib', but prior to execution of 'lib.foo';
this may result in unpredictable behaviour
 warn(RuntimeWarning(msg))
Package named 'lib'; __name__ is '__main__'
python2 lib.foo
python3 lib.foo
Package named 'lib'; __name__ is '__main__'
python2 lib.foo
Package named 'lib'; __name__ is 'lib.foo'
Package named 'lib'; __name__ is '__main__'
python3 lib.routine
Package named 'lib'; __name__ is 'lib.foo'
[...]/runpy.py:125: RuntimeWarning: 'lib.foo' found in sys.modules
after import of package 'lib', but prior to execution of 'lib.foo';
this may result in unpredictable behaviour
 warn(RuntimeWarning(msg))
Package named 'lib'; __name__ is '__main__'
Second iteration. Removed the shell prompts to avoid confusion.
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134
$ python2 lib.foo
$ python3 lib.foo
$ python2 lib.foo

Output:

Package named 'lib'; __name__ is 'lib.foo'
Package named 'lib'; __name__ is '__main__'
$ python3 lib.routine

Output:

Package named 'lib'; __name__ is 'lib.foo'
[...]/runpy.py:125: RuntimeWarning: 'lib.foo' found in sys.modules
after import of package 'lib', but prior to execution of 'lib.foo';
this may result in unpredictable behaviour
 warn(RuntimeWarning(msg))
Package named 'lib'; __name__ is '__main__'
$ python2 lib.foo
$ python3 lib.foo
$ python2 lib.foo
Package named 'lib'; __name__ is 'lib.foo'
Package named 'lib'; __name__ is '__main__'
$ python3 lib.routine
Package named 'lib'; __name__ is 'lib.foo'
[...]/runpy.py:125: RuntimeWarning: 'lib.foo' found in sys.modules
after import of package 'lib', but prior to execution of 'lib.foo';
this may result in unpredictable behaviour
 warn(RuntimeWarning(msg))
Package named 'lib'; __name__ is '__main__'
python2 lib.foo
python3 lib.foo
python2 lib.foo

Output:

Package named 'lib'; __name__ is 'lib.foo'
Package named 'lib'; __name__ is '__main__'
python3 lib.routine

Output:

Package named 'lib'; __name__ is 'lib.foo'
[...]/runpy.py:125: RuntimeWarning: 'lib.foo' found in sys.modules
after import of package 'lib', but prior to execution of 'lib.foo';
this may result in unpredictable behaviour
 warn(RuntimeWarning(msg))
Package named 'lib'; __name__ is '__main__'
Active reading [<https://en.wikipedia.org/wiki/History_of_Python#Version_2> <https://en.wikipedia.org/wiki/History_of_Python#Version_3>].
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134

The idea here is this (and note that these all function the same across python2Python 2.7 and python 3Python 3.x):

The idea here is this (and note that these all function the same across python2.7 and python 3.x):

The idea here is this (and note that these all function the same across Python 2.7 and Python 3.x):

Commonmark migration
Source Link
Loading
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot
Loading
Source Link
torek
  • 499.9k
  • 71
  • 765
  • 892
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /