Skip to Content
Python in a Nutshell
book

Python in a Nutshell

by Alex Martelli
March 2003
Intermediate to advanced
656 pages
39h 30m
English
O'Reilly Media, Inc.
Content preview from Python in a Nutshell

Name

__init__

Synopsis

__init__(self[,args...])

When a call C ( [args...] ) creates instance x of class C Python calls x .__init__( [args...] ) to let x initialize itself. If __init__ is absent, you must call class C without arguments, C ( ), and x has no instance-specific attributes upon creation (note that __init__ is never absent for a new-style class, since such a class inherits __init__ from object unless it redefines it). __init__ must return None. Python performs no implicit call to __init__ methods of class C’s superclasses. C .__init__ must explicitly perform any needed initialization. For example, when class C has a base class B to initialize without arguments, the code in C .__init__ must explicitly call B .__init__(self) (or better, for new-style classes, call super( C, self).__init__( )).

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python in a Nutshell, 3rd Edition

Python in a Nutshell, 3rd Edition

Alex Martelli, Anna Ravenscroft, Steve Holden
Python in a Nutshell, 4th Edition

Python in a Nutshell, 4th Edition

Alex Martelli, Anna Martelli Ravenscroft, Steve Holden, Paul McGuire
Data Wrangling with Python

Data Wrangling with Python

Jacqueline Kazil, Katharine Jarmul

Publisher Resources

ISBN: 0596001886Supplemental ContentCatalog PageErrata