Skip to content. Skip to navigation

isnomore.net

Document Actions

pyconbrasil[3][1]

by rbp posted at 2007-10-06 00:19 last modified 2008-01-23 18:23

Ooookay, the follow-up of my PyConBrasil[3] musings took longer than I expected :P

Anyway, after many hours of an exhausting drive, a nice get together in a local bar and, for at least two of us, an international travel, Danilo, Leo, Nate and I were all very tired. Besides, I forgot to mention on the previous post but, when we arrived at our hotel, we found out that they had cancelled our reservations without any warning! Luciano Ramalho managed to find a couple of rooms in the hotel where he was staying, we drove over and finally managed to sleep.

With all that, we were late for the first day of the conference and ended up missing Pedro Werneck's talk ("What Python Does When You're Not Looking", which was widely hailed and everyone agreed was a mistake to slot so early in the morning).

Actually, we got there just in time for Nate's "Multimedia and Podcasting with Plone" presentation (which was convenient, since he was in the car with us ;)). I only knew Plone4Artists by name and, being a frequent complainer about Plone's late adoption of "whistles and bells" (a complaint Plone3 also put to the ground), I was really impressed! I hope I get a chance to play around with it soon (and apparently I will! But more on that later). Nate also gave us a sneak preview of a website he and others at Jazkarta have been working on. But I won't name it or link to it here, because it only officially launches at PloneConf next week and I don't want to spoil the surprise :).

As usual, I skipped many of the presentations to talk to people outside the conference room, and the next one I watched was Dirceu Tiegs's "Introduction to Grok". Now, I've had a lot of interest in Grok lately and have been somewhat involved in Luciano's Kirbi project (though far less than I wanted to), so it was cool to see Grok in the spotlight (with at least two talks and a training session). I also got a chance to buy a Grok t-shirt (like the one Leo's wearing in this picture) :).

Leo, BTW, sensibly changed the topic of his presentation from "Security in Plone" (an interesting subject, but there were a lot of plone talks already) to Ipython (which most people at the conference didn't know about, or didn't use regularly). A very cool presentation, despite some difficulties getting the colour scheme right for projection.

I also particularly enjoyed Érico's "Why Python Matters" (and its point that "industry standards" are stuff to beware of) and Senra's "Pyrotechnical Show - Part II" (neat tricks, impress your friends at parties!).

Another one of notice to me was LZT's presentation of their gas station automation system (in Python, obviously): based on the screenshots they showed, the gas station where I usually refuel my car uses this system! I was so amused by this that I decided not to post here the picture of their jobs page written in php ;). That, and the picture came out too light :P.

There were a few more presentations, some more relevant than others, and then, of course, a large group of us went to a bar for the night :).



Fun for the whole family!

by rbp posted at 2007-09-27 15:29 last modified 2008-01-23 18:24

As I had mentioned earlier, I have been invited to speak at two different conferences. One of them has been postponed, but the other is confirmed!

And it's today :P

Ok, I should have given an earlier warning. But, as far as I know, everyone who reads this blog already knows about it, so it shouldn't be too much of a problem :)

The conference is a week-long IT even at Unicsul called WICA07 which is happening simultaneously at three locations. The one where my presentation will be is Sao Miguel.

My slot is from 21:20 to 22:40, and I'll talk about Python. It'll be introductory-level, since I don't think Unicsul teaches Python at all.

So, if you read this and want to show up, I'll do my best to keep you entertained! And let me know you read this blog, I'll be happy to hear about it ;)

BTW, I noticed Erico is speaking there tomorrow about Plone. Cool :)


Not equal not not equal. By default.

Or: always implement __ne__ alongside __eq__

by rbp posted at 2007-09-10 16:39 last modified 2008-01-23 18:24

At our last Dojo session (Danilo has blogged about our Dojo, in Portuguese - I wonder when he'll switch to English?), the Kata being presented required knowing whether two instances of the same class were equal, based on some internal semantics. As in "object1 == object2". The coders went on, dutifully, and implemented the __eq__ method, which, in Python, is called whenever such a comparison is requested. Except that it's not enough. Or, perhaps more dangerously, it seems to be enough, but isn't.

You see, Python's operator overloading defines which methods are called when each specific operator is used. So, when you want to add two objects of a class you wrote, "a + b" will be converted into "a.__add__(b)", and all you have to do is define an __add__ method to your class that handles addition according to your class's semantics (there's a bit more to it, but that'll suffice for now).

Back to equality: using the "==" operator will result in a call to the "__eq__" method; if there is no such method in your class (nor was it inherited), the default is to compare the object's address in memory, or "id" (that is to say, equality comparison is true if, and only if, the objects are precisely the same). So far so good:

class Default:
pass

class Rich:
def __init__(self, value):
self.value = value
def __eq__(self, other):
return self.value == other.value

The Default class just uses default comparison, and the Rich one checks for equality using a value passed to objects at the time of their creation:

>>> default_1 = Default()
>>> default_2 = Default()
>>> default_1 == default_2 # Different ids
False
>>> default_1 == default_1
True
>>> rich_1 = Rich(1)
>>> rich_2 = Rich(2)
>>> also_1 = Rich(1)
>>> rich_1 == rich_2 # Different values
False
>>> rich_1 == also_1 # Same values...
True
>>> rich_1 is also_1 # ... but different ids
False

Looks ok, and our Dojo coders got as far as that. Now we can tell if two objects are equal, but can we tell if they're different?

>>> rich_1 != rich_2
True

Fine. But what if they are supposed to be equal?

>>> rich_1 != also_1
True

That's the problem. When you define __eq__, you overload the "==" operator, but "!=" remains as the default, which is to check whether both objects are not located at the same address in memory! Objects rich_1 and also_1 have different addresses and thus compare as different when we look at them through !='s eyes, even though they're equal through =='s. So now we have objects that are equal and different at the same time!

>>> rich_1 == also_1, rich_1 != also_1
(True, True)

Fortunately, the solution is simple: we just have to define the __ne__ method to overload "!=". We don't even have to put the logic in there again, we can just make sure it's the opposite of what we're considering "being equal" to mean:

class Richer:
def __init__(self, value):
self.value = value
def __eq__(self, other):
return self.value == other.value
def __ne__(self, other):
return not (self == other)

Easy. Now the objects work as expected (at least as far as equality comparisons are concerned):

>>> richer_1 = Richer(1)
>>> alsoer_1 = Richer(1)
>>> richer_1 == alsoer_1
True
>>> richer_1 != alsoer_1
False

There.

Now, someone asked me why this behaviour (not __eq__) is not the default for __ne__.
I really have no idea. It seems to work even for the default case of __eq__ checking for the id. The Python documentation says: "There are no implied relationships among the comparison operators. The truth of x==y does not imply that x!=y is false", but I can't see a practical reason for it since, for the vast majority of uses, x==y should imply that x!=y is false. I don't think "explicit is better than implicit" applies, since there is already an implicit assumption for !=, if you don't do anything explicit about that.

Anyone?

pyconbrasil[3].pictures

by rbp posted at 2007-09-09 15:19 last modified 2008-01-23 18:25

Speaking of PyConBrasil3, I've put up a bunch of pictures on flickr, using Aline's Pro account. Descriptions are in Portuguese, but, if anyone asks for it, I can translate them.

PS: Yes, my pyconbrasil[3] "list" has a pictures attribute. So it's not really a list, but it provides a list-like interface. That's dynamic languages for you! ;)

pyconbrasil[3][0]

by rbp posted at 2007-09-08 19:56 last modified 2008-01-23 18:25

Wednesday, August 29th 2007

Intermission:

Python won't let me cross the boundaries of the list, so let me make it clear that, even though the conference started on Thursday, I got there one day earlier for the first public assembly of the Brazilian Python Association (and thus I indexed Wednesday at 0 and Sunday (the day after the conference) as -1).


Danilo came to my place in the morning, we took the car fueling, washing and oil changing, and drove to Guarulhos airport to meet Nate Aune. I didn't know him, but it wasn't hard to spot the american-looking guy underneath a palm tree holding a video camera and staring at his MacBook Pro :)

We waited a few more hours for Leo to arrive (he was returning from a month in Argentina) as his plane was late (how come Leo always manages to be late, even when he has absolutely no say over it??), had a quick spot of lunch at the airport and , by the time we finally left to Joinville, Nate, having arrived at 7am and it being 1pm already, knew the airport staff by name and spoke only in the soft monotonous voice of flight announcements. 7 hours, incessant rain, very dense fog and loads of lorries later, we arrived just in time to... Get lost in Joinville! Some more driving around, we asked a few locals and eventually managed to arrive at Sociesc's campus, where the conference would be held - and the Association's assembly had started about one hour earlier.

We arrived after the voting for the board had already taken place, but there was only one candidate group, which was elected by acclamation - and was the one I would have voted for anyway, so no harm done. There was some interesting discussion afterwards that served mainly to gather points to be addressed in the future. We should make sure that they are. I'd particularly like to see some action in one specific shortcoming of the Python community: we really suck at marketing! I'll probably write more about this later, but I think we lack better-looking websites (including python.org), easier, shorter tutorials (I'm sure there are a few, but they should be featured prominently on python.org) and basically more "wow factor" for newcomers (I believe experienced Python programmers are already reasonably well-served).

Anyway, once all the formalities were over, we carried on with what we were all really there for: dissing Java!

And beer, and food. Of course :)





pyconbrasil[3]

by rbp posted at 2007-09-08 17:50 last modified 2008-01-23 18:25

As people who saw the banner that adorned the top of the my page (and, now, the bottom of this post) these last few weeks might have guessed, I was at Joinville from Wednesday (August 29) to Sunday (September 2) for PyConBrasil3. The conference was tons of fun and I got to meet some friends of old and new alike.

My original plan was to blog daily updates, but, well... I need to get myself a laptop :(.  Volunteers? :)

So I'll leave procrastination for later and get on with a short summary.

Update: Change of plans. The post was getting too big and it was taking me too long to publish anything, so I'll write one post per day (that I was there, not in real-time).

Update on the update: apparently I forgot to publish this post, so it won't help building much anticipation :P



Calm down, there's rbp for everyone...

by rbp posted at 2007-09-05 16:18 last modified 2008-01-23 18:25

I just got back from PyConBrasil[3] (there's a post about it in the oven, should be ready soon) and have already received two invitations to speak at different conferences!

True, one of them was directed at several of pycon's speakers and the other had nothing to do with pycon at all. Still, nice to see the wheels spinning :)

As soon as I am confirmed on any of these, I'll post a note here.


Nearly there, now...

by rbp posted at 2007-07-02 15:59 last modified 2008-01-23 18:25

Well, zope and plone have been upgraded to the latest Plone < 3 bundle (that is, 2.5 series). I ran into a specific problem (stale transform causing upgrade failure) which I'll detail later for future reference.

The isnomore.net jabber server is also back online, which I think was the last remaining isnomore/cybershark service still not up. The migration is thus completed (except, of course, for the fact that I've been trying to transfer the isnomore.net out of godaddy and into aplus.net for more than a month now, with little to show for).

Hopefully that'll motivate me to shake things up a bit around here :)

Category(s)
meta
english

You vicious, heartless bastard!

by rbp posted at 2007-06-19 16:48 last modified 2008-01-23 18:25

That rant above is directed at me, for forgetting to properly thank daniduc in the previous post for the two solid weeks of work he put to bring our server back online.

Dank je, Dude :)

Category(s)
meta
english

I'm alive! Hello, birds! Hello, trees!

by rbp posted at 2007-06-18 16:39 last modified 2008-01-23 18:25

About two weeks ago, the server that held isnomore.net crashed. Literally. On the floor. I've used the "crashed, literally" joke a lot, these past days, but it's true. The shelf where we put the server fell from the wall and there went isnomore.net (and a few other domains). Obviously, our backup server was on the same shelf, and was found on the floor as well, but, fortunately, its hard drive still worked (unlike our main server's).

We (the {isnomore,cybershark}.net team) had been planning to move to a dedicated hosting anyway, so we took it as a sign from %(deity) and got to it right away. Since there was going to be a few days of downtime anyway, I went ahead and asked my previous ISP to transfer the domain to a registrar where I could control it directly. That, of course, started my very own little comedy of errors which guaranteed that isnomore.net remained unavailable long after the server had been migrated and all other services on it had resumed working properly.

The domain is not transfered yet, but at least I'm back online. I'll resume posting here soon (not counting this post) and I'll return to my priority list as well. Hopefully.

Category(s)
meta
english
[isnomore.net]
software
blog
completely different things
Google Reader shared items
Google Reader shared items rss feed
bê do érre
ali ckel
cybershark
Recent entries
pyconbrasil[3][1] rbp 2007-10-06
Fun for the whole family! rbp 2007-09-27
Not equal not not equal. By default. rbp 2007-09-10
pyconbrasil[3].pictures rbp 2007-09-09
pyconbrasil[3][0] rbp 2007-09-08
Recent comments
Re:pyconbrasil[3][1] Danilo Sato 2007-10-06
Re:pyconbrasil[3][1] rbp 2007-10-06
Re:Fun for the whole family! rbp 2007-10-02
Re:Fun for the whole family! Anonymous User 2007-10-02
Re:You vicious, heartless bastard! Anonymous User 2007-08-15
Categories
python (13)
meta (8)
english (19)
portugues (0)
OLPC (1)
spam (4)
agile (2)
nnebs (3)
coreblog (2)
community (6)
pyconbrasil3 (5)
About this blog
rbp's random ramblings (and alliterations, as always)
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: