Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 I can't use file __init__ to store shared variables and classes in the package
I placed global variables in file __init__ for each package. Now I get an error when I try to access these attributes:
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
AlekseyPython likes this post
Craig "Ichabod" O'Brien -
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

(Feb-03-2019, 08:49 PM)ichabod801 Wrote: Why not just import Forms?

import Forms
d = Forms.FormsDirectory

Thank you! Dance

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Importing variables from another file IILawrenceII 7 322 Jan-18-2020, 12:31 PM
Last Post: IILawrenceII
  Read csv file, parse data, and store in a dictionary markellefultz20 4 441 Nov-26-2019, 03:33 PM
Last Post: DeaD_EyE
  variables from a text file vlk 2 232 Sep-22-2019, 06:44 PM
Last Post: vlk
  I need help! How to package python code with other component into an exe file?? Wendy 4 393 Jul-15-2019, 01:29 PM
Last Post: snippsat
  Use Variables Generated from Functions in different files to use on the main file AykutRobotics 3 561 Jan-01-2019, 04:19 PM
Last Post: AykutRobotics
  Receive Serial Data and store in different Variables in Python jenkins43 5 1,094 Dec-28-2018, 01:33 PM
Last Post: snippsat
  How can classes access each other Functions and Variables at the same time PythonOK 4 473 Dec-09-2018, 03:46 AM
Last Post: ichabod801
  variables help / update config file mapvis 3 635 Nov-27-2018, 02:24 PM
Last Post: mapvis
  How do I read variables from another python file? ahmed_mokhles 6 1,008 Aug-21-2018, 02:13 PM
Last Post: ahmed_mokhles
  read from txt file and get variables ricardons 4 1,019 Mar-16-2018, 10:02 AM
Last Post: Larz60+

Forum Jump:

Users browsing this thread: 1 Guest(s)