mmmm Interesting

September 8, 2008

Keep on running …

Filed under: Python — e078120 @ 10:59 am

I first learned python at version 1.4 or so, and I am supporting python code that was also written around that time.

Since Python 1.5 there have been many improvements to the language, and I have religiously read the release notes of every new release in an attempt to stay up to date. My success was mixed, and I occasionally come across better ways to do things that were introduced in later Python releases, that passed me by somehow.

I plan to share them with you here….

Lets start with the ubiquitous dict

Dictionaries are wonderful things that can be used in all sorts of ways. Having a built a dictionary of values though, you will eventually need to retrieve data from it. Here is the first trap for an older user, I always want to write something like:

if dictionary.has_key(key):

data = dictionary[key]

….

This has of course been superseded and nowadays one writes:

if key in dictionary:

data = dictionary[key]

….

Note that if you want to return a default value if the key is not in the dict, you can use the get() method.

When iterating over a dictionary it’s a similar story:

for key in dictionary.keys():

…..

has been improved an you can use:

for key in dictionary:

……..

Naturally if you want to change the dictionary inside the for loop, you will have to use the keys() method to obtain a list to iterate over, just like in the old days!

I hope you found that useful …

August 2, 2007

Pricks and Mortar

Filed under: Blogroll, Commentary — e078120 @ 3:10 pm

Well its been sometime, hasn’t it.

I bet you thought that I’d got bored and gone away to new and more interesting things.

Well you thought wrong!

In fact I’ve been busy moving house, decorating, laying floors, and all those other knee destroying things that go with having a bank as your landlord.

After 9 months in the new place what do I have:

  • Less free time than ever.
  • Bad Knees.
  • Tennis elbow.
  • A current account balance in free fall.

Why do people buy houses? Its a supreme act of idiocy dammit!

Security I hear you say. Bullshit! A landlord is more likely to listen to your entreaties than a bank manager who knows exactly how deeply in the financial shit you are, and can look at your financial status with a clickety click of the keyboard.

Investment I hear you say. Bullshit! If I invest my hard earned cash in unit trusts, I get at least 9% pa. If I invest in a house, I pay 5% pa + repairs on the house + insurance in case the damn thing burns down. I wont even go into the costs of mad women with credit cards furnishing new houses here, as it may severely damage my bedroom rights.

Why do we buy houses then? Well I think its some instinct that comes from the time when there were no bank managers, and the size of your cave was used to attract crumpet. (Incidentally I think cars as an investment are just as stupid, but I’ll go into that later.)

Oh well, do as I say, not as I do,

It all goes to show I’m as big a prick as the next man….

October 5, 2006

The Internet with everything…

Filed under: Blogroll — e078120 @ 8:21 am

The Internet is getting in everywhere.

Ham radio has had repeaters for many years, they are systems placed at a good VHF/UHF locations that receive and re-transmit signals, allowing communications between stations that could not otherwise be in communication.

 

Now with the event of voice over IP it was natural that someone would write software allowing repeaters to be connected to the Internet, allowing someone to use a PC as a sort of extended microphone and speaker, attached to the repeater of their choice.

Well the latest step in this particular line of development is that I can now connect to my local repeater using my hand held transceiver, tell the repeater to connect to another repeater via the Internet by entering the node number using the DTMF keypad on my transceiver (Each echolink node has a unique number), and then have a conversation with anyone within range of that repeater.

The long and short of it is that I can now easily contact any ham who lives within range of an echolink connected repeater anywhere in the world, using a hand held transceiver.

Thats pretty cool, and way cheaper than using a handy…

I wonder what the next step will be?

If you are licensed, I can be reached via the repeater DB0EL (Node 7385) when I am listening. My call is DL4MGJ.

 

July 9, 2006

Staying in contact

Filed under: Blogroll — e078120 @ 10:02 pm

I started blogging because a friend of mine started, and it seemed like an interesting thing to do. I didn’t really expect it to take too long for me to get bored and let it drop.

It’s taking longer than I thought though…..

What I have realized is that blogging is a way of staying in touch, and I’m beginning to think that it does have some advantages over e-mail.

When I write someone an e-mail, I hope for a reply. The recipient feels obliged to send a reply, and when he does, I feel obliged to reply to his/her e-mail and so it goes on…

When I write a blog, I don’t expect a reply, but I am contacting people who know me and who read the blog. I know that when I read a friends blog’s it’s almost like receiving an e-mail, but with no obligations. Of course if something in the blog raises a question or comment, I am still free to send an e-mail or call them (preferable), just as they are.

So there you have it, I will probably be blogging for a little longer than I thought….

July 6, 2006

Glass Ankles

Filed under: Blogroll, Sport, Uncategorized — e078120 @ 8:10 am

Well it looks like the World Cup is over, it must be, there are markedly fewer cars around sporting German flags. Someone somewhere must be making a quilt.

As you have probably gussed, I am not a great football fan.

I did start to watch the Germany Italy match, but after 10 minutes of nothing really happening, I grew bored and went back to NASA TV and watched the shuttle perform its first orbital correction.

What I did see though was that a new rule has been added to the game since I played it in school. I haven’t seen the wording yet, but it must be something like:
“If you are tackled and loose the ball, throw yourself to the ground in the most spectacular way you can manage.” It seems that if the fall is spectacular enough, the referee will give you the ball back.

I was very impressed with some of the falls, being really convinced that the player had at least a complex fracture of the fibula, only to see the player get up totally unhurt. Really amazing….. This really must be suggested as an Olympic discipline. Points could be awarded for air time, number of ground rolls, and how convincing the expression of pain was…

So the World Cup? As far as I can tell the situation is a follows

  • England (My home country) Out…
  • Germany (My country of residence) Out…
  • Portugal (Age old allies…) Out…

That leaves me with the choice of France or Italy to support in the final.

mmmm Maybe NASA can launch something on Sunday?

July 1, 2006

mmm…

Filed under: Uncategorized — e078120 @ 6:55 am

We I have just posted my first blog, and spell checked it, and guess what…

The built in spell checker chokes on the word blog!

Oh well, nobodies perfect, and its not exactly the end of the world… Funny though dont you think…

I guess I will go look for a way to add to the spell check dictionary….

Hello world!

Filed under: Uncategorized — e078120 @ 6:13 am

A friend of mine has started to blog, and it seems like a nice idea so here I am in blogging space..

OK, so what do I have to say that is generally interesting? um, er, probably not a lot…. So why am I wasting Internet bandwidth and free server space? well to be completely honest, I really don’t know… I guess I find things that are new (at least to me) interesting and want to try them out…

Here are a few details about me:

I am an Electronics engineer and programmer…

I have been programming now for over 30 years…

I have experience in the Unix kernel, control systems, RF engineering, digital electronics and much more. I have programmed in most programming languages at some time or other. I don’t like Java (Much too bloated) or Perl (A real mess of a language). I do like “C”, “C++” and “Ruby” , but my language of choice is “Python”.

Why do I like “Python”? Well it is really cross platform, It is maintainable, and you can do allmost anything with it. It is good for quick 2 liners as well as large projects. You can do the most amazing things with its introspection and run time object building features and so on… If you have not yet tried it, you are missing out….

Well that’s all for now… Lets see if blogging holds my attention..

Don’t hold your breath though..

Blog at WordPress.com.