Skip to content

Instantly share code, notes, and snippets.

@vjrantal
Created July 29, 2019 07:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vjrantal/17c57a1ff48b08a7a497b8061805996a to your computer and use it in GitHub Desktop.
import os
def test_function():
if os.environ.get('SOMETHING_THAT_DOES_NOT_EXIST'):
tail = ''
if tail:
print('Not printed')
test_function()
@vjrantal
Copy link
Author

$ python test.py 
Traceback (most recent call last):
  File "test.py", line 9, in <module>
    test_function()
  File "test.py", line 6, in test_function
    if tail:
UnboundLocalError: local variable 'tail' referenced before assignment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment