I have an improperly packaged Python module. It only has __init__.py
file in the directory. This file defines the class that I wish to use. What would be the best way to use it as a module in my script?
** EDIT **
There was a period (.) in the the name of the folder. So the methods suggested here were not working. It works fine if I rename the folder to have a valid name.
That's not improper. It's a package.
http://docs.python.org/2/tutorial/modules.html#packages
package/
__init__.py
yourmodule.py
In yourmodule.py, you can do either of the following:
import package
x = package.ClassName()
Or:
from package import ClassName
x = ClassName()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With