Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. def FunctionName(headings):
  2. for c in headings:
  3. exec('global %s' % c)
  4. <Other code...>
  5.  
  6. import modulename
  7. headings = ['test1','test2','test3']
  8. modulename.FunctionName(headings)
  9. print(dir(modulename))
  10. print(modulename.test1)
  11.  
  12. ['FunctionName',<Other function but no variables>]
  13. Traceback (most recent call last):
  14. File "<path>main_program.py", line 6,
  15. in <module>
  16. print(modulename.test1)
  17. AttributeError: module 'modulename' has no attribute 'nice'
  18.  
  19. global <Var name>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement