Introduction to Classes

  • Hans Petter Langtangen
Part of the Texts in Computational Science and Engineering book series (TCSE, volume 6)

Abstract

A class packs a set of data (variables) together with a set of functions operating on the data. This allows the programmer to compose new objects with content and behavior designed for the problem at hand. Most of the mathematical computations in this book can easily be coded without using classes, but classes often offer more elegant solutions or code that is easier to extend at a later stage. This chapter gives an introduction to the class concept in Python with emphasis on applications to numerical computing. We cover in particular constructions that allow user-designed objects to enter arithmetic expressions.

Keywords

Special Method Boolean Expression Interactive Session Balance Attribute Ordinary Function 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Hans Petter Langtangen
    • 1
    • 2
  1. 1.Simula Research LaboratoryLysaker, FornebuNorway
  2. 2.Department of InformaticsUniversity of OsloOsloNorway

Personalised recommendations