Python's meta-class ORM

Source: Internet
Author: User
  • What is a meta-class
    In Python everything is object, the class is an object, the instance object is created by the class, and the class is created by the Meta class. In short, the class used to create the class is called a meta-class (Metaclass). The function type is actually a meta-class, and type is the meta-class that Python uses to create all the classes behind it.
  • The role of Globals ()
    The Globals () function returns a dictionary that holds all global variables for all current positions.
  • Type () dynamically create class
    Type (' Class name ', (parent class,), {attribute})
  • What is ORM?
    ORM is the object relational Mapping, the full name of a relational mapping. To simplify SQL operations, encapsulate the operations of a database into a class, map a table to a class, map a field to a property, and map a row to an instance. With such a mapping of one by one, we can avoid directly manipulating the database, as long as the appropriate method is called.
    Usage of 5.setattr () and GetAttr ()
    SetAttr (Object, property, property value) to set a value for an attribute in an object
    GetAttr (Object, property [, Default]) reads the value of the property from the object, you can set the default value, or read the default value if it does not exist.
    6. Built-in Modules
    Builtin in Python2
    Builtins in Python3
  • Python's meta-class ORM

    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.