Python Create object

Source: Internet
Author: User

Class Foo:

def F1 (self):

Pass

obj = Foo ()

OBJ.F1 ()

+++++++++++

obj = Foo ()

FOO.F1 (obj)

Python is a multi-inheritance, like in Java is a single inheritance, so if you want to inherit more, must one to

Tornado's handler has a hook in it that can be modular.

Class Foo (object):

def initialize (self):

Self. A =123

Super (foo,self). Initialize I think here, even if there is no parent class, only object, a single class can Inherit

Actions of the parent class

Class MainHandler (Foo,tornado.web.requesthandler):

def get (self):

Print (self. A

++++++++++++++

Of course, you can also inherit one

Class Foo (Tornado.web.RequestHandler):
def initialize (self):
Self. A = 123
Self.set_cookie (AG)
Super (Foo,self). Initialize ()

Class MainHandler (Foo):

def get (self):
Print (self. A
Self.write ("Hello, World")

Python Creation Object

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.