What is Python's equivalent of "public static void main(String[] args) { ... }"? I remember having used it in the past and then forgot.
What I'm basically trying to remember is a function which I think included some underscores (__)...
thx
In contrast, public static void main(String args[]) is a special method signature that tells the Java VM what what method of what class to start with. Python just starts at the top of the named module and begins running from there.
The keyword public static void main is the means by which you create a main method within the Java application. It's the core method of the program and calls all others. It can't return values and accepts parameters for complex command-line processing.
It will work. Nothing will happen ! It was nothing the program compiles and runs properly.
When java runtime starts, there is no object of the class present. That's why the main method has to be static so that JVM can load the class into memory and call the main method. If the main method won't be static, JVM would not be able to call it because there is no object of the class is present.
#!/usr/bin/env python
import sys
def main(args):
print args
if __name__ == '__main__':
main(sys.argv)
edit: emulate a void
return.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With