This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kxrob
Recipients kebab-mai-haddi, kxrob
Date 2021-02-22.18:14:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1614017643.61.0.333526769124.issue43247@roundup.psfhosted.org>
In-reply-to
Content
#  `__main__` of the source code directory: `/tmp/rebound/rebound`. 
#  differentiate `__main__` of my target source code to read from the built-in `__main__`? In other words, how do I read the module `__main__` of the codebase: rebound?

=> when __main__.py is inside a package, use the full dotted module name - and an appropriate search path below that directory:

pyclbr.readmodule_ex('rebound.__main__')
pyclbr.readmodule_ex('lib2to3.__main__')

When __main__.py is intended as a top level module / script, I think such a name collision with an internal module name is a bad idea at all.
(For a special local purposes you could use a symlink or so?)


(I experience a bug with pyclbr (in py3.10 at least) when it traverses an "import __main__" statement. It causes also "ValueError: __main__.__spec__ is None" or "ValueError: {}.__spec__ is not set".  But this seems to be an actual bug w/o bug report so far: #43299 )
History
Date User Action Args
2021-02-22 18:14:03kxrobsetrecipients: + kxrob, kebab-mai-haddi
2021-02-22 18:14:03kxrobsetmessageid: <1614017643.61.0.333526769124.issue43247@roundup.psfhosted.org>
2021-02-22 18:14:03kxroblinkissue43247 messages
2021-02-22 18:14:03kxrobcreate