Skip to content

Instantly share code, notes, and snippets.

@vjrantal
Created Jul 29, 2019
Embed
What would you like to do?
import os
def test_function():
if os.environ.get('SOMETHING_THAT_DOES_NOT_EXIST'):
tail = ''
if tail:
print('Not printed')
test_function()
@vjrantal

This comment has been minimized.

Copy link
Owner Author

@vjrantal vjrantal commented Jul 29, 2019

$ 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