Posts Tagged ‘rants’

Ontario, point form

I visited southern Ontario last month, making stops in Toronto, Kitchener-Waterloo, and Welland. I previously lived there for ten years, but I’ve been away for a few years now. I took notes on what I missed and didn’t miss, what I found surprising or annoying.

So then, in observed order, annoyances:

  • Parkades / parking garages are a pain to drive out of. Do drivers really put up with it regularly?
  • 2 or 3 cars on nearly every Mississauga driveway
  • The Toronto practice of sending one or two full-size fire trucks to every 911 emergency call. At busy locations like Dundas Square it means huge trucks rolling up several times during a weekend, disrupting everything around them and barely fitting in the space, often to respond to someone fainting from heat. This was one thing I was very impressed with in London: they have several classes of response vehicles ranging from motorcycles (a small motorcycle or scooter being the absolute fastest way to get around inner London) to smaller cars before getting to full-size ambulances, and North-American-sized fire trucks are rarely seen.
  • Similarly, shops in downtown Toronto being resupplied from tractor-trailer articulated container trucks, usually parked more or less illegally. (Often this is a sign of a food shop or restaurant being supplied by a larger catering company.) I understand the economic idea, but it is completely unsuitable to urban scale even in Toronto.
  • Lifted pickup trucks, and pickups in the city in general. I don’t have anything against vehicles being used for a job, but an oddly high amount of pickups I saw around were pristinely clean and weren’t carrying anything in the cargo area.
  • Loud exhausts:
    • Racing motorcycles
    • Harleys
    • Pickup trucks that sound like Harleys
  • Cheques are still a thing. Come on.
  • Window screens. They make me feel like I’m in a mini-prison.
  • This is super-specific, but the previously wonderful Museum of Inuit Art in Toronto has closed.

And the nice things I wasn’t quite expecting I’d miss so such:

  • Multiculturalism on the subway, and in just about any other public space
  • Free toilets
  • Widespread water fountains
  • The St. Lawrence / Esplanade neighbourhood – probably the most European part of Toronto
  • The sun is strong. This is a bit silly, but after two years at 51-52 degrees latitude, I really noticed the sun being stronger at 43 degrees.
  • The CN Tower is still nice. This is personal since it reminds me of my time in Toronto. But still.
  • The AGO is legitimately pretty great. (Once you get over charging for admission to a museum… but not everywhere can be London.)

No free publishing

Twitter is great. You can say anything you like, for free, and reach a huge audience. As long as Twitter likes it. Or Facebook, or Medium, or Snapchat.

In the past, you could have your books distributed by being copied by monks – as long as the church liked the book. Then the printing press came around and it turned out people had lots to say that the church didn’t like.

Or you could have gotten your message out for free by being interviewed on ad-supported TV or in a magazine. As long as the TV station, and ultimately the advertisers didn’t mind your message. People started photocopying zines and it turned out lots of people were into punk.

Not a fan of ad-supported TV? There was the free TV in authoritarian states. The government paid the bill, the government got the final say. Except in bibuła and samizdat.

Ultimately someone always pays for publishing, however little. When you’re the one paying, you control what is being published. When someone else pays, they control.

The goal should be not to make publishing free, but to make it cheaper.

Python zipfile and tarfile differences

A project of mine involves extracting files from .tar.gz and .zip archives as Python streams.

No problem, there are zipfile and tarfile.

As this is Python and the modules do similar things, you might expect they have similar interfaces. Or at least consistent interfaces.

Unfortunately they are annoyingly different. Consider:

task tarfile zipfile
open an archive zipfile.ZipFile(filename)
get a list of members of the archive opened_tarfile.getmembers() opened_zipfile.infolist()
get name of a member zipfile_member.filename
get size of a member tarfile_member.​size zipfile_member.​file_size
extract an archive member (create a file on the hard disk) opened_tarfile.​extract(tarfile_member) opened_zipfile.​extract(zipfile_member)
get a member as a file-like Python object opened_tarfile.​extractfile(tarfile_member) opened_zipfile.​open(zipfile_member)

There’s some more catches. If you opened the ZIP archive with ZipFile(zipfilename) and want to extract more than one member, each extraction will open and close the ZIP file separately, so use with open(zipfilename) as zipfp: ZipFile(zipfp) instead.

Also, for tar archives, in Python 3, the result of opened_tarfile.extractfile() inherits from BufferedReader and so supports a context manager. In Python 2 it inherits object, implements read() itself, and doesn’t include __enter__() and __exit__() required to support a context manager. Extracting members out of ZIP archives with gets a context manager-capable object since Python 2.7.

I understand what happened here: tarfile was added in 2.3 and was different (and better) than zipfile because tarfile’s author didn’t like [zipfile] interface very much. New things were added to zipfile in 2.6 and again in 2.7, and tarfile was improved in Python 3. But that doesn’t make it any less annoying to write code that works with both tarfile and zipfile on both Python 2 and Python 3. We’re stuck with two frustratingly different interfaces for very similar tasks for a while.