Python Forum
I can't use file __init__ to store shared variables and classes in the package
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?
Reply
#2
Why not just import Forms?

import Forms
d = Forms.FormsDirectory
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
(Feb-03-2019, 08:49 PM)ichabod801 Wrote: Why not just import Forms?

import Forms
d = Forms.FormsDirectory

Thank you! Dance
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Not able to install package caldwellpy and requirement txt file Samta282006 1 700 Dec-07-2023, 11:59 PM
Last Post: Larz60+
  How to store columns of a .csv in variables (when the .csv has no headers) ? hobbyist 6 1,251 Aug-18-2023, 02:06 PM
Last Post: deanhystad
  Organizing several similar classes with overlapping variables 6hearts 7 1,373 May-07-2023, 02:00 PM
Last Post: 6hearts
  File path by adding various variables Mishal0488 2 1,022 Apr-28-2023, 07:17 PM
Last Post: deanhystad
  Storing variables into one file for use in multiple Jupyter notebooks devansing 1 1,725 Feb-05-2022, 10:04 AM
Last Post: ibreeden
  Dynamic File Name to a shared folder with open command in python sjcsvatt 9 6,010 Jan-07-2022, 04:55 PM
Last Post: bowlofred
  Package cannot be loaded into PBS queue file emersonpl 1 1,817 Sep-09-2021, 08:06 PM
Last Post: emersonpl
  how do i store then call a mp3 from sqlite3 .db file gr3yali3n 3 5,701 Dec-11-2020, 10:28 AM
Last Post: snippsat
  Regex text file to store data in list TheSithSiggi 1 1,514 Dec-03-2020, 04:46 PM
Last Post: bowlofred
  Shared reference of variables... Denial 1 1,408 Aug-29-2020, 01:52 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020