Re: [Tutor] Random order program

2011-11-28 Thread Charles Becker
Dave, Myles, et al, On Nov 27, 2011, at 4:25 PM, Dave Angel wrote: > On 11/27/2011 05:17 PM, myles broomes wrote: >> >> >> >> >> >> >> >> #random order list >> while len(random_word_list) != len(word_list): >> word = random.choice(word_list) >> if word not in random_word_l

Re: [Tutor] Text Proccessing/Command Line Redirection/XML Parsing etc in Python.

2011-11-28 Thread Stefan Behnel
Pritesh Ugrankar, 28.11.2011 07:56: First of all, my apologies for writing this very long post. Welcome to the list. :) I have been through some related questions about this in Stack Overflow as well as googled it and found that Perl and Python are the two languages that offer most what I ne

Re: [Tutor] Random order program

2011-11-28 Thread Alan Gauld
On 28/11/11 07:57, Charles Becker wrote: A way to make the code more 'pythonic' and easier to read might be to replace the conditional while len(random_word_list) != len(word_list) With the following : for x in range(len(word_list)) Unfortunately that won't work with the OPs alg

Re: [Tutor] Random order program

2011-11-28 Thread Christian Witts
On 2011/11/28 12:17 AM, myles broomes wrote: I requested help for this code earlier and I thought it had been corrected but apparently, there is still a problem with it... #random word order program #the user gives the program a list of words #the program then returns them in a random order im

Re: [Tutor] Tutor Digest, Vol 93, Issue 158

2011-11-28 Thread Pritesh Ugrankar
t; use allow me the output to be directed to an XML FormatIs Python better > suited at this ? > > Few more questions pop up like, Which will give me more freedom and ease to > maintain ? Which scripting language is better from the employability point > of view? > > I do

Re: [Tutor] Tutor Digest, Vol 93, Issue 158

2011-11-28 Thread Alan Gauld
On 28/11/11 09:08, Pritesh Ugrankar wrote: I am sure that there will be something in Python that will let me generate the hex stuff that I was talking about. Python does hex as well as most languages, I'm not sure exactly what you want to do in hex however, it wasn't clear from your original

Re: [Tutor] Random order program

2011-11-28 Thread Alan Gauld
On 28/11/11 08:57, Christian Witts wrote: Is there anything wrong with just doing the following ? No, it's what we were trying to get the OP to discover for himself :-) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___

[Tutor] Critique and Question

2011-11-28 Thread Mark Lybrand
Okay, so I just started to learn Python. I have been working through Dive Into Python 3 and the Google stuff (great exercises IMHO, totally fun). However, with Dive, I had an issue with him referencing the files in the example directory, which from the website seem very unhandy. Although I have

Re: [Tutor] Random order program

2011-11-28 Thread Peter Otten
Christian Witts wrote: > Is there anything wrong with just doing the following ? > > from random import shuffle > # just type words with space separating the items > # ie. one two three four five > words = input('Please enter a list of words: ') > word_list = words.split() > print word_list > shu

Re: [Tutor] Random order program

2011-11-28 Thread Christian Witts
On 2011/11/28 11:37 AM, Peter Otten wrote: Christian Witts wrote: Is there anything wrong with just doing the following ? from random import shuffle # just type words with space separating the items # ie. one two three four five words = input('Please enter a list of words: ') word_list = words

[Tutor] why doesn't python show error

2011-11-28 Thread surya k
1. Why doesn't python show error(description given below) at the beginning when we use functions which aren't present in the standard modules... Example:  TheString = raw_input('enter a string')lengthofStr = strlen(TheString)Look closely, I used a wrong function to find length of the string. [

Re: [Tutor] why doesn't python show error

2011-11-28 Thread Sarma Tangirala
On 28 November 2011 15:23, surya k wrote: > > 1. Why doesn't python show error(description given below) at > the beginning when we use functions which aren't present in the standard > modules... > > Example: > > TheString = raw_input('enter a string')lengthofStr = strlen(TheString)Look > closely,

Re: [Tutor] why doesn't python show error

2011-11-28 Thread surya k
Thanks for that information. I understood what you are saying but in general when python doesn't give us executable files (whether its in Mac/ Linux/ Windows).. how could people develop programs ?. At some point of time people need to provide a file that runs without the help of a python interp

Re: [Tutor] why doesn't python show error

2011-11-28 Thread Steven D'Aprano
surya k wrote: Thanks for that information. I understood what you are saying but in general when python doesn't give us executable files (whether its in Mac/ Linux/ Windows).. how could people develop programs ?. At some point of time people need to provide a file that runs without the help of a

Re: [Tutor] How to handle conjunction operators

2011-11-28 Thread Timo
Op 27-11-11 20:02, Hugo Arts schreef: On Sun, Nov 27, 2011 at 7:52 PM, surya k wrote: Hi, Could you please tell me why this isn't working and how can I make it possible... Consider this code.. name = raw_input("Enter your first name: ") if name[0] == ("m" or "f" or "b") : rhyme = name[1:]

Re: [Tutor] How to handle conjunction operators

2011-11-28 Thread Peter Otten
surya k wrote: > Could you please tell me why this isn't working and how can I make it > possible... Consider this code.. > name = raw_input("Enter your first name:") > if name[0] == ("m" or "f" or "b") : >rhyme = name[1:] >What I want here is.. If the name starts with 'm' or >'f' or

Re: [Tutor] How to handle conjunction operators

2011-11-28 Thread Steven D'Aprano
Timo wrote: if name[0] in ("m", "f", "b"): Or even shorter: if name[0] in "mfb": Shorter, but wrong. name = ['fb', 'ph', 'xy'] # oops, bad data if name[0] in 'mfb': ... Bad data should lead to an error as close as possible to the source of the bad data, and do the wrong thing for a w

Re: [Tutor] Weird Try..Except Error

2011-11-28 Thread Michael M Mason
Alan Gauld wrote on 25 November 2011 at 21:11:- > This is one of the annoying ambiguities of Windows. > The way it finds the executable for executables(exe, bat cmd etc) is > different to how it finds the executable for associations. > > In the former case it uses PATH, in the latter it relies on

[Tutor] Multiplater gaming

2011-11-28 Thread surya k
I am building a multiplayer game (Game:Bingo) where friends(players) connect over internet. In this particular game, users sends a "character/ number" to all other players.. Can you please shed some light on it. I've been looking into 'Core Python Programming' book by Chun but I couldn't unders

Re: [Tutor] Critique and Question

2011-11-28 Thread Dave Angel
On 11/28/2011 04:28 AM, Mark Lybrand wrote: Okay, so I just started to learn Python. I have been working through Dive Into Python 3 and the Google stuff (great exercises IMHO, totally fun). However, with Dive, I had an issue with him referencing the files in the example directory, which from t

Re: [Tutor] Multiplater gaming

2011-11-28 Thread Andreas Perstinger
On 2011-11-28 13:22, surya k wrote: I am building a multiplayer game (Game:Bingo) where friends(players) connect over internet. In this particular game, users sends a "character/ number" to all other players.. Can you please shed some light on it. I've been looking into 'Core Python Programming'

Re: [Tutor] Critique and Question

2011-11-28 Thread Mark Lybrand
Sorry for not providing all the required info. I am running python 3.2 on windows vista. I determined the files are double spaced by viewong them (random sampling) in notepad++. Not double spaced on server by downloading one in the browser. Can I use the 'Wu' flag when writing. I might just be 'w'

[Tutor] pass tuples to user defined function(beginner)

2011-11-28 Thread Mayo Adams
I am trying to pass a set of tuple strings from a file to a function I have defined.  Each tuple is on a separate line, and looks something like this: ('note',2048) The function has two parameters , and is defined thus: def findindex(dval,ticks): Apparently, I need to cast the second value as an i

Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-28 Thread James Reynolds
On Mon, Nov 28, 2011 at 12:32 PM, Mayo Adams wrote: > I am trying to pass a set of tuple strings from a file to a function I > have defined. Each tuple is on a separate line, and looks something > like this: > ('note',2048) > The function has two parameters , and is defined thus: def > findinde

Re: [Tutor] Critique and Question

2011-11-28 Thread Dave Angel
On 11/28/2011 12:31 PM, Mark Lybrand wrote: Sorry for not providing all the required info. I am running python 3.2 on windows vista. I determined the files are double spaced by viewong them (random sampling) in notepad++. Not double spaced on server by downloading one in the browser. Can I use th

[Tutor] Functional tutorial covering SQL database + GUI interface

2011-11-28 Thread Monte Milanuk
Hello all, Thought I might ask here just to make sure my Google-fu isn't on the fritz and I'm not missing something already existing... Is there / do you know of any tutorial that covers actually using an SQL database with a GUI interface (say, sqlite and tkinter since they come packaged with

[Tutor] tkinter message & button questions

2011-11-28 Thread Cranky Frankie
I have a program I'm testing in Python 3.1 in Windows XP using tkinker to dispay random quotes. It works except for two things. 1) The program displays a random quote of the day when it's invoked, but I want to have a "Next quote" button so that additional random quotes can be displayed. Here are

Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-28 Thread Dave Angel
On 11/28/2011 12:47 PM, James Reynolds wrote: On Mon, Nov 28, 2011 at 12:32 PM, Mayo Adams wrote: I am trying to pass a set of tuple strings from a file to a function I That's an undefined term. Python doesn't have a type called 'tuple strings'. have defined. Each tuple is on a separate li

Re: [Tutor] tkinter message & button questions

2011-11-28 Thread Peter Otten
Cranky Frankie wrote: > I have a program I'm testing in Python 3.1 in Windows XP using tkinker > to dispay random quotes. It works except for two things. > > 1) The program displays a random quote of the day when it's invoked, > but I want to have a "Next quote" button so that additional random >

Re: [Tutor] Functional tutorial covering SQL database + GUI interface

2011-11-28 Thread Alan Gauld
On 28/11/11 17:49, Monte Milanuk wrote: Is there / do you know of any tutorial that covers actually using an SQL database with a GUI interface (say, sqlite and tkinter since they come packaged with python by default) to build something moderately useful like a small address book i.e. CRUD applic

[Tutor] advice

2011-11-28 Thread Chris Hare
I have been searching around a bit, but not really finding anything which is meaningful. I want to embed a set of help files in my application, and display them from within the application. I could use plain text files, which would be easy to suck into a Text field, but it would be nice to in

Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-28 Thread Steven D'Aprano
James Reynolds wrote: Alternatively, since you aren't actually passing a "tuple" but something that looks like a python tuple as a string, you could eval it: Please don't give beginners terrible advice like this. There are already too many programs vulnerable to code injection attacks withou

Re: [Tutor] advice

2011-11-28 Thread Alan Gauld
On 28/11/11 22:05, Chris Hare wrote: Is there some way of displaying rich text files, such as RTF or HTML from within a python Tkinter widget? Not so much RTF but you can set different fonts and colours etc within the standard text widget. You could either use HTML or a subset to save your s

Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-28 Thread Dave Angel
1. Please post messages to the list, a private response is not appropriate unless it's just a thanks, or other private msg. Easiest way is probably to use Reply-All. 2. Don't top-post. Put your responses AFTER whatever you're quoting. It's a forum policy, for most usenet groups. On 11/28

Re: [Tutor] Critique and Question

2011-11-28 Thread Mark Lybrand
Just so y'all know, I replaced all the urlopen, read, write, nonsense with the following: urllib.request.urlretrieve(url_root + this_file, os.path.join(file_root, this_file)) and it's all good :) Mark ___ Tutor maillist - Tutor@python.org To unsubscr

Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-28 Thread bob gailer
On 11/28/2011 12:47 PM, James Reynolds wrote: On Mon, Nov 28, 2011 at 12:32 PM, Mayo Adams > wrote: I am trying to pass a set of tuple strings from a file to a function I have defined. Each tuple is on a separate line, and looks something like this:

Re: [Tutor] Coin game

2011-11-28 Thread bob gailer
On 11/27/2011 7:43 PM, Guess?!? wrote: Two players take turns flipping a fair coin. The game ends when the same outcome occurs on three flips in a row. Whichever player flipped the coin last, wins. For example: Here's my version of a simple compact program. import random N = 10 tosses = '

[Tutor] useful function or reinventing the wheel??

2011-11-28 Thread Mark Lybrand
I am a habitual wheel re-inventor, so it would not surprise me, but I made this little function that I was kinda proud of (seeing that I have only been learning python like a week now): It just takes a directory and checks to see if all the directories, sub-directories exist and creates them if th

Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-28 Thread Dave Angel
On 11/28/2011 11:25 PM, bob gailer wrote: On 11/28/2011 12:47 PM, James Reynolds wrote: On Mon, Nov 28, 2011 at 12:32 PM, Mayo Adams > wrote: I am trying to pass a set of tuple strings from a file to a function I have defined. Each tuple is on a separat

Re: [Tutor] useful function or reinventing the wheel??

2011-11-28 Thread Dave Angel
On 11/28/2011 11:30 PM, Mark Lybrand wrote: I am a habitual wheel re-inventor, so it would not surprise me, but I made this little function that I was kinda proud of (seeing that I have only been learning python like a week now): It just takes a directory and checks to see if all the directories

Re: [Tutor] useful function or reinventing the wheel??

2011-11-28 Thread Mark Lybrand
> > >> I couldn't follow your code, but finally concluded that it's trying to > create a directory, creating the directories parents also if they don't > exist either. It would be much simpler if written recursively, but there's > no need. > > Check out os.makedirs(), and see if it meets your nee

Re: [Tutor] useful function or reinventing the wheel??

2011-11-28 Thread Dave Angel
On 11/29/2011 12:19 AM, Mark Lybrand wrote: I couldn't follow your code, but finally concluded that it's trying to create a directory, creating the directories parents also if they don't exist either. It would be much simpler if written recursively, but there's no need. Check out os.maked