Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Post Timeline

added 328 characters in body
Source Link
user3072164
user3072164

Some issues with your code:

  1. Python is case-sensitive. The keyword is class, not Class.

  2. After the line class A there has to be a colon: class A:

  3. If the function myFunction is supposed to be part of class A, it has to be indented:

    class A:
     def myFunction(a,b)
    
  4. Methods of classes should have self as first parameter: def myFunction(self, a, b)

  5. After def myFunction(self, a,b) there has to be a colon: def myFunction(self, a,b):

  6. Your function must have at least one line of indented code following. If it is supposed to do nothing, you can use the keyword `pass:

    def myFunction(self, a,b):
     pass
    
  7. If you want to use sys.argv you first have to import sys at the beginning of your code with import sys.

  8. myFunction is part of a class, you first have to instantiate it to use the function:

    Av = A()
    Av.myFunction(a,b)
    
  9. The first commandline argument is the second entry of sys.argv, not the first.

However it seems to me that you don't want a class anyway, so just write:

def myFunction(a,b):
 pass
if __name__ == '__main__':
 a = sys.argv[1]
 b = sys.argv[2]
 myFunction(a,b)

Also you call python scripts with python file.py arg1 arg2. If you want to omit python at the beginning then you can (in unix-like systems) add a shebang in the first line of the python-file: #!/usr/bin/env python. Then as long as the execution flag is set chmod +x file.py it may be called like ./file.py arg1 arg2.

Some issues with your code:

  1. Python is case-sensitive. The keyword is class, not Class.

  2. After the line class A there has to be a colon: class A:

  3. If the function myFunction is supposed to be part of class A, it has to be indented:

    class A:
     def myFunction(a,b)
    
  4. Methods of classes should have self as first parameter: def myFunction(self, a, b)

  5. After def myFunction(self, a,b) there has to be a colon: def myFunction(self, a,b):

  6. Your function must have at least one line of indented code following. If it is supposed to do nothing, you can use the keyword `pass:

    def myFunction(self, a,b):
     pass
    
  7. If you want to use sys.argv you first have to import sys at the beginning of your code with import sys.

  8. myFunction is part of a class, you first have to instantiate it to use the function:

    Av = A()
    Av.myFunction(a,b)
    
  9. The first commandline argument is the second entry of sys.argv, not the first.

However it seems to me that you don't want a class anyway, so just write:

def myFunction(a,b):
 pass
if __name__ == '__main__':
 a = sys.argv[1]
 b = sys.argv[2]
 myFunction(a,b)

Some issues with your code:

  1. Python is case-sensitive. The keyword is class, not Class.

  2. After the line class A there has to be a colon: class A:

  3. If the function myFunction is supposed to be part of class A, it has to be indented:

    class A:
     def myFunction(a,b)
    
  4. Methods of classes should have self as first parameter: def myFunction(self, a, b)

  5. After def myFunction(self, a,b) there has to be a colon: def myFunction(self, a,b):

  6. Your function must have at least one line of indented code following. If it is supposed to do nothing, you can use the keyword `pass:

    def myFunction(self, a,b):
     pass
    
  7. If you want to use sys.argv you first have to import sys at the beginning of your code with import sys.

  8. myFunction is part of a class, you first have to instantiate it to use the function:

    Av = A()
    Av.myFunction(a,b)
    
  9. The first commandline argument is the second entry of sys.argv, not the first.

However it seems to me that you don't want a class anyway, so just write:

def myFunction(a,b):
 pass
if __name__ == '__main__':
 a = sys.argv[1]
 b = sys.argv[2]
 myFunction(a,b)

Also you call python scripts with python file.py arg1 arg2. If you want to omit python at the beginning then you can (in unix-like systems) add a shebang in the first line of the python-file: #!/usr/bin/env python. Then as long as the execution flag is set chmod +x file.py it may be called like ./file.py arg1 arg2.

Post Undeleted by Community Bot
added 939 characters in body
Source Link
user3072164
user3072164

Some issues with your code:

  1. Python is case-sensitive. The keyword is class, not Class.

    Python is case-sensitive. The keyword is class, not Class.

  2. After the line class A there has to be a colon: class A:

    After the line class A there has to be a colon: class A:

  3. If the function myFunction is supposed to be part of class A, it has to be intended:

    If the function myFunction is supposed to be part of class A, it has to be indented:

    class A:
     def myFunction(a,b)
    
  4. Methods of classes should have self as first parameter: def myFunction(self, a, b)

  5. After def myFunction(self, a,b) there has to be a colon: def myFunction(self, a,b):

  6. Your function must have at least one line of indented code following. If it is supposed to do nothing, you can use the keyword `pass:

    def myFunction(self, a,b):
     pass
    
  7. If you want to use sys.argv you first have to import sys at the beginning of your code with import sys.

  8. myFunction is part of a class, you first have to instantiate it to use the function:

    Av = A()
    Av.myFunction(a,b)
    
  9. The first commandline argument is the second entry of sys.argv, not the first.

However it seems to me that you don't want a class A: def myFunction(aanyway,b) 4. After so just write:

def myFunction(a,b):
 pass
if __name__ == '__main__':
 a = sys.argv[1]
 b = sys.argv[2]
 myFunction(a,b)

Some issues with your code:

  1. Python is case-sensitive. The keyword is class, not Class.
  2. After the line class A there has to be a colon: class A:
  3. If the function myFunction is supposed to be part of class A, it has to be intended:

class A: def myFunction(a,b) 4. After

Some issues with your code:

  1. Python is case-sensitive. The keyword is class, not Class.

  2. After the line class A there has to be a colon: class A:

  3. If the function myFunction is supposed to be part of class A, it has to be indented:

    class A:
     def myFunction(a,b)
    
  4. Methods of classes should have self as first parameter: def myFunction(self, a, b)

  5. After def myFunction(self, a,b) there has to be a colon: def myFunction(self, a,b):

  6. Your function must have at least one line of indented code following. If it is supposed to do nothing, you can use the keyword `pass:

    def myFunction(self, a,b):
     pass
    
  7. If you want to use sys.argv you first have to import sys at the beginning of your code with import sys.

  8. myFunction is part of a class, you first have to instantiate it to use the function:

    Av = A()
    Av.myFunction(a,b)
    
  9. The first commandline argument is the second entry of sys.argv, not the first.

However it seems to me that you don't want a class anyway, so just write:

def myFunction(a,b):
 pass
if __name__ == '__main__':
 a = sys.argv[1]
 b = sys.argv[2]
 myFunction(a,b)
Post Deleted by Community Bot
Source Link
user3072164
user3072164

Some issues with your code:

  1. Python is case-sensitive. The keyword is class, not Class.
  2. After the line class A there has to be a colon: class A:
  3. If the function myFunction is supposed to be part of class A, it has to be intended:

class A: def myFunction(a,b) 4. After

lang-py

AltStyle によって変換されたページ (->オリジナル) /