Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update building our first class.py #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nikitapandeyy
Copy link

The comment before the class definition is misleading. It says "Below is the method how classes are defined" but it's not a method, it's an example of how to define a class.

The class definition is incomplete. It only has the "pass" statement, which means it doesn't have any attributes or methods.

The variable names "Varun" and "larry" should start with a lowercase letter according to Python naming conventions.

The attributes are being added dynamically to the objects, which is not a good practice. It's better to define the attributes in the class definition.

The attribute "subjects" is being assigned a list, which is fine, but the attribute "std" is being assigned an integer and a float value in different instances, which could cause issues if the class methods rely on those values being of the same type.

The comment before the class definition is misleading. It says "Below is the method how classes are defined" but it's not a method, it's an example of how to define a class.

The class definition is incomplete. It only has the "pass" statement, which means it doesn't have any attributes or methods.

The variable names "Varun" and "larry" should start with a lowercase letter according to Python naming conventions.

The attributes are being added dynamically to the objects, which is not a good practice. It's better to define the attributes in the class definition.

The attribute "subjects" is being assigned a list, which is fine, but the attribute "std" is being assigned an integer and a float value in different instances, which could cause issues if the class methods rely on those values being of the same type.
@Aashray24092000
Copy link

A class is a code template for creating objects. Objects have member variables and have behaviour associated with them. In python a class is created by the keyword class.

An object is created using the constructor of the class. This object will then be called the instance of the class. In Python we create instances in the following manner

instance=class(parameter)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants