Python-delattr (object, name)

Source: Internet
Author: User
Delattr (object, name)

英文说明: Remove the property with the object name named name. The name of this function is very easy to understand Ah, and jquery in the same, but the function is not the same oh, pay attention.

Parameter: Object.

Parameter name: property name string.

Version: This function is supported in each version and is still available in Python3.

English Description: This is a relative of setattr (). The arguments is an object and a string. The string must be the name of the one of the object ' s attributes. The function deletes the named attribute, provided the object allows it. For example, delattr (x, ' Foobar ') are equivalent to Del X.foobar.

code example:

>>> class Person: ...     def __init__ (self, Name, age): ...             Self.name = Name             ... Self.age = age...>>> Tom = person ("Tom", "a") >>> dir (Tom) [' __doc__ ', ' __init__ ', ' __module__ ', ' age ', ' n Ame ']>>> delattr (Tom, "Age") >>> dir (Tom) [' __doc__ ', ' __init__ ', ' __module__ ', ' name ']
  • 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.