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
  Installed Python3.7 from package, trying to run pip3.7 does not work JBristow1729 4 284 Aug-11-2019, 08:24 AM
Last Post: michaellossagk
  How do I install apps from google play store? using python + selenium.. mongo 0 91 Aug-05-2019, 12:41 AM
Last Post: mongo
  Best method: Python script called from another app, package as complete executable ironfelix717 2 121 Jul-24-2019, 07:39 AM
Last Post: DeaD_EyE
  Calling Extended Embedding Python as shared library jibarra 0 122 Jul-19-2019, 05:22 PM
Last Post: jibarra
  Can't decide - install modules with Ubuntu package manager (apt) or pip3 in venv Thisisaline 6 239 Jul-19-2019, 04:58 PM
Last Post: snippsat
  I need help! How to package python code with other component into an exe file?? Wendy 4 201 Jul-15-2019, 01:29 PM
Last Post: snippsat
  Help | Classes to use in real world soothsayerpg 9 400 Jul-08-2019, 07:30 PM
Last Post: nilamo
  Problems with inheritance with classes internetguy 3 428 Jul-04-2019, 11:59 AM
Last Post: metulburr
  Unexpected Output using classes and inheritance langley 2 156 Jul-04-2019, 09:33 AM
Last Post: langley
  Store a product/item in a inventory program viktoria_linn 1 147 Jul-02-2019, 09:26 PM
Last Post: DeaD_EyE

Forum Jump:


Users browsing this thread: 1 Guest(s)