0

I am importing a module (i am using its name as module only). Whenever i press

module.__name__ 

it is showing some name Module.module

when i did

print module 

,i go to the path mentioned. I don't have the module, it has a pyd file. I am completely confused about python importing process,What exactly is __name__? How does change in __name__ change the way we import, how does main change while importing

1

1 Answer 1

2

You have several different questions here. __name__ is the name of the module, including any packages from which it was imported. For the __main__ issue, see the link Blender provided. I don't understand what you mean by "change in __name__ changes the way we import".

As for the .pyd file, that is a Python extension written in C. It is basically a DLL that can be imported as a Python module. You can use it from Python, but it's not written in Python.

Sign up to request clarification or add additional context in comments.

4 Comments

e.g., relative imports use __name__ to find where the module is in package hierarchy i.e., by changing __name__ you can change what get imported though it is unlikely that OP means exactly that.
change in name i mean now i can use modules by the name printed out when "module.__name__" is pressed though there is no module by that name
if name is the name of the module when i do module.__name__ why is it showing Module.module but not just the name by which i imported it with
@user1869634: print module doesn't print .__name__ it prints module object itself (its representation as a string) that probably includes its type, name, filename.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.