Re: how to use more than 1 __init__ constructor in a class ?

2005-06-23 Thread Singletoned
Rocco Moretti wrote:
> Steven D'Aprano wrote:

> > That's the joys of a mostly self-taught programming knowledge: you miss
> > out on all the buzzwords.
>
> Being mostly self taught myself, I have a tendancy to use infrequently
> encountered terms in related but technically inappropriate contexts,
> confusing the better informed people I deal with. ;-)

Indeed.  I find I use even more buzzwords because I can just make up as
many as I want.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ls files --> list packer

2006-02-24 Thread Singletoned
Try using The Path module:
http://www.jorendorff.com/articles/python/path/.

I wrote a little script to traverse a directory structure which you
could use.  (You just pass a function to it and it runs it on each file
in the directory.  You want it to run on each directory instead, so
I've changed it a little for you).

import path

def traverse(directory, function, depth=0, onfiles=True, ondirs=False):
   thedir = path.path(directory)
   if onfiles == True:
  for item in thedir.files():
  function(item, depth)
   if ondirs == True:
  for item in thedir.dirs():
 function(item, depth)
   for item in thedir.dirs():
   traverse(item, function, depth+1, onfiles, ondirs)

You can use it like so:

def printaifs(thedir, depth):
   print thedir.name
   for item in thedir.files("*.aif'"):
  print "\t" + item

traverse(r"/Users/foo/snd", printaifs, onfiles=False, ondirs=True)

NB: I've quickly adapted this whilst away from an installation of
Python, so it is untested, but should mostly work, unless there's a
typo.

Hope this helps at least a little...

Ed

PS The Python Tutor list tends to be a much better place to discuss
this kind of stuff.  If you haven't yet encountered Kent and Alan's
help, then you have a joyous experience ahead of you.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Aaaargh! "global name 'eggz' is not defined"

2009-11-03 Thread Singletoned
On Oct 30, 8:53 am, Bruno Desthuilliers  wrote:
> Robert Kern a écrit :> On 2009-10-29 16:52 PM, Aahz wrote:
> (snip)
> >> Coincidentally, I tried PyFlakes yesterday and was unimpressed with the
> >> way it doesn't work with "import *".
>
> > I consider "import *" the first error to be fixed, so it doesn't bother
> > me much. :-)
>
> +1 QOTW

Bruno, do you actually get to decide the QOTW?  Because everytime you `
+1 QOTW` it gets to be the QOTW.

Ed

BTW I was the grateful recipient of your vote the other week.
-- 
http://mail.python.org/mailman/listinfo/python-list