ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module |
| Last Crawled | 2026-04-08 17:44:39 (1 day ago) |
| First Indexed | not set |
| HTTP Status Code | 200 |
| Meta Title | package - Absolute vs. explicit relative import of Python module - Stack Overflow |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | Python relative imports are no longer strongly discouraged, but using absolute_import is strongly suggested in that case.
Please see
this discussion
citing Guido himself:
"Isn't this mostly historical? Until the new relative-import syntax
was implemented there were various problems with relative imports. The
short-term solution was to recommend not using them. The long-term
solution was to implement an unambiguous syntax. Now it is time to
withdraw the anti-recommendation. Of course, without going overboard
-- I still find them an acquired taste; but they have their place."
The OP correctly links the
PEP 328
that says:
Several use cases were presented, the most important of which is being
able to rearrange the structure of large packages without having to
edit sub-packages. In addition, a module inside a package can't easily
import itself without relative imports.
Also see almost duplicate question
When or why to use relative imports in Python
Of course it still stands as a matter of taste. While it's easier to move code around with relative imports, that might also unexpectedly break things; and renaming the imports is not that difficult.
To force the new behaviour from PEP 328 use:
from
__future__
import
absolute_import
In this case, implicit relative import will no longer be possible (eg.
import localfile
will not work anymore, only
from . import localfile
). For clean and future proof behaviour, using absolute_import is advisable.
An important caveat is that because of
PEP 338
and
PEP 366
, relative imports require the python file to be imported as a module - you cannot execute a file.py that has a relative import or you'll get a
ValueError: Attempted relative import in non-package
.
This limitation should be taken into account when evaluating the best approach. Guido is against running scripts from a module in any case:
I'm -1 on this and on any other proposed twiddlings of the __main__ machinery.
The only use case seems to be running scripts that happen to be living inside a module's directory, which I've always seen as an antipattern.
To make me change my mind you'd have to convince me that it isn't.
Exhaustive discussions on the matter can be found on SO; re. Python 3 this is quite comprehensive:
Relative imports in Python 3 |
| Markdown | # 
By clicking “Sign up”, you agree to our [terms of service](https://stackoverflow.com/legal/terms-of-service/public) and acknowledge you have read our [privacy policy](https://stackoverflow.com/legal/privacy-policy).
# OR
Already have an account? [Log in](https://stackoverflow.com/users/login)
[Skip to main content](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#content)
[Stack Overflow](https://stackoverflow.com/)
1. [About](https://stackoverflow.co/)
2. Products
3. [For Teams](https://stackoverflow.co/internal/)
1. [Stack Internal Implement a knowledge platform layer to power your enterprise and AI tools.](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams)
2. [Stack Data Licensing Get access to top-class technical expertise with trusted & attributed content.](https://stackoverflow.co/data-licensing/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api)
3. [Stack Ads Connect your brand to the world’s most trusted technologist communities.](https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising)
4. [Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal.](https://stackoverflow.blog/releases/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=releases)
5. [About the company](https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company) [Visit the blog](https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog)
1. ### [current community](https://stackoverflow.com/)
- [Stack Overflow](https://stackoverflow.com/)
[help](https://stackoverflow.com/help) [chat](https://chat.stackoverflow.com/?tab=explore)
- [Meta Stack Overflow](https://meta.stackoverflow.com/)
### your communities
[Sign up](https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F4209641%2Fabsolute-vs-explicit-relative-import-of-python-module) or [log in](https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F4209641%2Fabsolute-vs-explicit-relative-import-of-python-module) to customize your list.
### [more stack exchange communities](https://stackexchange.com/sites)
[company blog](https://stackoverflow.blog/)
2. [Log in](https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F4209641%2Fabsolute-vs-explicit-relative-import-of-python-module)
3. [Sign up](https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F4209641%2Fabsolute-vs-explicit-relative-import-of-python-module)
# Let's set up your homepage Select a few topics you're interested in:
python
javascript
c\#
reactjs
java
android
html
flutter
c++
node.js
typescript
css
r
php
angular
next.js
spring-boot
machine-learning
sql
excel
ios
azure
docker
Or search from our full list:
- javascript
- python
- java
- c\#
- php
- android
- html
- jquery
- c++
- css
- ios
- sql
- mysql
- r
- reactjs
- node.js
- arrays
- c
- asp.net
- json
- python-3.x
- .net
- ruby-on-rails
- sql-server
- swift
- django
- angular
- objective-c
- excel
- pandas
- angularjs
- regex
- typescript
- ruby
- linux
- ajax
- iphone
- vba
- xml
- laravel
- spring
- asp.net-mvc
- database
- wordpress
- string
- flutter
- postgresql
- mongodb
- wpf
- windows
- xcode
- amazon-web-services
- bash
- git
- oracle-database
- spring-boot
- dataframe
- azure
- firebase
- list
- multithreading
- docker
- vb.net
- react-native
- eclipse
- algorithm
- powershell
- macos
- visual-studio
- numpy
- image
- forms
- scala
- function
- vue.js
- performance
- twitter-bootstrap
- selenium
- winforms
- kotlin
- loops
- dart
- express
- hibernate
- sqlite
- matlab
- python-2.7
- shell
- rest
- apache
- entity-framework
- android-studio
- csv
- maven
- linq
- qt
- dictionary
- unit-testing
- asp.net-core
- facebook
- apache-spark
- tensorflow
- file
- swing
- class
- unity-game-engine
- sorting
- date
- authentication
- go
- symfony
- t-sql
- opencv
- matplotlib
- .htaccess
- google-chrome
- for-loop
- datetime
- codeigniter
- perl
- http
- validation
- sockets
- google-maps
- object
- uitableview
- xaml
- oop
- visual-studio-code
- if-statement
- cordova
- ubuntu
- web-services
- email
- android-layout
- github
- spring-mvc
- elasticsearch
- kubernetes
- selenium-webdriver
- ms-access
- ggplot2
- user-interface
- parsing
- pointers
- google-sheets
- c++11
- security
- machine-learning
- google-apps-script
- ruby-on-rails-3
- templates
- flask
- nginx
- variables
- exception
- sql-server-2008
- gradle
- debugging
- tkinter
- delphi
- listview
- jpa
- asynchronous
- haskell
- web-scraping
- pdf
- jsp
- ssl
- amazon-s3
- google-cloud-platform
- testing
- xamarin
- jenkins
- wcf
- batch-file
- generics
- npm
- ionic-framework
- network-programming
- unix
- recursion
- google-app-engine
- mongoose
- visual-studio-2010
- .net-core
- android-fragments
- assembly
- animation
- math
- svg
- rust
- session
- intellij-idea
- hadoop
- join
- curl
- winapi
- django-models
- laravel-5
- next.js
- url
- heroku
- http-redirect
- tomcat
- inheritance
- google-cloud-firestore
- webpack
- gcc
- image-processing
- swiftui
- keras
- asp.net-mvc-4
- logging
- dom
- matrix
- pyspark
- actionscript-3
- button
- post
- optimization
- firebase-realtime-database
- jquery-ui
- cocoa
- xpath
- iis
- web
- d3.js
- javafx
- firefox
- xslt
- internet-explorer
- caching
- select
- asp.net-mvc-3
- opengl
- events
- asp.net-web-api
- plot
- dplyr
- encryption
- magento
- stored-procedures
- search
- amazon-ec2
- ruby-on-rails-4
- memory
- canvas
- multidimensional-array
- audio
- random
- jsf
- vector
- redux
- cookies
- input
- facebook-graph-api
- flash
- indexing
- xamarin.forms
- arraylist
- ipad
- cocoa-touch
- data-structures
- video
- model-view-controller
- azure-devops
- serialization
- apache-kafka
- jdbc
- razor
- woocommerce
- awk
- routes
- mod-rewrite
- servlets
- excel-formula
- beautifulsoup
- filter
- iframe
- docker-compose
- design-patterns
- aws-lambda
- text
- visual-c++
- django-rest-framework
- cakephp
- mobile
- android-intent
- struct
- react-hooks
- methods
- groovy
- mvvm
- lambda
- ssh
- checkbox
- time
- ecmascript-6
- grails
- google-chrome-extension
- installation
- cmake
- sharepoint
- shiny
- spring-security
- jakarta-ee
- plsql
- android-recyclerview
- core-data
- types
- sed
- meteor
- android-activity
- bootstrap-4
- activerecord
- websocket
- replace
- graph
- group-by
- scikit-learn
- vim
- file-upload
- boost
- junit
- memory-management
- sass
- async-await
- import
- deep-learning
- error-handling
- eloquent
- dynamic
- dependency-injection
- soap
- silverlight
- layout
- apache-spark-sql
- charts
- deployment
- browser
- gridview
- svn
- while-loop
- google-bigquery
- vuejs2
- highcharts
- dll
- ffmpeg
- view
- foreach
- makefile
- plugins
- redis
- c\#-4.0
- reporting-services
- jupyter-notebook
- unicode
- merge
- reflection
- https
- server
- google-maps-api-3
- twitter
- oauth-2.0
- extjs
- terminal
- axios
- pip
- split
- cmd
- pytorch
- encoding
- django-views
- collections
- database-design
- hash
- netbeans
- automation
- data-binding
- ember.js
- build
- tcp
- pdo
- sqlalchemy
- apache-flex
- entity-framework-core
- concurrency
- command-line
- spring-data-jpa
- printing
- react-redux
- java-8
- lua
- html-table
- neo4j
- ansible
- service
- jestjs
- mysqli
- enums
- parameters
- flexbox
- material-ui
- module
- promise
- visual-studio-2012
- outlook
- web-applications
- uwp
- firebase-authentication
- webview
- jquery-mobile
- utf-8
- datatable
- python-requests
- parallel-processing
- colors
- drop-down-menu
- scipy
- tfs
- scroll
- hive
- count
- syntax
- ms-word
- twitter-bootstrap-3
- ssis
- fonts
- rxjs
- constructor
- google-analytics
- file-io
- paypal
- three.js
- powerbi
- graphql
- cassandra
- discord
- graphics
- compiler-errors
- gwt
- react-router
- socket.io
- backbone.js
- solr
- memory-leaks
- url-rewriting
- datatables
- nlp
- terraform
- oauth
- datagridview
- drupal
- zend-framework
- oracle11g
- knockout.js
- triggers
- interface
- neural-network
- django-forms
- casting
- angular-material
- jmeter
- linked-list
- google-api
- path
- timer
- django-templates
- arduino
- orm
- proxy
- windows-phone-7
- directory
- parse-platform
- visual-studio-2015
- cron
- conditional-statements
- push-notification
- functional-programming
- primefaces
- pagination
- model
- jar
- xamarin.android
- hyperlink
- uiview
- vbscript
- visual-studio-2013
- google-cloud-functions
- azure-active-directory
- gitlab
- jwt
- download
- swift3
- sql-server-2005
- process
- rspec
- configuration
- pygame
- properties
- callback
- combobox
- windows-phone-8
- linux-kernel
- safari
- scrapy
- emacs
- permissions
- x86
- clojure
- scripting
- raspberry-pi
- scope
- io
- azure-functions
- compilation
- expo
- responsive-design
- mongodb-query
- nhibernate
- angularjs-directive
- reference
- bluetooth
- request
- binding
- architecture
- dns
- playframework
- 3d
- pyqt
- version-control
- discord.js
- doctrine-orm
- package
- f\#
- rubygems
- get
- sql-server-2012
- autocomplete
- tree
- openssl
- datepicker
- kendo-ui
- jackson
- yii
- controller
- grep
- nested
- xamarin.ios
- static
- null
- transactions
- statistics
- datagrid
- active-directory
- dockerfile
- uiviewcontroller
- webforms
- sas
- discord.py
- computer-vision
- phpmyadmin
- notifications
- duplicates
- pycharm
- mocking
- youtube
- yaml
- nullpointerexception
- menu
- blazor
- sum
- plotly
- bitmap
- visual-studio-2008
- asp.net-mvc-5
- floating-point
- yii2
- css-selectors
- stl
- electron
- android-listview
- jsf-2
- time-series
- cryptography
- ant
- character-encoding
- hashmap
- stream
- msbuild
- asp.net-core-mvc
- sdk
- google-drive-api
- jboss
- selenium-chromedriver
- joomla
- devise
- navigation
- cors
- cuda
- anaconda
- frontend
- background
- multiprocessing
- binary
- pyqt5
- camera
- iterator
- linq-to-sql
- mariadb
- onclick
- android-jetpack-compose
- ios7
- microsoft-graph-api
- android-asynctask
- rabbitmq
- tabs
- amazon-dynamodb
- laravel-4
- environment-variables
- uicollectionview
- insert
- linker
- xsd
- coldfusion
- console
- continuous-integration
- upload
- textview
- ftp
- opengl-es
- macros
- operating-system
- mockito
- localization
- formatting
- xml-parsing
- json.net
- type-conversion
- vuejs3
- data.table
- kivy
- timestamp
- integer
- calendar
- segmentation-fault
- android-ndk
- prolog
- char
- drag-and-drop
- crash
- jasmine
- dependencies
- automated-tests
- geometry
- azure-pipelines
- fortran
- android-gradle-plugin
- itext
- sprite-kit
- mfc
- header
- attributes
- nosql
- firebase-cloud-messaging
- format
- nuxt.js
- odoo
- db2
- jquery-plugins
- event-handling
- julia
- jenkins-pipeline
- leaflet
- annotations
- flutter-layout
- nestjs
- keyboard
- postman
- arm
- textbox
- stripe-payments
- visual-studio-2017
- gulp
- libgdx
- uikit
- synchronization
- timezone
- azure-web-app-service
- dom-events
- wso2
- xampp
- google-sheets-formula
- crystal-reports
- aggregation-framework
- namespaces
- swagger
- android-emulator
- uiscrollview
- jvm
- sequelize.js
- chart.js
- com
- snowflake-cloud-data-platform
- subprocess
- geolocation
- webdriver
- garbage-collection
- html5-canvas
- sql-update
- centos
- dialog
- concatenation
- numbers
- widget
- qml
- tuples
- set
- java-stream
- mapreduce
- ionic2
- smtp
- windows-10
- android-edittext
- rotation
- nuget
- spring-data
- modal-dialog
- radio-button
- doctrine
- http-headers
- grid
- sonarqube
- lucene
- xmlhttprequest
- listbox
- switch-statement
- initialization
- internationalization
- components
- boolean
- apache-camel
- google-play
- gdb
- serial-port
- ios5
- ldap
- return
- youtube-api
- pivot
- eclipse-plugin
- latex
- frameworks
- tags
- containers
- c++17
- subquery
- github-actions
- embedded
- dataset
- asp-classic
- foreign-keys
- label
- uinavigationcontroller
- delegates
- copy
- struts2
- google-cloud-storage
- migration
- protractor
- base64
- uibutton
- find
- queue
- sql-server-2008-r2
- arguments
- composer-php
- append
- jaxb
- stack
- zip
- tailwind-css
- cucumber
- autolayout
- ide
- entity-framework-6
- iteration
- popup
- r-markdown
- windows-7
- vb6
- airflow
- g++
- clang
- hover
- ssl-certificate
- jqgrid
- range
- gmail
Next
You’ll be prompted to create an account to view your personalized homepage.
1. 1. [Home](https://stackoverflow.com/)
2. [Questions](https://stackoverflow.com/questions)
3. [AI Assist](https://stackoverflow.com/ai-assist)
4. [Tags](https://stackoverflow.com/tags)
5. [Challenges](https://stackoverflow.com/beta/challenges)
6. [Chat](https://chat.stackoverflow.com/?tab=explore)
7. [Articles](https://stackoverflow.blog/contributed?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=so-blog&utm_content=experiment-articles)
8. [Users](https://stackoverflow.com/users)
9. [Companies](https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav)
10. [Collectives]()
11. Communities for your favorite technologies. [Explore all Collectives](https://stackoverflow.com/collectives-all)
2. Stack Internal
Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work.
[Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams)
3. [Stack Internal]()
4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact)
##### Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
[Learn more about Collectives](https://stackoverflow.com/collectives)
**Stack Internal**
Knowledge at work
Bring the best of human thought and AI automation together at your work.
[Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover)
# [Absolute vs. explicit relative import of Python module](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module)
[Ask Question](https://stackoverflow.com/questions/ask)
Asked
15 years, 2 months ago
Modified [5 years, 5 months ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module?lastactivity "2020-08-15 05:31:00Z")
Viewed 92k times
This question shows research effort; it is useful and clear
124
Save this question.
Show activity on this post.
I'm wondering about the preferred way to import packages in a Python application. I have a package structure like this:
```
Copy
```
`project.app1.views` imports `project.app1.models` and `project.app2.models`. There are two ways to do this that come to mind.
With absolute imports:
```
Copy
```
or with explicit relative imports, as introduced in [Python 2.5 with PEP 328](http://docs.python.org/whatsnew/2.5.html#pep-328-absolute-and-relative-imports):
```
Copy
```
What is the most pythonic way to do this?
- [python](https://stackoverflow.com/questions/tagged/python "show questions tagged 'python'")
- [package](https://stackoverflow.com/questions/tagged/package "show questions tagged 'package'")
- [python-import](https://stackoverflow.com/questions/tagged/python-import "show questions tagged 'python-import'")
[Share](https://stackoverflow.com/q/4209641 "Short permalink to this question")
Share a link to this question
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this question](https://stackoverflow.com/posts/4209641/edit)
Follow
Follow this question to receive notifications
[edited Nov 4, 2019 at 9:04](https://stackoverflow.com/posts/4209641/revisions "show all edits to this post")
asked Nov 17, 2010 at 22:07
[](https://stackoverflow.com/users/211960/daniel-hepper)
[Daniel Hepper](https://stackoverflow.com/users/211960/daniel-hepper)
30\.2k1010 gold badges7878 silver badges7979 bronze badges
0
[Add a comment](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module "Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.") \|
## 3 Answers 3
Sorted by:
[Reset to default](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module?answertab=scoredesc#tab-top)
This answer is useful
156
Save this answer.
Show activity on this post.
Python relative imports are no longer strongly discouraged, but using absolute\_import is strongly suggested in that case.
Please see [this discussion](http://bugs.python.org/issue10031) citing Guido himself:
> "Isn't this mostly historical? Until the new relative-import syntax was implemented there were various problems with relative imports. The short-term solution was to recommend not using them. The long-term solution was to implement an unambiguous syntax. Now it is time to withdraw the anti-recommendation. Of course, without going overboard -- I still find them an acquired taste; but they have their place."
The OP correctly links the [PEP 328](http://www.python.org/dev/peps/pep-0328/#rationale-for-relative-imports) that says:
> Several use cases were presented, the most important of which is being able to rearrange the structure of large packages without having to edit sub-packages. In addition, a module inside a package can't easily import itself without relative imports.
Also see almost duplicate question [When or why to use relative imports in Python](https://stackoverflow.com/questions/12738889/when-or-why-to-use-relative-imports-in-python)
Of course it still stands as a matter of taste. While it's easier to move code around with relative imports, that might also unexpectedly break things; and renaming the imports is not that difficult.
To force the new behaviour from PEP 328 use:
```
Copyfrom __future__ import absolute_import
```
In this case, implicit relative import will no longer be possible (eg. `import localfile` will not work anymore, only `from . import localfile`). For clean and future proof behaviour, using absolute\_import is advisable.
An important caveat is that because of [PEP 338](http://www.python.org/dev/peps/pep-0338) and [PEP 366](http://www.python.org/dev/peps/pep-0366), relative imports require the python file to be imported as a module - you cannot execute a file.py that has a relative import or you'll get a `ValueError: Attempted relative import in non-package`.
This limitation should be taken into account when evaluating the best approach. Guido is against running scripts from a module in any case:
> I'm -1 on this and on any other proposed twiddlings of the \_\_main\_\_ machinery. The only use case seems to be running scripts that happen to be living inside a module's directory, which I've always seen as an antipattern. To make me change my mind you'd have to convince me that it isn't.
Exhaustive discussions on the matter can be found on SO; re. Python 3 this is quite comprehensive:
- [Relative imports in Python 3](https://stackoverflow.com/questions/16981921/relative-imports-in-python-3)
[Share](https://stackoverflow.com/a/16748366 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://stackoverflow.com/posts/16748366/edit)
Follow
Follow this answer to receive notifications
[edited May 23, 2017 at 12:26](https://stackoverflow.com/posts/16748366/revisions "show all edits to this post")
[](https://stackoverflow.com/users/-1/community)
[Community](https://stackoverflow.com/users/-1/community)Bot
111 silver badge
answered May 25, 2013 at 9:54
[](https://stackoverflow.com/users/422670/stefano)
[Stefano](https://stackoverflow.com/users/422670/stefano)
18\.7k1313 gold badges6767 silver badges7979 bronze badges
Sign up to request clarification or add additional context in comments.
## 7 Comments
Add a comment
[](https://stackoverflow.com/users/232485/jabba)
Jabba
[Jabba](https://stackoverflow.com/users/232485/jabba)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment31375229_16748366)
Guido wrote that in 2010 and it's still in the PEP? How can we trust PEPs if they are so outdated?
2014-01-03T11:45:49.54Z+00:00
13
Reply
- Copy link
[](https://stackoverflow.com/users/230884/cpplearner)
CppLearner
[CppLearner](https://stackoverflow.com/users/230884/cpplearner)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment36923453_16748366)
PEP are like US amendments in the sense that you can amend things. There are lot of rejected PEPS too. PEPs are proposals. They can be accepted, rejected or become obsolete which often means new PEP. PEP 8 is a style guide so it can be modified in place.
2014-05-31T02:40:20.17Z+00:00
6
Reply
- Copy link
[](https://stackoverflow.com/users/2078678/matiascelasco)
matiascelasco
[matiascelasco](https://stackoverflow.com/users/2078678/matiascelasco)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment42995675_16748366)
I am confused about the "a module inside a package can't easily import itself... " part. I had never heard about modules importing themselves before.
2014-12-03T00:06:40.957Z+00:00
3
Reply
- Copy link
[](https://stackoverflow.com/users/422670/stefano)
Stefano
[Stefano](https://stackoverflow.com/users/422670/stefano)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment43022950_16748366)
One possible example @matiascelasco : if you have foo/bar.py and foo/baz.py but also baz.py somewhere else. If you want to import foo.baz from bar you might want to be sure of what you are importing, eg. `import .baz` - this is just one simplistic of many similar situations described in the PEP though.
2014-12-03T16:41:58.003Z+00:00
3
Reply
- Copy link
[](https://stackoverflow.com/users/341744/ninmonkey)
ninMonkey
[ninMonkey](https://stackoverflow.com/users/341744/ninmonkey)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment52958026_16748366)
Your answer doesn't clearly distinguish the change in allowing them. Implicit relative imports should never be used, but explicit relative imports are ok to use. Implicit relative has been removed from Python3.
2015-09-13T15:04:26.243Z+00:00
0
Reply
- Copy link
Add a comment
\|
Show 2 more comments
This answer is useful
69
Save this answer.
Show activity on this post.
Absolute imports. From PEP 8:
> Relative imports for intra-package imports are highly discouraged. Always use the absolute package path for all imports. Even now that PEP 328 \[7\] is fully implemented in Python 2.5, its style of explicit relative imports is actively discouraged; absolute imports are more portable and usually more readable.
Explicit relative imports are a nice language feature (I guess), but they're not nearly as explicit as absolute imports. The more readable form is:
```
Copy
```
especially if you import several different namespaces. If you look at some well written projects/tutorials that include imports from within packages, they usually follow this style.
The few extra keystrokes you take to be more explicit will save others (and perhaps you) plenty of time in the future when they're trying to figure out your namespace (especially if you migrate to 3.x, in which some of the package names have changed).
[Share](https://stackoverflow.com/a/4209771 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/ "The current license for this post: CC BY-SA 2.5")
[Improve this answer](https://stackoverflow.com/posts/4209771/edit)
Follow
Follow this answer to receive notifications
[edited Aug 15, 2020 at 5:31](https://stackoverflow.com/posts/4209771/revisions "show all edits to this post")
[](https://stackoverflow.com/users/6368697/patrick-mevzek)
[Patrick Mevzek](https://stackoverflow.com/users/6368697/patrick-mevzek)
12\.9k1717 gold badges4646 silver badges6262 bronze badges
answered Nov 17, 2010 at 22:22
[](https://stackoverflow.com/users/399815/rafe-kettler)
[Rafe Kettler](https://stackoverflow.com/users/399815/rafe-kettler)
77\.2k2121 gold badges161161 silver badges152152 bronze badges
## 10 Comments
Add a comment
[](https://stackoverflow.com/users/86643/denis)
denis
[denis](https://stackoverflow.com/users/86643/denis)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment5077476_4209771)
@Rafe, "look at some well written projects ..." any suggestions ?
2011-01-06T17:32:21.803Z+00:00
1
Reply
- Copy link
[](https://stackoverflow.com/users/399815/rafe-kettler)
Rafe Kettler
[Rafe Kettler](https://stackoverflow.com/users/399815/rafe-kettler)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment5077725_4209771)
@Denis: Rietveld is Guido van Rossum's own project, so I'd imagine that'd be a good place to look ([code.google.com/p/rietveld](http://code.google.com/p/rietveld/)). The Python standard library isn't so great, a lot of that code doesn't follow conventions.
2011-01-06T17:48:53.173Z+00:00
0
Reply
- Copy link
[](https://stackoverflow.com/users/85360/brandon-rhodes)
Brandon Rhodes
[Brandon Rhodes](https://stackoverflow.com/users/85360/brandon-rhodes)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment6685896_4209771)
@Rafe: that part of PEP-8 is outdated, according to Guido. [mail.python.org/pipermail/python-dev/2010-October/104476.html](http://mail.python.org/pipermail/python-dev/2010-October/104476.html)
2011-04-28T20:52:35.417Z+00:00
74
Reply
- Copy link
[](https://stackoverflow.com/users/2073595/dano)
dano
[dano](https://stackoverflow.com/users/2073595/dano)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment39033523_4209771)
That statement is no longer in PEP-8 at all now. It now states absolute imports are recommended, but relative imports are an acceptable alternative.
2014-08-01T18:33:12.693Z+00:00
16
Reply
- Copy link
[](https://stackoverflow.com/users/143397/davida)
davidA
[davidA](https://stackoverflow.com/users/143397/davida)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment72181159_4209771)
The problem I have with absolute imports is when using a package within another package. In my case, it's present as a git submodule. In this case, although I can import the top-level package, any packages below this one cannot be imported because they fail to find their own modules with absolute imports. Whereas if I use relative imports at this bottom level, it all just works.
2017-03-01T02:40:32.677Z+00:00
7
Reply
- Copy link
Add a comment
\|
Show 5 more comments
This answer is useful
51
Save this answer.
Show activity on this post.
Relative imports not only leave you free to rename your package later without changing dozens of internal imports, but I have also had success with them in solving certain problems involving things like circular imports or namespace packages, because they do not send Python "back to the top" to start the search for the next module all over again from the top-level namespace.
[Share](https://stackoverflow.com/a/4209804 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/ "The current license for this post: CC BY-SA 2.5")
[Improve this answer](https://stackoverflow.com/posts/4209804/edit)
Follow
Follow this answer to receive notifications
answered Nov 17, 2010 at 22:25
[](https://stackoverflow.com/users/85360/brandon-rhodes)
[Brandon Rhodes](https://stackoverflow.com/users/85360/brandon-rhodes)
91\.1k1616 gold badges110110 silver badges149149 bronze badges
## 2 Comments
Add a comment
[](https://stackoverflow.com/users/143397/davida)
davidA
[davidA](https://stackoverflow.com/users/143397/davida)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment72218609_4209804)
@RafeKettler can you explain how you would use absolute imports in a package that is itself included within another package? The absolute imports will fail within the inner package because they don't know about the new top level. Relative imports continue to work. One could probably argue that the package shouldn't be nested inside another in the first place, but some code is meant to be reusable and this happens a lot. A lot of reused code isn't packaged for the public and therefore isn't provided as a separate package so ad-hoc methods such as VCS import/submodules end up being used instead
2017-03-01T20:30:05.82Z+00:00
2
Reply
- Copy link
[](https://stackoverflow.com/users/582917/cmcdragonkai)
CMCDragonkai
[CMCDragonkai](https://stackoverflow.com/users/582917/cmcdragonkai)
[Over a year ago](https://stackoverflow.com/questions/4209641/absolute-vs-explicit-relative-import-of-python-module#comment87272981_4209804)
@meowsqueak I agree, some packages are not easily installable (they are not on pip, you don't want to use `python setup.py install` or `python setup.py develop` for whatever reason), in those cases I fork the source code and add it as a git submodule. When those packages use absolute imports on their own package name, their imports fail. The only solution is to use explicit relative imports. That is what should be encouraged I think.
2018-05-02T05:20:55.473Z+00:00
4
Reply
- Copy link
Start asking to get answers
Find the answer to your question by asking.
[Ask question](https://stackoverflow.com/questions/ask)
Explore related questions
- [python](https://stackoverflow.com/questions/tagged/python "show questions tagged 'python'")
- [package](https://stackoverflow.com/questions/tagged/package "show questions tagged 'package'")
- [python-import](https://stackoverflow.com/questions/tagged/python-import "show questions tagged 'python-import'")
See similar questions with these tags.
- The Overflow Blog
- [AI can 10x developers...in creating tech debt](https://stackoverflow.blog/2026/01/23/ai-can-10x-developers-in-creating-tech-debt/?cb=1)
- [Stack Gives Back 2025\!](https://stackoverflow.blog/2026/01/26/stack-gives-back-2025/?cb=1)
- Featured on Meta
- [AI Assist: recent updates (January 2026)](https://meta.stackexchange.com/questions/416954/ai-assist-recent-updates-january-2026?cb=1)
- [Community Engagement Across the Network: Focus for 2026](https://meta.stackexchange.com/questions/416985/community-engagement-across-the-network-focus-for-2026?cb=1)
- [All users on Stack Overflow can now participate in chat](https://meta.stackoverflow.com/questions/437932/all-users-on-stack-overflow-can-now-participate-in-chat?cb=1)
- [Policy: Generative AI (e.g., ChatGPT) is banned](https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned?cb=1)
- [Stack Overflow now uses machine learning to flag spam automatically](https://meta.stackoverflow.com/questions/437959/stack-overflow-now-uses-machine-learning-to-flag-spam-automatically?cb=1)
- [No, I do not believe this is the end](https://meta.stackoverflow.com/questions/438009/no-i-do-not-believe-this-is-the-end?cb=1)
Community activity
Last 1 hr
- Users online activity
15101 users online
- 18 questions
- 20 answers
- 73 comments
- 267 upvotes
Popular tags
[c\#](https://stackoverflow.com/questions/tagged/c)[python](https://stackoverflow.com/questions/tagged/python)[javascript](https://stackoverflow.com/questions/tagged/javascript)[c++](https://stackoverflow.com/questions/tagged/c++)[c](https://stackoverflow.com/questions/tagged/c)
Popular unanswered question
[Android \<include\> constraints are not working anymore](https://stackoverflow.com/questions/79115360)
[android](https://stackoverflow.com/questions/tagged/android)[layout](https://stackoverflow.com/questions/tagged/layout)[include](https://stackoverflow.com/questions/tagged/include)[constraints](https://stackoverflow.com/questions/tagged/constraints)
[](https://stackoverflow.com/users/9083835)
[Erick Cabral](https://stackoverflow.com/users/9083835)
- 170
461 days ago
#### Linked
[40](https://stackoverflow.com/questions/12738889/when-or-why-to-use-relative-imports-in-python?lq=1 "Question score (upvotes - downvotes)")
[When or why to use relative imports in Python](https://stackoverflow.com/questions/12738889/when-or-why-to-use-relative-imports-in-python?noredirect=1&lq=1)
[19](https://stackoverflow.com/questions/5811463/when-to-use-absolute-imports?lq=1 "Question score (upvotes - downvotes)")
[When to use absolute imports](https://stackoverflow.com/questions/5811463/when-to-use-absolute-imports?noredirect=1&lq=1)
[0](https://stackoverflow.com/questions/63824758/what-is-the-difference-between-local-imports-and-package-imports?lq=1 "Question score (upvotes - downvotes)")
[What is the difference between local imports and package imports?](https://stackoverflow.com/questions/63824758/what-is-the-difference-between-local-imports-and-package-imports?noredirect=1&lq=1)
[1881](https://stackoverflow.com/questions/16981921/relative-imports-in-python-3?lq=1 "Question score (upvotes - downvotes)")
[Relative imports in Python 3](https://stackoverflow.com/questions/16981921/relative-imports-in-python-3?noredirect=1&lq=1)
[140](https://stackoverflow.com/questions/25827160/importing-correctly-with-pytest?lq=1 "Question score (upvotes - downvotes)")
[Importing correctly with pytest](https://stackoverflow.com/questions/25827160/importing-correctly-with-pytest?noredirect=1&lq=1)
[61](https://stackoverflow.com/questions/3842616/organizing-python-classes-in-modules-and-or-packages?lq=1 "Question score (upvotes - downvotes)")
[Organizing Python classes in modules and/or packages](https://stackoverflow.com/questions/3842616/organizing-python-classes-in-modules-and-or-packages?noredirect=1&lq=1)
[94](https://stackoverflow.com/questions/36826839/python-relative-import-script-two-levels-up?lq=1 "Question score (upvotes - downvotes)")
[Python relative-import script two levels up](https://stackoverflow.com/questions/36826839/python-relative-import-script-two-levels-up?noredirect=1&lq=1)
[16](https://stackoverflow.com/questions/45020963/modulenotfounderror-no-module-named-models?lq=1 "Question score (upvotes - downvotes)")
[ModuleNotFoundError: No module named 'models'](https://stackoverflow.com/questions/45020963/modulenotfounderror-no-module-named-models?noredirect=1&lq=1)
[5](https://stackoverflow.com/questions/58868333/python-imports-modulenotfounderror-no-module-named-x?lq=1 "Question score (upvotes - downvotes)")
[Python imports - ModuleNotFoundError: No module named X](https://stackoverflow.com/questions/58868333/python-imports-modulenotfounderror-no-module-named-x?noredirect=1&lq=1)
[5](https://stackoverflow.com/questions/46810554/python-nested-subpackage-doesnt-import-when-running-tests?lq=1 "Question score (upvotes - downvotes)")
[Python nested subpackage doesn't import when running tests](https://stackoverflow.com/questions/46810554/python-nested-subpackage-doesnt-import-when-running-tests?noredirect=1&lq=1)
[See more linked questions](https://stackoverflow.com/questions/linked/4209641?lq=1)
#### Related
[26](https://stackoverflow.com/questions/3616952/how-can-i-properly-use-relative-or-absolute-imports-in-python-modules?rq=3 "Question score (upvotes - downvotes)")
[How can I properly use relative or absolute imports in Python modules?](https://stackoverflow.com/questions/3616952/how-can-i-properly-use-relative-or-absolute-imports-in-python-modules?rq=3)
[4](https://stackoverflow.com/questions/10059002/python-packages-relative-imports?rq=3 "Question score (upvotes - downvotes)")
[Python packages: relative imports](https://stackoverflow.com/questions/10059002/python-packages-relative-imports?rq=3)
[40](https://stackoverflow.com/questions/12738889/when-or-why-to-use-relative-imports-in-python?rq=3 "Question score (upvotes - downvotes)")
[When or why to use relative imports in Python](https://stackoverflow.com/questions/12738889/when-or-why-to-use-relative-imports-in-python?rq=3)
[16](https://stackoverflow.com/questions/20706335/python-module-imports-explicit-vs-implicit-relative-imports?rq=3 "Question score (upvotes - downvotes)")
[Python Module Imports - Explicit vs Implicit Relative Imports](https://stackoverflow.com/questions/20706335/python-module-imports-explicit-vs-implicit-relative-imports?rq=3)
[1](https://stackoverflow.com/questions/20821968/relative-import-in-python?rq=3 "Question score (upvotes - downvotes)")
[Relative Import in Python](https://stackoverflow.com/questions/20821968/relative-import-in-python?rq=3)
[3](https://stackoverflow.com/questions/25583756/using-absolute-import-while-in-developing-python-modules?rq=3 "Question score (upvotes - downvotes)")
[Using absolute import while in developing Python modules?](https://stackoverflow.com/questions/25583756/using-absolute-import-while-in-developing-python-modules?rq=3)
[1](https://stackoverflow.com/questions/27239643/python-relative-imports-and-packages?rq=3 "Question score (upvotes - downvotes)")
[Python Relative Imports and Packages](https://stackoverflow.com/questions/27239643/python-relative-imports-and-packages?rq=3)
[12](https://stackoverflow.com/questions/28400690/python3-correct-way-to-import-relative-or-absolute?rq=3 "Question score (upvotes - downvotes)")
[Python3 correct way to import relative or absolute?](https://stackoverflow.com/questions/28400690/python3-correct-way-to-import-relative-or-absolute?rq=3)
[2](https://stackoverflow.com/questions/28527832/absolute-vs-relative-imports-in-python-2?rq=3 "Question score (upvotes - downvotes)")
[Absolute vs Relative Imports in Python 2](https://stackoverflow.com/questions/28527832/absolute-vs-relative-imports-in-python-2?rq=3)
[1](https://stackoverflow.com/questions/68043019/relative-import-in-python-packages?rq=3 "Question score (upvotes - downvotes)")
[Relative import in python packages](https://stackoverflow.com/questions/68043019/relative-import-in-python-packages?rq=3)
#### [Hot Network Questions](https://stackexchange.com/questions?tab=hot)
- [Can a mordent fall before the beat?](https://music.stackexchange.com/questions/143123/can-a-mordent-fall-before-the-beat)
- [Is there a way to fill everything but air?](https://gaming.stackexchange.com/questions/417684/is-there-a-way-to-fill-everything-but-air)
- [поотпадать and other verbs with an otiose по-](https://russian.stackexchange.com/questions/29549/%D0%BF%D0%BE%D0%BE%D1%82%D0%BF%D0%B0%D0%B4%D0%B0%D1%82%D1%8C-and-other-verbs-with-an-otiose-%D0%BF%D0%BE)
- [How do I determine a cone's area of effect on the map when it is orientated at an angle to the map?](https://rpg.stackexchange.com/questions/218608/how-do-i-determine-a-cones-area-of-effect-on-the-map-when-it-is-orientated-at-a)
- [Lowest fraction of a population to take part in an election during a (civil) war?](https://politics.stackexchange.com/questions/94134/lowest-fraction-of-a-population-to-take-part-in-an-election-during-a-civil-war)
- [How do I get a stable \\noteta?](https://tex.stackexchange.com/questions/758768/how-do-i-get-a-stable-noteta)
- [Looking for a book where the protagonist goes to a library to find a book on how to build a cannon with only primitive means](https://scifi.stackexchange.com/questions/302999/looking-for-a-book-where-the-protagonist-goes-to-a-library-to-find-a-book-on-how)
- [Screen (commandline tool) session created from closed SSH connections cannot access local network (No route to host)](https://apple.stackexchange.com/questions/485719/screen-commandline-tool-session-created-from-closed-ssh-connections-cannot-acc)
- [Hochschild-Serre spectral sequence with rational coefficients](https://mathoverflow.net/questions/507415/hochschild-serre-spectral-sequence-with-rational-coefficients)
- [Warpriest sacred weapon with enlarge person and other size change effects](https://rpg.stackexchange.com/questions/218604/warpriest-sacred-weapon-with-enlarge-person-and-other-size-change-effects)
- [After an offeree has made a counteroffer, do they still have the power to accept the original offer?](https://law.stackexchange.com/questions/114017/after-an-offeree-has-made-a-counteroffer-do-they-still-have-the-power-to-accept)
- [What is the purpose of glutinous rice flour in this kimchi paste? Can I leave it out or substitute?](https://cooking.stackexchange.com/questions/136655/what-is-the-purpose-of-glutinous-rice-flour-in-this-kimchi-paste-can-i-leave-it)
- [Effective study workflow for multi-module technical courses. From PDFs to retention?](https://academia.stackexchange.com/questions/225738/effective-study-workflow-for-multi-module-technical-courses-from-pdfs-to-retent)
- [What is the meaning of the Airbus model numbering system?](https://aviation.stackexchange.com/questions/114884/what-is-the-meaning-of-the-airbus-model-numbering-system)
- [A novel about a future galactic war against a race I think are called Hydranics. Possibly DAW books](https://scifi.stackexchange.com/questions/303000/a-novel-about-a-future-galactic-war-against-a-race-i-think-are-called-hydranics)
- [Graecism or Latinism for 'false balancing'](https://english.stackexchange.com/questions/638783/graecism-or-latinism-for-false-balancing)
- [What are the best starting nations?](https://gaming.stackexchange.com/questions/417691/what-are-the-best-starting-nations)
- [Questions about 'God' in Tractatus Logico-Philosophicus](https://philosophy.stackexchange.com/questions/135579/questions-about-god-in-tractatus-logico-philosophicus)
- [Is there a musical term for notes that are sharps or flats?](https://music.stackexchange.com/questions/143095/is-there-a-musical-term-for-notes-that-are-sharps-or-flats)
- [Is it possible to have Global toon shaders?](https://blender.stackexchange.com/questions/344741/is-it-possible-to-have-global-toon-shaders)
- [Does TTL output specify the maximum current it can source?](https://electronics.stackexchange.com/questions/764836/does-ttl-output-specify-the-maximum-current-it-can-source)
- [Surfactant removal from carbon](https://chemistry.stackexchange.com/questions/194867/surfactant-removal-from-carbon)
- [What is causing chain to drop to lower cogs while backpedaling?](https://bicycles.stackexchange.com/questions/99968/what-is-causing-chain-to-drop-to-lower-cogs-while-backpedaling)
- [ObjectCountingSort.java](https://codereview.stackexchange.com/questions/301106/objectcountingsort-java)
[Question feed](https://stackoverflow.com/feeds/question/4209641 "Feed of this question and its answers")
# Subscribe to RSS
Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-py
# Why are you flagging this comment?
Probable spam.
This comment promotes a product, service or website while [failing to disclose the author's affiliation](https://stackoverflow.com/help/promotion).
Unfriendly or contains harassment/bigotry/abuse.
This comment is unkind, insulting or attacks another person or group. Learn more in our [Abusive behavior policy](https://stackoverflow.com/conduct/abusive-behavior).
Not needed.
This comment is not relevant to the post.
```
```
Enter at least 6 characters
Something else.
A problem not listed above. Try to be as specific as possible.
```
```
Enter at least 6 characters
Flag comment
Cancel
You have 0 flags left today
# 
# Hang on, you can't upvote just yet.
You'll need to complete a few actions and gain 15 reputation points before being able to upvote. **Upvoting** indicates when questions and answers are useful. [What's reputation and how do I get it?](https://stackoverflow.com/help/whats-reputation)
Instead, you can save this post to reference later.
Save this post for later
Not now
##### [Stack Overflow](https://stackoverflow.com/)
- [Questions](https://stackoverflow.com/questions)
- [Help](https://stackoverflow.com/help)
- [Chat](https://chat.stackoverflow.com/?tab=explore)
##### [Business](https://stackoverflow.co/)
- [Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams)
- [Stack Data Licensing](https://stackoverflow.co/data-licensing/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=data-licensing)
- [Stack Ads](https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising)
##### [Company](https://stackoverflow.co/)
- [About](https://stackoverflow.co/)
- [Press](https://stackoverflow.co/company/press/)
- [Work Here](https://stackoverflow.co/company/work-here/)
- [Legal](https://stackoverflow.com/legal)
- [Privacy Policy](https://stackoverflow.com/legal/privacy-policy)
- [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public)
- [Contact Us](https://stackoverflow.com/contact)
- Cookie Settings
- [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy)
##### [Stack Exchange Network](https://stackexchange.com/)
- [Technology](https://stackexchange.com/sites#technology)
- [Culture & recreation](https://stackexchange.com/sites#culturerecreation)
- [Life & arts](https://stackexchange.com/sites#lifearts)
- [Science](https://stackexchange.com/sites#science)
- [Professional](https://stackexchange.com/sites#professional)
- [Business](https://stackexchange.com/sites#business)
- [API](https://api.stackexchange.com/)
- [Data](https://data.stackexchange.com/)
- [Blog](https://stackoverflow.blog/?blb=1)
- [Facebook](https://www.facebook.com/officialstackoverflow/)
- [Twitter](https://twitter.com/stackoverflow)
- [LinkedIn](https://linkedin.com/company/stack-overflow)
- [Instagram](https://www.instagram.com/thestackoverflow)
Site design / logo © 2026 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2026.1.22.38918 |
| Readable Markdown | null |
| Shard | 169 (laksa) |
| Root Hash | 714406497480128969 |
| Unparsed URL | com,stackoverflow!/questions/4209641/absolute-vs-explicit-relative-import-of-python-module s443 |