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
#1
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?
Quote
#2
Why not just import Forms?

import Forms
d = Forms.FormsDirectory
AlekseyPython likes this post
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

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

import Forms
d = Forms.FormsDirectory

Thank you! Dance
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  variables from a text file vlk 1 54 7 hours ago
Last Post: Yoriz
  I need help! How to package python code with other component into an exe file?? Wendy 4 236 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 404 Jan-01-2019, 04:19 PM
Last Post: AykutRobotics
  Receive Serial Data and store in different Variables in Python jenkins43 5 721 Dec-28-2018, 01:33 PM
Last Post: snippsat
  How can classes access each other Functions and Variables at the same time PythonOK 4 360 Dec-09-2018, 03:46 AM
Last Post: ichabod801
  variables help / update config file mapvis 3 466 Nov-27-2018, 02:24 PM
Last Post: mapvis
  How do I read variables from another python file? ahmed_mokhles 6 784 Aug-21-2018, 02:13 PM
Last Post: ahmed_mokhles
  Shared queues l00p1n6 3 659 May-15-2018, 01:38 PM
Last Post: DeaD_EyE
  read from txt file and get variables ricardons 4 854 Mar-16-2018, 10:02 AM
Last Post: Larz60+
  Store twitter DM's in a .txt file buflek 5 1,617 Nov-16-2017, 04:41 PM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)