Python Forum
dynamic use of attributes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dynamic use of attributes
#2
You could simply use the common module
def en():
    import common
    common.foo = 'faen'
You can also play with
>>> class Share:
...     def __init__(self):
...         self.__dict__ = globals()
... 
>>> share = Share()
>>> share.foo = 'bar'
>>> foo
'bar'
Remember that "Simple is better than complex" (the Zen of Python)
Reply


Messages In This Thread
dynamic use of attributes - by Skaperen - Oct-18-2018, 03:49 AM
RE: dynamic use of attributes - by Gribouillis - Oct-18-2018, 05:29 AM
RE: dynamic use of attributes - by Skaperen - Oct-18-2018, 08:41 PM
RE: dynamic use of attributes - by ichabod801 - Oct-19-2018, 03:12 AM
RE: dynamic use of attributes - by Skaperen - Oct-19-2018, 06:00 AM

Forum Jump:

User Panel Messages

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