Python Core Programming Chapter 4th Answer (second edition 75 pages)

Source: Internet
Author: User

4-1python objects

All Python objects has three Attributes:type,id,and value.

All was readonly with a possible expection of the value (which can being changed only if the object is mutable).

4-5str () and repr ()

Repr () is a built-in function while STR () was a built-in function, changed to a factory function Inpython2.2.they would Both returns a string representation of an OBJECT;HOWEVER,STR () returns a printable string representation while repr () ret Urns an evaluatable string representation of an object,meaning that it's astring that represents a Python object that Wou LD is created if passed to eval ().

4-6object Equality

Type (a) = = Type (b) whether the value of type (a) is the same as the value of type (b) ... = = is a value compare
Type (a) is type (b) whether the type objects returned by type (a) and type (b) is the same object
Since there exists only one (type) object for each built-in type, there are no need to check their values; Hence, only the latter form should is used.

Isinstance (object, class-or-type-or-tuple), BOOL

Return whether an object are an instance of a class or of a subclass thereof.
With a type as second argument, return whether this is the object ' s type.
The form using a tuple, isinstance (x, (A, B, ...)), is a shortcut for
Isinstance (x, A) or isinstance (x, B) or ... (etc.).

Python Core Programming Chapter 4th Answer (second edition 75 pages)

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.