[Tutor] Getting os.walk output into a list

2013-03-15 Thread Paradox
There is something I can't figure out about the following code (using python 2.7.3): def return_tree_files(rootpath, pattern): for root, dirs, files in os.walk(rootpath): i = [os.path.join(root, filename) for filename in fnmatch.filter(files, pattern)] return i I thought

Re: [Tutor] Getting os.walk output into a list

2013-03-15 Thread Dave Angel
On 03/15/2013 01:53 AM, Paradox wrote: There is something I can't figure out about the following code (using python 2.7.3): def return_tree_files(rootpath, pattern): for root, dirs, files in os.walk(rootpath): i = [os.path.join(root, filename) for filename in fnmatch.filter(files,

Re: [Tutor] Getting os.walk output into a list :p:

2013-03-15 Thread Paradox
On 03/15/2013 02:31 PM, Dave Angel wrote: On 03/15/2013 01:53 AM, Paradox wrote: There is something I can't figure out about the following code (using python 2.7.3): def return_tree_files(rootpath, pattern): for root, dirs, files in os.walk(rootpath): i = [os.path.join(root,

[Tutor] Random Python Tip

2013-03-15 Thread Mark Lybrand
I seem to remember a web page that generated a random Python programming tip. However my Google Fu is weak today. Does anyone recall the URL of what I am talking about? -- Mark :) ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] Random Python Tip

2013-03-15 Thread Dave Angel
On 03/15/2013 03:57 AM, Mark Lybrand wrote: I seem to remember a web page that generated a random Python programming tip. However my Google Fu is weak today. Does anyone recall the URL of what I am talking about? Closest that I've seen is the Module of the Week

Re: [Tutor] Designing a program (File-Fetcher)

2013-03-15 Thread bob gailer
On 3/14/2013 5:25 PM, Christopher Emery wrote: Hello All, Okay, I know the best way to learn how to do something is to jump in so I have decided I would like to make a program (command line) to get files from a website that will be then used later on by another program. I read your post

[Tutor] converting upper case to lowercase and vice-versa

2013-03-15 Thread Shall, Sydney
I am just learning Python and my book does not solve my problem. I have not yet been successful in searching the Python 2.7.3 tutorial I am doing an encryption exercise. Python 2.7.3 MAC OS X 10.6.8 What is the correct syntax to covert English characters from uppercase to lowercase and from

Re: [Tutor] Designing a program (File-Fetcher)

2013-03-15 Thread Christopher Emery
Hello Bob, BG: I am looking for the command line program (Linux and Windows) to speak text from a file or from stdin. Do you know where it is or how one gets it? CE: If you are putting it on Linux such as debian then you can run apt-get install eSpeak, it is in most distro of Linux these days.

[Tutor] Fwd: converting upper case to lowercase and vice-versa

2013-03-15 Thread Bod Soutar
Did'nt realise this went offlist, my fault -- Bodsda -- Forwarded message -- From: Shall, Sydney sydney.sh...@kcl.ac.uk Date: 15 March 2013 14:43 Subject: Re: [Tutor] converting upper case to lowercase and vice-versa To: Bod Soutar bod...@googlemail.com On 15/03/2013 14:30,

Re: [Tutor] Fwd: converting upper case to lowercase and vice-versa

2013-03-15 Thread Peter Otten
Bod Soutar wrote: mystring = THIS is A string newstring = for item in mystring: if item.isupper(): newstring += item.upper() else: newstring += item.lower() print newstring This does nothing the hard way as newstring and mystring are equal ;) If you

[Tutor] File-Fetcher (cmdline-parser)

2013-03-15 Thread Christopher Emery
Hello All, OS = Raspbain Wheezy Ubuntu 12.10 (both updated daily) Python Version = 3.2 3.3 Python Understanding = Beginner (very basic - just started) See paste bin for code, has 44 lines, code does not give any errors. http://pastebin.com/2tLHvUym Okay, I am writing to ask a few question

Re: [Tutor] File-Fetcher (cmdline-parser)

2013-03-15 Thread Peter Otten
Christopher Emery wrote: Hello All, OS = Raspbain Wheezy Ubuntu 12.10 (both updated daily) Python Version = 3.2 3.3 Python Understanding = Beginner (very basic - just started) See paste bin for code, has 44 lines, code does not give any errors. http://pastebin.com/2tLHvUym Okay,

Re: [Tutor] File-Fetcher (cmdline-parser)

2013-03-15 Thread Christopher Emery
Hello Peter, First let me say thanks for your feedback, please see comments / question below, yours starting with PO and mine starting with CE. PO: dest determines the attribute name under which the option is stored. I rarely set it explicitly; instead I provide a --long-option: CE: Is there a

Re: [Tutor] File-Fetcher (cmdline-parser)

2013-03-15 Thread Peter Otten
Christopher Emery wrote: Hello Peter, First let me say thanks for your feedback, please see comments / question below, yours starting with PO and mine starting with CE. PO: dest determines the attribute name under which the option is stored. I rarely set it explicitly; instead I provide

Re: [Tutor] File-Fetcher (cmdline-parser)

2013-03-15 Thread Christopher Emery
Hello Peter, Thank you this is much appreciated! It is much clear now. Thank you PO: Also, if you make it a habit to keep long option and dest in sync (something you get for free if you only specify the option) you can deduce the attribute name used in the script from its commandline interface.

[Tutor] Script to generate statements

2013-03-15 Thread Charles Leviton
I was recently given this task. it's a very IBM mainframe specific task so I'm not sure how to find equivalent terms in another environment. I will just use the mainframe terminology and hopefully y'all can figure out what I mean. Given a list of DBRM members create a JCL which has a series of

Re: [Tutor] File-Fetcher (cmdline-parser)

2013-03-15 Thread Prasad, Ramit
Christopher Emery wrote: Hello Peter, Thank you this is much appreciated! It is much clear now. Thank you PO: Also, if you make it a habit to keep long option and dest in sync (something you get for free if you only specify the option) you can deduce the attribute name used in the

Re: [Tutor] File-Fetcher (cmdline-parser)

2013-03-15 Thread Christopher Emery
Hello Ramit, No offense taking. I guess I am now going to disclose information. I do this because I am blind and its not easy to follow people basing it off of or or as people don't know how to clean up there mails,I try my best to and clean others trails all the time. However in a perfect

[Tutor] func-question_y_n.py

2013-03-15 Thread Christopher Emery
Hello All, Okay, I have created a small function that will check to see if a user has answered with a Yes, No or other response. If the user puts yes or no the function ends, if they put anything but yes or no then the function will ask them the same question and tell them they either need to

Re: [Tutor] Script to generate statements

2013-03-15 Thread Hugo Arts
On Fri, Mar 15, 2013 at 7:42 PM, Charles Leviton charles.levi...@gmail.comwrote: I was recently given this task. it's a very IBM mainframe specific task so I'm not sure how to find equivalent terms in another environment. I will just use the mainframe terminology and hopefully y'all can

Re: [Tutor] func-question_y_n.py

2013-03-15 Thread Hugo Arts
On Fri, Mar 15, 2013 at 9:01 PM, Christopher Emery cpe.l...@gmail.comwrote: Hello All, Okay, I have created a small function that will check to see if a user has answered with a Yes, No or other response. If the user puts yes or no the function ends, if they put anything but yes or no then

[Tutor] __init__ doesn't seem to be running

2013-03-15 Thread Cameron Macleod
Hello everyone, I'm using Python 3.3 and am trying to write a simple to-do list program. I have a class which runs pretty much everything called todo and the __init__ method doesn't seem to be running. class todo(): def __init__(self): tasks = [] def writeTask(todoList):

Re: [Tutor] func-question_y_n.py

2013-03-15 Thread Mitya Sirenef
On 03/15/2013 05:01 PM, Christopher Emery wrote: Hello All, Okay, I have created a small function that will check to see if a user has answered with a Yes, No or other response. If the user puts yes or no the function ends, if they put anything but yes or no then the function will ask them

Re: [Tutor] __init__ doesn't seem to be running

2013-03-15 Thread Hugo Arts
On Fri, Mar 15, 2013 at 9:21 PM, Cameron Macleod cmacleod...@googlemail.com wrote: Hello everyone, I'm using Python 3.3 and am trying to write a simple to-do list program. I have a class which runs pretty much everything called todo and the __init__ method doesn't seem to be running. class

Re: [Tutor] func-question_y_n.py

2013-03-15 Thread Christopher Emery
Hi Mitya, Thank for your example of code, however at this time its well over my head and I think its best if I slowly work on a function that provided only what I need and then add to it IF it works into it. Yours appears to do a whole lot more then process a Yes/No from a question and re-ask

Re: [Tutor] func-question_y_n.py

2013-03-15 Thread Christopher Emery
Hello Hugo, # Defines the start of a function and its options (question) def question_y_n(question): #1. Ask Question from user, user enters either Yes, No or whatever (anything that is not Yes or No) answer = input(question) # prompts the user and assigns the answer to var answer #2. If

Re: [Tutor] __init__ doesn't seem to be running

2013-03-15 Thread Cameron Macleod
I added the self. to both the references to tasks and then I added the print statement to the __init__ function and I got the dreaded NameError of death: Traceback (most recent call last): File C:\Python33\todo.py, line 6, in module class todo: File C:\Python33\todo.py, line 31, in todo

Re: [Tutor] func-question_y_n.py

2013-03-15 Thread Dave Angel
On 03/15/2013 06:09 PM, Christopher Emery wrote: -- Hugo said: 1. ask a question, receive an answer 2. if the answer is Yes or No, return the answer 3. else, print a message and go back to step 1 Hello Hugo, # Defines the start of a function and its options (question)

Re: [Tutor] func-question_y_n.py

2013-03-15 Thread Mark Lawrence
On 15/03/2013 22:09, Christopher Emery wrote: Hello Hugo, # Defines the start of a function and its options (question) def question_y_n(question): #1. Ask Question from user, user enters either Yes, No or whatever (anything that is not Yes or No) answer = input(question) # prompts the

Re: [Tutor] __init__ doesn't seem to be running

2013-03-15 Thread Hugo Arts
On Fri, Mar 15, 2013 at 10:25 PM, Cameron Macleod cmacleod...@googlemail.com wrote: I added the self. to both the references to tasks and then I added the print statement to the __init__ function and I got the dreaded NameError of death: Traceback (most recent call last): File

[Tutor] __init__ argument

2013-03-15 Thread Joshua Wilkerson
The program keeps telling me that the __init__ in Rock takes two arguments and only one is given. Ideas? The point of the game is to dodge falling rocks. Two more appear every time one reaches the bottom of the screen. # Avalanche, a dodging game # Written by Josh Wilkerson # Dodge falling

Re: [Tutor] __init__ doesn't seem to be running

2013-03-15 Thread Dave Angel
(By top-posting, you lost all the context. Next time, post your responses AFTER the part you're quoting. And don't just quote it all, only the part that's relevant.) On 03/15/2013 06:25 PM, Cameron Macleod wrote: I added the self. to both the references to tasks and then I added the print

Re: [Tutor] func-question_y_n.py

2013-03-15 Thread Hugo Arts
On Fri, Mar 15, 2013 at 10:09 PM, Christopher Emery cpe.l...@gmail.comwrote: This code works and produces the results that I am looking for, however I know there is a better way to do it and now you have me thinking about this again. I just spent about 3 hours doing this code. Yes!

Re: [Tutor] __init__ argument

2013-03-15 Thread Dave Angel
On 03/15/2013 06:46 PM, Joshua Wilkerson wrote: The program keeps telling me that the __init__ in Rock takes two arguments and only one is given. Ideas? The point of the game is to dodge falling rocks. Two more appear every time one reaches the bottom of the screen. # Avalanche, a dodging

Re: [Tutor] func-question_y_n.py

2013-03-15 Thread Christopher Emery
Hello Hugo, Mark, Dave, First thank you all greatly, you all have given me food for thought and bytes to chew! I now would like to say please don't take offense at what I say below, however because we are all people and this IS a learning list I would like to give feedback of the last three

Re: [Tutor] func-question_y_n.py

2013-03-15 Thread Mitya Sirenef
On 03/15/2013 05:47 PM, Christopher Emery wrote: Hi Mitya, Thank for your example of code, however at this time its well over my head and I think its best if I slowly work on a function that provided only what I need and then add to it IF it works into it. Yours appears to do a whole lot

Re: [Tutor] func-question_y_n.py

2013-03-15 Thread Mark Lawrence
On 15/03/2013 23:37, Christopher Emery wrote: Hello Hugo, Mark, Dave, For Mark: Thank you for your answer at the end of your email. If you don't mind me stating for future can you explain things a little more so I may understand the why to your statement WHy the unneeded parenthesis? What

Re: [Tutor] Script to generate statements

2013-03-15 Thread Alan Gauld
On 15/03/13 19:42, Charles Leviton wrote: Given a list of DBRM members create a JCL which has a series of bind statements for each DBRM. Ah, the joys of JCL. I haven't read a JCL script in about 15 years! :-) This is the tack I took. I have 3 input files a_ contains the fixed part of the

Re: [Tutor] func-question_y_n.py

2013-03-15 Thread Alan Gauld
On 15/03/13 23:37, Christopher Emery wrote: so I may understand the why to your statement WHy the unneeded parenthesis? Mark was pointing out that parentheses are not needed in a while statement. So why add them? They just add visual clutter. What about 'yes'? And here he was alluding

Re: [Tutor] Script to generate statements

2013-03-15 Thread Dave Angel
On 03/15/2013 08:53 PM, Alan Gauld wrote: On 15/03/13 19:42, Charles Leviton wrote: Given a list of DBRM members create a JCL which has a series of bind statements for each DBRM. Ah, the joys of JCL. I haven't read a JCL script in about 15 years! :-) Been over 40 years for me, so I may

Re: [Tutor] __init__ argument

2013-03-15 Thread Steven D'Aprano
On 16/03/13 09:46, Joshua Wilkerson wrote: The program keeps telling me that the __init__ in Rock takes two arguments and only one is given. Ideas? Yes. You need to look at the arguments required when you construct a Rock() instance, and compare it to the arguments actually given. [snip

Re: [Tutor] Script to generate statements

2013-03-15 Thread Steven D'Aprano
On 16/03/13 06:42, Charles Leviton wrote: This is the script I came up with...Would you critique it and let me know how I could have done it better? #create a series of bind statements fo = open('i:/text/jclout.txt', 'w') fi = open('i:/text/bindjclfirstpart.txt','rU') fibindjclvar =

[Tutor] Loop Exception Handles

2013-03-15 Thread Vincent Balmori
I am trying to loop a simple exception. I tried to put a while loop, but I keep getting syntax issues. I also tried to alternatively use something on the lines of while number != int also with no avail.    def main():     print(\t\tWelcome to Blackjack!\n)          names = []     try:        

Re: [Tutor] Loop Exception Handles

2013-03-15 Thread Robert Sjoblom
On 16 March 2013 05:08, Vincent Balmori vincentbalm...@yahoo.com wrote: I am trying to loop a simple exception. I tried to put a while loop, but I keep getting syntax issues. I also tried to alternatively use something on the lines of while number != int also with no avail. It would help if

Re: [Tutor] Loop Exception Handles

2013-03-15 Thread Mark Lawrence
On 16/03/2013 04:08, Vincent Balmori wrote: I am trying to loop a simple exception. I tried to put a while loop, but I keep getting syntax issues. I also tried to alternatively use something on the lines of while number != int also with no avail. Please help us to help you. What did your