Python Class and Class (object) Usage differences

Source: Internet
Author: User

Start is to see Liao's tutorial time some doubts

Class A (object): and Class A: What's the difference?

So the internet search, found in the python2 there is a difference, the original paste https://my.oschina.net/shyl/blog/692930:

So, I tried with python3, found that there seems to be no difference:

1 classAnimal (object):2     Print('Test')3 4A =Animal ()5 Print(A.__class__)6 Print(Type (Animal))7 Print(Type (a))8 9 classDuck ():Ten     Print('Test') One  Ab =Duck () - Print(b.__class__) - Print(Type (Duck)) the Print(type (b))

Result

1<class '__main__. Animal'>2<class 'type'>3<class '__main__. Animal'>4 Test5<class '__main__. Duck'>6<class 'type'>7<class '__main__. Duck'>

And when I went to check the documentation, I found that the class of the document was written like this.

1 class ClassName: 2     <statement-1>3    . 4     . 5     . 6     <statement-N>

Summary: Python2 There is a difference, Python3 no

Python Class and Class (object) Usage differences

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.