Re: [Tutor] extracting phrases and their memberships from syntax trees

2009-02-12 Thread A.T.Hofkamp
Emad Nawfal (عماد نوفل) wrote: just want to be able to do this myself. My question is: what tools do I need for this? Could you please give me pointers to where to start? I'll then try to do it myself, and ask questions when I get stuck. I'd start with parsing (reading) the tree to a generic ab

Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-12 Thread John Fouhy
2009/2/13 Eric Dorsey : > Alan, can you give a short snippet of what that would look like? I was > trying to code out some idea of how you'd retain insertion order using > another dict or a list and didn't get anywhere. Here's something basic: class o_dict(dict): def __init__(self, *args, **

Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-12 Thread Eric Dorsey
But you need to have an order that will work with sorted(). > Its not just the order you add items to the dict. To store an > arbitrary order I suspect you would need to maintain a > secondary list with the keys in the order of insertion. > The most reliable way to dop that would be to subclas

Re: [Tutor] IDLE/phythonWin -- Who's On First? (Abbott and Costello)

2009-02-12 Thread Alan Gauld
"ALAN GAULD" wrote solved since about v2.3. However it does still through up issues, Ahem! That should of course be "throw up issues"! Sorry, Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ ___ Tutor maillist - Tu

Re: [Tutor] Detecting wx

2009-02-12 Thread Alan Gauld
"Ricardo Aráoz" wrote wx shell I want to establish a wx app. But if I'm in pythonWin I didn't think pythonwin was a wx application. I believe it's written in pure Windows, using the pywin extensions on top of Scintilla. But that aside I'd be interested in the answer to this one. there is a

[Tutor] extracting phrases and their memberships from syntax trees

2009-02-12 Thread عماد نوفل
Dear Tutors, I have syntax trees like the one below. I need to extract the membership information like which adjective belongs to which noun phrase, and so on. In short, I want to do something like this: http://ilk.uvt.nl/team/sabine/chunklink/README.html I already have the Perl script that does th

Re: [Tutor] Detecting wx

2009-02-12 Thread John Fouhy
2009/2/13 Ricardo Aráoz : > There are a couple of utilities I want to be able to run from the > command window. Now, if I'm at the command window, or Idle, or other non > wx shell I want to establish a wx app. But if I'm in pythonWin, PyCrust, > or any other wx based shell then there is a wx event

Re: [Tutor] print function in python 2.6 and 3

2009-02-12 Thread Sander Sweers
On Thu, Feb 12, 2009 at 22:50, Alan Gauld wrote: >> Now what should be used and promoted on the list? > > We can't shouldn't promote one over the other since the remit > of this list is to help newbies, regardless of the Python version. OK, understood. > The only thing I would strongly request i

[Tutor] Detecting wx

2009-02-12 Thread Ricardo Aráoz
There are a couple of utilities I want to be able to run from the command window. Now, if I'm at the command window, or Idle, or other non wx shell I want to establish a wx app. But if I'm in pythonWin, PyCrust, or any other wx based shell then there is a wx event loop already running and if I crea

Re: [Tutor] print function in python 2.6 and 3

2009-02-12 Thread Alan Gauld
"Sander Sweers" wrote I see more people posting answers with the new print() function only available in python 3 and in python 2.6 via an import from __future__. Now I am not confused by this but I can understand that people very new to python can get confused byt this. Especially people fol

[Tutor] print function in python 2.6 and 3

2009-02-12 Thread Sander Sweers
Hello, I see more people posting answers with the new print() function only available in python 3 and in python 2.6 via an import from __future__. Now I am not confused by this but I can understand that people very new to python can get confused byt this. Especially people following a guide online

Re: [Tutor] Converting a numerical variable into a string variable

2009-02-12 Thread Shawn Milochik
>>> for x in range(1,9): print("G%dBF" % (x,)) G1BF G2BF G3BF G4BF G5BF G6BF G7BF G8BF >>> ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Converting a numerical variable into a string variable

2009-02-12 Thread Sander Sweers
On Thu, Feb 12, 2009 at 21:06, Andres Sanchez wrote: > Please, give me a hand with this. Say I have a vector defined as > x=[1,2,3,4,...,9]. I need to write string variables with the names > G1BF...G9BF. Thus, the first string variable would be 'G'+'1'+'BF', being > the number 1 equal to x[0]. Now

[Tutor] Converting a numerical variable into a string variable

2009-02-12 Thread Andres Sanchez
Folks, Please, give me a hand with this. Say I have a vector defined as x=[1,2,3,4,...,9]. I need to write string variables with the names G1BFG9BF. Thus, the first string variable would be 'G'+'1'+'BF', being the number 1 equal to x[0]. Now, using a for loop, I want to do something like:

Re: [Tutor] How to foreach over a dynamic number of levels

2009-02-12 Thread Kent Johnson
On Thu, Feb 12, 2009 at 1:04 PM, Alexander Daychilde (Gmail) wrote: >> Now what you want is the Cartesian product of all the lists. Python >> has a function (new in Python 2.6) in the itertools library module >> that will do this: > > I'm stuck on 2.5.2 because of the framework I'm driving... Doe

[Tutor] ConfigParser re-read fails

2009-02-12 Thread Timo
Hello all, I use a file for my program that I read with ConfigParser. I append all sections of this file into a treeview (using pyGTK). The user can add, edit or remove sections, options and values. These I write back to the file and then update the treeview. The problem is that it doesn't up

Re: [Tutor] How to foreach over a dynamic number of levels

2009-02-12 Thread Alexander Daychilde (Gmail)
First, thank you VERY much for your help! That's amazingly much easier than I thought it would be... I was considering looping through and generating nested for loops, then exec'ing the whole mess.. UGH, and security risk, to boot... Couple of questions: > Make a list containing all the steps: >

Re: [Tutor] Program to report if file was modified today

2009-02-12 Thread David
David wrote: > Kent Johnson wrote: > >> On Wed, Feb 11, 2009 at 11:21 PM, bob gailer wrote: >> >> >> > Thanks Alan and Kent, > This works as expected; > > #!/usr/bin/python > import sys > import os > import time > > def mod(): > """Find files modified today, given a file path.""" >

Re: [Tutor] Program to report if file was modified today

2009-02-12 Thread David
Kent Johnson wrote: > On Wed, Feb 11, 2009 at 11:21 PM, bob gailer wrote: > > Thanks Alan and Kent, This works as expected; #!/usr/bin/python import sys import os import time def mod(): """Find files modified today, given a file path.""" now = time.strftime('%Y-%m-%d', time.localtime(

Re: [Tutor] Program to report if file was modified today

2009-02-12 Thread Kent Johnson
On Wed, Feb 11, 2009 at 11:21 PM, bob gailer wrote: > David wrote: >> >> I get this error with the int(time.localtime()) >> start_of_today = int(time.localtime()) >> TypeError: int() argument must be a string or a number, not >> 'time.struct_time' > > Should have been start_of_today = int(time.ti

Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-12 Thread spir
Le Thu, 12 Feb 2009 09:25:22 -, "Alan Gauld" a écrit : > > config_names = {"start_time : '18:00:00', 'gray_scale' : True, > > "long": 120.00} > > > > If I iterate over it, the entries will appear in any order, as > > opposed to > > what I see above. However, in the config file, I'd like to

Re: [Tutor] IDLE/phythonWin -- Who's On First? (Abbott and Costello)

2009-02-12 Thread Wayne Watson
That's a good reason. I'm off to a XP Pro group to see how to break out of this, and restore order to IDLE. ALAN GAULD wrote: There used to be a lot of problems running Tkinter programs inside IDLE but most of these have been solved since about v2.3. However it does still through up

Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-12 Thread Kent Johnson
On Thu, Feb 12, 2009 at 4:25 AM, Alan Gauld wrote: > Thats tricky! Dictionaries are not sorted and do not retain insertion order. > But you need to have an order that will work with sorted(). > Its not just the order you add items to the dict. To store an > arbitrary order I suspect you would ne

Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-12 Thread Senthil Kumaran
On Thu, Feb 12, 2009 at 2:55 PM, Alan Gauld wrote: > But you need to have an order that will work with sorted(). > Its not just the order you add items to the dict. And yes algorithmically, there is No Requirement or I should say a good Use Case for a Dict to have sorted keys. More we work with

Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-12 Thread Alan Gauld
"Eric Dorsey" wrote config_names {'start_time': '18:00:00', 'gray_scale': True, 'long': 120.0} for i, x in config_names.items(): ... print i, x ... start_time 18:00:00 gray_scale True long 120.0 Thats pretty much a happy coincidence, there is no guarantee that it will work like that

Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-12 Thread Alan Gauld
"Wayne Watson" wrote config_names = {"start_time : '18:00:00', 'gray_scale' : True, "long": 120.00} If I iterate over it, the entries will appear in any order, as opposed to what I see above. However, in the config file, I'd like to keep them in the order above. Thats tricky! Dictionaries

Re: [Tutor] [tutor] IDLE

2009-02-12 Thread Alan Gauld
"WM." wrote IDLE also now works perfectly, whether I open into IDLE or edit window. Below is a copy/paste: IDLE 2.6 >>> i = 9 >>> while i > 2: print i i -= 1 The problem occurs when you go to a second level block: if 42 > 66: print 'false' else:

Re: [Tutor] Program to report if file was modified today

2009-02-12 Thread Alan Gauld
"David" wrote I really only want it to report when a file has been modified so this seems to work, #!/usr/bin/python import sys import os import time def mod(): """Find files modified today, given a file path.""" latest = 0 now = time.strftime('%Y-%m-%d', time.localtime())

Re: [Tutor] IDLE/phythonWin -- Who's On First? (Abbott and Costello)

2009-02-12 Thread ALAN GAULD
There used to be a lot of problems running Tkinter programs inside IDLE but most of these have been solved since about v2.3. However it does still through up issues, so the simple solution it to always test GUI programs outside of the IDE. Another reason why for serious programming I tend to