Reputation: 3163
Can I have a package and a module with the same name in Python?
ex:
import json
import myapp.json.jsoncustommodule
I don't know if this has anything to do with the fact that json is in Python built-in library.
In most languages, this is acceptable. However, Python seems to confuse both things, even if they are in different parent packages.
Upvotes: 0
Views: 1749
Reputation: 36506
To answer your question, there's no issue with doing something like this in python.
However if you have a namespace conflict resulting from something like this:-
import json
from myspecialpackage import json
You will need to resolve it by using as
keyword, like this:-
from myspecialpackage import json as special_json
Upvotes: 3