#๐ Need Definitions and answers to some questions
12 messages ยท Page 1 of 1 (latest)
@languid igloo
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
instance and object are roughly the same thing, you get them from instantiating a class. A class is like a blueprint, an instance is like a house built from the blueprint. self is a special name that always refers to the current instance.
in Python specifically, nearly everything is an object. 42 is an object, it's an instance of class int
ooh i see , that makes it quite clear and whats the deal with _ _ init _ _() method?
__init__ is for initializing an object, once the object exists, __init__ is called to allow you to setup its state. For example, if you have DatabaseConnection class, in __init__ you might try to connect to the server, set the properties like self.address = "localhost" or what not
You don't have to implement __init__ for a class if it doesn't need any special setup and just holds data (like dataclasses for example (even though the __init__ will be hidden and actually do some work))
okay i think i got it
thank you
!close
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.