Skip to main content
added 109 characters in body
Source Link
Strigoides
  • 4.6k
  • 5
  • 26
  • 25

When you execute

MyClass = MyClass(abc)

you are creating a new instance of MyClass, and assigning it to the class itself, whereas with a different nameMyclass1 = MyClass(abc), you don't overwrite the class. Overwriting the class shouldn't throw an exception (the exception may be to do with calling your MyFunction() method with an argument, since it doesn't take any, or perhaps calling the constructor of MyClass with an argument, since that doesn't take any either), but I imagine it isn't what you intend to do.

Myclass1 = MyClass(abc) looks alright to me (besides the argument being passed), although I would recommend using myClass1 (or even better, the generally used python style of my_class1) for variables, rather than capitalizing the fist letter, as it prevents confusion about which object is a class.

When you execute

MyClass = MyClass(abc)

you are creating a new instance of MyClass, and assigning it to the class itself, whereas with a different name, you don't overwrite the class. Overwriting the class shouldn't throw an exception, but I imagine it isn't what you intend to do.

Myclass1 = MyClass(abc) looks alright to me, although I would recommend using myClass1 (or even better, the generally used python style of my_class1) for variables, rather than capitalizing the fist letter, as it prevents confusion about which object is a class.

When you execute

MyClass = MyClass(abc)

you are creating a new instance of MyClass, and assigning it to the class itself, whereas with Myclass1 = MyClass(abc), you don't overwrite the class. Overwriting the class shouldn't throw an exception (the exception may be to do with calling your MyFunction() method with an argument, since it doesn't take any, or perhaps calling the constructor of MyClass with an argument, since that doesn't take any either), but I imagine it isn't what you intend to do.

Myclass1 = MyClass(abc) looks alright to me (besides the argument being passed), although I would recommend using myClass1 (or even better, the generally used python style of my_class1) for variables, rather than capitalizing the fist letter, as it prevents confusion about which object is a class.

Source Link
Strigoides
  • 4.6k
  • 5
  • 26
  • 25

When you execute

MyClass = MyClass(abc)

you are creating a new instance of MyClass, and assigning it to the class itself, whereas with a different name, you don't overwrite the class. Overwriting the class shouldn't throw an exception, but I imagine it isn't what you intend to do.

Myclass1 = MyClass(abc) looks alright to me, although I would recommend using myClass1 (or even better, the generally used python style of my_class1) for variables, rather than capitalizing the fist letter, as it prevents confusion about which object is a class.