Introducing Docstrings

January 8th, 2010

By: Mark Mruss

Note: This article was first published the February 2008 issue of Python Magazine

Of all the tasks assigned to programmers, commenting code and writing documentation are among the most disliked. This article introduces you to Python’s documentation strings. While they won’t make commenting your code any more enjoyable, they will provide a systematic approach to doing it, as well as access to additional tools for documentation generation and testing.

Read the rest of this entry »


Iterators, Iterables, and Generators! Oh, my!

February 23rd, 2009

By: Mark Mruss

Note: This article was first published the January 2008 issue of Python Magazine

Iterators, iterables, and generators are features handled so wall by Python that people programming in other languages cannot help but drool over. Fortunately for us, creating iterators, iterables and generators is a relatively simple task. This article introduces the concepts of iterators, iterables, and generators and illustrates how easy it is to add them to your code.

  1. Introduction
  2. Iteration in Python
  3. An Initial Example
  4. Creating An Iterator
  5. Looking More Closely At The Iterator
  6. The Upside And Downside Of Iterators
  7. Generators
  8. Looking Closely At The Generator
  9. But What About Iterables?
  10. Creating An Iterable Object
  11. Conclusion

Read the rest of this entry »


DodgerEditor 0.1a

November 14th, 2008

So just to prove that I’m a masochist and that the Dodger Editor is not dead (even though I don’t think that anyone has been using it) I thought I’d post a quick update. No the editor is not dead and no neither am I.

I’m still writing for Python Magazine and working on the editor in some of the free time that I get. I just added a selection cursor mode to the editor which makes it easier for me to use. You can see it in the second row of the pallet in the following screen shot.

Now with a Select Mode!

Now with a Select Mode!

If you want access to the newest code you can grab it from the mercurial repository: http://freehg.org/u/selsine/dodger/

If anyone is at all interested in this project, whether it’s using or helping to develop, or just some suggestions please let me know. I’m always open to opinions. If I get the time I’d like to work on a short post showing you how you can use the Dodger Editor to create the level files for a game, when that will be I don’t know but hopefully soon.

TextWidget 0.1

September 21st, 2008

It’s been a long time since I worked on TextWidget at all, but since someone posted a question about it I decided to fix the issue and re-release the source. But since I didn’t want to simply update the blog post I decided to give the project a proper home on google code: http://code.google.com/p/textwidget/

The project is really simple and meant as an easy way for you to create “text buttons” for your PyGame projects. It’s not meant to be the definitive way to do this, just a simple solution for people that just want to drop a class in and have working “text buttons”. It’s LGPL so you can use it in whatever way you want. If you do decide to use it please drop me an email and let me know.

For more information on how to use the project please take a look at the initial blog post.

An Introduction to PyQt: creating GUIs with Python’s QT bindings

September 20th, 2008

By: Mark Mruss

Note: This article was first published the December 2007 issue of Python Magazine

While the command line will never cease to be useful, nothing will impress your friends more than your latest python masterpiece wrapped up in a slick cross-platform Graphical User Interface (GUI). This tutorial will show you how to create a simple GUI in Python using PyQt4.

  1. Introduction
  2. Installing PyQt4
  3. Your First PyQt4 Application
  4. The Main Window
  5. Adding Some Widgets
  6. Signal Handling
  7. Displaying a Message
  8. Conclusion

Read the rest of this entry »

Dodger Editor 0.1

August 25th, 2008

So here it is the initial release of the Dodger Editor. You can download the source from the google code page. Originally I wanted to wait longer to release the first version, but as time went on and it kept taking longer and longer I realized that if I didn’t release the first version at some point in time I might never release it.

If I had gotten done everything that I wanted to get done then I would be releasing the full first version of the project instead of this incredibly alpha release. So if something doesn’t work don’t be surprised. That being said you should be able to use it for it’s basic functionality. Or at least that’s what I’m hoping.

Installation

Once you have met the requirements:

You should be able to install dodger by downloading the and extracting the source tarball. Once you have extracted the source change into the source directory and install using:


python setyup.py install

If you don’t want to install and just want to test dodger out simply follow the above instructions except instead of installing dodger run the following:


python runner.py

Contributing

I still want to setup a dedicated site that will host a mercurial repository of the code but for now I’m going to use the fabulous http://freehg.org site. For now if you want you can pull the source from  http://freehg.org/u/selsine/dodger/:


hg clone http://freehg.org/u/selsine/dodger/

For now any changes that you make or fixes will have to be emailed as a patch but eventually I want to make it much much easier for people to submit fixes.

If you are really interested in contributing to this project let me know via a comment to this post and or an email. Then once all of the source issue are setup we can start working together.

New Features

Since the last release there has been a lot of changes under the hood. The most visible changes for anyone using dodger is the addition of the zoom feature:

zoom example

zoomed out example

zoomed in example

zoomed in example

General Usage

For general usage information please read the README file or General Information page on the google site. It’s pretty rough right now but hopefully over time we’ll be able to work on it.

History

If you are interested in the history of this project you can read the following blog posts to see how everything came about:

Beware

If you do decide to use or test dodger remember that you are going to find a lot of bugs during the iteration. Please be kind and report the issue.

Back from Holidays

August 18th, 2008

Sorry about the lack of updates and responses here everyone. I’ve been away on holidays so I haven’t had any time to access this blog or work on the level editor at all. I’m going to try to get the code up as soon as possible so that anyone interested can start playing with it and hopefully fix all of my mistakes.

Thanks for you patience everyone, I’ll be back with more soon!

Level Editor 0.3 (Dodger)

June 22nd, 2008

I know it’s been a while and for that I apologize the last few months have been pretty crazy around here…although I’m starting to see a trend with life in general lately, namely that it’s always crazy.

I’ve been busy with work, Python Magazine, my wife, trips to Dallas, and yes whenever I get a chance this slowly growing level editor. Let’s see what I’ve been working on for the last little while:

Name: There has a been a name for the editor ever since I started working on it. I wasn’t sure if I was going to think up something really cool and change, or leave it. Turns out I just left it.

So from this point forward this project is christened: “Dodger”, or probably more correctly: “Dodger Level Editor”.

The name has its roots in the name of one of my cats and a history in the multitudes of level editors and game engines that I have tried to create in the past, but I wont’ go into that. So Dodger it is.

Saving and Loading: Saving and loading in the default YAML project type now really works. I still need to put in support for optional project types: XML, JSON, and other formats

dodger editor welcome dialog

Welcome Dialog: This was a real pain, but it’s made the last while so much easier. I added a working (at least I hope) welcome dialog with a way to create new projects, open old ones, and a recent file list. The recent file list really makes testing easier for me.

dodger editor rect tracking

Rect tracking: Rect tracking is finally working properly. I’ve had the rect tracker in there for a while but it didn’t really do anything until now.

dodger editor multiple selection

Multiple Selection/Multiple Properties: I’ve also finally got multiple selection going, which is what makes the rect tracker actually useful. You can select multiple sprties, move them around and add properties to all of them.

Remove Properties: Now you can remove custom properties that you have added. This was a must but I was lazy and left it for a while.

Steps towards being made public: A lot of the changes (and I do mean a lot) that I’ve been making have been behind the scenes. There has been a lot of refactoring and reorganizing of the code, often the result of quick and dirty implementations that I made earlier (sigh). I’ve also started working on getting the distribution of this editor going so that other people can use/develop it.

I’ve added support for zc.Buildout so that if anyone wants to develop they can quickly gather dependencies and won’t have to install the editor system wide, not that you have to anyways but zc.Buildout is really neat.

I’ve also worked on the license (GPLv3) and setup.py and README and all of that. None of it’s done but it’s working its way forward.

Faster: It’s also much faster now. None of you have used it so you’ll probably think it’s slow, but trust me it’s much faster then it was before.

Bugs: There have been loads of bugs that have been fixed and created. Plus one doozy related to
changes made to pyglet. Not pyglets fault but it took a long time to figure out what the issue was.

Google Code: The project has a temporary homepage over at google code: http://code.google.com/p/dodger-editor/ There’s nothing there yet but over time I will start to host the project there so that people can easily download it. I’ll still post updates here until the site has a full-time home.

I’m going to use Mercurial for the revision control system for the project so the CVS support at the google code site will just be for downloading. Eventually I will want to host the project on some space of my own and get a nice web interface for the mercurial repository going. I’ll have to find a new hosting company so it will take a while.

So that’s it, that’s what’s happened to the Dodger Level Editor over the last few months. I know I promised to make it public earlier but given the shape it was in at that time there really was no point. I want this to be at a point where people can actually almost use it before I make it public.

I know it’s been a while, and I know the few of you that actually care about this project have probably moved onto bigger and better things, but hopefully if you stick with me there will be something out soon.

Operator Overload! Learn how to change the behavior of equality operators.

June 21st, 2008

By: Mark Mruss

Note: This article was first published the November 2007 issue of Python Magazine

While the equality operator works great on numbers and strings the fact the way it treats your custom objects really is not that useful. This article looks into overloading the equality operator so that you can easily compare your custom classes.

  1. Introduction
  2. Introducing the terms: operators and operator overloading
  3. A Quick Example of the Default Equality Operator
  4. Overloading the Equality Operator
  5. Telling Python that the Comparison has Not Been Implemented
  6. The Inequality Operator
  7. Dangers
  8. Conclusion

Read the rest of this entry »

Possible hackage

May 30th, 2008

Note: The blog was hacked. I spent all night trying to clean it up. If you have registered here you may think about changing your password. Sorry about this folks it pretty much sucks.

Hey everyone,

Just to let you know there is a strong possibility that this blog was hacked recently. A helpful user (Eoin) informed me that when trying to visit the blog from Google he was re-directed to an advertising website.

In response I’ve updated the blog and tried my best to ensure that anything that was hacked is back to normal.

If anyone noticed anything strange happening on this blog please let me know.

Thanks.

Fraking hackers…