Re: [Tutor] Please look at my wordFrequency.py

2005-10-12 Thread Dick Moores
John Fouhy wrote at 15:09 10/11/2005: >On 12/10/05, Dick Moores <[EMAIL PROTECTED]> wrote: > >Hi Dick, > >Glad you're making progress :-) > > > Yes, that's about the difference I was seeing. Thanks for taking the > > trouble. I went from 30 to 27. With no regex use (don't understand it > yet). > >

[Tutor] another error in tagging program

2005-10-12 Thread enas khalil
hello all i have run  the following code :# the taggerI interfacefrom nltk.tagger import *from nltk.tokenizer import WhitespaceTokenizerfrom nltk.tokenizer import *from nltk.token import * # Using UnigramTagger##Before aUnigramTagger can be used to tag data ,it must be trained on training corpus,#

Re: [Tutor] Please look at my wordFrequency.py

2005-10-12 Thread Alan Gauld
> See Also:Mastering Regular Expressions Book on regular expressions by > Jeffrey Friedl, published by O'Reilly. The second edition of the book no > longer covers Python at all, but the first edition covered writing good > regular expression patterns in great detail. " > > So I'd like to ask if

Re: [Tutor] another error in tagging program

2005-10-12 Thread w chun
On 10/12/05, enas khalil <[EMAIL PROTECTED]> wrote: > > and got the following error : > Traceback (most recent call last): > File "F:\MSC first Chapters\error correct.py", line 19, in -toplevel- > tagger.train(tagged_txt_token) > File > "C:\Python24\Lib\site-packages\nltk\tagger\__init__.py

[Tutor] launching and monitor from make

2005-10-12 Thread Ertl, John
All, I have a very simple python program that reads one file and overwrites anouther text file. This workes great from the command line and it has error checking but just outputs messages and the like to the screen. The CM team here would like to have the script run each week as part of the auto

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

2005-10-12 Thread Joseph Quigley
Hi, Here's my directory listing as a list: ['ga041001.gif', 'ga041002.gif', 'ga041003.gif', 'ga041004.gif', 'ga041005.gif', 'ga041006.gif', 'ga041007.gif', 'ga041008.gif', 'ga041009.gif', 'ga041010.gif', 'ga041011.gif', 'ga000619.gif', 'ga050101.gif', 'ga050102.gif', 'ga050103.gif', 'ga050104.gif',

Re: [Tutor] launching and monitor from make

2005-10-12 Thread Ertl, John
Ewald, That easy...If you know. Thanks for the example and the help. Now lets see if I can modify the make file without upsetting the make god. Thanks again. John Ertl -Original Message- From: Ewald Ertl [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 12, 2005 7:40 AM To:

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

2005-10-12 Thread dataw0lf
Joseph Quigley wrote: > When I use: > files = os.listdir() > x = 0 > direction = 1 > while True: > ShowImg(files[x]) # An image display function > x += -1 > > it doesn't display the images in the right order! It will skip from > ga050123.gif and go to ga050120.gif! Why not do something l

Re: [Tutor] Please look at my wordFrequency.py

2005-10-12 Thread Dick Moores
Alan Gauld wrote at 06:00 10/12/2005: > > See Also:Mastering Regular Expressions Book on regular expressions by > > Jeffrey Friedl, published by O'Reilly. The second edition of the book no > > longer covers Python at all, but the first edition covered writing good > > regular expression patterns in

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

2005-10-12 Thread Kent Johnson
Joseph Quigley wrote: > Hi, > Here's my directory listing as a list: > ['ga041001.gif', 'ga041002.gif', 'ga041003.gif', 'ga041004.gif', > 'ga041005.gif', 'ga041006.gif', 'ga041007.gif', 'ga041008.gif', > 'ga041009.gif', 'ga041010.gif', 'ga041011.gif', 'ga000619.gif', > 'ga050101.gif', 'ga050102.gif

Re: [Tutor] Please look at my wordFrequency.py

2005-10-12 Thread Kent Johnson
Dick Moores wrote: > The regex HOWTO, above, mentions, in section 3.3, a tool that comes with > Python 2.4 for practicing/testing regex. Tools/scripts/redemo.py . Can > you recommend this? And how about Kodos? () Yes, it's very handy. Try it! Kodos is similar. I th

[Tutor] Problem with Winpdb.

2005-10-12 Thread Steve Robb
Can anyone point me to what the problem may be with running Winpdb? I am running Win98, unfortunately, Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7. I have python 2.4, Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32. I have Winpdb, W

Re: [Tutor] launching and monitor from make

2005-10-12 Thread Alan Gauld
> The CM team here would like to have the script run each week as part of > the > automated rebuilds. The suggestion was to make the execution of the > scritp > part of the bigger programs make file. How would I handel errors when the > program is run from a makefile? I hate make so I have not

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

2005-10-12 Thread Alan Gauld
> When I use: > files = os.listdir() Have you tried printing 'files'? Are they in order there? > it doesn't display the images in the right order! It will skip from > ga050123.gif and go to ga050120.gif! I suspect listdir doesn't use name order. You probably need to do a sort() on the files list

Re: [Tutor] launching and monitor from make

2005-10-12 Thread Ertl, John
Alan, Thanks, just as you and Ewald said it works great. Almost too easy...I have this feeling something will turn around a bite me once it goes to ops. Thanks again John Ertl -Original Message- From: Alan Gauld [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 12, 200

Re: [Tutor] Please look at my wordFrequency.py

2005-10-12 Thread Alan Gauld
> The regex HOWTO, above, mentions, in section 3.3, a tool that comes with > Python 2.4 for practicing/testing regex. Tools/scripts/redemo.py . Can you > recommend this? And how about Kodos? () Yes I can recommend it, its a great tool for trying REs out Alan G.

[Tutor] (no subject)

2005-10-12 Thread Jeff Peery
hello, I am trying to find the source code for FFT. I found the FFT.py module athough I cannot find the actual code that runs the FFT. Is it in a compiled form or can I view its source?   thanks.___ Tutor maillist - Tutor@python.org http://mail.python.o

Re: [Tutor] (no subject)

2005-10-12 Thread Kent Johnson
Jeff Peery wrote: > hello, I am trying to find the source code for FFT. I found the FFT.py > module athough I cannot find the actual code that runs the FFT. Is it in > a compiled form or can I view its source? Which FFT (where did you get fft.py)? you asked this same question in August, here is

Re: [Tutor] Please look at my wordFrequency.py

2005-10-12 Thread Dick Moores
Alan Gauld wrote at 10:04 10/12/2005: > > The regex HOWTO, above, mentions, in section 3.3, a tool that comes with > > Python 2.4 for practicing/testing regex. Tools/scripts/redemo.py . > Can you > > recommend this? And how about Kodos? () > >Yes I can recommend it,

[Tutor] how to extract number of files from directory

2005-10-12 Thread Marc Buehler
hi. i'm new to Python ... i would like to extract the number of JPG files from the current directory and use that number as a parameter in my python script. i tried: a = os.system('ls *JPG | wc -l') when i do: print a i get '0'. what am i missing? marc ---

[Tutor] Can anyone teach me...?

2005-10-12 Thread Nathan Pinno
Hey all, When I said that I might go to Visual Basic in an earlier message, someone replied by saying that I should ask here how to do it in Python. Well, I'm asking now: Can anyone teach me how to make a simple program that uses a GUI? Thanks, Nathan Pinno Crew, McDonalds Restaurant and fan extra

Re: [Tutor] how to extract number of files from directory

2005-10-12 Thread Kent Johnson
Marc Buehler wrote: > i would like to extract the number of JPG files > from the current directory and use that number > as a parameter in my python script. > i tried: > a = os.system('ls *JPG | wc -l') > when i do: > print a > i get '0'. > > what am i missing? os.system() returns the exit code

Re: [Tutor] how to extract number of files from directory

2005-10-12 Thread Ertl, John
Marc, You can do most system type stuff in Python and it makes it much easier. import glob jpgList = glob.glob("*.jpg") # the glob allows you to use wild cards in the search jpgCount = len(jpgList) This gives you a list of all files that end in .jpg. You can then do a len(jpgList) to get the nu

Re: [Tutor] how to extract number of files from directory

2005-10-12 Thread Eric Walker
I think os.system returns status of commands Try this: w = os.popen('ls -l | wc -l').readlines() Python Newbie... On Wednesday 12 October 2005 12:10 pm, Marc Buehler wrote: > hi. > > i'm new to Python ... > > i would like to extract the number of JPG files > from the current directory and use th

[Tutor] comiling python to microchip?

2005-10-12 Thread Jeff Peery
is it possible to take python code and compile it for use in a microprocessor?___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to extract number of files from directory

2005-10-12 Thread w chun
On 10/12/05, Ertl, John <[EMAIL PROTECTED]> wrote: You can do most system type stuff in Python and it makes it much easier.import globjpgList = glob.glob("*.jpg") # the glob allows you to use wild cards in thesearchjpgCount = len(jpgList)This gives you a list of all files that end in .jpg.  You can

Re: [Tutor] how to extract number of files from directory

2005-10-12 Thread Kent Johnson
w chun wrote: > glob seems to be a good idea, but is there a way to do it > case-insensitively, i.e., .jpg and .JPG? > > it may be slower than glob, but i'm finding myself thinking more like... > > len([i for i in os.listdir('tmp') if i.lower().endswith('.jpg')]) > > now, anyone with a solution

Re: [Tutor] how to extract number of files from directory

2005-10-12 Thread Alan Gauld
> a = os.system('ls *JPG | wc -l') > when i do: > print a > i get '0'. os.system only returns the exitcode of the command not the output. Look at the new Subprocess module and its Popen class. It can look intimidating at first but read the examples and you should find it easy enough. Altrerna

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

2005-10-12 Thread Alan Gauld
Hello again Nathan, > When I said that I might go to Visual Basic in an earlier message, > someone replied by saying that I should ask here how to do it in Python. > Well, I'm asking now: Can anyone teach me how to make a simple > program that uses a GUI? Take a look at the GUI section of my t

Re: [Tutor] how to extract number of files from directory

2005-10-12 Thread Kent Johnson
Alan Gauld wrote: > a = len(os.listdir(mydir, '*JPG') > > Should be about right... No, os.listdir() only takes one argument, the directory. See the solutions with glob.glob(). Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailma

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

2005-10-12 Thread Murtog
The correct code looks like this: files = os.listdir() files.sort()x = 0direction = 1while True:     ShowImg(files[x]) # An image display function     x += -1-- Cheers, Murtog ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinf

[Tutor] __slots__

2005-10-12 Thread Liam Clarke
If you've been wondering about how useful this is... Well, all I can say is, don't use them unless you need them, they're a lot of hassle. I created two versions of the same object, same attribute values, one with slots, one without. With slots, it pickled to a string of 163 characters. Without,

Re: [Tutor] comiling python to microchip?

2005-10-12 Thread Alan Gauld
From: "Jeff Peery" <[EMAIL PROTECTED]> > is it possible to take python code and compile it for use in a > microprocessor? > In the same way that Sun have been threatening to build a chip that has Java as its machine code then it would be possible to build a chip that ran Python bytecode but it w

Re: [Tutor] how to extract number of files from directory

2005-10-12 Thread Alan Gauld
> glob seems to be a good idea, ... Yep, I got my glob and listdir mixed up earlier... > it may be slower than glob, but i'm finding myself thinking more like... > len([i for i in os.listdir('tmp') if i.lower().endswith('.jpg')]) > > now, anyone with a solution for .jpg, .JPG, .jpeg, *and* .JPEG?

Re: [Tutor] how to extract number of files from directory

2005-10-12 Thread Alan Gauld
>> a = len(os.listdir(mydir, '*JPG') >> >> Should be about right... > > No, os.listdir() only takes one argument, the directory. See the solutions > with glob.glob(). Oops! Quite right, my mistake. (As is the missing right paren!) Alan g. ___ Tutor m

[Tutor] Struct headspinner

2005-10-12 Thread Liam Clarke
Hi all, Erm, can someone please aid me? I'm using Windows XP, haven't tested this code on Linux yet, but, well watch this... '<' indicates little-endian, @ indicates native. i is an integer, q is a long. >>> struct.calcsize('<3i') 12 >>> struct.calcsize('@3i') 12 >>> struct.calcsize('<3iq') 20 >

Re: [Tutor] __slots__

2005-10-12 Thread Alan Gauld
> 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 many and there are techniques to minimise the space by using '

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

2005-10-12 Thread luke p
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 say it doesn't have the windows "

Re: [Tutor] Struct headspinner

2005-10-12 Thread Tim Peters
[Liam Clarke] > Erm, can someone please aid me? I'm using Windows XP, haven't tested > this code on Linux yet, but, well watch this... > > '<' indicates little-endian, @ indicates native. i is an integer, Yes x 3. > q is a long. No. q in native mode is C "long long" on Linux, or "_int64" on Win

Re: [Tutor] comiling python to microchip?

2005-10-12 Thread Adam
On 12/10/05, Jeff Peery <[EMAIL PROTECTED]> wrote: is it possible to take python code and compile it for use in a microprocessor? ___Tutor maillist  -  Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Building on what Alan said this may be

Re: [Tutor] comiling python to microchip?

2005-10-12 Thread Kent Johnson
Jeff Peery wrote: > is it possible to take python code and compile it for use in a > microprocessor? I don't think you can compile python code but python itself has been ported to many tiny architectures. Take a look at http://www.python.org/download/download_other.html if you don't see what yo

Re: [Tutor] __slots__

2005-10-12 Thread Kent Johnson
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 conventional advice is something like, if you don't understand why using slots is a bad idea, you have no business using them :-) > I created two versions of the same object,

Re: [Tutor] Struct headspinner

2005-10-12 Thread Danny Yoo
On Wed, 12 Oct 2005, Liam Clarke wrote: > Erm, can someone please aid me? I'm using Windows XP, haven't tested > this code on Linux yet, but, well watch this... > > '<' indicates little-endian, @ indicates native. i is an integer, q is a long. > > >>> struct.calcsize('<3i') > 12 > >>> struct.cal

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

2005-10-12 Thread Terry Carroll
On Wed, 12 Oct 2005, Alan Gauld wrote: > However I have to be honest and say that building GUIs in VB ... is a > lot easier than in Python IMHO. I have to say, I agree with that. I just started using VB a month ago (for a course I'm taking, all projects need to be in VB), and it's really a ple

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

2005-10-12 Thread w chun
On 10/12/05, Terry Carroll <[EMAIL PROTECTED]> wrote: On Wed, 12 Oct 2005, Alan Gauld wrote:> However I have to be honest and say that building GUIs in VB ... is a> lot easier than in Python IMHO.But, man, VB as a language and library set is horrible; and pointlessly horrible, in many cases.The bes

Re: [Tutor] comiling python to microchip?

2005-10-12 Thread Michael Sparks
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... More accurately it translates the restricted subset to C and then *that* can be compiled. Some code can get quite dramatic speed improvements - t

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

2005-10-12 Thread Ismael Garrido
Alan Gauld wrote: >However I have to be honest and say that building GUIs in VB >(or Borland's Delphi/Kylix) is a lot easier than in Python IMHO. >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.

Re: [Tutor] how to extract number of files from directory

2005-10-12 Thread Michael Sparks
On Wednesday 12 October 2005 19:10, Marc Buehler wrote: > i would like to extract the number of JPG files > from the current directory and use that number I've looked through the thread, and the following strikes me as simpler than the suggestions so far. path = "." # Current directory, unix at

Re: [Tutor] comiling python to microchip?

2005-10-12 Thread Kent Johnson
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-C++ compiler. It can convert many Python programs into opt

Re: [Tutor] comiling python to microchip?

2005-10-12 Thread R. Alan Monroe
> From: "Jeff Peery" <[EMAIL PROTECTED]> >> is it possible to take python code and compile it for use in a >> microprocessor? >> > In the same way that Sun have been threatening to build a chip that has Java > as its machine code then it would be possible to build a chip that ran > Python > byte

[Tutor] help with elif statements

2005-10-12 Thread andrade1
hello 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? def getcredits(num): if num < 7: return 'Freshman' elif num >= 7

Re: [Tutor] help with elif statements

2005-10-12 Thread John Fouhy
On 13/10/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > 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? Which is the first bran

Re: [Tutor] help with elif statements

2005-10-12 Thread Hans Dushanthakumar
U might wanna change the code to something along the lines of def getcredits(num): if num < 7: return 'Freshman' elif num >= 7 and num <16 return 'Sophomore' elif num >= 16 and num < 26: return 'Junior' Etc... Or even def getcredits(num): if num < 7:

Re: [Tutor] help with elif statements

2005-10-12 Thread Danny Yoo
On Wed, 12 Oct 2005 [EMAIL PROTECTED] wrote: > 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? If we have the following: ### Ps

Re: [Tutor] launching and monitor from make

2005-10-12 Thread Michael P. Reilly
On 10/12/05, Ertl, John <[EMAIL PROTECTED]> wrote: I have a very simple python program that reads one file and overwritesanouther text file.  This workes great from the command line and it haserror checking but just outputs messages and the like to the screen. The CM team here would like to have th

Re: [Tutor] help with elif statements

2005-10-12 Thread bob
At 06:04 PM 10/12/2005, [EMAIL PROTECTED] wrote: >hello > >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? > >def getcredits(num): >

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

2005-10-12 Thread Raduz
On Thursday 13 of October 2005 00:27, Terry Carroll wrote: > > The best of both worlds, to me, would be the ability to use a VB-like GUI > and the Python language and libraries. You would be able to do some > pretty powerful work in just minutes. Right now, I find creating a > Tkinter app to be p

[Tutor] how to speed up this code?

2005-10-12 Thread Pujo Aji
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):         for j in range(n):             a[i,j] = f(xcoor[i], ycoor[j])  # f(x,y) =

[Tutor] PLC programming with Python?

2005-10-12 Thread Johan Geldenhuys
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 - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor