Re: [Tutor] Unit testing
On 6/27/06, Kent Johnson [EMAIL PROTECTED] wrote: Tino Dai wrote: How I have it now: semaA = threading.semaphore() class nameA:def __init__(self): do some stuffdef run(self): do some stuffsemaA.release() class nameB:def __init__(self): do some stuffdef run(self): semaA.acquire()do some stuff Does that make sense. Or is there a better way?class nameA: def __init__(self, sema):self.sema = semado some stuff def run(self): do some stuff self.sema.release()class nameB: def __init__(self, sema):self.sema = semado some stuff def run(self): self.semaA.acquire() do some stuffIn the client code or the unit test:semaA = threading.semaphore()anA = nameA(semaA)aB = nameB(semaA)anA.run ()aB.run()I got it. I guess it doesn't work like regular variables! Thanks! -Tino ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to check a files size
Perhaps this? stat = os.stat(self.file_name) file_size = stat[6] Thank you, Andrew Robert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] How to check a files size
Hi everyone. I would like to ask what is the best way to get the file size on a large file. the operation i'm trying to preform is to copy a large file to another drive using python file I/O commands. perhaps there is a better solution or a module that is doing this more easy? Thanks Magnus Wirström ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to check a files size
On Thu, 29 Jun 2006, [ISO-8859-1] Magnus Wirstr?m wrote: I would like to ask what is the best way to get the file size on a large file. filesize = os.stat(filename).st_size ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Unit testing
On Wed, 28 Jun 2006, Tino Dai wrote: Ok, I think I'm going to back up and explain what I'm am heading towards. I'm working on an app that fire off a bunch of threads. Each one of these threads in connected via queues to another thread in a sequence like a chain. And how I tell the next stage thread that there is data in the queue is via semaphore. You can just use a series of Queues, where each Queue represents the work being passed from one thread to the other. With respect to each Queue, the producing thread places a work unit onto it with Queue.put; the consumer thread takes a work unit off with Queue.get(True), so it will wait until there's something in the Queue for it to do. And of course, each consumer thread (except the last) is a producer thread to the next consumer thread. You could have the parent start up each thread, passing it the Queue from which it is to read and the Queue to which it is going to write. No globals. I think you'll find that to be much more straightforward than using semaphores. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to check a files size
From: Magnus Wirström [EMAIL PROTECTED] Hi everyone. I would like to ask what is the best way to get the file size on a large file. the operation i'm trying to preform is to copy a large file to another drive using python file I/O commands. perhaps there is a better solution or a module that is doing this more easy? See shutil.copyfile() Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to check a files size
On 29/06/06, Kent Johnson [EMAIL PROTECTED] wrote: See shutil.copyfile() Why isn't this function in the os module with the other file commands? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Threading
Hello. I am trying to learn threading, and found a good example at: http://effbot.org/librarybook/queue.htm (Using the Queue module with a maximum size). It works like a dream as is. But, I added it to a downloading-script I have made before. The difference is that in my version it has a wxPython-gui and download files. The module I use to download works great, so does the gui. So, when I start the downloading, the thread-example downloads from 20-80 files, and a box comes up, saying that Python has crashed. It ask if I would like to shut down or debug. (On Win XP). However, I can see the program run in the background as if nothing has happened. What does cause an error like that? Two threads write to same memoryspace? And, does anyone know of some great sites where I can learn more about threads? I have found a lot, but they are not basic enough. I have no idea what a 'lock' is, as most all sites assumes one should. So, the simpler the better... Thanks in advance, Øyvind -- This email has been scanned for viruses spam by Decna as - www.decna.no Denne e-posten er sjekket for virus spam av Decna as - www.decna.no ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Threading
Øyvind wrote: And, does anyone know of some great sites where I can learn more about threads? I have found a lot, but they are not basic enough. I have no idea what a 'lock' is, as most all sites assumes one should. So, the simpler the better... The Little Book of Semaphores is a good introduction to locks and related threading issues. http://greenteapress.com/semaphores/ Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] treelistctrl help!
hello, I'm having some trouble with treelistctrl in wx python and I was wondering if there is someone who would share their code as an example. thanks!Jeff Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail Beta.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] NumPy
To all, Can somebody tell me from where to download NumPy easely. Thank you Michel Maho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] NumPy
On Wed, Jun 28, 2006 at 04:35:15PM +0200, michel maho wrote: To all, Can somebody tell me from where to download NumPy easely. Thank you Michel Maho Well, you probably want SciPy, which is the latest in scientific programming for Python. It's here: http://scipy.org/ There is also a NumPy page. But, I believe that NumPy is built into SciPy. See: - http://www.scipy.org/more_about_SciPy - http://numpy.org/ Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] File compression
On Tue, Jun 27, 2006 at 03:27:47PM -0700, Matthew White wrote: Hi Magnus, I would check out the python tarfile module: http://docs.python.org/lib/module-tarfile.html Looks like it will compress with bzip too! Also look at the following: - http://docs.python.org/lib/module-zipfile.html - http://docs.python.org/lib/module-zlib.html - http://docs.python.org/lib/module-gzip.html - http://docs.python.org/lib/module-bz2.html Dave -mtw On Wed, Jun 28, 2006 at 12:19:19AM +0200, Magnus Wirström ([EMAIL PROTECTED]) wrote: Hi Everyone I'm starting to python and i need to write a program that are able to compress a high amount of files and directories into a single file that is later going to be transfered with ftp to a backup storage server. [snip] -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Unit testing
Tino Dai schreef: How I have it now: semaA = threading.semaphore() class nameA: def __init__(self): do some stuff def run(self): do some stuff semaA.release() class nameB: def __init__(self): do some stuff def run(self): semaA.acquire() do some stuff Does that make sense. Or is there a better way? I think it's better to do something like: class nameA: def __init__(self, sema): self.sema = sema other stuff def run(self): do some stuff self.sema.release() class nameB: def __init__(self, sema): self.sema = sema other stuff def run(self): self.sema.acquire() do some stuff Then where you create instances of those classes: sema = threading.semaphore() a = nameA(sema) b = nameB(sema) Maybe you don't even need the semaphore at all: have a look at Queue.Queue, it might do exactly what you need. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Unit testing
Then where you create instances of those classes:sema = threading.semaphore() a = nameA(sema)b = nameB(sema)Maybe you don't even need the semaphore at all: have a look atQueue.Queue, it might do exactly what you need.Ok, I think I'm going to back up and explain what I'm am heading towards. I'm working on an app that fire off a bunch of threads. Each one of these threads in connected via queues to another thread in a sequence like a chain. And how I tell the next stage thread that there is data in the queue is via semaphore. I couldn't come up with a better idea to control is sequence without having to get into patterns (maybe there is a observer pattern like in java for python, I don't know). And presently the global semaphores work (I know it's bad programming practice and it will be fixed - it's on the short list of thing to do). Presently, I'm reading about unit testing because that's a relatively new field to me, and I understand the basics of unit testing. It is the more depth concepts such as how the unit test threads that's not apparent to me (which google doesn't seem to have). Ok, back to searching! -Tino ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor