Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7583823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:46:31+00:00 2026-05-30T18:46:31+00:00

I have noticed that in Python some of the fundamental types have two types

  • 0

I have noticed that in Python some of the fundamental types have two types of methods: those that are surrounded by __ and those that don’t.

For example, if I have a variable of type float called my_number, I can see in IPython that it has the following methods:

my_number.__abs__           my_number.__pos__
my_number.__add__           my_number.__pow__
my_number.__class__         my_number.__radd__
my_number.__coerce__        my_number.__rdiv__
my_number.__delattr__       my_number.__rdivmod__
my_number.__div__           my_number.__reduce__
my_number.__divmod__        my_number.__reduce_ex__
my_number.__doc__           my_number.__repr__
my_number.__eq__            my_number.__rfloordiv__
my_number.__float__         my_number.__rmod__
my_number.__floordiv__      my_number.__rmul__
my_number.__format__        my_number.__rpow__
my_number.__ge__            my_number.__rsub__
my_number.__getattribute__  my_number.__rtruediv__
my_number.__getformat__     my_number.__setattr__
my_number.__getnewargs__    my_number.__setformat__
my_number.__gt__            my_number.__sizeof__
my_number.__hash__          my_number.__str__
my_number.__init__          my_number.__sub__
my_number.__int__           my_number.__subclasshook__
my_number.__le__            my_number.__truediv__
my_number.__long__          my_number.__trunc__
my_number.__lt__            my_number.as_integer_ratio
my_number.__mod__           my_number.conjugate
my_number.__mul__           my_number.fromhex
my_number.__ne__            my_number.hex
my_number.__neg__           my_number.imag
my_number.__new__           my_number.is_integer
my_number.__nonzero__       my_number.real
  1. What is the difference between those that are surrounded by ___ and those that aren’t?
  2. Is this some sort of standard used in other programming languages? Does it usually mean the same thing in similar languages?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:46:32+00:00Added an answer on May 30, 2026 at 6:46 pm

    1) The variables you speak of __*__ are system variables or methods.

    To quote the Python reference guide:

    System-defined names. These names are defined by the interpreter and its implementation (including the standard library); applications should not expect to define additional names using this convention. The set of names of this class defined by Python may be extended in future versions.

    Essentially they are variables or methods pre defined by the system. For example the system variable __name__ can be used within any function and will always contain the name of that function. You can find more comprehensive information and examples here.

    2) This concept of system reserved variables is fundamental in most programming languages. For example PHP refers to them as Magic Constants. The Python example above to get a function name can be achieved in PHP using __FUNCTION__. More examples here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading cpython code for python 3k and I have noticed, that __missing__
I have noticed that some apps like Safari and Mail show a loading indicator
I have some data that uses unixtime . I'm using Python and MySQL. I
I have noticed that considerably amount of questions in SO, relating to Python, are
I've noticed that Java, Python, Perl, and Haskell/Clojure have distinctively different treatment of static
I have noticed that cURL in PHP returns different data when told to output
I have noticed that regardless of a given script's execution time, every date() call
I have noticed that my particular instance of Trac is not running quickly and
I have noticed that my geocoder is inconsistent in the code shown below because
I have noticed that both IE6 and IE7 push the parent div down when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.