[Tutor] language aid

2010-02-04 Thread Owain Clarke
Hello, all. I am a newcomer to Python, and I know that I have much learning to do before I implement my idea, but I am working on the beginnings of a vocabulary building program. This is how I am catching new words at the moment. def newVocab(x,y): Add new word pair, English word second.

Re: [Tutor] language aid

2010-02-04 Thread Owain Clarke
Thanks for your input. I had discounted the idea of a dictionary because all the keys need to be unique, so whether the key is the English or non-English word, it couldn't cope with for example "too", or a similar word in the other language. Owain Albert-Jan Roskam wrote:

Re: [Tutor] language aid

2010-02-04 Thread spir
On Thu, 04 Feb 2010 16:11:33 + Owain Clarke simb...@cooptel.net wrote: But if one word has different meanings in the other language, you may need to use a list of words as the values. ? You can have a more sophisticated structure for you dict. For instance, love is both a noun and a

Re: [Tutor] language aid

2010-02-04 Thread Alan Gauld
Owain Clarke simb...@cooptel.net wrote I had discounted the idea of a dictionary because all the keys need to be unique, Thats true but the values can be lists and do not need to be unique. Its probably a better starting point that search through a list looking at every item. so whether

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread spir
On Thu, 4 Feb 2010 12:11:24 -0500 Serdar Tumgoren zstumgo...@gmail.com wrote: Hi folks, A few months back I posted my first (and only) recipe to ActiveState. It was just a little function to convert an integer or its string representation to an ordinal value: 1 to 1st, 2 to 2nd, etc.

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Wayne Werner
On Thu, Feb 4, 2010 at 11:11 AM, Serdar Tumgoren zstumgo...@gmail.comwrote: Hi folks, snip I just noticed, however, that in the comments section of the ActiveState recipe that someone is getting incorrect results for certain numbers (11 and 12, specifically). But when I use the code on my

[Tutor] Help with cursors please

2010-02-04 Thread Alan Harris-Reid
Hi, I have a SQLite cursor which I want to traverse more than once, eg... for row in MyCursor: method1(row) then later... for row in MyCursor: method2(row) Method2 is never run, I guess because the pointer is at the bottom of the row 'stack' after the first 'for' loop How can I

Re: [Tutor] language aid

2010-02-04 Thread spir
On Thu, 04 Feb 2010 16:11:33 + Owain Clarke simb...@cooptel.net wrote: But if one word has different meanings in the other language, you may need to use a list of words as the values. ? You can have a more sophisticated structure for you dict. For instance, love is both a noun and a

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Alan Gauld
Serdar Tumgoren zstumgo...@gmail.com wrote was hoping that you all could help me crowdsource the issue. If you have the time and inclination, could you look at the code and tell me if and where I've gone wrong? Not sure about the reported bugs but some comments: What happens if if value %

Re: [Tutor] language aid

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 5:43 AM, Owain Clarke simb...@cooptel.net wrote: My question is, that if I proceed like this I will end up with a single list of potentially several hundred strings of the form frword:engword. In terms of performance, is this a reasonable way to do it, or will the

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Serdar Tumgoren
No time to search for the issue, but here are some trials (hole from 10 -- 19): for i in range(21):        print %s\t: %s %(i,ordinal(i)) for i in (-1,22,33,99,100,101,199,200,999,1000):        print %s\t: %s %(i,ordinal(i)) == 0       : 0th 1       : 1st 2       : 2nd 3       : 3rd 4

Re: [Tutor] language aid

2010-02-04 Thread Carnell, James E
Hi, ? A dictionary (associative array of keys and values) seems a good datatype to use. vocab = {} vocab[frenchword]?= englishword ? ... Cheers!! Albert-Jan Sure, a dict is the obvious choice. For saving into file, if the app is to be used internally, you can even print it in the

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 12:11 PM, Serdar Tumgoren zstumgo...@gmail.com wrote: I just noticed, however, that in the comments section of the ActiveState recipe that someone is getting incorrect results for certain numbers (11 and 12, specifically). But when I use the code on my own machine it

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 1:09 PM, Kent Johnson ken...@tds.net wrote: On Thu, Feb 4, 2010 at 12:11 PM, Serdar Tumgoren zstumgo...@gmail.com wrote: Here's the link to the recipe: http://code.activestate.com/recipes/576888/ Perhaps the code on activestate is not a correct copy of what you are

Re: [Tutor] Help with cursors please

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 12:47 PM, Alan Harris-Reid aharrisr...@googlemail.com wrote: Hi, I have a SQLite cursor which I want to traverse more than once, eg... for row in MyCursor:   method1(row)  then later... for row in MyCursor:   method2(row)  Method2 is never run, I guess because the

Re: [Tutor] language aid

2010-02-04 Thread Alan Plum
On Do, 2010-02-04 at 16:11 +, Owain Clarke wrote: Thanks for your input. I had discounted the idea of a dictionary because all the keys need to be unique, so whether the key is the English or non-English word, it couldn't cope with for example too, or a similar word in the other language.

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Serdar Tumgoren
Perhaps the code on activestate is not a correct copy of what you are running? The conditional at line 23 extends all the way to line 35 - the end of the function - so if value % 100/10 == 1 no more code is executed and None is returned. Here is the code that I'm running locally (hopefully

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Serdar Tumgoren
On Thu, Feb 4, 2010 at 1:21 PM, Serdar Tumgoren zstumgo...@gmail.com wrote: Perhaps the code on activestate is not a correct copy of what you are running? The conditional at line 23 extends all the way to line 35 - the end of the function - so if value % 100/10 == 1 no more code is executed

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Wayne Werner
On Thu, Feb 4, 2010 at 12:30 PM, Serdar Tumgoren zstumgo...@gmail.comwrote: Geez -- I think I found the (now-obvious) mistake. If you compare the above to the ActiveState recipe, it's obvious that I forgot to copy over the final, outer else: clause. Could you all indulge me one last time

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Sander Sweers
On do, 2010-02-04 at 13:30 -0500, Serdar Tumgoren wrote: Could you all indulge me one last time and tell me if the above version works for you? If so, I'll update the recipe to spare others a similar headache. It now works ok but.. You should not use ord as variable as ord() is used by python

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Serdar Tumgoren
It now works ok but.. You should not use ord as variable as ord() is used by python already. Also this will fail in python 3 and 2 with import from future, it does division differently. from __future__ import division 11 % 100 / 10 1.1001 So if value % 100/10 1: should be

[Tutor] Variable: From input and output

2010-02-04 Thread ssiverling
Greetings, So I want to learn assembly. However, it can take a experienced C programmer a year to learn assembly. With me it might take longer. One thing I was reading is that alot of the tutorials assume prior programming experience. So I figure I would go with an easier language. So I

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 1:21 PM, Serdar Tumgoren zstumgo...@gmail.com wrote: Perhaps the code on activestate is not a correct copy of what you are running? The conditional at line 23 extends all the way to line 35 - the end of the function - so if value % 100/10 == 1 no more code is executed

Re: [Tutor] Variable: From input and output

2010-02-04 Thread Wayne Werner
On Thu, Feb 4, 2010 at 12:19 PM, ssiverling ssiverl...@gmail.com wrote: Greetings, So I want to learn assembly. However, it can take a experienced C programmer a year to learn assembly. With me it might take longer. One thing I was reading is that alot of the tutorials assume prior

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Serdar Tumgoren
If you want value % 100/10 to give the same result in Python 2.6 and Python 3 you can use value % 100//10 which will always use integer division. Kent, thanks for anticipating this. I actually was struggling to figure out how to update the division and wasn't certain how. Below is the fully

Re: [Tutor] Variable: From input and output

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 1:19 PM, ssiverling ssiverl...@gmail.com wrote: So I have been working on this example for a little while.  I looked for the answer before posting.  I tried to use two raw inputs, then use sys.stdout.write, to add them together.  However I think I might need to use a

Re: [Tutor] Variable: From input and output

2010-02-04 Thread Alan Gauld
ssiverling ssiverl...@gmail.com wrote So I want to learn assembly. However, it can take a experienced C programmer a year to learn assembly. Dunno where you got that from. An experienced C programmer should pick up assembler in a few days. C is just portable assembler It is almost a textual

Re: [Tutor] Variable: From input and output

2010-02-04 Thread Alan Gauld
ssiverling ssiverl...@gmail.com wrote thing I was reading is that alot of the tutorials assume prior programming I just checked and Amazon have the Soul of CP/M still available second hand for less than a dollar! Gotta be a bargain! OH, yes, If you want a free PC assembler you can use DOS

Re: [Tutor] Variable: From input and output

2010-02-04 Thread ssiverling
Greetings, Thank you all for you help. I appreciate your help. Anyway, I thought I was answer something. Dunno where you got that from. It was from the book on assembly I was reading. -- View this message in context:

Re: [Tutor] Variable: From input and output

2010-02-04 Thread ssiverling
I uploaded a file. I know it's not very impressive. Kent Johnson wrote: On Thu, Feb 4, 2010 at 1:19 PM, ssiverling ssiverl...@gmail.com wrote: So I have been working on this example for a little while.  I looked for the answer before posting.  I tried to use two raw inputs, then use

Re: [Tutor] Variable: From input and output

2010-02-04 Thread ssiverling
Thank you, yes I still have xp. I heard alot of bad things about vista. Then my parents bought a new computer and they I saw why. Anyway, I'm going to atleast wait till the first service pack come out for Windows 7. Though I am going to upgrade to xp pro. A dollar you said? Hmm.. I might

Re: [Tutor] Help with cursors please

2010-02-04 Thread Alan Harris-Reid
Kent Johnson wrote: On Thu, Feb 4, 2010 at 12:47 PM, Alan Harris-Reid aharrisr...@googlemail.com wrote: Hi, I have a SQLite cursor which I want to traverse more than once, eg... for row in MyCursor: method1(row) then later... for row in MyCursor: method2(row) Method2 is never run, I