“C has a feature called a ‘struct’. Struct allows a group of
variable assignments, of different data types, to be collected
under a single name. The variables can be pointers to functions.
Many ‘instances’ can be declared of a struct. The instance can be
referred to by a pointer. The pointers can be stored in arrays. The
structs can contain other structs.“C++, and later Java, expanded the functionality of a struct in
something called a class. Among other things, functions (methods),
could now be part of a class. And the concept of ‘private’ data was
created. Then languages like Python, Ruby and PHP relaxed the
strict definitions of what a class should or has to be. The result
is that today, we have a very useful mechanism or structure called
a class, with commonality between languages.“This article will explore the mechanics of classes in Python.
It will not discuss the whole theory of object oriented
programming. This article may serve, if you come from a C
backround, to show that a class is just an enhanced struct.”
A First Look at Python Classes
By
Get the Free Newsletter!
Subscribe to Developer Insider for top news, trends, & analysis