[Tutor] if-else statements

2005-10-13 Thread andrade1
Hello I'm having some trouble with my if, else statements. For some reason, the months that have 31 days work fine, but the months that have 28/30 do not work. Am I doing something wrong? it is supposed to take a date as an input like 9/31/1991 and then say that the date is not valid because septe

[Tutor] First post

2005-10-13 Thread Anthoni Shogan
Hello people, this is my first post as a test.. -- Anthoni Shogan Fame is a vapor; popularity an accident; the only earthly certainty is oblivion. -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/lis

Re: [Tutor] passing variable to python script

2005-10-13 Thread Alan Gauld
> i want to pass an argument (a number) to a python > script when running it: >> python script.py > > i want to be able to use within script.py > as a parameter. > > how do i set this up? This is covered in the 'talking to the user' topic in my tutorial. The short answer is use sys.argv Alan

Re: [Tutor] python ncurses vs OS X Tiger's xterms.

2005-10-13 Thread Alan Gauld
Bill this is a guess but try setting the terminal type to vt220 or vt330 or similar rather than xterm. Does that make any difference? curses uses the termcap database to determine how int interacts with the keyboard so changing the terminal type to somethingwell defined might make a difference? B

Re: [Tutor] redemo.py and r'python\.org'

2005-10-13 Thread Kent Johnson
Dick Moores wrote: > BTW in redemo.py, what do the checkboxes VERBOSE, LOCALE, and DOTALL > mean? (I understand IGNORECASE and MULTILINE.) http://docs.python.org/lib/node115.html Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mail

Re: [Tutor] redemo.py and r'python\.org'

2005-10-13 Thread Dick Moores
Kent Johnson wrote at 14:36 10/13/2005: >Dick Moores wrote: > > I've begun to try out redemo.py to test and learn regular > expressions. It > > doesn't seem to accept Python's raw strings as raw strings, e.g., > > r'python\.org' for matching python.org and nothing else. Am I > correct, > > or

Re: [Tutor] how to alter list content

2005-10-13 Thread w chun
combining the best of both worlds of nick using a faster list comp and brett using os.path.splitext():>>> files = ['DSC1.JPG', 'DSC2.JPG', 'DSC3.JPG']>>> newFiles = [os.path.splitext (f)[0] for f in files]>>> print newFiles['DSC1', 'DSC2', 'DSC3']cheers,-- wesley- - - - - -

Re: [Tutor] Clean up loop and search in a list

2005-10-13 Thread Kent Johnson
Markus Rosenstihl wrote: > Thank you for the fast reply > > Am 13.10.2005 um 19:43 schrieb Kent Johnson: > > > >> if len(filter(re_name.search, line)) > 0: >>could be written >> if re_name.search(line): > > > this is not working because I am parsing a line in a list (i think): Ah, sorry,

Re: [Tutor] if-elif-else statements

2005-10-13 Thread Danny Yoo
On Thu, 13 Oct 2005 [EMAIL PROTECTED] wrote: > amount is supposed to equal fine because there are a couple of different > fines. there is a fine for going over 90mph that includes a penalty and > then there is a fine for just going over the speed limit as long as it > is under 90. Hi Andradel,

Re: [Tutor] if-elif-else statements

2005-10-13 Thread Carroll, Barry
Greetings: I have two comments to make. First, I recommend renaming your variables to be more clear. For example: # speedlimit = input("Please enter the legal speed limit: ") clockedspeed = input("Please enter the clocked speed limit: ") excessspeed = clockedspeed - sp

Re: [Tutor] if-elif-else statements

2005-10-13 Thread Akbar Pasha
I think you should check the if conditions with "clocked" not speedlimit which is the differential. ::akbarOn 10/13/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: amount is supposed to equal fine because there are a couple of differentfines. there is a fine for going over 90mph that includes a p

Re: [Tutor] if-elif-else statements

2005-10-13 Thread Jason Massey
More than anything, I think clearer variable names will help here. Something like: def main(): ... speed_limit = 60 ... clocked = int(raw_input("Clocked speed:")) ... miles_over = clocked - speed_limit ... fine = 50 + 5 * miles_over ... if miles_over >= 30: ... pri

Re: [Tutor] passing variable to python script

2005-10-13 Thread bob
At 04:09 PM 10/13/2005, Marc Buehler wrote: >hi. > >i want to pass an argument (a number) to a python >script when running it: > > python script.py > >i want to be able to use within script.py >as a parameter. > >how do i set this up? In the sys module there is a property argv. The docs say: "Th

Re: [Tutor] passing variable to python script

2005-10-13 Thread John Fouhy
On 14/10/05, Marc Buehler <[EMAIL PROTECTED]> wrote: > hi. > > i want to pass an argument (a number) to a python > script when running it: > > python script.py Have a look at sys.argv! testargs.py import sys print sys.argv C:\temp>python testargv.py 1 2 foo ['testargv.py', '1', '

Re: [Tutor] passing variable to python script

2005-10-13 Thread Eric Walker
z = raw_input("Please Enter? :\n") On Thursday 13 October 2005 05:09 pm, Marc Buehler wrote: > hi. > > i want to pass an argument (a number) to a python > > script when running it: > > python script.py > > i want to be able to use within script.py > as a parameter. > > how do i set this up? > > m

Re: [Tutor] if-elif-else statements

2005-10-13 Thread andrade1
amount is supposed to equal fine because there are a couple of different fines. there is a fine for going over 90mph that includes a penalty and then there is a fine for just going over the speed limit as long as it is under 90. > Is amount suppose to equal total instead of fine? > > > > On Thurs

[Tutor] passing variable to python script

2005-10-13 Thread Marc Buehler
hi. i want to pass an argument (a number) to a python script when running it: > python script.py i want to be able to use within script.py as a parameter. how do i set this up? marc --- The apocalyptic visio

Re: [Tutor] if-elif-else statements

2005-10-13 Thread Eric Walker
Is amount suppose to equal total instead of fine? On Thursday 13 October 2005 04:58 pm, [EMAIL PROTECTED] wrote: > def main(): >     actual = input("Please enter the legal speed limit: ") >     clocked = input("Please enter the clocked speed limit: ") >     speedlimit = clocked - actual > >    

[Tutor] if-elif-else statements

2005-10-13 Thread andrade1
Hello I am having trouble getting my program to calculate the correct total if the speed limit is over 90mph. For example when i enter 100 for the clocked speed and 50 for the actual speed it returns 300 when I should receive 500. It also seems to be skipping over the else statement of if the pers

Re: [Tutor] how to alter list content

2005-10-13 Thread Brett Hoerner
> i create a list of all JPG files with: > >>> list = glob.glob('*.JPG') > the content of 'list' is now: > >>> print list > ['DSC1.JPG', 'DSC2.JPG', 'DSC3.JPG'] > > but what i want is this type of list: > ['DSC1', 'DSC2', 'DSC3'] I would make use of os.path.splitext, which

Re: [Tutor] how to alter list content

2005-10-13 Thread Nick Lunt
Hi marc, > > i create a list of all JPG files with: > >>> list = glob.glob('*.JPG') > the content of 'list' is now: > >>> print list > ['DSC1.JPG', 'DSC2.JPG', 'DSC3.JPG'] > > but what i want is this type of list: > ['DSC1', 'DSC2', 'DSC3'] > i.e. the names w/o the file e

[Tutor] how to alter list content

2005-10-13 Thread Marc Buehler
hi. i create a list of all JPG files with: >>> list = glob.glob('*.JPG') the content of 'list' is now: >>> print list ['DSC1.JPG', 'DSC2.JPG', 'DSC3.JPG'] but what i want is this type of list: ['DSC1', 'DSC2', 'DSC3'] i.e. the names w/o the file extension. what's the easi

Re: [Tutor] redemo.py and r'python\.org'

2005-10-13 Thread Kent Johnson
Dick Moores wrote: > I've begun to try out redemo.py to test and learn regular expressions. It > doesn't seem to accept Python's raw strings as raw strings, e.g., > r'python\.org' for matching python.org and nothing else. Am I correct, > or is there something I don't understand here? In rede

Re: [Tutor] redemo.py and r'python\.org'

2005-10-13 Thread Dick Moores
Alan Gauld wrote at 14:09 10/13/2005: >Hi Dick, > > > I've begun to try out redemo.py to test and learn regular > expressions. It > > doesn't seem to accept Python's raw strings as raw strings, e.g., > > r'python\.org' for matching python.org and nothing else. Am I > correct, > > or is there s

Re: [Tutor] redemo.py and r'python\.org'

2005-10-13 Thread Alan Gauld
Hi Dick, > I've begun to try out redemo.py to test and learn regular expressions. It > doesn't seem to accept Python's raw strings as raw strings, e.g., > r'python\.org' for matching python.org and nothing else. Am I correct, > or is there something I don't understand here? I might be getti

[Tutor] python ncurses vs OS X Tiger's xterms.

2005-10-13 Thread Bill Campbell
I'm having an ``interesting'' problem running interactive python ncurses applications in xterms under Mac OS X where the numeric keypad is forced into application mode and the numlock key has no effect. We're using curses with accounting and data entry applications for efficient keyboard entry, wh

[Tutor] redemo.py and r'python\.org'

2005-10-13 Thread Dick Moores
I've begun to try out redemo.py to test and learn regular expressions. It doesn't seem to accept Python's raw strings as raw strings, e.g., r'python\.org' for matching python.org and nothing else. Am I correct, or is there something I don't understand here? BTW redemo.py can be found in Pyth

[Tutor] hand-holding for web development

2005-10-13 Thread nitin chandra
Hi!... i am new to Python and i want to develop a website with forms; data submitted through forms will be stored in PostgreSQL. I am working on derivant of FC3, OpenLX. I have Apache 2.0.54 version installed, which is pre-configured with mod_python. how do i load and view my .py/.html web page (f

Re: [Tutor] Clean up loop and search in a list

2005-10-13 Thread Markus Rosenstihl
Thank you for the fast reply Am 13.10.2005 um 19:43 schrieb Kent Johnson: > if len(filter(re_name.search, line)) > 0: > could be written > if re_name.search(line): this is not working because I am parsing a line in a list (i think): Traceback (most recent call last): File "telekom2.py

Re: [Tutor] how to create GUI for Python progs

2005-10-13 Thread w chun
On 10/13/05, Nick Lunt <[EMAIL PROTECTED]> wrote: > I'm really confused on the issue how to create windows, forms, etc. in> Python & can't find any manual for that.> Could you possibly advise me smth useful?this has come up quite a bit recently on the list. I would recommend that you go herehttp://

[Tutor] IOError: brown is not installed

2005-10-13 Thread enas khalil
hello , when i run this code for unigramtagger :   from nltk.tagger import *from nltk.corpus import brown    # Tokenize ten texts from the Brown Corpustrain_tokens = []for item in brown.items()[:10]:    train_tokens.append(brown.read(item))    # Initialise and train a unigram taggermytagger = Unigr

Re: [Tutor] how to create GUI for Python progs

2005-10-13 Thread Nick Lunt
Hi Olexiy, > I'm really confused on the issue how to create windows, forms, etc. in > Python & can't find any manual for that. > Could you possibly advise me smth useful? > -- > Best regards, > > Olexiy Kharchyshyn this has come up quite a bit recently on the list. I would recommend that you go

Re: [Tutor] Getting info about processes via pid

2005-10-13 Thread Dwyer, Michael
Hi Lawrence, In a UNIX environment the method used to determine if a process is running is to issue a "kill -0 pid". If the process is running the return value will be zero (0) and -1 with errno set to ESRCH - No process or process group can be found corresponding to that specified by pid. THANX

[Tutor] how to create GUI for Python progs

2005-10-13 Thread Olexiy Kharchyshyn
I'm really confused on the issue how to create windows, forms, etc. in Python & can't find any manual for that. Could you possibly advise me smth useful? -- Best regards, Olexiy Kharchyshyn [EMAIL PROTECTED] ___ Tutor maillis

Re: [Tutor] Clean up loop and search in a list

2005-10-13 Thread Kent Johnson
Markus Rosenstihl wrote: > Hi, > I wrote a program (see below) to analyse my phone bill, which is shared > by three others and I don't know if there is a way to make lines like > this nicer: > if len(filter(re_name.search, line)) > 0 and len(filter(re_misc.search, > line)) == 0 if len(filter

[Tutor] Getting info about processes via pid

2005-10-13 Thread lawrence wang
So I have a list of pids, and I want to check whether the pids still refer to live processes or not. Currently I'm doing that thus: pids = ['4550\n', ...] procs = os.popen("ps ax|grep %s|awk '{ print $1 }'" % keyword).readlines() and comparing the two lists. I'm wondering, though, if there's a wa

[Tutor] Clean up loop and search in a list

2005-10-13 Thread Markus Rosenstihl
Hi, I wrote a program (see below) to analyse my phone bill, which is shared by three others and I don't know if there is a way to make lines like this nicer: if len(filter(re_name.search, line)) > 0 and len(filter(re_misc.search, line)) == 0 Is there for example a way to search the whole list

Re: [Tutor] slide show won't display the images in right order

2005-10-13 Thread Kent Johnson
Joseph Quigley wrote: > Hey, if you are a Garfield fan or you just want to see the source code, > you can download the whole kaboodle (it's cross platform) from: > http://www.jqsoftware.com/software/Gacor/gacor-096.py I hope you like some comments... IMO the use of the Data class as a global op

Re: [Tutor] comiling python to microchip?

2005-10-13 Thread Michael Sparks
On Thursday 13 October 2005 01:08, Kent Johnson wrote: > Michael Sparks wrote: > > On Wednesday 12 October 2005 23:19, Kent Johnson wrote: > >>I don't think you can compile python code > > > > Pypy can compile a restricted subset of python... > > There is also Shed Skin - "an experimental Python-to

Re: [Tutor] __slots__

2005-10-13 Thread Kent Johnson
Mike Hansen wrote: >>From: >>Kent Johnson <[EMAIL PROTECTED]> >>I think the conventional advice is something like, if you don't >>understand why using slots is a bad idea, you have no business using >>them :-) >> > Can you tell us the pros and cons of using slots? I think I am in the group of p

Re: [Tutor] Problem with Winpdb.

2005-10-13 Thread Steve Robb
Message: 5 Date: Thu, 13 Oct 2005 05:51:04 -0400 From: Kent Johnson <[EMAIL PROTECTED]> Subject: Re: [Tutor] Problem with Winpdb. Cc: tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Steve Robb wrote: > Can anyone point me to what

Re: [Tutor] slide show won't display the images in right order

2005-10-13 Thread Joseph Quigley
Hi, Thank you all for your help. I must say that the python mailing list is the most helpfull of any place I've ever asked for help on. A close second comes linuxquestions.org. Somehow sort() got passed me in the Python Documentation and sort() has fixed all my problems. EDIT> Sort still didn'

Re: [Tutor] __slots__

2005-10-13 Thread Mike Hansen
> Subject: > Re: [Tutor] __slots__ > From: > Kent Johnson <[EMAIL PROTECTED]> > Date: > Wed, 12 Oct 2005 18:22:46 -0400 > > CC: > Python Tutor Mailing List > > > Liam Clarke wrote: > >> Well, all I can say is, don't use them unless you need them, they're a >> lot of hassle. > > > I think the

Re: [Tutor] Problem with Winpdb.

2005-10-13 Thread Kent Johnson
Steve Robb wrote: > Can anyone point me to what the problem may be with running Winpdb? > > I am running Win98, unfortunately > > However, when I try, > ..\python _winpdb.py, from the same directory, I get the following > traceback. > > Traceback (most recent call last): > File "C:\Python24\L

Re: [Tutor] __slots__

2005-10-13 Thread Alan Gauld
> > As a matter of interest why do you need so many in RAM at once? > > I'm creating an object for each header (for want of a better word.) A > song is described by an object with several children objects, each one > has certain attributes. OK, But you only need the song object group to manipulat

Re: [Tutor] help with elif statements

2005-10-13 Thread Alan Gauld
> below is my code and everytime I input a value of 16 or more it keeps > returning sophomore. could anyone help me figure out what to change so > that it won't return sophmore for things greater than or equal to 16? This is one of the gotchas of if/elif chains and I discuss it in my branching to

Re: [Tutor] Can anyone teach me...?

2005-10-13 Thread Alan Gauld
>>I use Delphi for most of my real-world heavy duty GUI work. >> > Have you tried Boa Constructor? It is quite similar to Delphi. It builds > wxPython. I tried it a couple of years ago but couldn't get it to work! Even if I had it didn't offer many of the features of VB/Delphi such as live da

Re: [Tutor] how to speed up this code?

2005-10-13 Thread Pujo Aji
Hello Andrew,   Thanks for the info. I wonder if everytime we have to solve loop inside loop which use big array will force us to think another algorithm like matrix model. Since this model is suitable with Numeric.py    I think looping style sometimes easier to describe our problem.  pujo  On 10/1

Re: [Tutor] how to speed up this code?

2005-10-13 Thread Andrew P
It's way past my bedtime, but any use of numpy/numarray that involves two nested for loops to step over each element is the wrong solution :)  You need to figure out how to get rid of that inner for.  That is what is slowing you down.  Compare these two ways to multiply a 1000 element array by 10

Re: [Tutor] Can anyone teach me...?

2005-10-13 Thread Scott Oertel
luke p wrote: nathan, there are a few GUI options available to you. the one that is bundled with the python installation is TKInter.  that's an "i" not an "L". you can also use the python interface for WxWindows, I forget what it's called. anyway, TKInter looks fairly nice, some sa

Re: [Tutor] how to speed up this code?

2005-10-13 Thread Pujo Aji
hello chun,   I use Numeric. using 'while' instead of for, has the same effect. still slow   pujo  On 10/13/05, w chun <[EMAIL PROTECTED]> wrote: On 10/12/05, Pujo Aji <[EMAIL PROTECTED]> wrote:> I have code like this: >> def f(x,y):> return math.sin(x*y) + 8 * x>> def main():> n = 2000>   

Re: [Tutor] Problem with Winpdb.

2005-10-13 Thread Franz Steinh�usler
On Wed, 12 Oct 2005 11:41:16 -0500, Steve Robb <[EMAIL PROTECTED]> wrote: >Can anyone point me to what the problem may be with running Winpdb? >[snip] Hello Steve, I think, best would be to post this into: http://sourceforge.net/projects/winpdb/ bug tracker. -- Franz Steinhaeusler ___

Re: [Tutor] Struct headspinner

2005-10-13 Thread Liam Clarke
> > """By default, C numbers are represented in the machine's native format > and byte order, and properly aligned by skipping pad bytes if necessary > (according to the rules used by the C compiler).""" > > > Does this make sense? Please feel free to ask more questions on this; > it's a bit of a

Re: [Tutor] PLC programming with Python?

2005-10-13 Thread Liam Clarke
On 10/13/05, Johan Geldenhuys <[EMAIL PROTECTED]> wrote: > Hi all, > Can Python be used to do PLC (programmable logic controller) > programming? I'm not sure because Python needs some platform to run on? > > Thanks, > > Johan > ___ > Tutor maillist - Tu

Re: [Tutor] __slots__

2005-10-13 Thread Liam Clarke
On 10/13/05, Alan Gauld <[EMAIL PROTECTED]> wrote: > > an object with 70ish attributes makes. FWIW, I'm doing the exact > > opposite of XP, and building to handle 300,000 to 600,000 objects... > > As a matter of interest why do you need so many in RAM at once? > Its very unusual to require that man

Re: [Tutor] how to speed up this code?

2005-10-13 Thread w chun
On 10/12/05, Pujo Aji <[EMAIL PROTECTED]> wrote: > I have code like this: > > def f(x,y): > return math.sin(x*y) + 8 * x > > def main(): > n = 2000 > a = zeros((n,n), Float) > xcoor = arange(0,1,1/float(n)) > ycoor = arange(0,1,1/float(n)) > > for i in range(n): > fo