Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Python (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Methods=== [[Method (computer programming)|Methods]] of objects are functions attached to the object's class; the syntax for normal methods and functions, {{code|lang=python|code=instance.method(argument)}}, is [[syntactic sugar]] for {{code|lang=python|code=Class.method(instance, argument)}}. Python methods have an explicit <code>[[this (computer programming)|self]]</code> parameter to access [[instance data]], in contrast to the implicit self (or <code>this</code>) parameter in some object-oriented programming languages (e.g., [[C++]], [[Java (programming language)|Java]], [[Objective-C]], [[Ruby (programming language)|Ruby]]).<ref name="AutoNT-61"/> Python also provides methods, often called ''dunder methods'' (because their names begin and end with double underscores); these methods allow user-defined classes to modify how they are handled by native operations including length, comparison, [[arithmetic operations|arithmetic]], and type conversion.<ref>{{cite book |last1=Sweigart |first1=Al |title=Beyond the Basic Stuff with Python: Best Practices for Writing Clean Code |year=2020 |publisher=No Starch Press |isbn=978-1-59327-966-0 |page=322 |url=https://books.google.com/books?id=7GUKEAAAQBAJ&pg=PA322 |language=en |access-date=7 July 2021 |archive-date=13 August 2021 |archive-url=https://web.archive.org/web/20210813194312/https://books.google.com/books?id=7GUKEAAAQBAJ&pg=PA322 |url-status=live}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)