You are not logged in.

#1 2005-08-24 11:19:02

Cam
Member
From: Brisbane, Aus
Registered: 2004-12-21
Posts: 658
Website

python namespaces

This is a dumb question probably but I can't find the answer,  I'm probably searching for the wrong term or something at python.org.

I'm writing a bunch of classes to work with my LIRC remote, what do I have to do to set it up so I put the files in site-packages and then I can import them like:

import lirc.mpd as mpd

I've had a look at some of the setups that I already have from other packages, I'm guessing that the key is in the __init__.py file but I can't make any sense out of the contents. Any tips or even better links that point me in the right direction would be greatly appreciated.

Thanks big_smile

Offline

#2 2005-08-24 11:34:41

xerxes2
Member
From: Malmoe, Sweden
Registered: 2004-04-23
Posts: 1,249
Website

Re: python namespaces

if you don't wanna compile it to bytecode it's just to create a dir in site-packages and save the files in there with a __init__.py file, __init__.py is just a dummy file with no contents in it,

if you want to compile it to bytecode you should use distutils, i've learned these things the hard way (trial and error) so if you got more problems i'm sure i could help you,

edit: you can take a look at libpypac and lazy-pac-cli on my site for learning more about distutils


arch + gentoo + initng + python = enlisy

Offline

#3 2005-08-24 11:51:00

Cam
Member
From: Brisbane, Aus
Registered: 2004-12-21
Posts: 658
Website

Re: python namespaces

Hurray, thanks heaps! lol

I just created the blank __init__.py and now everything works like I wanted! I don't really think I need to worry about distutils, I'm just writing some scripts so that I can control as much of my computer's media functions as I can from my bed with my remote wink  A nice Xosd menu would be good next, preferably in Python but anything that works will do. Pyosd isn't very mature and animenu won't compile with Xft enabled and it doesn't even work with the supplied example config so I guess I'll have to keep on looking wink

Offline

#4 2005-08-24 12:06:57

xerxes2
Member
From: Malmoe, Sweden
Registered: 2004-04-23
Posts: 1,249
Website

Re: python namespaces

if it's just a few smaller scripts for your own use it's not worth the hassle with distutils,


arch + gentoo + initng + python = enlisy

Offline

Board footer

Powered by FluxBB