Issue
How can I get access to my_args
list data type in __main__
?
test1.py
#!/usr/bin/env python
def main():
print 'main function'
one()
def one():
print 'one function'
my_args = ["QA-65"]
def two():
print 'two function'
if __name__ == "__main__":
main()
getattr(my_args, pop)
Solution
You can if you return
them from one()
:
#!/usr/bin/env python
def main():
print 'main function'
args = one() # returns my_args, which i'm assigning to args
print 'i got args from one():', args
print args.pop()
def one():
print 'one function'
my_args = ["QA-65"]
return my_args
def two():
print 'two function'
if __name__ == "__main__":
main()
#getattr(my_args, pop)
# ^^^ Moved this up to main() ^^^
Outputs:
main function
one function
i got args from one(): ['QA-65']
QA-65
Answered By - jathanism
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.