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 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 pointer is

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 hav

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 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.stdo

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: http://old.nabble.com/Variable%3A-From-input-and-output-tp27457364p

Re: [Tutor] Variable: From input and output

2010-02-04 Thread Alan Gauld
"ssiverling" 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 debug. Its still th

Re: [Tutor] Variable: From input and output

2010-02-04 Thread Alan Gauld
"ssiverling" 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 replacement for

Re: [Tutor] Variable: From input and output

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 1:19 PM, ssiverling 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 variable.  Any help

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 ful

Re: [Tutor] Variable: From input and output

2010-02-04 Thread Wayne Werner
On Thu, Feb 4, 2010 at 12:19 PM, ssiverling 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 programming > experi

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 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 and None is ret

[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 look

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/1

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 pyth

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 wrote: > > 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 and tell me if

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 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 and None is ret

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 (hopeful

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 lang

Re: [Tutor] Help with cursors please

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 12:47 PM, Alan Harris-Reid 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 pointer is at the b

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 wrote: > On Thu, Feb 4, 2010 at 12:11 PM, Serdar Tumgoren 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 > running? The conditional a

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 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 still works fine.

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

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 >

Re: [Tutor] language aid

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 5:43 AM, Owain Clarke 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 program > increasingl

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

2010-02-04 Thread Alan Gauld
"Serdar Tumgoren" 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 % 100/10 <> 1is fal

Re: [Tutor] language aid

2010-02-04 Thread spir
On Thu, 04 Feb 2010 16:11:33 + Owain Clarke 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 verb, and each has

[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 mo

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 wrote: > Hi folks, > > 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 sti

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 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. > > Not sure if t

Re: [Tutor] language aid

2010-02-04 Thread Alan Gauld
"Owain Clarke" 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 the key is the Engl

Re: [Tutor] language aid

2010-02-04 Thread spir
On Thu, 04 Feb 2010 16:11:33 + Owain Clarke 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 verb, and each has

Re: [Tutor] language aid

2010-02-04 Thread spir
On Thu, 4 Feb 2010 07:39:29 -0800 (PST) Albert-Jan Roskam wrote: > Hi, >   > A dictionary (associative array of keys and values) seems a good datatype to > use. > vocab = {} > vocab[frenchword] = englishword >   > For instance: > >>> vocab = {"aimer": "love"} > >>> vocab > {'aimer': 'love'} > >>

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

2010-02-04 Thread Serdar Tumgoren
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. Not sure if this really qualifies as a recipe, per se, but it was a handy little functio

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 Albert-Jan Roskam
Hi,   A dictionary (associative array of keys and values) seems a good datatype to use. vocab = {} vocab[frenchword] = englishword   For instance: >>> vocab = {"aimer": "love"} >>> vocab {'aimer': 'love'} >>> vocab["parler"] = "speak" >>> vocab {'aimer': 'love', 'parler': 'speak'} >>> for engword,

[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.