Skip to content
Programming pages
  • Home
  • About
  • Blog
Menu Close
  • Home
  • About
  • Blog

Author: gwarowe

This author has written 36 articles
  1. Home>
  2. gwarowe

Overloading the [ ] operator for indexing and slicing

  • Post author:gwarowe
  • Post published:22 July 2021
  • Post category:Python
  • Post comments:0 Comments

The square bracket operator [ ] is used by built-in collection data types such as lists, tuples and dictionaries. The item placed inside the brackets can be a single object…

Continue ReadingOverloading the [ ] operator for indexing and slicing

Encapsulation with the @property decorator

  • Post author:gwarowe
  • Post published:9 July 2021
  • Post category:Python
  • Post comments:0 Comments

When we discussed encapsulation in classes, we saw that a class's data fields should be kept as private fields, with getter and setter methods being provided to access or change…

Continue ReadingEncapsulation with the @property decorator

Instance, static and class methods

  • Post author:gwarowe
  • Post published:6 July 2021
  • Post category:Python
  • Post comments:0 Comments

The most common use of a class is as a recipe for creating objects, each of which is a specific instance of the class. The methods that we've defined inside…

Continue ReadingInstance, static and class methods

Generator functions: send(), throw() and close()

  • Post author:gwarowe
  • Post published:1 July 2021
  • Post category:Python
  • Post comments:0 Comments

We introduced generator functions as a way of writing functions that yield successive values while maintaining the function's state in memory. We've seen how to use the yield statement to…

Continue ReadingGenerator functions: send(), throw() and close()

Generator functions and the yield statement

  • Post author:gwarowe
  • Post published:1 July 2021
  • Post category:Python
  • Post comments:0 Comments

[latexpage] A normal function in Python can be terminated with a return statement, which may or may not return a value back to the statement that called the function. After…

Continue ReadingGenerator functions and the yield statement

Recursion: introduction and binary trees

  • Post author:gwarowe
  • Post published:28 June 2021
  • Post category:Python
  • Post comments:0 Comments

[latexpage] A recursive function is one that calls itself. We can illustrate this with the usual example: the factorial function. Before presenting the example, however, it's advisable to begin with…

Continue ReadingRecursion: introduction and binary trees

Handling errors with exceptions

  • Post author:gwarowe
  • Post published:24 June 2021
  • Post category:Python
  • Post comments:0 Comments

Input errors One of the most tedious jobs in writing code designed to be used by others is checking a user's input to make sure it's valid. As an example,…

Continue ReadingHandling errors with exceptions

Writing and reading Python objects – the pickle module

  • Post author:gwarowe
  • Post published:21 June 2021
  • Post category:Python
  • Post comments:0 Comments

We've seen how to write and read text files. This is fine if you want to store the data in a human readable form or transfer the data to some…

Continue ReadingWriting and reading Python objects – the pickle module

Writing and reading text files

  • Post author:gwarowe
  • Post published:19 June 2021
  • Post category:Python
  • Post comments:0 Comments

Writing and reading text files in Python is fairly straightforward. It's easiest to illustrate the process with an example. Here is some code that generates the 52 cards in a…

Continue ReadingWriting and reading text files

Overloading comparison operators

  • Post author:gwarowe
  • Post published:17 June 2021
  • Post category:Python
  • Post comments:0 Comments

[latexpage] Overloading the six comparison operators works in a similar way to the overloading of arithmetic operators. The operators and their associated methods are: Default behaviour Before we try overloading…

Continue ReadingOverloading comparison operators
  • 1
  • 2
  • 3
  • 4
  • Go to the next page

Archives

  • July 2021
  • June 2021
  • May 2021
  • April 2021

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Recent Posts

  • Overloading the [ ] operator for indexing and slicing
  • Encapsulation with the @property decorator
  • Instance, static and class methods
  • Generator functions: send(), throw() and close()
  • Generator functions and the yield statement

PhysicsPages

I also host Physics pages, a blog with notes on physics.

Recent Posts

  • Overloading the [ ] operator for indexing and slicing
  • Encapsulation with the @property decorator
  • Instance, static and class methods
  • Generator functions: send(), throw() and close()
  • Generator functions and the yield statement

Recent Comments

  • Utkarsha Srivastava on Sets
  • InOnIt Blog on Sets

Archives

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Archives

  • July 2021
  • June 2021
  • May 2021
  • April 2021

Categories

  • Python

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
  • Facebook
  • Twitter
  • Instagram
  • Email
Copyright - OceanWP Theme by OceanWP