Python Forum

Full Version: I can't use file __init__ to store shared variables and classes in the package
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I placed global variables in file __init__ for each package. Now I get an error when I try to access these attributes:
Error:
AttributeError: 'method-wrapper' object has no attribute 'FormsDirectory'
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?
Why not just import Forms?

import Forms
d = Forms.FormsDirectory
(Feb-03-2019, 08:49 PM)ichabod801 Wrote: [ -> ]Why not just import Forms?

import Forms
d = Forms.FormsDirectory

Thank you! Dance