How to write this (Java) in Python?
class Test
{
private String test1 = "test";
private static void main(String args[])
{
System.out.println("test" + test1);
}
}
asked Nov 24, 2011 at 11:53
user285594
2 Answers 2
Since Python supports code outside of classes, the equivalent is as simple as:
test1 = "test"
print("test" + test1)
UPDATE: To get the args:
import sys
print sys.argv
You really should start with the tutorial!
answered Nov 24, 2011 at 11:55
Ferdinand Beyer
67.7k18 gold badges161 silver badges147 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Ferdinand Beyer
Well you're example did not use args.
Hmmm, like this:
test1 = "test"
print "test" + test1
But if you are using Python 3 you must write print("test" + test1).
answered Nov 24, 2011 at 11:56
Hauleth
23.7k4 gold badges67 silver badges117 bronze badges
Comments
lang-py
test1is an instance variable andmainis a static function.