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
  How do I store the data in another txt file blacklight 1 128 Jun-26-2020, 11:09 AM
Last Post: Larz60+
  module to store functions/variables and how to call them? mstichler 3 177 Jun-03-2020, 06:49 PM
Last Post: mstichler
  ChatterBot: How to store unanswered question in a text file? animrehrm 0 144 May-16-2020, 06:00 AM
Last Post: animrehrm
  can we write command output to new csv file using Panda package? PythonBeginner_2020 3 385 Mar-13-2020, 12:38 PM
Last Post: ndc85430
  Importing variables from another file IILawrenceII 7 2,172 Jan-18-2020, 12:31 PM
Last Post: IILawrenceII
  Read csv file, parse data, and store in a dictionary markellefultz20 4 765 Nov-26-2019, 03:33 PM
Last Post: DeaD_EyE
  variables from a text file vlk 2 353 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 521 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 702 Jan-01-2019, 04:19 PM
Last Post: AykutRobotics
  Receive Serial Data and store in different Variables in Python jenkins43 5 1,346 Dec-28-2018, 01:33 PM
Last Post: snippsat

Forum Jump:

Users browsing this thread: 1 Guest(s)