Friday, December 28, 2012

Python class : getting started

I have never done any OO in Python, but I think I should. OO is good.
Maybe one day will shall say "there was a time where people believed in OO, hahaha what a bunch of losers, now we know that the right thing to do is.... (name your methodology)".

But in the meantime OO is better than Hashtables.

Minimalistic class:
class Pippo:
    name = "hello"


Unlike in Java, this doesn't work:
class Pippo:


there MUST be something inside a class.

Now you can do:
a = Pippo()

this is valid because Pippo has been defined.... if you do
a = Peppo()
you get an error because Peppo class is not defined.

If you do:
a = Pippo()
print a.name
hello

as expected, name was initialized and it's a Object variable, not a Class variable (I mean, it's not static):

a = Pippo()
b = Pippo()
a.name ="bla"
b.name = "mumble"

print a.name
bla
print b.name
mumble

Now let's do:
a.name = "ciao"
a.surname = "bello"
print a


print a.name
ciao

print a.surname
bello

so it's not necessary to declare a member of a class in order to use it. I don't like it, very error prone. I am VERY much in favor of VERY strict syntax.


So it's a MUCH better approach to use mainly Constructors to assign values to attributes:



class Pippo:
    def __init__(self, name, surname):
        self.name = name
        self.surname = surname


a = Pippo("alfa", "beta")

print a.name
alfa
print a.surname
beta


now you can define your classes in a module myclasses.py and then do:

from myclasses import Pippo




iTunes, worse than ever

I was hoping that, after the death of Steve Jobs (god bless his soul), the design of the iTunes software would go back to some more reasonable, humanly acceptable UI standard.

It turns out that his latest release is even more counter-intuitive, freaky and obnoxious than past ones - which I thought were already breaking all records of poor design.

Forget the poverty of the iPhone device: iTunes alone is a very good reason to steer clear from Apple products.

If I had a trading account I would short AAPL.

I had been warned not to buy iPhone, and rather buy Android.... ah if only I listened to other people advice ....

Thursday, December 27, 2012

more Puppet

previous post with videos here. http://www.javamonamour.org/2012/06/puppet-labs.html



Learning Puppet: http://docs.puppetlabs.com/learning/

First steps here: http://docs.puppetlabs.com/learning/agentprep.html

Download the VM : http://info.puppetlabs.com/download-learning-puppet-VM.html and you get a file learn_puppet_centos_pe2.5.1_vmx.2012.04.18.zip


  1. Puppet open source downloads
  2. Comprehensive Puppet installation guide
  3. A step-by-step guide to learning Puppet
  4. The Puppet 3 Reference Manual



  1. Download Puppet: If you haven't already downloaded Puppet, get your free download now and access the latest versions of Puppet, Facter, and MCollective.

  2. Install Puppet: Review the Installing Puppet Documentation to install and configure the latest Puppet open source releases.

  3. Get Schooled: We have an extensive collection of resources to guide you through using Puppet. Here are a few to help you get started: