PyCon Pune 2017

A conference on the Python programming language

PyCon, the gathering for the community using and developing the open-source Python programming language. This is the first year of the PyCon Pune where the community will meet for two days of talks and working on upstream projects in two days of dev sprint. CFP ends on 30th November AoE.

Hosted by

PyCon Pune 2017 more

Tasdik Rahman

@tasdikrahman

Diving deep on how imports work in Python

Submitted Nov 28, 2016

It just so happens python abstracts away the inner workings of import statement beautifully. But are we aware of how python behaves when it encounters an import statement for a module?

  • Better yet what is a module actually?
  • Packages anybody?
  • More than one import style? How to choose between them.
  • How would different import styles compare with each other.
  • Any Best practices when importing modules. What about that __init.py__ you saw the last time you read someone else’s code.

This talk will walk you through the above and more.

Outline

Materials @ github

  • Modules
  • What happens when you import a module?
  • Packages
  • Why packages
  • Different styles for importing modules
  • python 2 pitfalls
  • Module names best practices
  • Module lookup
  • Modules get imported Only once!
  • What really happens when you reload a module?
  • Implicit Relative imports
  • Absolute relative imports
  • Explicit relative imports
  • What should you put into __init__.py? Advantages in doing so?
  • Questions?

A rough slide presentation has been created uploaded on speakerdeck.

Requirements

python3
material present at: https://github.com/prodicus/talks/tree/master/pyconpune2017

Speaker bio

Slides

https://speakerdeck.com/tasdikrahman/diving-deep-on-how-imports-work-in-python-pycon-pune-2017-proposed-talk

Comments

{{ gettext('Login to leave a comment') }}

{{ gettext('Post a comment…') }}
{{ gettext('New comment') }}
{{ formTitle }}

{{ errorMsg }}

{{ gettext('No comments posted yet') }}

Hosted by

PyCon Pune 2017 more