You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2016-09-10.23:32:37.550>created_at=<Date2016-09-10.23:27:30.298>labels= ['type-bug', 'invalid']
title='Empty Strings are not parsed to None.'updated_at=<Date2016-09-10.23:32:37.548>user='https://github.com/AraHaan'
I noticed that the Python interpreter does not interpret a empty string as None so I have to do this unclean workaround every time in functions that cannot have a empty string passed to them.
Here is some example Code I have to do to bypass this (the function itself):
defcreate_one(url):
ifurl=='':
url=NoneifurlisnotNone:
url_data=urllib.parse.urlencode(dict(url=url))
byte_data=str.encode(url_data)
ret=urllib.request.urlopen(API_CREATE, data=byte_data).read().strip()
almost_result=str(ret)
closer_result=almost_result.strip("b")
result=closer_result.strip("'")
returnresultelse:
URLError('The given URL Cannot be \'None\'.')
So yeah I suggest for the interpreter to interpret empty strings as None so that way it can cleanup some lines of trying to parse it to None which can be a lot of work. It also makes code simpler as well.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: