I can't use file __init__ to store shared variables and classes in the package - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: I can't use file __init__ to store shared variables and classes in the package (/thread-15852.html) |
I can't use file __init__ to store shared variables and classes in the package - AlekseyPython - Feb-03-2019 I placed global variables in file __init__ for each package. Now I get an error when I try to access these attributes: There is a single line in the __init__ file of the Forms package:FormsDirectory = '/home/alesha/eclipse-workspace/AnalysisData/Forms/'In another file (where I want to use this variable) I wrote: from Forms import __init__ as MyForms d = MyForms.FormsDirectory // ERROR !!!I looked in the debugger- mode: indeed, the variable MyForms has the type methodwrapper... Why? RE: I can't use file __init__ to store shared variables and classes in the package - ichabod801 - Feb-03-2019 Why not just import Forms? import Forms d = Forms.FormsDirectory RE: I can't use file __init__ to store shared variables and classes in the package - AlekseyPython - Feb-04-2019 (Feb-03-2019, 08:49 PM)ichabod801 Wrote: Why not just import Forms? Thank you! |