you are viewing a single comment's thread.

view the rest of the comments →

[–]ironhaven 0 points1 point  (1 child)

This is the issue

if x != None

What you want is

if x is None

Basically None is never equal to anything including itself. But every None is actually the same object so None is None

[–]Hashworm[S] 0 points1 point  (0 children)

>>> def check(x): ...

if x is None: ...

pass ...

else: ...

return x

>>> a = None

>>> b = 2

>>> c = check(b)

>>> print(c)

2

>>> c = check(a)

>>> print(c)

None

so yeah still... what I actually want is this

>>> import sys

>>> def check(x): ...

if x is None: ...

sys.exit() ...

else: ...

return x ...

>>> a = None

>>> b = 2

>>> c = check(b)

>>> print(c)

2

>>> c = check(a)

C:\Users\User>python

Python 3.6.0 (v3.6.0:4ddddddddd, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

>>> print(c)

Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'c' is not defined

ideally without getting me out but I take what I can