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
  can we write command output to new csv file using Panda package? PythonBeginner_2020 3 233 Mar-13-2020, 12:38 PM
Last Post: ndc85430
  Importing variables from another file IILawrenceII 7 700 Jan-18-2020, 12:31 PM
Last Post: IILawrenceII
  Read csv file, parse data, and store in a dictionary markellefultz20 4 523 Nov-26-2019, 03:33 PM
Last Post: DeaD_EyE
  variables from a text file vlk 2 252 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 419 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 596 Jan-01-2019, 04:19 PM
Last Post: AykutRobotics
  Receive Serial Data and store in different Variables in Python jenkins43 5 1,141 Dec-28-2018, 01:33 PM
Last Post: snippsat
  How can classes access each other Functions and Variables at the same time PythonOK 4 502 Dec-09-2018, 03:46 AM
Last Post: ichabod801
  variables help / update config file mapvis 3 669 Nov-27-2018, 02:24 PM
Last Post: mapvis
  How do I read variables from another python file? ahmed_mokhles 6 1,046 Aug-21-2018, 02:13 PM
Last Post: ahmed_mokhles

Forum Jump:

Users browsing this thread: 1 Guest(s)