Category Archives: identi.ca

Python 3

I attended the Detroit PythonPerl Mongers meeting last night. They opened it up some time ago to include all the interpreted languages (Lisp, Python, etc), and so the lion’s share of last night’s meeting was about the brand new backwards-incompatible Python 3.0, and how it’s different from Python 2.x. I was asked via Identica to take notes, so here they are:

The presentation was given by Steven Kryskalla, who has more python stuff on his home page, but it seems a bit out of date (May 2007?). There’s slides there for what’s new in Python 2.5 (current versions being 2.6 and 3.0), but nothing from last night. At least not yet.

Mind you, I’m normally a horrible note taker. If you find these notes lacking, I should tell you that these are possibly the best notes I’ve ever taken, so be happy with what you got. Shoulda been at the meeting! 🙂

A link to the official What’s new?

Print is now a function. Primarily, this means extra worthless keystrokes, since you now have to enclose what you want printed inside parens. There’s also advantages to being able to call print as a function. For starters, you can now specify the End Of Line character to be something other than the default \n:
print(“hello world”, end=”*”)
That prints “hello world*” and does not give a newline. You can also change the separator from a space to something else, or specify a file to print to.
(attempting to declare a “sep” today, as I have in my notes, does nothing. Not even an error.)

All strings are unicode.

Unless you don’t want them to be. In which case you can use one of the two new datatypes, byte and bytearray

Iterators use lazy evaluation by default. The example of this is “range(9)”. Rather than printing out “0, 1, 2, 3, 4, 5, 6, 7, 8, 9”, it gives the result “range(0, 9)”. Supposedly this saves on memory by not evaluating until necessary. I merely find it annoying.

True division replaces int division. Thankyouthankyouthankyou! I have really hated the Python convention that 1/2=0. Now at long last 1/2=0.5

There is no more “long” datatype.

Can now use hex, octal, and binary literals (0x11, 0o11, 0b11, evaluating to 17, 9, and 3 in decimal). I really like this.

Functions can now have annotated variables, such as:
def f (x: int, y: “Some other annotation”):
I can see the annotations on this function with “f.__annotations__”. It’s important to note that Python doesn’t enforce variable typing via annotations. Even though I declared “x: int” in the function, I can pass a string to x and it still processes just fine.

Extended unpacking(a,*b,c = array… b gets multiple values). In other words:
a,*b,c = range(9)
a=0
b=1,2,3,4,5,6,7
c=8
a,b,*c = range(9)
a=0
b=1
c=2,3,4,5,6,7,8

New string formatting. He did some stuff to make the words in a short sentence come out in a totally different order, and showed how it was different from the old printf style of doing so. I didn’t pay very close attention to this.

I know a bunch of my Identica peeps use Django, so I wanted to link to the Porting Django to Py3k wiki.

Variants of Python (Jython/IronPython/etc.) don’t exist yet for 3.0

Last but certainly not least, there’s a rather nifty tool to help port Py2 code to Py3. It’s called, simply, “2to3”, and if you feed it a python file, it poops out a diff. Does a lot of the grunt work of upgrading (i.e. adding parens around the object of a print statement).

So that’s that. If these notes confuse the hell out of you, don’t say I didn’t warn you.

Microblogging and IRC

I keep hearing people say that microblogging is just like IRC. Others say it’s nothing like IRC. Here are my views on how they relate.

Microblogging and IRC are different because:
In microblogging you select who you want to listen to. In IRC you listen to whoever comes into the room. Granted, you can view the whole public timeline on a microblogging service, but that’s like trying to sip water from a firehose. It’s not the way microblogging is meant to be used.
In microblogging, you say whatever you like. On IRC, you (theoritcally) hover around the topic of the channel you are in.
In microblogging, nobody can stop you from saying what you like. They can stop listening to you, but they can’t censor you. On IRC, the room mods can kick and/or ban you from the channel. Some channels are read-only and you need special permission to speak.
In microblogging you often see half a conversation (between someone you follow and someone you do not). On IRC you always see the entire conversation, or none of it (if the others are in private chat)
In microbogging, you put something out there for the world to see, and you have no idea who’s reading it. On IRC, you can see exactly who is in the room at the time you type your message.

Microblogging and IRC are similar because:
You have a limited amount of space to speak your peace.
You can easily meet new people from around the world and develop friendships with them without ever meeting them.
There is a sense of community amongst the people you converse with.

I think it’s pretty clear there’s more differences than similarities.

Gearing up for OLF

Ohio LinuxFest 2008 is coming up in October, which sounds farther away than it is. I’ve never been to OLF before, but I’ve heard great things about it. There’s a “free” admission, which I will probably take advantage of since I’m looking at $150 or more in gas and hotel fees (and that’s with sharing a ride and sharing a room). On the plus side, there’s going to be a lot of local Ubuntu folk there. Jono Bacon is speaking again (I enjoyed his presentation at Penguicon earlier this year), and so is Zonker. Looking forward to a good geeky time, and maybe get some more people doing 5-a-day for Ubuntu (which I’ve been slacking on myself until last night). If you’re going, and want to meet up, give me a shout here in the comments, or the Friday night of OLF on Identica.

Twitterfeed now works for Identica?

Testing 1, 2, 3. Hopefully this will prove out that Twitterfeed is now working for Identi.ca (and supposedly other laconi.ca microblog sites). Now we just need to get them using ur1.ca to shorten links 🙂

Linkucopia

It’s been a while since I’ve done this. In fact, I don’t think I’ve done this since starting up the NTSHMA blog. But there’s a bunch of stuff I want to point out, where none of it warrants a full blog post:

Dr. Horrible’s Sing-a-long Blog looks like all sorts of comedic geeky goodness. Check out the trailer.
Identi.ca has all but replaced Twitter for me. As soon as they support SMS and have an API, I think I will kick Twitter to the curb.
The same folks bring us ur1.ca to replace tinyurl et al… And it adheres to the Open Service Definition, if you’re into that freedom crap, like I am.
I’m also using TwitterFeed to copy my identi.ca posts to Twitter. It’s not the most effective thing in the world, but it works.
There’s another way (on Linux, at least) for Bit Torrent to beat Comcast’s tcp resets.
There’s more Firefly on the way, in comic book form.

Happy birthday to me (tomorrow). For my birthday, I want a new job. Hopefully the interviewer on Monday grants my wish.