Snippets Of The Day – Wednesday, September 25, 2013

Posted on Posted in Snippets

orange-scissors-pen

Here are some of the most recently published snippets!

Define and manage custom objects in python

This simple snippet shows how to define a basic custom object (‘myInfo’) and how to manage it into a dictionary. You can define the object’s attributes and reference to them while accessing the data.

Open the snippet

Author: lbottaro

How to populate a dictionary in python

This code shows how to populate a dictionary, using the built-in method setdefault. If the key does not exist, it will be created setting its value too. Otherwise the new value will be appended to the existing ones. In this way the key existence in automatically checked by python during run time.

Open the snippet

Author: lbottaro

Leave a Reply

Your email address will not be published. Required fields are marked *