Re: [Tutor] Criticism / Suggestions

2005-03-01 Thread Jeff Shannon
On Wed, 02 Mar 2005 01:17:28 -0500, Bill Kranec <[EMAIL PROTECTED]> wrote: > [...] I wanted to be able to define > multiple tournament objects off of the same roundlist, to avoid > generating the list every time a new object is created. I think what I > really want to do is have a separate Round

Re: [Tutor] Criticism / Suggestions

2005-03-01 Thread Bill Kranec
Hi Kent, First off, thank you so much for the suggestions! They have helped clarify some of the concepts I've been struggling with lately ( mostly object - related ones ). I have been teaching myself Python in my spare time for the last few months, and have no previous programming experience,

Re: [Tutor] reading from stdin

2005-03-01 Thread David Rock
* Nick Lunt <[EMAIL PROTECTED]> [2005-03-01 22:23]: > On Tue, 2005-03-01 at 14:14 -0800, Sean Perry wrote: > > > > > unless you want the output for some other reason, a more idiomatic way > > is: > > > > for line in sys.stdin.readlines(): > > # handle the line > > > > I tend to use xreadli

[Tutor] Re: open a socket from a named file on linux

2005-03-01 Thread Lee Harr
Sorry. I sent this yesterday but forgot the subject. Hope this helps point you in the right direction ... I attempting to control xfmedia, http://spuriousinterrupt.org/projects/xfmedia/ , via it's remote from python and I can not get a connection. s = socket.fromfd('/tmp/xfmedia_remote.1001.0', s

Re: [Tutor] Setting up a database

2005-03-01 Thread Danny Yoo
> ### > >>> d = {} > >>> def addTally(name): > ... d.setdefault(name[0], []).append(name) > ... > >>> addTally('john') > >>> addTally('brian') > >>> addTally('jane') > >>> addTally('alice') > >>> addTally('bob') > >>> d > {'a': ['alice'], 'j': ['john', 'jane'], 'b': ['brian', 'bob']} > ### > >

Re: [Tutor] Setting up a database

2005-03-01 Thread Danny Yoo
On Tue, 1 Mar 2005, James O. Sweeney wrote: > I have an assignment that entails entering cash transactions as records. Hi James, Just to make it clear: we are prohibited from doing homework questions. Since it's an assignment, we'll try to stay clear of direct solutions. > My question is ab

Re: [Tutor] Setting up a database

2005-03-01 Thread Liam Clarke
While we generally don't get too specific with assignments and/or homework - For a traditional database, you'd have to go the mySQL route. A dictionary is good, but for only one discreet key. That said, you could do it with objects like this - dictOfTransactionObjects = {} class CashTransaction

Re: [Tutor] Tab delim file

2005-03-01 Thread Liam Clarke
Hi Srinivas, You want to use the csv module, it's designed for this kind of stuff. http://docs.python.org/lib/module-csv.html So, I think for your thing you'd want = import csv f1 = open('my_file.txt','r') reader = csv.reader(f1) reader.delimiter = '\t' fileA = [] fileB = [] for row in read

Re: [Tutor] reading from stdin

2005-03-01 Thread =?ISO-8859-1?Q?Hugo_Gonz=E1lez_Monteverde?=
Everypne else has answered pretty muh about this. I just want to add that if you want to read noncanonically (less thana line ending in "\n" you'll have to do it char by char =( AFAIK, there's no way to redefine a separator por readlines() (other than \n..) Hugo Nick Lunt wrote: Hi folks, I've

[Tutor] Setting up a database

2005-03-01 Thread James O. Sweeney
Hello, I have an assignment that entails entering cash transactions as records. The significant record fields are a date/time stamp, the amount, and whether the transaction is a deposit or withdrawal. My question is about setting up the database file. In Python there is a dictionary functi

Re: [Tutor] reading from stdin

2005-03-01 Thread Peter Markowsky
Hi, On Mar 1, 2005, at 6:01 PM, Sean Perry wrote: [EMAIL PROTECTED] wrote: If I do: $ ./produce.py | ./read.py I get nothing for ten seconds, then I get the numbers 0 through 9, one per line. What am I missing? From the python man page: -u Force stdin, stdout and stderr to be totally unbuffere

Re: [Tutor] reading from stdin

2005-03-01 Thread Sean Perry
[EMAIL PROTECTED] wrote: If I do: $ ./produce.py | ./read.py I get nothing for ten seconds, then I get the numbers 0 through 9, one per line. What am I missing? From the python man page: -u Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, st

Re: [Tutor] reading from stdin

2005-03-01 Thread jfouhy
Quoting Max Noel <[EMAIL PROTECTED]>: > UNIX philosophy is to have programs start acting as soon as possible > -- in that case, as soon as the first line is available. You should be > reading sys.stdin as an iterator (same thing you'd do for a file): > > import sys > for line in sys.stdin:

Re: [Tutor] reading from stdin

2005-03-01 Thread Nick Lunt
On Wed, 2005-03-02 at 11:22 +1300, [EMAIL PROTECTED] wrote: > Quoting Sean Perry <[EMAIL PROTECTED]>: > > > for line in sys.stdin.readlines(): > > # handle the line > > > > I tend to use xreadlines() which does not read the entire input at once. > > xreadlines() these days just does 'return sel

Re: [Tutor] reading from stdin

2005-03-01 Thread Nick Lunt
On Tue, 2005-03-01 at 22:20 +, Max Noel wrote: > I don't think you are. You're using readlines(), which means your > program won't execute until ps terminates. > UNIX philosophy is to have programs start acting as soon as possible > -- in that case, as soon as the first line is a

Re: [Tutor] reading from stdin

2005-03-01 Thread jfouhy
Quoting Sean Perry <[EMAIL PROTECTED]>: > for line in sys.stdin.readlines(): > # handle the line > > I tend to use xreadlines() which does not read the entire input at once. xreadlines() these days just does 'return self', I believe. File objects are their own iterators; you can just do: for

[Tutor] Tab delim file

2005-03-01 Thread Srinivas Iyyer
Hello: I have a nasty file where I have 165 column and 140K lines. For every 12 columns, a new dataset is written. 0-12 - File A's data is there 13-24 - File B's data is there. My task is to write data in each 12 columns to a file. I have a rough idea, but when I try I am unable to proceed

Re: [Tutor] reading from stdin

2005-03-01 Thread Nick Lunt
On Tue, 2005-03-01 at 14:14 -0800, Sean Perry wrote: > > unless you want the output for some other reason, a more idiomatic way > is: > > for line in sys.stdin.readlines(): > # handle the line > > I tend to use xreadlines() which does not read the entire input at once. > For stdin this

Re: [Tutor] reading from stdin

2005-03-01 Thread Max Noel
On Mar 1, 2005, at 22:08, Nick Lunt wrote: The way I did this was to use sys.stdin.readlines() to get the output from the pipe. Here is the program: [code] import sys, glob args = sys.stdin.readlines() # found on the net pat = sys.argv[1] for i in args: if (i.find(pat) != -1):

Re: [Tutor] reading from stdin

2005-03-01 Thread Sean Perry
Nick Lunt wrote: The way I did this was to use sys.stdin.readlines() to get the output from the pipe. Here is the program: [code] import sys, glob args = sys.stdin.readlines() # found on the net pat = sys.argv[1] for i in args: if (i.find(pat) != -1): print i, [/code] My que

[Tutor] reading from stdin

2005-03-01 Thread Nick Lunt
Hi folks, I've been pondering how to get python to read from a pipe outside of itself, sort of. For example I tried a simple python prog to do a grep, eg # ps -e | myprog.py cron would give this output 3778 ?00:00:00 crond same as # ps -e | grep cron The way I did this was to use sy

Re: [Tutor] Criticism / Suggestions

2005-03-01 Thread Alan Gauld
> programs that help me automate updating my website: > - to invoke a players' ranking program, > - to convert text files to php formats, > - ... > > I would like to go even further and employ Tkinter to: If you want to put Tkinter on your web site then you probably will be dissapointed. If you

Re: [Tutor] How to use threads ?

2005-03-01 Thread Shitiz Bansal
--- Mark Kels <[EMAIL PROTECTED]> wrote: > Can anyone give me a very simple example on thread > programming ? > I looked at some tutorials but they don't really > make sense... > > > Thanks in advance > -- > 1. The day Microsoft makes something that doesn't > suck is probably the > day they st

Re: [Tutor] to employ Tkinter

2005-03-01 Thread John Fouhy
Andrzej Kolinski wrote: I would like to go even further and employ Tkinter to: - open and run a C and/or Python code (including arguments where necessary), - name and save generated html/php files. The only thing I found is the following line of code: filemenu.add_command(label="Open...", command

Re: [Tutor] Saving Entry fields in Tkinter

2005-03-01 Thread Michael Lange
On Tue, 1 Mar 2005 12:52:57 +0100 Ewald Ertl <[EMAIL PROTECTED]> wrote: > Hi! > > Perhaps this could help you: > > fileContent=open( "my/file/to/read", "r").readlines() > > for line in fileContent: > print line.strip() # remove leading and trailing whitspace's incl. \n > > > In the l

[Tutor] Check if user exist in domain

2005-03-01 Thread jon . papageorgiou
I need to check if a user is in a domain from a computer that is not in a domain. Currently, we are running an NT domain, but will be moving to ActiveDirectory2003 in the next few months. I thought if I could get user information for the user I could verify that the user account existed: #COD

Re: [Tutor] Saving Entry fields in Tkinter

2005-03-01 Thread Ewald Ertl
Hi on Tue, 1 Mar 2005 15:31:10 + Adam Cripps <[EMAIL PROTECTED]> wrote : - Adam Cripps > > Adam Cripps > Thanks Ewald - this is what I have so far, with a far from perfect result: Adam Cripps >

Re: [Tutor] Saving Entry fields in Tkinter

2005-03-01 Thread Adam Cripps
On Tue, 1 Mar 2005 15:31:10 +, Adam Cripps <[EMAIL PROTECTED]> wrote: > On Tue, 1 Mar 2005 15:30:02 +, Adam Cripps <[EMAIL PROTECTED]> wrote: > > On Tue, 1 Mar 2005 12:52:57 +0100, Ewald Ertl <[EMAIL PROTECTED]> wrote: > > > Hi! > > > > > > Perhaps this could help you: > > > > > > fileConte

Re: [Tutor] Saving Entry fields in Tkinter

2005-03-01 Thread Adam Cripps
On Tue, 1 Mar 2005 15:30:02 +, Adam Cripps <[EMAIL PROTECTED]> wrote: > On Tue, 1 Mar 2005 12:52:57 +0100, Ewald Ertl <[EMAIL PROTECTED]> wrote: > > Hi! > > > > Perhaps this could help you: > > > > fileContent=open( "my/file/to/read", "r").readlines() > > > > for line in fileContent: > >

[Tutor] to employ Tkinter

2005-03-01 Thread Andrzej Kolinski
  My apologies for leaving Subject entry unchanged :-).        _/_/      _/     _/   _/       _/  _/   _/  _/_/_/_/  _/ _/ _/      _/  _/   _/ _/     _/  _/      _/ Andrzej Kolinski - Forwarded by Andrzej Kolinski/NRI on 01/03/2005 10:12 AM - Andrzej Kolinski <[EMAIL PROTECTED]>

Re: [Tutor] Criticism / Suggestions

2005-03-01 Thread Andrzej Kolinski
On my way to write my own scripts from scratch I'm still assembling bits and pieces from everywhere in the Python universe to create little programs that help me automate updating my website: - to invoke a players' ranking program, - to convert text files to php formats, - ... I would like to go

[Tutor] How to use threads ?

2005-03-01 Thread Mark Kels
Can anyone give me a very simple example on thread programming ? I looked at some tutorials but they don't really make sense... Thanks in advance -- 1. The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners. 2. Unix is user friendly - it's just

Re: [Tutor] printing out a box of O's

2005-03-01 Thread Rainer Mansfeld
Kevin schrieb: I just started getting in to python and for taking a look at the for loop. I want to print out a box of O's 10o chars long by 10 lines long this is what I came up with. Is there a better way to do this: j = 'O' for i in j*10: print i * 100 Thanks Kevin Hi Kevin, I don't know,

Re: [Tutor] Criticism / Suggestions

2005-03-01 Thread Kent Johnson
Bill Kranec wrote: Hello, So I think that I've 'completed' my first real Python program, and I would appreciate any constructive criticism you all could offer. The program deals with a question that my Dad asked me awhile ago, which was "If twelve people want to divide into teams of two and pla

Re: [Tutor] How to read unicode strings from a binary file and display them as plain ascii?

2005-03-01 Thread R. Alan Monroe
> R. Alan Monroe wrote: >> I started writing a program to parse the headers of truetype fonts to >> examine their family info. But I can't manage to print out the strings >> without the zero bytes in between each character (they display as a >> black block labeled 'NUL' in Scite's output pane) >>

Re: [Tutor] Saving Entry fields in Tkinter

2005-03-01 Thread Ewald Ertl
Hi! Perhaps this could help you: fileContent=open( "my/file/to/read", "r").readlines() for line in fileContent: print line.strip() # remove leading and trailing whitspace's incl. \n In the loop you could perhaps populate the entry-widgets. HTH Ewald on Tue, 1 Mar 2005 09:22:0

Re: [Tutor] How to read unicode strings from a binary file and display them as plain ascii?

2005-03-01 Thread Kent Johnson
R. Alan Monroe wrote: I started writing a program to parse the headers of truetype fonts to examine their family info. But I can't manage to print out the strings without the zero bytes in between each character (they display as a black block labeled 'NUL' in Scite's output pane) I tried: stuf

Re: [Tutor] Re: How to read unicode strings from a binary file and display them as plain ascii?

2005-03-01 Thread R. Alan Monroe
> R. Alan Monroe wrote: >> I started writing a program to parse the headers of truetype fonts to >> examine their family info. But I can't manage to print out the strings >> without the zero bytes in between each character (they display as a >> black block labeled 'NUL' in Scite's output pane) >>

[Tutor] Saving Entry fields in Tkinter

2005-03-01 Thread Adam Cripps
I'm writing an application which has rows of Entry fields (created in a loop - see previous thread; and thanks guys!). All the content of the Entry fields are accessed through self.contentlist[i].get() Now I'm trying to save the content of those fields in a friendly format. I've used pickle in the