Mar-02-2017, 11:05 PM
forum_import.py:
EGG = 'eggses' class Egg(object): def __init__(self, style): self.style = style egg = Egg('scrambled') egg.scrapple = 'bacon'forum_test.py:
from forum_import import * HAM = 'hocks' class Spam(object): def __init__(self, spice): self.spice = spice def test(self): print(self.spice) if hasattr(self, 'ham'): print(self.ham) print(HAM) print(EGG) print(egg.style) print(egg.scrapple) spam = Spam('garlic') spam.ham = 'Wilbur' spam.test()The output of running forum_test.py:
garlic Wilbur hocks eggses scrambled baconCorrect me if I'm wrong, but doesn't this cover everything you're talking about? If you are defining something like HAM, and your Spam instance can't see it, there is some other problem going on. It's not a namespace issue.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures