- Open a command prompt on your operating system of choice and start up python.
- Inside the python interpreter import the python package who’s path you wish to find: >>import pyglet
- Now issue the following command: pyglet.__path__
- This is the response you get back on a windows system: ['C:\Python25\lib\site-packages\pyglet']
- To get the path of a module, first import your module then issue the following command: module.__file__
February 26, 2009
Random Tech Nugget: Finding paths to Python libraries/files
Sometimes its nice to be able to find the path of where a specific python package or module is installed. For example on recently I was trying to find the path to the pyglet source code so I could look at how text gets rendered to the screen. In order to find this out do the following:
February 25, 2009
Learning the Vi and VIM Editors 7th Edition by Arnold Robbins, Elbert Hannah & Linda Lamb
This book is all about how to use the text editor Vi and the improved version of it Vim and to a lesser extent other editors derived from Vi . If you deal with Unix on a regular basis then knowing the basics about how to move around in Vi can be an invaluable skill to have. This editor is bundled with nearly every Unix variant know to man including prehistoric versions of HP-UX and Solaris (SunOS) as well as other more obscure creatures. A good understanding of Vi can save you a lot of pain if ever you find yourself having to deal with editing config files on legacy systems. Apart from all that Vim, properly configured and coupled with cscope, is an incredibly powerful and light weight editor, which once mastered allows a competent developer to hack away at a blistering speed.
If you come from a windows background or are used to dealing with rich IDE’s then Vi /Vim, with its seemingly archaic keyboard combination’s, can be a bit of a shock to the system. This book does an excellent job of putting the editor in perspective, explaining why it works the way it does and how with a bit of discipline and patience it make you edit files faster. The first 8 chapters go through the basic’s of moving around with Vi and provide a number of useful examples on how to do all the basic things you will want to do (moving around, deleting, search and replace, using buffers, regex). The next 8 chapters go into using Vim and discuss various issues like setting up color schemes, configuring it, indentation and a whole bunch of other goodies, again they do a good job of covering all of the things you would want to know if you never used Vim before. The last 3 chapters cover other Vi derivatives such as Nvi, Elvis and Vile, these chapters give more of an overview of each of these editors than a comprehensive review of what they can do.
Their are a couple of things I did not like about this book. First of all I felt that, for me, someone with a working knowledge of Vi /Vim it was generally a little bit wordy and a good half inch thicker than it needed to be. Secondly, I often find myself needing a little guidance on how to do certain things in Vim, on a number of occasions I attempted to flick through the index/appendix at the back of the book in search of an appropriate example. Googling almost always yielded a better example, so the use of this book as a day to day reference is a little questionable. Thirdly, the absence of any lengthy discussion of cscope is to my mind a disservice to any developers reading this book.
In summary I think this is a fantastic book for anyone new to Vi /Vim but not so much for the more experienced user who will get a few usefull tibits out of it but little more. The previous edition is currently priced at around $26 on amazon and I believe it only covers Vi , the price on the back of my review copy of the 7th edition is $34. I think for a newbie anything under $40 is a fair price to pay.
If you come from a windows background or are used to dealing with rich IDE’s then Vi /Vim, with its seemingly archaic keyboard combination’s, can be a bit of a shock to the system. This book does an excellent job of putting the editor in perspective, explaining why it works the way it does and how with a bit of discipline and patience it make you edit files faster. The first 8 chapters go through the basic’s of moving around with Vi and provide a number of useful examples on how to do all the basic things you will want to do (moving around, deleting, search and replace, using buffers, regex). The next 8 chapters go into using Vim and discuss various issues like setting up color schemes, configuring it, indentation and a whole bunch of other goodies, again they do a good job of covering all of the things you would want to know if you never used Vim before. The last 3 chapters cover other Vi derivatives such as Nvi, Elvis and Vile, these chapters give more of an overview of each of these editors than a comprehensive review of what they can do.
Their are a couple of things I did not like about this book. First of all I felt that, for me, someone with a working knowledge of Vi /Vim it was generally a little bit wordy and a good half inch thicker than it needed to be. Secondly, I often find myself needing a little guidance on how to do certain things in Vim, on a number of occasions I attempted to flick through the index/appendix at the back of the book in search of an appropriate example. Googling almost always yielded a better example, so the use of this book as a day to day reference is a little questionable. Thirdly, the absence of any lengthy discussion of cscope is to my mind a disservice to any developers reading this book.
In summary I think this is a fantastic book for anyone new to Vi /Vim but not so much for the more experienced user who will get a few usefull tibits out of it but little more. The previous edition is currently priced at around $26 on amazon and I believe it only covers Vi , the price on the back of my review copy of the 7th edition is $34. I think for a newbie anything under $40 is a fair price to pay.
February 24, 2009
Random Tech Nugget: How to schedule a task with cron on OpenBSD
On OpenBSD or most Unix like system’s cron is the way you schedule a periodic task for execution. In the following example I am scheduling webalizer to parse the logs of my blog once every half hour.
* * * * * command to be executed
- - - - -
| | | | |
| | | | +—– day of week (0 – 6) (Sunday=0)
| | | +——- month (1 – 12)
| | +——— day of month (1 – 31)
| +———– hour (0 – 23)
+————- min (0 – 59)
The above diagram was taken from this article. For more infromation see man cron.
- First create tab file: sudo touch /var/cron/tabs/harry
- Then edit tab file for user: sudo crontab -e -u harry
- A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.
- In the following example I am scheduling webalizer to parse my apache log files every half hour: */30 * * * * webalizer -Q -p -o ~/somedir/wp-logs/ /var/www/logs/harrytormey.log
* * * * * command to be executed
- - - - -
| | | | |
| | | | +—– day of week (0 – 6) (Sunday=0)
| | | +——- month (1 – 12)
| | +——— day of month (1 – 31)
| +———– hour (0 – 23)
+————- min (0 – 59)
The above diagram was taken from this article. For more infromation see man cron.
February 23, 2009
In the Flesh: The Cultural Politics of Body Modification by Victoria Pitts
The general tone of this book is very much like a second rate graduate thesis. It manages to be blandly academic in terms of style yet with none of the rigor one would associate with a decent sociology text. For example the author appears to have interviewed a grand total of about five people. Also none of the people interviewed are particularly interesting characters; the focus seems to be people recovering from sexual abuse or people affirming their sexuality by getting branded.
Now I don’t have a problem with this phenomenon. I think its pretty interesting but If you want to read that kind of thing you can find tons of it free on Bmezine. Bmezine has tons of experience stories like this, actual pictures and a means to contact the authors/subjects.
If you scrape away the interviews all you have left are the authors opinions about modification and a few cheap sudo cyberpunk photo’s. If you want a good read about body modification read the modern primitives re search title and the industrial culture handbook. I don’t really have any good academic recommendations but I bet with a bit of research you can find something a lot better than this.
Currently this title is selling for $21.55 on amazon, personally I put the amusement value somewhere bettween $1.95 and $3.oo. If you knew nothing about this subject, were stuck in an airport and had no way of buying either of the other two titles or acess the internet that would be an ok price to pay.
Now I don’t have a problem with this phenomenon. I think its pretty interesting but If you want to read that kind of thing you can find tons of it free on Bmezine. Bmezine has tons of experience stories like this, actual pictures and a means to contact the authors/subjects.
If you scrape away the interviews all you have left are the authors opinions about modification and a few cheap sudo cyberpunk photo’s. If you want a good read about body modification read the modern primitives re search title and the industrial culture handbook. I don’t really have any good academic recommendations but I bet with a bit of research you can find something a lot better than this.
Currently this title is selling for $21.55 on amazon, personally I put the amusement value somewhere bettween $1.95 and $3.oo. If you knew nothing about this subject, were stuck in an airport and had no way of buying either of the other two titles or acess the internet that would be an ok price to pay.
An Anthropologist On Mars: Seven Paradoxical Tales by Oliver Sacks
This book introduces the reader to a collection of weird neurological conditions accompanied by stories and supplemental background information relating to each example. Its focus is on the stories of patients encountered by the author during the course of his career.
Sacks has a great eye for the details that make his characters interesting; his descriptions of his patients bizarre behavior are spot on. His tone is warm, friendly and has a touch of humor to it which I find most endearing. All of the stories are real page turners and I literally couldn’t put this or its prequel (the man who mistook his wife for a hat) down till I had devoured them both.
The other thing that makes this book amazing is the way sacks presents the background information for each of his cases. For example; the artist who lost the ability to see in color. Sacks does a great job of mixing case history with philosophy and physics in his efforts to explain how the human brain deals with color. The real art of this is that he manages to do it in the middle of the story without killing the readers interest.
In my opinion this book is worth between $17 -$30 in terms of amusement, priced at $10 on amazon its a total steal. Buy it now!
Sacks has a great eye for the details that make his characters interesting; his descriptions of his patients bizarre behavior are spot on. His tone is warm, friendly and has a touch of humor to it which I find most endearing. All of the stories are real page turners and I literally couldn’t put this or its prequel (the man who mistook his wife for a hat) down till I had devoured them both.
The other thing that makes this book amazing is the way sacks presents the background information for each of his cases. For example; the artist who lost the ability to see in color. Sacks does a great job of mixing case history with philosophy and physics in his efforts to explain how the human brain deals with color. The real art of this is that he manages to do it in the middle of the story without killing the readers interest.
In my opinion this book is worth between $17 -$30 in terms of amusement, priced at $10 on amazon its a total steal. Buy it now!
February 6, 2009
PyGameSF meetup Tuesday February 10th 6pm @ NEW VENUE: Main San Francisco Public Library
This months PyGameSF meet up is in a new venue, the STONG conference room on the first floor of the main San Francisco public library beside civic center BART. The library closes at 8pm so we will be finishing up earlier than usual and reconviening to frjtz on hayes street for dinner/drinks afterwords.
This month’s presentations are:
installations, and festivals, around the World – not to mention a couple of
extraterrestrial pilgrimages to burning man. Various and sundry devices
were used: tablets, midi controllers, vuppets, handicams, fisheyes, and
bubble domes – all deployed to fill dark spaces with light.
The backbone of the visual synth is a software patch-bay, called Tr3. Tr3
was originally a thin layer around C++ objects to marshal events. Tr3 has
since grown and shrunk. “Grown” in that Tr3 was redesigned to be an
executable ontology for real-time events – complete with a visualization.
“Shrunk” in that one of Tr3’s parsers was written in Python. Since this is
a Pygame meetup, Warren will be focusing on the Python bits. Here’s what
might be covered:
1) Short demo of visual synth with tablet
a) short history of Tr3 (Windows version)
3) Python port in progress (Mac version)
a) Metaclass hacking the Python Dictionaries
b) A quasi-BNF parser using python statements with fixable exceptions
c) What Py2x won’t do, but what Py3K might (stack rewinding)
4) C++ back port from Python generated parse def
a) performances issues with Tr3.Py
b) Cross python c++ Issues (discussion)
6) Code release (suggestions?)
7) Future directions (suggestions?)
Belgian alternatives
Talk will include how to combine objective C and C++
and basic audio processing.
This month’s presentations are:
- Warren Stringer: Tr3.py media ontology demo and code firehose.
installations, and festivals, around the World – not to mention a couple of
extraterrestrial pilgrimages to burning man. Various and sundry devices
were used: tablets, midi controllers, vuppets, handicams, fisheyes, and
bubble domes – all deployed to fill dark spaces with light.
The backbone of the visual synth is a software patch-bay, called Tr3. Tr3
was originally a thin layer around C++ objects to marshal events. Tr3 has
since grown and shrunk. “Grown” in that Tr3 was redesigned to be an
executable ontology for real-time events – complete with a visualization.
“Shrunk” in that one of Tr3’s parsers was written in Python. Since this is
a Pygame meetup, Warren will be focusing on the Python bits. Here’s what
might be covered:
1) Short demo of visual synth with tablet
a) short history of Tr3 (Windows version)
3) Python port in progress (Mac version)
a) Metaclass hacking the Python Dictionaries
b) A quasi-BNF parser using python statements with fixable exceptions
c) What Py2x won’t do, but what Py3K might (stack rewinding)
4) C++ back port from Python generated parse def
a) performances issues with Tr3.Py
b) Cross python c++ Issues (discussion)
6) Code release (suggestions?)
7) Future directions (suggestions?)
- Robert Ferguson : Audio iPhone Development
Talk will include how to combine objective C and C++
and basic audio processing.