Find out all attributes of an object

Source: Internet
Author: User

For example:

# Create a complex data object

>>> Complex_data = 1 + 1j

# Find out all attributes of complex_data using method Dir ()
>>> Dir (complex_data)
['_ ABS _', '_ add _', '_ class _', '_ coerce __', '_ delattr _', '_ Div _', '_ divmod _', '_ Doc _', '_ eq __', '_ float _', '_ floordiv _', '_ format _', '_ Ge _', '_ getattribute __', '_ getnewargs _', '_ GT _', '_ Hash _', '_ init _', '_ int __', '_ Le __',
'_ Long _', '_ LT _', '_ mod _', '_ Mul _', '_ ne __', '_ neg _', '_ new _', '_ nonzero _', '_ POS _', '_ POW __', '_ Radd _', '_ rdiv _', '_ rdivmod _', '_ reduce _', '_ performance_ex __', '_ repr _', '_ rfloordiv _', '_ rmod _', '_ rmul _', '_ rpow __', '_ rsub __',
'_ Rtruediv _', '_ setattr _', '_ sizeof _', '_ STR _', '_ Sub __', '_ subclasshook _', '_ truediv _', 'conjugate', 'imag', 'real']

# Access complex_data's attributes using '.'

>>> Complex_data.real
1.0
>>> Complex_data.imag
1.0
>>> Complex_data.conjugate ()
(1-1j)
>>>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.