There is no such thing as "returning nothing" in Python. Every function returns some value (unless it raises an exception). If no explicit return statement is used, Python treats it as returning None.
So, you need to think about what is most appropriate for your function. Either you should return None (or some other sentinel value) and add appropriate logic to your calling code to detect this, or you should raise an exception (which the calling code can catch, if it wants to).
There is no such thing as "returning nothing" in Python. Every function returns some value (unless it raises an exception). If no explicit return statement is used, Python treats it as returning None.
So, you need to think about what is most appropriate for your function. Either you should return None (or some other sentinel value) and add appropriate logic to your calling code to detect this, or you should raise an exception (which the calling code can catch, if it wants to).
To literally return 'nothing' use pass, which basically returns the value None if put in a function(Functions must return a value, so why not 'nothing'). You can do this explicitly and return None yourself though.
So either:
if x>1:
return(x)
else:
pass
or
if x>1:
return(x)
else:
return None
will do the trick.
Python and I are NOT getting along today.
I have the script below, which takes arguments like username and fromdate and passes it into the appropriate place in the URL (the link variable). Now, if the user just inputs username and doesn't input fromdate, Python will return None instead of nothing. Why do you do this, Python!? I never asked you to!
How can I avoid this monstrosity?
Command
main.py -u jacksfilms
Script
import requests, re, argparse
parser = argparse.ArgumentParser()
parser.add_argument('-u','--username', required=False)
parser.add_argument('-from','--fromdate', required=False)
parser.add_argument('-to','--todate', required=False)
args = vars(parser.parse_args())
username = args['username']
fromdate = args['fromdate']
todate = args['todate']
link = "https://web.archive.org/cdx/search/cdx?url=twitter.com/{}/status&matchType=prefix&from={}&to={}".format(username,fromdate,todate)
data = []
c = requests.get(link).text
urls = re.findall(r'https?://[^\s<>"]+[|www\.^\s<>"]+', c)
for i, url in enumerate (urls):
data.append(f"{i}: {url}\n")
print(data)How to not return None? (Arithmetic Formatter)
Why does the my code return none!? I’m a noob so I don’t know whether the question is overtly stupid or what😃
Deprecate bare return statements - Ideas - Discussions on Python.org
How to have Python return nothing instead of None?
Videos
Looking at what you've shown, I guess there are at least two issues.
First, your path is incorrect. You shouldn't set your path to "/usr/bin/python3.6". I think that's an executable. You should set your path to "/usr/bin/" (which should have been set for you). In that directory, there should be a symbolic link from "python3" to "python3.6" (in /usr/bin/ do a ls -al python*). If what you want is python3, then the above should fix your problem.
You should be able to type "which python3". I don't know what "python" should point to (i.e., python2 or python3...I've lost track if it still points to python2). So, if what you're after is python 2.X, then you should check to see if it has been installed on your system.
Miniconda is a completely different issue. If you've installed Miniconda, you probably need to do a conda activate. This would activate your base environment. Alternatively, if you want to find an environment, then conda activate <some environment>. If you check your path, activating a Miniconda environment essentially prepends its path in front of PATH.
(You might want to double-check that conda is in your path; that is, if it was correctly installed. i.e., which conda Also, the bottom of your ~/.bashrc should have been modified.)
Given what you asked, I guess the second solution is what you wanted. But you should fix your PATH variable anyway.
You may not have a file or symbolic link in /usr/bin folder. I made a symbolic link to see something from which python command line:
ln -s /usr/bin/python3.6 /usr/bin/python