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 qagren
Recipients qagren
Date 2018-10-26.05:31:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1540531905.09.0.788709270274.issue35073@psf.upfronthosting.co.za>
In-reply-to
Content
I'm running Python 3.6 on Ubuntu 16.04

I don't know if this should qualify as a bug, but I noticed the following behavior difference in the (contrived?) scenario of directly importing '__init__' from a package:

## Setup ##

mkdir app
echo 'print(f"Executing app/__init__.py as {__name__}")' > app/__init__.py

## Native: executes __init__ *once* ##

python -c 'from app import __init__'
# Output:
# Executing app/__init__.py as app

## Importlib: executes __init__ *twice* ##

python -c "import importlib; importlib.import_module('.__init__', 'app')"
# Output:
# Executing app/__init__.py as app
# Executing app/__init__.py as app.__init__

Note in addition that absolute import (either with importlib or native) executes '__init__' twice.
History
Date User Action Args
2018-10-26 05:31:45qagrensetrecipients: + qagren
2018-10-26 05:31:45qagrensetmessageid: <1540531905.09.0.788709270274.issue35073@psf.upfronthosting.co.za>
2018-10-26 05:31:45qagrenlinkissue35073 messages
2018-10-26 05:31:44qagrencreate