Oct-18-2018, 03:49 AM
a while back i saw a web page that showed how to create an object in which attributes can be created by an assignment to that attribute.
you would get the nice object from a call to a function or a class such as
i got it to work using ordinary dictionary syntax. i'm still guessing-and-trying to get it to work with attribute syntax.
en.py:
you would get the nice object from a call to a function or a class such as
foo = objectmaker()
. thwn you could assign directly to attributes of that object like foo.bar = 5
and so on. i can't find that page, now. does anyone know how this is done and can explain how?i got it to work using ordinary dictionary syntax. i'm still guessing-and-trying to get it to work with attribute syntax.
en.py:
def en(): import common c = common.share() c['foo'] = 'faen' returnto.py:
def to(): import common c = common.share() print(c['foo']) returnhoved.py:
from en import en from to import to en() to()common.py:
def share(): return globals()the above works but i want to use
c.foo
instead of c['foo']
.