[Tutor] Lights game

2005-01-15 Thread Ismael Garrido
Hello list. I'd really appreciate any comments, particulary regarding style corrections. I'm a newbie... Thanks! Ismael import random import tkMessageBox from Tkinter import * class GUI: def __init__(self): self._crearGUI() def _crearGUI(self): self.root = Tk() self.roo

[Tutor] Posting a large amount of code?

2005-01-15 Thread Bill Burns
Hello, I've been working on a small GUI program (on & off) for a little while now and I'd love to have the group (or anyone for that matter) take a look at it and give me some pointers. Since I'm not a programmer and I don't do this continuously, I don't now if I'm on the right track or not. I'd l

Re: [Tutor] sockets, files, threads

2005-01-15 Thread Danny Yoo
> I have only wrapped my lock around file-descriptor creations. Should I > wrap it around closings too? Or the whole open -> close transaction? > It sounds like error-prone work to do the latter. What am I missing? Hi Marilyn, Can you send a link to the source code to the Tutor list? I'm ge

Re: Sending a command to a program using os.system (was [Tutor]: Using os.popen*() and os.spawn*() to interact with a DOS box)

2005-01-15 Thread Orri Ganel
Orri Ganel wrote: I did some googling, and found this in the archives of this mailing list: import os os.system('c:\\abaqus\\5.8-14\\abaqus.exe post') , where post was a command, *not* a file.  Now, I tried something similar, since essentially what I wish to be able to do is have A

Sending a command to a program using os.system (was [Tutor]: Using os.popen*() and os.spawn*() to interact with a DOS box)

2005-01-15 Thread Orri Ganel
I did some googling, and found this in the archives of this mailing list: import os os.system('c:\\abaqus\\5.8-14\\abaqus.exe post') , where post was a command, *not* a file.  Now, I tried something similar, since essentially what I wish to be able to do is have Audacity think I typed the 'R

Re: [Tutor] sockets, files, threads

2005-01-15 Thread Marilyn Davis
p.p.s. I have only wrapped my lock around file-descriptor creations. Should I wrap it around closings too? Or the whole open -> close transaction? It sounds like error-prone work to do the latter. What am I missing? What should I be reading to get a better clue? I'll do some googling. Thank

Re: [Tutor] Using os.popen*() and os.spawn*() to interact with a dos-box

2005-01-15 Thread Orri Ganel
Alan Gauld wrote: Well, ultimately, what I want to be able to do is open Audacity (http://audacity.sourceforge.net/) at a predetermined time and have it begin recording wave mix out (the default i have it set to anyway), and then have it stop agai

Re: [Tutor] sockets, files, threads

2005-01-15 Thread Marilyn Davis
Dearest Tutors, Bah! It's not over yet. I don't know why, but again my file descriptors are being trampled upon now and then. This time I can see in my log that I'm not trampling on them myself, like I used to do, unless I'm making calls to the system that I'm not aware of. And, first I get th

Re: [Tutor] Faster procedure to filter two lists . Please help

2005-01-15 Thread Tim Peters
[Alan Gauld] > OK, The timbot's word is good enough for me, I won't bother > looking at the code, I'll revert to my previous assumption! :-) It's educational to look at the code anyway . Here it is, from Python's listobject.c: static int list_length(PyListObject *a) { return a->ob_size;

Re: [Tutor] Faster procedure to filter two lists . Please help

2005-01-15 Thread Alan Gauld
> GR> len is actually a field in the underlying C object so len() is a > GR> constant (O(1)) and as-fast-as-it-can-be operation. > TP> ...n integers), but (ignoring the range() complication) there's no TP> difference in O() behavior between the two. OK, The timbot's word is good enough for me, I w

Re: [Tutor] Faster procedure to filter two lists . Please help

2005-01-15 Thread Alan Gauld
> It this correct? Python lists are not linked-lists (as in Scheme, for > example). They are more like arrays (or vectors in C++/Java) with a > little more sofistication built into them to allow, for example, to > amortize over time a sequence of append operations. But in a nutshell, > len is actua

Re: [Tutor] Faster procedure to filter two lists . Please help

2005-01-15 Thread Tim Peters
[Gonçalo Rodrigues] > It this correct? Python lists are not linked-lists (as in Scheme, for > example). They are more like arrays (or vectors in C++/Java) with a > little more sofistication built into them to allow, for example, to > amortize over time a sequence of append operations. But in a nuts

Re: [Tutor] sockets, files, threads

2005-01-15 Thread Marilyn Davis
Whew! What a trip this bug has been! Danny was exactly right here: > is exactly the sort of thing I'd expect if two threads were > contending for the same resource, so let's see if the bug has to do > with this. This bug drove me nuts. (it's a short drive) So I started wrapping my file open

Re: [Tutor] Using os.popen*() and os.spawn*() to interact with a dos-box

2005-01-15 Thread Alan Gauld
> Well, ultimately, what I want to be able to do is open Audacity > (http://audacity.sourceforge.net/) at a predetermined time and have it > begin recording wave mix out (the default i have it set to anyway), and > then have it stop again when i send it a command. This will be much easier from pyt

Re: [Tutor] Faster procedure to filter two lists . Please help

2005-01-15 Thread Gonçalo Rodrigues
Alan Gauld wrote: By missing out a loop(*) and some splits it should speed up significantly for the cost of some small added complexity in building the dictionaries in the first case. (*)In fact 3 loops because you aren't doing len() which effectively loops over the collection too. It this cor

Re: [Tutor] Using os.popen*() and os.spawn*() to interact with a dos-box

2005-01-15 Thread Orri Ganel
Alan Gauld wrote: I'm trying to use Python to start the dos-box ("cmd.exe") and be able to call commands on it and receive output from it. The Command window is just a terminal, there is no output to be had other than an exit code when it closes.

Re: [Tutor] style question: when to "hide" variable, modules

2005-01-15 Thread Jacob S.
I'm not too sure about this... Couldn't you make that a package? Rename Backup.py to __init__.py Put all of the modules in a folder named Backup in your sys.path - Question: Does it have to be in site-packages? Well, there's my two bits, Jacob > During the recent discussion on jython, a poster >

Re: [Tutor] Intro for interfacing with Microsoft Access?

2005-01-15 Thread Kent Johnson
You have to set up your Access database as an ODBC data source. I can't give you all the details but on my Win2k system if I go to Start / Control Panels / Administrative Tools / Data Sources (ODBC) that is the place to set it up. IIRC you give the data source a name. Then in the ODBC driver (th

Re: [Tutor] Using os.popen*() and os.spawn*() to interact with a dos-box

2005-01-15 Thread Alan Gauld
> I'm trying to use Python to start the dos-box ("cmd.exe") and be able to > call commands on it and receive output from it. The Command window is just a terminal, there is no output to be had other than an exit code when it closes. > However, none of the documentation for popen and > spawn cover

Re: [Tutor] Faster procedure to filter two lists . Please help

2005-01-15 Thread Alan Gauld
> Thank you for your suggestion. I tried creating a > dictionary of 'what' list and searched keys with > has_key method and it is pretty fast. Use try/except and it will be faster still. The except only gets triggered if theres a missing entry - which in your case should be hardly ever! So you

Re: [Tutor] Help

2005-01-15 Thread Alan Gauld
> a = input("Type in the Grose: ") > b = input("type in the Miles: ") > print "a * 0.74 / b is" a*0.74/b Try adding a comma between the message and the calculation. print "a * 0.74 / b is", a*0.74/b It tells print that there are two separate things to print. Also when posting problems it is alw

Re: [Tutor] Faster procedure to filter two lists . Please help

2005-01-15 Thread Alan Gauld
> >>>for i in range(len(what)): > ele = split(what[i],'\t') > cor1 = ele[0] It will be faster if you stop using len() in your for loops! for item in what: > for k in range(len(my_report)): > cols = split(my_report[k],'\t') > cor = cols[0] And again: for item in my_report: > if cor1 == cor: > p