Re: [Tutor] Crazy craps problem

2011-10-08 Thread Andreas Perstinger
On 2011-10-09 08:25, col speed wrote: Thanks for your prompt reply! Here's the whole thing: import random message = """Welcome to craps Place your bet and roll the dice. 7 or 11 wins. 2, 3 or 12 loses. Others are "point".""" player = "

Re: [Tutor] Crazy craps problem

2011-10-08 Thread Steven D'Aprano
col speed wrote: Hi again, Once more I've come up with a problem I can't explain. It must be something simple, but I can't work it out. The part of the script that is causing the problem is as follows: def point(num): while True: raw_input("Roll") You ask the user for input, but d

Re: [Tutor] Crazy craps problem

2011-10-08 Thread col speed
On 9 October 2011 13:17, Andreas Perstinger wrote: > On 2011-10-09 07:16, col speed wrote: > >> The part of the script that is causing the problem is as follows: >> >> def point(num): >> while True: >> raw_input("Roll") >> uno, dos = random.choice(dice), random.choice(dice) >>

Re: [Tutor] Crazy craps problem

2011-10-08 Thread Andreas Perstinger
On 2011-10-09 07:16, col speed wrote: The part of the script that is causing the problem is as follows: def point(num): while True: raw_input("Roll") uno, dos = random.choice(dice), random.choice(dice) three = uno+dos print "{0} + {1} = {2}".format(uno, d

[Tutor] Crazy craps problem

2011-10-08 Thread col speed
Hi again, Once more I've come up with a problem I can't explain. It must be something simple, but I can't work it out. The part of the script that is causing the problem is as follows: def point(num): while True: raw_input("Roll") uno, dos = random.choice(dice), random.choice(

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread Steven D'Aprano
Walter Prins wrote: As for the compiler/interpreter argument, I'll just point out again that actually Python in its various forms can either be compiled and/or interepreted, it depends on you really. For compiled Python flavours, see for example Cython (http://cython.org/) which provides a way

Re: [Tutor] START-UP PROJECT

2011-10-08 Thread bob gailer
On 10/8/2011 2:20 PM, delegb...@dudupay.com wrote: Hi all, I have been coding python for a while but I just can't get to rate myself. I have been part of few projects that are python based and did a pretty good job with other team mates. I however want to step up my game and make python my co

Re: [Tutor] START-UP PROJECT

2011-10-08 Thread Alan Gauld
On 08/10/11 19:20, delegb...@dudupay.com wrote: I have been coding python for a while but I just can't get to rate myself. I have been part of few projects that are python based and did a pretty good job with other team mates. OK, You probably don't need the Python tutor list then :-) Have you

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread Walter Prins
Hi Lina, On 8 October 2011 18:18, lina wrote: > I write mainly critical speed code and large memory code that are meant to > run as hug jobs over cluster (transportability is an issue; > my C code is really faster than my Maple code; interpreter language are > good for development of algorithm

Re: [Tutor] String switch

2011-10-08 Thread Dave Angel
On 10/08/2011 03:03 PM, Christopher King wrote: Okay, here's what I what to do *--Target.py--* print "Hello World" *--Target.py Output--* *Hello World* *--Main.py--* target=open("target.py", "r") old=target.read() target.close() target=open("target.py", "w") target.write(''' Str.__repr__ = Str.__

Re: [Tutor] String switch

2011-10-08 Thread Christopher King
Okay, here's what I what to do *--Target.py--* print "Hello World" *--Target.py Output--* *Hello World* *--Main.py--* target=open("target.py", "r") old=target.read() target.close() target=open("target.py", "w") target.write(''' Str.__repr__ = Str.__repr__.swapcase()'''+old) target.close() *--Modifi

Re: [Tutor] START-UP PROJECT

2011-10-08 Thread R. Alan Monroe
> I really can't figure out what project to take on but would be > prepared to take on anything and get my hand dirtier than before. Popular ones are: http://www.pythonchallenge.com/ http://projecteuler.net/ I also like: http://www.atariarchives.org/basicgames/ http://www.atariarchives.org/moreb

[Tutor] START-UP PROJECT

2011-10-08 Thread delegbede
Hi all, I have been coding python for a while but I just can't get to rate myself. I have been part of few projects that are python based and did a pretty good job with other team mates. I however want to step up my game and make python my core competence; the challenge I have is what projec

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread Walter Prins
Lina, Just a couple of comments on the topic of Python vs other languages to add to what others have said: On 7 October 2011 16:40, lina wrote: > but today I was also discouraged, I was told that you should not have > learned python, you should focus on C or bash, or D, cause python is going >

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread lina
On Sat, Oct 8, 2011 at 11:34 PM, Alan Gauld wrote: > On 08/10/11 14:17, lina wrote: > > You will never say, "Gosh, I wish I knew FEWER programming languages!" >> Ha Ha ... >> >> regarding the python and C, I was told that python is good for interface >> and others, but slow. and further was su

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread lina
On Sat, Oct 8, 2011 at 11:34 PM, Alan Gauld wrote: > On 08/10/11 14:17, lina wrote: > > You will never say, "Gosh, I wish I knew FEWER programming languages!" >> Ha Ha ... >> >> regarding the python and C, I was told that python is good for interface >> and others, but slow. and further was su

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread lina
On Sat, Oct 8, 2011 at 10:50 PM, Alan Gauld wrote: > On 08/10/11 11:27, Alan Gauld wrote: > > What you want, I think, is to join the original list >> with spaces(and maybe add a newline for writing to file) >> >> summary = ' '.join(summary) + \n >> > > But you need to make the original items stri

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread Alan Gauld
On 08/10/11 14:17, lina wrote: You will never say, "Gosh, I wish I knew FEWER programming languages!" Ha Ha ... regarding the python and C, I was told that python is good for interface and others, but slow. and further was suggested to write the main part in C and wrapped in python. The m

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread Alan Gauld
On 08/10/11 11:27, Alan Gauld wrote: What you want, I think, is to join the original list with spaces(and maybe add a newline for writing to file) summary = ' '.join(summary) + \n But you need to make the original items strings first so it should be: summary = ' '.join( map(str,summary) ) +

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread lina
On Sat, Oct 8, 2011 at 6:27 PM, Alan Gauld wrote: > On 08/10/11 04:34, lina wrote: > > print(summary) ### output is [1,3,5,6] >> summary='\n'.join(str(summary)**.split(',')) >> > > This line is wrong. > This is converting summary to a string -> '[1,3,5,6]' > Then splitting by co

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread lina
On Sat, Oct 8, 2011 at 6:27 PM, Alan Gauld wrote: > On 08/10/11 04:34, lina wrote: > > print(summary) ### output is [1,3,5,6] >> summary='\n'.join(str(summary)**.split(',')) >> > > This line is wrong. > This is converting summary to a string -> '[1,3,5,6]' > Then splitting by co

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread lina
On Sat, Oct 8, 2011 at 4:43 PM, Steven D'Aprano wrote: > Alan Gauld wrote: > >> On 07/10/11 16:40, lina wrote: >> >> but today I was also discouraged, I was told that you should not have >>> learned python, you should focus on C or bash, or D, cause python is >>> going to be obsolete, >>> >> >>

Re: [Tutor] swapping list elements based on some criterion

2011-10-08 Thread عمـ نوفل ـاد
On Sat, Oct 8, 2011 at 12:34 PM, Andreas Perstinger < andreas.perstin...@gmx.net> wrote: > On 2011-10-08 11:11, Andreas Perstinger wrote: > >> def swap(sentence): >> s = sentence.split() >> for i in reversed(range(len(s))): >> if s[i].endswith("/N") and s[i-1].endswith("/ADJ"):

Re: [Tutor] Runtime error while Test data creation

2011-10-08 Thread Steven D'Aprano
Guess?!? wrote: Hello all, I am trying to create some test data for a search module that I am building. Since I dont want to hit performance related issues late in the game, I decided to create half a million records in the DB. My approach is create a csv file with valid UUIDs which I already h

Re: [Tutor] Runtime error while Test data creation

2011-10-08 Thread Alan Gauld
On 07/10/11 22:32, Guess?!? wrote: Thanks for the suggestions. There is no traceback/stacktrace errors that I can see The key is the last phrase. Your GUI IDE is hiding it. If you run your program from an Operating Command prompt then you should see the full error stack trace which (usually)

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread Alan Gauld
On 08/10/11 04:34, lina wrote: print(summary) ### output is [1,3,5,6] summary='\n'.join(str(summary).split(',')) This line is wrong. This is converting summary to a string -> '[1,3,5,6]' Then splitting by commas to create a new list -> [ '[1', '3', '5', 6]' ] Notice the fir

Re: [Tutor] swapping list elements based on some criterion

2011-10-08 Thread Andreas Perstinger
On 2011-10-08 11:11, Andreas Perstinger wrote: def swap(sentence): s = sentence.split() for i in reversed(range(len(s))): if s[i].endswith("/N") and s[i-1].endswith("/ADJ"): s[i], s[i-1] = s[i-1], s[i] return s Oops, noticed a little bug: The for-loop sh

Re: [Tutor] swapping list elements based on some criterion

2011-10-08 Thread عمـ نوفل ـاد
On Sat, Oct 8, 2011 at 12:11 PM, Andreas Perstinger < andreas.perstin...@gmx.net> wrote: > On 2011-10-08 09:53, Peter Otten wrote: > >> Emad Nawfal (عمـ نوفل ـاد) wrote: >> >>> Here is the function as I used it, and it works fine: >>> >>> def swap(sentence): >>>buffer = [] >>>adjectives

Re: [Tutor] swapping list elements based on some criterion

2011-10-08 Thread Andreas Perstinger
On 2011-10-08 09:53, Peter Otten wrote: Emad Nawfal (عمـ نوفل ـاد) wrote: Here is the function as I used it, and it works fine: def swap(sentence): buffer = [] adjectives = [] for word in sentence.split(): if word.endswith('/ADJ'): adjectives.append(word)

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread Steven D'Aprano
Alan Gauld wrote: On 07/10/11 16:40, lina wrote: but today I was also discouraged, I was told that you should not have learned python, you should focus on C or bash, or D, cause python is going to be obsolete, C is a great language for writing Operating Systems and other "near the metal" cod

Re: [Tutor] swapping list elements based on some criterion

2011-10-08 Thread Peter Otten
Emad Nawfal (عمـ نوفل ـاد) wrote: > Here is the function as I used it, and it works fine: > > def swap(sentence): >buffer = [] >adjectives = [] >for word in sentence.split(): >if word.endswith('/ADJ'): >adjectives.append(word) >elif word.endswith('/N'): >

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread Andreas Perstinger
On 2011-10-08 09:12, lina wrote: $ python3 counter-vertically-WORKING.py [26, 22, 28, 30, 32, 27, 30, 29, 28, 30, 32, 24, 27, 27, 28, 30, 32, 30, 33, 27, 33, 32, 34, 31, 28, 34, 33, 32, 25, 35, 30, 32, 30, 32, 25, 30, 26, 24, 33, 28, 27, 26, 23, 27, 27, 28, 27, 25, 24, 23, 23, 27, 24, 27, 26, 23,

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread lina
On Sat, Oct 8, 2011 at 2:50 PM, Andreas Perstinger < andreas.perstin...@gmx.net> wrote: > On 2011-10-08 08:25, lina wrote: > >> Still have a reading "multiple" files issue: >>> Traceback (most recent call last): File "counter-vertically-WORKING.py", line 26, in

Re: [Tutor] a quick Q: how to use for loop to read a series of files with .doc end

2011-10-08 Thread lina
On Sat, Oct 8, 2011 at 2:50 PM, Andreas Perstinger < andreas.perstin...@gmx.net> wrote: > On 2011-10-08 08:25, lina wrote: > >> Still have a reading "multiple" files issue: >>> Traceback (most recent call last): File "counter-vertically-WORKING.py", line 26, in