[Tutor] program code for Python Programming for the Absolute Beginner, 3rd ed.?
The book says the program code is in py3e_source.zip, at www.courseptr.com/downloads , but that leads to the book at http://www.delmarlearning.com/companions/index.asp?isbn=1435455002 with a View Available Downloads link that yields no downloads. Does anyone know where py3e_source.zip is? Or if you have it, could you email it to me? Thanks, Dick Moores ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] One basic question about the Python's PID of Process object.
Hello, 1. When I tried to run the following code (belonging to one Python program), for the dynamically created object of CUSTOMER as Process type, the printed PID as the following is always the same. Why? 2. Second question: When I changed the os.getpid() to os.getppid() or self. _pid, the Python’s interpreter generates some error message like “Customer object has no attribute ‘_pid’”. Thanks for your help! Partly code for the CUSTOMER object: class Customer(Process): def buyBaguette(self,cusType,bakery): tIn=now() print PID is %d%(os.getpid()) yield get,self,bakery.stock,r.choice(buy[cusType]) waits[cusType].append(now()-tIn) def __del__(self): print distroy the customer ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] program code for Python Programming for the Absolute Beginner, 3rd ed.?
On Mon, Aug 29, 2011 at 00:19, TheIrda thei...@gmail.com wrote: on the left check the Programming, networking and security and look for your book. Click download and you can see the link to the source code and book related software http://www.delmarlearning.com/companions/content/1435455002/downloads/index.asp?isbn=1435455002 Got it. Thanks very much! Dick ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] One basic question about the Python's PID of Process object.
On Monday 29 August 2011 07:17:51 Han Guanghua wrote: 2. Second question: When I changed the os.getpid() to os.getppid() or self. _pid, the Python’s interpreter generates some error message like “Customer object has no attribute ‘_pid’”. I'm very much a beginner myself, but I am sure that someone will correct me if I am wrong. Should it not be self.pid rather than self._pid? Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Auto-detecting of Python version - wrong!
Hi All, I'm trying to use easy_install on my Mac to get the Python networx package. On my machine I have installed version 2.5 AND 2.6 of Python. However, wehn I try to install this package, I get: easy_install networkx Searching for networkx Reading http://pypi.python.org/simple/networkx/ Reading http://networkx.lanl.gov/ Reading http://networkx.lanl.gov/download/networkx Reading http://sourceforge.net/project/showfiles.php?group_id=122233 Reading http://networkx.lanl.gov/download Reading http://networkx.lanl.gov Reading https://networkx.lanl.gov Best match: networkx 1.5 Downloading http://networkx.lanl.gov/download/networkx/networkx-1.5.zip Processing networkx-1.5.zip Running networkx-1.5/setup.py -q bdist_egg --dist-dir /var/folders/RF/RFpRZ44UEoO77eeJ7t1eOE+++TM/-Tmp-/easy_install-mTZw0S/networkx-1.5/egg-dist-tmp-TGWeRV *NetworkX requires Python version 2.6 or later (2.5 detected).* error: Setup script exited with -1 this, despite the fact that my default python is version 2.6: python Python *2.6.2* (r262:71600, Apr 16 2009, 09:17:39) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Any ideas how to solve this? Thanks in advance, Elisha ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Sorting list of tuples in two passes
On 08/29/2011 01:59 AM, Hugo Arts wrote: On Mon, Aug 29, 2011 at 2:19 AM, Dayo Adewunmicontactd...@gmail.com wrote: On 08/28/2011 06:23 PM, Hugo Arts wrote: On Sun, Aug 28, 2011 at 6:43 PM, Dayo Adewunmicontactd...@gmail.com wrote: Hi I have a list of tuples that each have four elements: [(firstName,lastName,userName,gidNumber),(.)] I'm trying to sort this list in two passes. First by gidNumber and then the subgroups by lastName. So far i've only been able to sort by gidNumber. But I can't seem to wrap my mind around lambda, which is what my browsing around seems to indicate is needed to achieve this? Thanks Dayo Python's builtin sort is stable, which means that ordering of items with the same key is preserved. This property means that you can do multiple pass sorting very easily and efficiently just by sorting twice: # we'll simplify the problem a bit and have tuples with just last name and id. l = [('aaa', 1), ('bbb', 1), ('ccc', 1), ('aaa', 2), ('bbb', 2), ('ccc', 2)] l.sort(key=itemgetter(0)) l [('aaa', 1), ('aaa', 2), ('bbb', 1), ('bbb', 2), ('ccc', 1), ('ccc', 2)] l.sort(key=itemgetter(1)) l [('aaa', 1), ('bbb', 1), ('ccc', 1), ('aaa', 2), ('bbb', 2), ('ccc', 2)] We sort by last name first, then sort again by id. As you can see, the sorting of groups with the same id is preserved, and our list is now in the correct order. Hugo It works when I use your example, but I don't understand why it won't work when I use 4-element tuples instead of 2: l = [('wascas','aaa','fdvdfv', 1), ('rtgdsf','bbb','trfg', 1), ('addwe','ccc','esd', 1), ('xasd','aaa','wascaq', 2), ('nhy','bbb','asw', 2), ('','ccc','dgdeg', 2)] l [('wascas', 'aaa', 'fdvdfv', 1), ('rtgdsf', 'bbb', 'trfg', 1), ('addwe', 'ccc', 'esd', 1), ('xasd', 'aaa', 'wascaq', 2), ('nhy', 'bbb', 'asw', 2), ('', 'ccc', 'dgdeg', 2)] l.sort(key=itemgetter(3)) l [('wascas', 'aaa', 'fdvdfv', 1), ('rtgdsf', 'bbb', 'trfg', 1), ('addwe', 'ccc', 'esd', 1), ('xasd', 'aaa', 'wascaq', 2), ('nhy', 'bbb', 'asw', 2), ('', 'ccc', 'dgdeg', 2)] l.sort(key=itemgetter(1)) l [('wascas', 'aaa', 'fdvdfv', 1), ('xasd', 'aaa', 'wascaq', 2), ('rtgdsf', 'bbb', 'trfg', 1), ('nhy', 'bbb', ' asw', 2), ('addwe', 'ccc', 'esd', 1), ('', 'ccc', 'dgdeg', 2)] Also I notice your original list and your end result list are in the same order. Thanks Dayo In my original example, you can shuffle the list before you sort it and it will still work. Try it, with a quick from random import shuffle; shuffle(l). Also, notice that you want to sort by your primary order *last*. I sorted by last name first, then sorted by id second, which means the final list's primary order is by id, and secondary order by last name. So the sorting goes in reverse. In your example, you sort by id first, then last name. So your final list's primary order is by last name. Hugo I tried it this way and it worked nicely: sortedList = sorted(l, key = itemgetter(3,1)) Thank you :-) Dayo ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Package installation on Mac does not detect newer version of python
Hi All, I'm trying to use easy_install on my Mac to get the Python networx package. On my machine I have installed version 2.5 AND 2.6 of Python. However, wehn I try to install this package, I get: easy_install networkx Searching for networkx Reading http://pypi.python.org/simple/networkx/ Reading http://networkx.lanl.gov/ Reading http://networkx.lanl.gov/download/networkx Reading http://sourceforge.net/project/showfiles.php?group_id=122233 Reading http://networkx.lanl.gov/download Reading http://networkx.lanl.gov Reading https://networkx.lanl.gov Best match: networkx 1.5 Downloading http://networkx.lanl.gov/download/networkx/networkx-1.5.zip Processing networkx-1.5.zip Running networkx-1.5/setup.py -q bdist_egg --dist-dir /var/folders/RF/RFpRZ44UEoO77eeJ7t1eOE+++TM/-Tmp-/easy_install-mTZw0S/networkx-1.5/egg-dist-tmp-TGWeRV *NetworkX requires Python version 2.6 or later (2.5 detected).* error: Setup script exited with -1 this, despite the fact that my default python is version 2.6: python Python *2.6.2* (r262:71600, Apr 16 2009, 09:17:39) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Any ideas how to solve this? Thanks in advance, Elisha ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Auto-detecting of Python version - wrong!
Elisha Rosensweig wrote: I'm trying to use easy_install on my Mac to get the Python networx package. On my machine I have installed version 2.5 AND 2.6 of Python. However, wehn I try to install this package, I get: Hi Elisha, This list is for beginners trying to learning Python the language, not trying to solve arbitrary Python-related problems. You are more likely to get an answer by asking on one of the larger/busier lists, like python-l...@python.org (also available on Usenet under comp.lang.python). You are more likely to find somebody who uses easy_install and a Mac there. But in the meantime, my *wild guess* is that this is a file association problem. If you call the python app directly with python, the most recently added version (version 2.6) gets called, but if you try to run the easy_install directly script, the Mac automatically associates it with Python 2.5 and installation fails. Can you show us exactly how you are calling the easy install script? Another possibility is that it is an issue with the PATH. If you are calling python from the command line as a regular user, it might be picking up one version of Python, but if you call it as root (superuser), you might get a different PATH and therefore a different version of Python. Again, this depends on how you are calling the easy install script. (I emphasis that these are guesses... I haven't used Apple Macs regularly since System 7, back when Steve Jobs was still persona non grata at Apple. How times have changed.) -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Intro
Hi Python tutor listers, as an intro I'll repost what I sent to my Linux groups, since one of their members turned me on to you: Before Borders imploded I'd joined their club so they'd send me 50% coupons now and then. One afternoon last year I was in the store browsing the computer books and this Python book caught my eye. I knew very little about Python but I knew it had a good rep and I love Monty Python so I bought the book then put in on the shelf. Only recently did I get around to reading it and I only wish I'd done so sooner, it's that good. The book is Python Programming for the Absolute Beginner, Third Edition by Michael Dawson, Course Technology, ISBN-13 978-1-4354-5500-9, published in 2010. He presumes you know nothing about programming and then uses simple computer games to demonstrate the power of Python. He starts with those text based games many of us used to play, finishing off with GUI based games with music and animation, and all the code is downloadable from the publisher's web site. That's pretty good for a beginner book, I'd say. Python itself is a beautiful language. Because it uses indenting for constructing programming blocks, not semi-colons or braces, the code is inherently clean and crisp. More about Python: - it's easy to learn yet very powerful - very concise and tight syntax - comes with it's own IDE - no compiling yet can create stand alone apps - can be used for scripting or full blown applications - runs on all the major OSs - no variably type declarations, it can infer them - lots of modules (pre-coded specific code routines) available - can get productive quickly - can code in a procedural or object-oriented style Here's the typical introductory Hello World program: print(Hello World) Doesn't get much simpler than that! He even gets into GUI programming, event driven design, sprites, etc. For a book for a supposed absolute beginner I think that's amazing, because I can see someone getting this even if they really have no coding background. That's how clearly it's written and how clean and clear the example code is. One more side benefit of this book: it contains the gentlest, easiest to digest introduction to object-oriented programming I've ever seen, and I read a lot of computer stuff. If you're an old-timer like me who only studied procedural languages, this is about as easy an introduction to the power and flexibility of O-O programming that you will ever find. What I've been wanting to do for a long time is write an app that, when my computer starts, displays a window with a quote of the day. With this book I now have several ways to take my huge collected quotes file, import it into arrays in a Python program, apply a random function, and display a random quote each time I log on. That kind of app is a natural for Python, but don't kid yourself - he actually writes a space invaders type game using some game modules - and this in a beginner book! Amazing. This is a great book about a great language. -- Frank L. Cranky Frankie Palmeri Risible Riding Raconteur Writer . . . and the extended forecast, until you come back to me, baby, is high tonight, low tomorrow, and precipitation is expected. - Tom Waits, Emotional Weather Report ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
Is it just me, or is this a blatant plug for a specific book, and is it therefore Spam? For what it is worth, I hate all those games. Alan seems to use address books (anyhow initially). Now I can see the point in that. Lisi On Monday 29 August 2011 16:26:55 Cranky Frankie wrote: Hi Python tutor listers, as an intro I'll repost what I sent to my Linux groups, since one of their members turned me on to you: Before Borders imploded I'd joined their club so they'd send me 50% coupons now and then. One afternoon last year I was in the store browsing the computer books and this Python book caught my eye. I knew very little about Python but I knew it had a good rep and I love Monty Python so I bought the book then put in on the shelf. Only recently did I get around to reading it and I only wish I'd done so sooner, it's that good. The book is Python Programming for the Absolute Beginner, Third Edition by Michael Dawson, Course Technology, ISBN-13 978-1-4354-5500-9, published in 2010. He presumes you know nothing about programming and then uses simple computer games to demonstrate the power of Python. He starts with those text based games many of us used to play, finishing off with GUI based games with music and animation, and all the code is downloadable from the publisher's web site. That's pretty good for a beginner book, I'd say. Python itself is a beautiful language. Because it uses indenting for constructing programming blocks, not semi-colons or braces, the code is inherently clean and crisp. More about Python: - it's easy to learn yet very powerful - very concise and tight syntax - comes with it's own IDE - no compiling yet can create stand alone apps - can be used for scripting or full blown applications - runs on all the major OSs - no variably type declarations, it can infer them - lots of modules (pre-coded specific code routines) available - can get productive quickly - can code in a procedural or object-oriented style Here's the typical introductory Hello World program: print(Hello World) Doesn't get much simpler than that! He even gets into GUI programming, event driven design, sprites, etc. For a book for a supposed absolute beginner I think that's amazing, because I can see someone getting this even if they really have no coding background. That's how clearly it's written and how clean and clear the example code is. One more side benefit of this book: it contains the gentlest, easiest to digest introduction to object-oriented programming I've ever seen, and I read a lot of computer stuff. If you're an old-timer like me who only studied procedural languages, this is about as easy an introduction to the power and flexibility of O-O programming that you will ever find. What I've been wanting to do for a long time is write an app that, when my computer starts, displays a window with a quote of the day. With this book I now have several ways to take my huge collected quotes file, import it into arrays in a Python program, apply a random function, and display a random quote each time I log on. That kind of app is a natural for Python, but don't kid yourself - he actually writes a space invaders type game using some game modules - and this in a beginner book! Amazing. This is a great book about a great language. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
On Monday 29 August 2011 16:45:17 Lisi wrote: Is it just me, or is this a blatant plug for a specific book, and is it therefore Spam? Given that remark, I ought not to have included the full text in my reply. I apologise to our spam filters. :-( Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 90, Issue 97
Lisi lisi.re...@gmail.com wrote: Is it just me, or is this a blatant plug for a specific book, and is it therefore Spam? I hope it's just you, because it is not spam. As I said, I read a *lot* of computer books (I'm a database administrator) and this book really stands out. It's so good I'm thinking of seeing if my wife, who knows nothing about programming, would like to read it. I've never felt that way about a computer book before, and since this is so unusual in the computer book field, I thought I'd share it here. For what it is worth, I hate all those games. I'm not a gamer either, but this paradigm allowed the author to show the great flexibility of Python. I think he made a wise choice. Using games as a starting point should also make this book useful to teachers of programming 101, because kids love games. Anything that gets kids coding instead of just wasting time is good IMHO. Alan seems to use address books (anyhow initially). Now I can see the point in that. I'm sorry you were offended by my posts. If others were as well let me know and I'll unsubscribe immediately. -- Frank L. Cranky Frankie Palmeri Risible Riding Raconteur Writer . . . and the extended forecast, until you come back to me, baby, is high tonight, low tomorrow, and precipitation is expected. - Tom Waits, Emotional Weather Report ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
On Mon, Aug 29, 2011 at 11:26 AM, Cranky Frankie cranky.fran...@gmail.com wrote: Hi Python tutor listers, as an intro I'll repost what I sent to my Linux groups, since one of their members turned me on to you: Glad you're so happy with this book...did you have a question for this list? -- Brett Ritter / SwiftOne swift...@swiftone.org ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Personal: Re: Tutor Digest, Vol 90, Issue 97
Hi Frank, Please don't unsubscribe. Book reviews are always welcome. Malcolm ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
On 29/08/11 16:45, Lisi wrote: Is it just me, or is this a blatant plug for a specific book, and is it therefore Spam? I think its intended to be a plug for Python rather than (or as well as) the book :-) For what it is worth, I hate all those games. Alan seems to use address books (anyhow initially). Now I can see the point in that. To be fair, in the paper edition of my tutor I do use a Games framework as a second case-study. I then use the framework to build a number guessing game and a Hangman (and a Mastermind on the CD)... Games are popular with many beginners especially hobbyists rather than corporate types :-). -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Auto-detecting of Python version - wrong!
On 29/08/11 13:54, Steven D'Aprano wrote: (I emphasis that these are guesses... I haven't used Apple Macs regularly since System 7, back when Steve Jobs was still persona non grata at Apple. How times have changed.) Yeah, although I hear that he is leaving Apple(again) although on friendly terms this time... Due to health problems I believe. Another of the computer heroes leaves the field :-( -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
I'm trying to decide what would be better: - reading the huge quote file (hundreds of entries, two strings, author and quotation) in each time the program starts - loading the quotes into an array in the program I'd like to be able to add new quotes easily, so that is a factor as well. I'm satisfied to use a dialog box, I don't need a GUI at this point so no tkinter (yet). On Mon, Aug 29, 2011 at 1:29 PM, Brett Ritter swift...@swiftone.org wrote: ou: Glad you're so happy with this book...did you have a question for this list? -- Brett Ritter / SwiftOne swift...@swiftone.org -- Frank L. Cranky Frankie Palmeri Risible Riding Raconteur Writer . . . and the extended forecast, until you come back to me, baby, is high tonight, low tomorrow, and precipitation is expected. - Tom Waits, Emotional Weather Report ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
On Mon, Aug 29, 2011 at 2:29 PM, Cranky Frankie cranky.fran...@gmail.comwrote: I'm trying to decide what would be better: - reading the huge quote file (hundreds of entries, two strings, author and quotation) in each time the program starts - loading the quotes into an array in the program I'd like to be able to add new quotes easily, so that is a factor as well. I'm satisfied to use a dialog box, I don't need a GUI at this point so no tkinter (yet). On Mon, Aug 29, 2011 at 1:29 PM, Brett Ritter swift...@swiftone.org wrote: ou: Glad you're so happy with this book...did you have a question for this list? -- Brett Ritter / SwiftOne swift...@swiftone.org I'm not sure I understand the either or part of your question. A file of several hundred quotes doesn't really seem huge to me. At any rate, if you write a program to let you enter the quote and author, you will still need to store them somewhere. A file would be a simpler choice than a database for someone new to programming. What have you got so far? Joel Goldstick ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 90, Issue 97
On Monday 29 August 2011 18:01:44 Cranky Frankie wrote: I'm sorry you were offended by my posts. If others were as well let me know and I'll unsubscribe immediately. Post in the singular. I could not, and can not, I'm afraid, see the point in writing such a long panegyric about Python to a list of Python users. And you do seem to have gone wa OT over that particular book, which I bought and found unusable. But it didn't _offend_ me, it just struck me as spam. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
On Monday 29 August 2011 19:02:29 Alan Gauld wrote: To be fair, in the paper edition of my tutor I do use a Games framework as a second case-study. I then use the framework to build a number guessing game and a Hangman (and a Mastermind on the CD)... Now, I knew there was a reason I decided to use the on-line version. ;-) I just didn't realise how wise my decision was. Anyhow, those games strike me as being reasonably innocuous - and fairly untypical of what computer games seem normally to be about. Games are popular with many beginners especially hobbyists rather than corporate types :-). Yes, I agree. I also agree that many (male) youngsters would like it. But statistically women don't like computer games (and yes, I know some do, but among women they are statistically in a minority). So using games for _all_ programming books strikes me as being almost sexist. It is after all, a good way to keep women out! ;-) And what have you got against corporate types??? ;-) Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
I think I will take a page from rantingrick and state facts without providing any sources to back them up :) But statistically women don't like computer games (and yes, I know some do, but among women they are statistically in a minority). This has been historically true but women gamers are on the rise. In my opinion, the difference traditionally occurs because men and women frequently like to play different types games. As the gaming industry continues to expand (both in terms of target audience and developers), this ratio is starting to change. I can probably attribute some of that to things like Facebook games (e.g. Zynga) for a lot more women playing games (although, they usually do not consider themselves gamers). Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 90, Issue 98
Joel Goldstick joel.goldst...@gmail.com wrote: What have you got so far? Just planning it out in my head so far, like pseudocode. I hope to get started soon. I'm just looking to have a little dialog box come up, display a random quote of the day, and then hit enter and it's gone. Should be a nice, simple way to get started with Python. -- Frank L. Cranky Frankie Palmeri Risible Riding Raconteur Writer . . . and the extended forecast, until you come back to me, baby, is high tonight, low tomorrow, and precipitation is expected. - Tom Waits, Emotional Weather Report ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
On 8/29/2011 11:29 AM Cranky Frankie said... I'm trying to decide what would be better: 'better' is subjective. On the one hand, you have a monolithic python program that consolidates data and program into a single source; on the other hand, you have separation of logic and data. Most often, and particularly for larger on-going projects, I'll use the second approach as the infrastructure to support it is already in place. However, I am rather fond of certain monolithic solutions as both maintenance and deployment are much easier. TiddlyWiki and Monmotha's firewall script come to mind. - reading the huge quote file (hundreds of entries, two strings, author and quotation) in each time the program starts - loading the quotes into an array in the program I don't imagine you'd see much difference here. The content must be read from disk and organized in a python structure regardless. I'd like to be able to add new quotes easily, so that is a factor as well. I'm satisfied to use a dialog box, I don't need a GUI at this point so no tkinter (yet). There's not much difference either in the 'launch a program' or 'load a program' approaches to adding quotes. For learning purposes, I think I'd advise a complete newbie to start with the monolithic approach and build up and out from there. Emile ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Loops and matrices'
Hi all, I have a matrix which contains temperatures. The columns are time, spaced 33 seconds apart, and the rows are depth intervals. What I'm trying to do is create another matrix that contains the rate of change of temperature for each depth. The array is called LS_JULY_11 and the output array should be delta_temp What I have so far is:- import numpy #determine the existing matrix size columnsize = LS_JULY_11.columnSize() matrixsize = LS_JULY_11.size() rowsize = matrixsize/columnsize #define time step TIME_STEP = 33 #create matrix size of the same size delta_temp = numpy.zeros((rowsize,columnsize)) #cycle through all indicies in temperature matrix for i in rowsize: for j in columnsize: delta_temp(i,j) = (LS_JULY_11(i,j) - LS_JULY_11(i,j-1))/TIME_STEP j = j+1 i = i + 1 the error I get is:- File string, line 18 (33) SyntaxError: can't assign to function call Help would be greatly appreciated Thanks Danny ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Loops and matrices'
Hi Danny, Most likely you want delta_temp(i,j) = (LS_JULY_11(i,j) - LS_JULY_11(i,j-1))/TIME_STEP to become (changed the character from '()' to '[]': delta_temp[i,j] = (LS_JULY_11(i,j) - LS_JULY_11(i,j-1))/TIME_STEP Basically it thinks delta_temp(i,j) is a function call and function calls cannot be assigned a value. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Loops and matrices'
On 8/29/2011 3:28 PM Reed DA (Danny) at Aera said... Hi all, I have a matrix which contains temperatures. The columns are time, spaced 33 seconds apart, and the rows are depth intervals. What I'm trying to do is create another matrix that contains the rate of change of temperature for each depth. The array is called LS_JULY_11 and the output array should be delta_temp What I have so far is:- import numpy #determine the existing matrix size columnsize = LS_JULY_11.columnSize() matrixsize = LS_JULY_11.size() rowsize = matrixsize/columnsize #define time step TIME_STEP = 33 #create matrix size of the same size delta_temp = numpy.zeros((rowsize,columnsize)) #cycle through all indicies in temperature matrix for i in rowsize: for j in columnsize: delta_temp(i,j) = (LS_JULY_11(i,j) - LS_JULY_11(i,j-1))/TIME_STEP j = j+1 i = i + 1 the error I get is:- File string, line 18 (33) SyntaxError: can't assign to function call delta_temp access and assignment likely wants to be expressed with brackets rather than parens. Emile ActivePython 2.6.6.15 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. spam(1,2)=6 File stdin, line 1 SyntaxError: can't assign to function call Help would be greatly appreciated Thanks Danny ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] select particular directories and files
I am trying to select particular files within a particular subdirectory, I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have selected. The code I am using is: import os MainFolder=rD:/samples/ for (path, dirs, files) in os.walk(MainFolder): for dir in dirs: if dir=='01': print selected directories are:,dir for ncfile in dir: if ncfile[-3:]=='.nc': print ncfiles are:, ncfile Any feedback will be greatly appreciated!! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] select particular directories and files
On 8/29/2011 4:52 PM questions anon said... I am trying to select particular files within a particular subdirectory, You might find glob a better starting point: ActivePython 2.6.6.15 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import glob help(glob.glob) Help on function glob in module glob: glob(pathname) Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. for filename in glob.glob(r'C:\WSG\GL\2011-08\*.txt'): print filename ... C:\WSG\GL\2011-08\2011-01-WIP-Details.txt C:\WSG\GL\2011-08\2011-02-WIP-Details.txt C:\WSG\GL\2011-08\2011-03-WIP-Details.txt C:\WSG\GL\2011-08\2011-04-WIP-Details.txt C:\WSG\GL\2011-08\2011-05-WIP-Details.txt C:\WSG\GL\2011-08\2011-06-WIP-Details.txt C:\WSG\GL\2011-08\2011-07 - bankToRec.txt C:\WSG\GL\2011-08\2011-07 - vsdsToRec.txt C:\WSG\GL\2011-08\2011-07-WIP-Details.txt C:\WSG\GL\2011-08\5790-00 RECONCILIATION.txt C:\WSG\GL\2011-08\BankRecUtils.txt C:\WSG\GL\2011-08\CapitalizationExamples.txt C:\WSG\GL\2011-08\DEALLOCATE-2011-04.txt C:\WSG\GL\2011-08\dump glsmf1 data for 2004-2010.txt C:\WSG\GL\2011-08\MAR DEALLOCATION.txt C:\WSG\GL\2011-08\Notes.txt C:\WSG\GL\2011-08\shipping safety net util.txt C:\WSG\GL\2011-08\UNBILLED WIP.txt C:\WSG\GL\2011-08\Vacation Accrual - post-bonus-changes.txt C:\WSG\GL\2011-08\Vacation Accrual - pre-bonus-changes.txt C:\WSG\GL\2011-08\vacation accrual notes.txt I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have selected. The code I am using is: import os MainFolder=rD:/samples/ for (path, dirs, files) in os.walk(MainFolder): for dir in dirs: if dir=='01': print selected directories are:,dir for ncfile in dir: if ncfile[-3:]=='.nc': print ncfiles are:, ncfile Any feedback will be greatly appreciated!! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
On 29/08/11 19:29, Cranky Frankie wrote: - reading the huge quote file (hundreds of entries, two strings, author and quotation) in each time the program starts - loading the quotes into an array in the program If you just want a random quote find the size of the file. Generate a random number in that range and go back to find the start of the quote.(Assuming some readily identifiable marker exists) Or, if you write a quote maintenance program to add/delete quotes then even easier is to keep a tally of the number of quotes at the start of the file and then generate the random number based on that. Then simply read forward that many quotes. If it was a really big file(millions of quotes) you could store a table of contents including the quote number and offset, but I suspect you haven't that many quotes yet... I'm satisfied to use a dialog box, I don't need a GUI at this point so no tkinter (yet). Consider EasyGUI, its ideal for that. Altthough you could use the standard Tkinter dialogs too (from which easyGUI is built I suspect) The Talking to the User topic of my tutor describes EasyGUI and the GUI topic describes the basic Tkinter message dialogs. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] 答复: One basic question about the Python's PID of Process object.
Thanks for your help. Now I think I found the reason why os.getpid() returns the same PID value for the Process object, because Process object is NOT the standard Python's process which is adapted by a library called SimPy.(Simulation with Python). BRs, Han / Henrry -邮件原件- 发件人: tutor-bounces+guanghua.han=huawei@python.org [mailto:tutor-bounces+guanghua.han=huawei@python.org] 代表 Lisi 发送时间: 2011年8月29日 17:12 收件人: tutor@python.org 主题: Re: [Tutor] One basic question about the Python's PID of Process object. On Monday 29 August 2011 07:17:51 Han Guanghua wrote: 2. Second question: When I changed the os.getpid() to os.getppid() or self. _pid, the Python’s interpreter generates some error message like “Customer object has no attribute ‘_pid’”. I'm very much a beginner myself, but I am sure that someone will correct me if I am wrong. Should it not be self.pid rather than self._pid? Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 90, Issue 98
On 29/08/11 21:08, Cranky Frankie wrote: Please use meaningful subject lines. Re: Tutor Digest, Vol 90, Issue 98 doesn't help anyone identify a topic in the future and it doesn't help filter messages now. However, on the plus side, thank you for *not* including the whole digest in your message, as so often happens! :-) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Loops and matrices'
On 30/08/11 00:26, Emile van Sebille wrote: delta_temp(i,j) = (LS_JULY_11(i,j) - LS_JULY_11(i,j-1))/TIME_STEP delta_temp access and assignment likely wants to be expressed with brackets rather than parens. And for those not speaking the US variant of English that'll be square brackets as opposed to round brackets! ;-) [ One of the sources of amusement to me when having my book reviewed was the fact that *all* the US reviewers picked up on my use of shape brackets to cover [],,(), {}. Apparently US usage of brackets is limited to []. Something that greatly surprised me and my English, Indian and South African colleagues! :-) ] -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 90, Issue 97
On 29/08/11 20:23, Lisi wrote: ...I could not, and can not, I'm afraid, see the point in writing such a long panegyric about Python It's actually quite common on this list. Especially from programmers newly come to Python from other languages and who get quite excited when they discover how powerful and succint Python can be :-) They seem somehow surprised that the folks on a Python list have already figured that out!... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Loops and matrices'
Alan Gauld wrote: On 30/08/11 00:26, Emile van Sebille wrote: delta_temp(i,j) = (LS_JULY_11(i,j) - LS_JULY_11(i,j-1))/TIME_STEP delta_temp access and assignment likely wants to be expressed with brackets rather than parens. And for those not speaking the US variant of English that'll be square brackets as opposed to round brackets! ;-) [ One of the sources of amusement to me when having my book reviewed was the fact that *all* the US reviewers picked up on my use of shape brackets to cover [],,(), {}. Apparently US usage of brackets is limited to []. Something that greatly surprised me and my English, Indian and South African colleagues! :-) ] And Australians and New Zealanders too. Any Canadians want to weigh in with an opinion? Brackets are anything that, er, brackets an expression (excluding quotation marks), where the one on the left is different from the one on the right. So: () round brackets [] square brackets {} curly brackets angle brackets Easier to spell than parenthesis/parentheses, but longer than brace/braces :) Strictly speaking, the chevrons (angle brackets) should be ⟨⟩ rather than less than and greater than signs, but they're hard to type at the keyboard and look too similar to round brackets in small font sizes. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 90, Issue 97
Lisi wrote: On Monday 29 August 2011 18:01:44 Cranky Frankie wrote: I'm sorry you were offended by my posts. If others were as well let me know and I'll unsubscribe immediately. Post in the singular. I could not, and can not, I'm afraid, see the point in writing such a long panegyric about Python to a list of Python users. It's a book review for a book that Cranky Frankie really loved. As book reviews go, I've read much worse. But I'm not sure that this is the right place for it... Frankie, do you have a blog? Perhaps you should consider getting one. Actually, given that this list is aimed at beginners, and the question of what's a good book to read keeps coming up, on balance I'm inclined to say that such reviews are legitimate (so long as Frankie has no direct, or indirect, incentive to shill for the book he is reviewing). But please don't over do it. And you do seem to have gone wa OT over that particular book, which I bought and found unusable. Heh, well different people find different approaches useful. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] select particular directories and files
Thanks for responding When I try glob.glob I receive no errors but nothing prints. MainFolder=rE:/Sample/ for dir in glob.glob(MainFolder + '01'): print my selected directories are:, dir for ncfile in glob.glob('.nc'): print my selected netcdf files are:, ncfile any suggestions? thanks On Tue, Aug 30, 2011 at 10:07 AM, Emile van Sebille em...@fenx.com wrote: On 8/29/2011 4:52 PM questions anon said... I am trying to select particular files within a particular subdirectory, You might find glob a better starting point: ActivePython 2.6.6.15 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import glob help(glob.glob) Help on function glob in module glob: glob(pathname) Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. for filename in glob.glob(r'C:\WSG\GL\2011-08\***.txt'): print filename ... C:\WSG\GL\2011-08\2011-01-WIP-**Details.txt C:\WSG\GL\2011-08\2011-02-WIP-**Details.txt C:\WSG\GL\2011-08\2011-03-WIP-**Details.txt C:\WSG\GL\2011-08\2011-04-WIP-**Details.txt C:\WSG\GL\2011-08\2011-05-WIP-**Details.txt C:\WSG\GL\2011-08\2011-06-WIP-**Details.txt C:\WSG\GL\2011-08\2011-07 - bankToRec.txt C:\WSG\GL\2011-08\2011-07 - vsdsToRec.txt C:\WSG\GL\2011-08\2011-07-WIP-**Details.txt C:\WSG\GL\2011-08\5790-00 RECONCILIATION.txt C:\WSG\GL\2011-08\**BankRecUtils.txt C:\WSG\GL\2011-08\**CapitalizationExamples.txt C:\WSG\GL\2011-08\DEALLOCATE-**2011-04.txt C:\WSG\GL\2011-08\dump glsmf1 data for 2004-2010.txt C:\WSG\GL\2011-08\MAR DEALLOCATION.txt C:\WSG\GL\2011-08\Notes.txt C:\WSG\GL\2011-08\shipping safety net util.txt C:\WSG\GL\2011-08\UNBILLED WIP.txt C:\WSG\GL\2011-08\Vacation Accrual - post-bonus-changes.txt C:\WSG\GL\2011-08\Vacation Accrual - pre-bonus-changes.txt C:\WSG\GL\2011-08\vacation accrual notes.txt I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have selected. The code I am using is: import os MainFolder=rD:/samples/ for (path, dirs, files) in os.walk(MainFolder): for dir in dirs: if dir=='01': print selected directories are:,dir for ncfile in dir: if ncfile[-3:]=='.nc': print ncfiles are:, ncfile Any feedback will be greatly appreciated!! __**_ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/**mailman/listinfo/tutorhttp://mail.python.org/mailman/listinfo/tutor __**_ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/**mailman/listinfo/tutorhttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] select particular directories and files
Dear Anonymous Questioner, I am not sure how the Windows environment works, but in linux, I would replace for ncfile in glob.glob('.nc'): with for ncfile in glob.glob('*.nc'): ie, add the wild card '*' character to grab all files which end in '.nc' Andre On Aug 29, 2011, at 7:23 PM, questions anon wrote: Thanks for responding When I try glob.glob I receive no errors but nothing prints. MainFolder=rE:/Sample/ for dir in glob.glob(MainFolder + '01'): print my selected directories are:, dir for ncfile in glob.glob('.nc'): print my selected netcdf files are:, ncfile any suggestions? thanks On Tue, Aug 30, 2011 at 10:07 AM, Emile van Sebille em...@fenx.com wrote: On 8/29/2011 4:52 PM questions anon said... I am trying to select particular files within a particular subdirectory, You might find glob a better starting point: ActivePython 2.6.6.15 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import glob help(glob.glob) Help on function glob in module glob: glob(pathname) Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. for filename in glob.glob(r'C:\WSG\GL\2011-08\*.txt'): print filename ... C:\WSG\GL\2011-08\2011-01-WIP-Details.txt C:\WSG\GL\2011-08\2011-02-WIP-Details.txt C:\WSG\GL\2011-08\2011-03-WIP-Details.txt C:\WSG\GL\2011-08\2011-04-WIP-Details.txt C:\WSG\GL\2011-08\2011-05-WIP-Details.txt C:\WSG\GL\2011-08\2011-06-WIP-Details.txt C:\WSG\GL\2011-08\2011-07 - bankToRec.txt C:\WSG\GL\2011-08\2011-07 - vsdsToRec.txt C:\WSG\GL\2011-08\2011-07-WIP-Details.txt C:\WSG\GL\2011-08\5790-00 RECONCILIATION.txt C:\WSG\GL\2011-08\BankRecUtils.txt C:\WSG\GL\2011-08\CapitalizationExamples.txt C:\WSG\GL\2011-08\DEALLOCATE-2011-04.txt C:\WSG\GL\2011-08\dump glsmf1 data for 2004-2010.txt C:\WSG\GL\2011-08\MAR DEALLOCATION.txt C:\WSG\GL\2011-08\Notes.txt C:\WSG\GL\2011-08\shipping safety net util.txt C:\WSG\GL\2011-08\UNBILLED WIP.txt C:\WSG\GL\2011-08\Vacation Accrual - post-bonus-changes.txt C:\WSG\GL\2011-08\Vacation Accrual - pre-bonus-changes.txt C:\WSG\GL\2011-08\vacation accrual notes.txt I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have selected. The code I am using is: import os MainFolder=rD:/samples/ for (path, dirs, files) in os.walk(MainFolder): for dir in dirs: if dir=='01': print selected directories are:,dir for ncfile in dir: if ncfile[-3:]=='.nc': print ncfiles are:, ncfile Any feedback will be greatly appreciated!! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] select particular directories and files
thanks, that was an error by me. but that still doesn't help me select the dir and files! Could it be because I am trying to select folders within other folders to then get a file from each of those folders? On Tue, Aug 30, 2011 at 1:30 PM, Andre' Walker-Loud walksl...@gmail.comwrote: Dear Anonymous Questioner, I am not sure how the Windows environment works, but in linux, I would replace for ncfile in glob.glob('.nc'): with for ncfile in glob.glob('*.nc'): ie, add the wild card '*' character to grab all files which end in '.nc' Andre On Aug 29, 2011, at 7:23 PM, questions anon wrote: Thanks for responding When I try glob.glob I receive no errors but nothing prints. MainFolder=rE:/Sample/ for dir in glob.glob(MainFolder + '01'): print my selected directories are:, dir for ncfile in glob.glob('.nc'): print my selected netcdf files are:, ncfile any suggestions? thanks On Tue, Aug 30, 2011 at 10:07 AM, Emile van Sebille em...@fenx.comwrote: On 8/29/2011 4:52 PM questions anon said... I am trying to select particular files within a particular subdirectory, You might find glob a better starting point: ActivePython 2.6.6.15 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import glob help(glob.glob) Help on function glob in module glob: glob(pathname) Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. for filename in glob.glob(r'C:\WSG\GL\2011-08\***.txt'): print filename ... C:\WSG\GL\2011-08\2011-01-WIP-**Details.txt C:\WSG\GL\2011-08\2011-02-WIP-**Details.txt C:\WSG\GL\2011-08\2011-03-WIP-**Details.txt C:\WSG\GL\2011-08\2011-04-WIP-**Details.txt C:\WSG\GL\2011-08\2011-05-WIP-**Details.txt C:\WSG\GL\2011-08\2011-06-WIP-**Details.txt C:\WSG\GL\2011-08\2011-07 - bankToRec.txt C:\WSG\GL\2011-08\2011-07 - vsdsToRec.txt C:\WSG\GL\2011-08\2011-07-WIP-**Details.txt C:\WSG\GL\2011-08\5790-00 RECONCILIATION.txt C:\WSG\GL\2011-08\**BankRecUtils.txt C:\WSG\GL\2011-08\**CapitalizationExamples.txt C:\WSG\GL\2011-08\DEALLOCATE-**2011-04.txt C:\WSG\GL\2011-08\dump glsmf1 data for 2004-2010.txt C:\WSG\GL\2011-08\MAR DEALLOCATION.txt C:\WSG\GL\2011-08\Notes.txt C:\WSG\GL\2011-08\shipping safety net util.txt C:\WSG\GL\2011-08\UNBILLED WIP.txt C:\WSG\GL\2011-08\Vacation Accrual - post-bonus-changes.txt C:\WSG\GL\2011-08\Vacation Accrual - pre-bonus-changes.txt C:\WSG\GL\2011-08\vacation accrual notes.txt I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have selected. The code I am using is: import os MainFolder=rD:/samples/ for (path, dirs, files) in os.walk(MainFolder): for dir in dirs: if dir=='01': print selected directories are:,dir for ncfile in dir: if ncfile[-3:]=='.nc': print ncfiles are:, ncfile Any feedback will be greatly appreciated!! __**_ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/**mailman/listinfo/tutorhttp://mail.python.org/mailman/listinfo/tutor __**_ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/**mailman/listinfo/tutorhttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] select particular directories and files
hello, yes, I would also try adding a wild card in the dir search for dir in glob.glob(MainFolder + '01\*'): to check if this is helps, in an interpreter (rather than script) try dirs = glob.glob(MainFolder + '\01\*'): print dirs if you get [] then this was not the answer, but if you get a list of directories, then this should work. Well, it should work with the correction for ncfile in glob.glob(dir+'\*.nc'): Cheers, Andre On Aug 29, 2011, at 8:35 PM, questions anon wrote: thanks, that was an error by me. but that still doesn't help me select the dir and files! Could it be because I am trying to select folders within other folders to then get a file from each of those folders? On Tue, Aug 30, 2011 at 1:30 PM, Andre' Walker-Loud walksl...@gmail.com wrote: Dear Anonymous Questioner, I am not sure how the Windows environment works, but in linux, I would replace for ncfile in glob.glob('.nc'): with for ncfile in glob.glob('*.nc'): ie, add the wild card '*' character to grab all files which end in '.nc' Andre On Aug 29, 2011, at 7:23 PM, questions anon wrote: Thanks for responding When I try glob.glob I receive no errors but nothing prints. MainFolder=rE:/Sample/ for dir in glob.glob(MainFolder + '01'): print my selected directories are:, dir for ncfile in glob.glob('.nc'): print my selected netcdf files are:, ncfile any suggestions? thanks On Tue, Aug 30, 2011 at 10:07 AM, Emile van Sebille em...@fenx.com wrote: On 8/29/2011 4:52 PM questions anon said... I am trying to select particular files within a particular subdirectory, You might find glob a better starting point: ActivePython 2.6.6.15 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import glob help(glob.glob) Help on function glob in module glob: glob(pathname) Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. for filename in glob.glob(r'C:\WSG\GL\2011-08\*.txt'): print filename ... C:\WSG\GL\2011-08\2011-01-WIP-Details.txt C:\WSG\GL\2011-08\2011-02-WIP-Details.txt C:\WSG\GL\2011-08\2011-03-WIP-Details.txt C:\WSG\GL\2011-08\2011-04-WIP-Details.txt C:\WSG\GL\2011-08\2011-05-WIP-Details.txt C:\WSG\GL\2011-08\2011-06-WIP-Details.txt C:\WSG\GL\2011-08\2011-07 - bankToRec.txt C:\WSG\GL\2011-08\2011-07 - vsdsToRec.txt C:\WSG\GL\2011-08\2011-07-WIP-Details.txt C:\WSG\GL\2011-08\5790-00 RECONCILIATION.txt C:\WSG\GL\2011-08\BankRecUtils.txt C:\WSG\GL\2011-08\CapitalizationExamples.txt C:\WSG\GL\2011-08\DEALLOCATE-2011-04.txt C:\WSG\GL\2011-08\dump glsmf1 data for 2004-2010.txt C:\WSG\GL\2011-08\MAR DEALLOCATION.txt C:\WSG\GL\2011-08\Notes.txt C:\WSG\GL\2011-08\shipping safety net util.txt C:\WSG\GL\2011-08\UNBILLED WIP.txt C:\WSG\GL\2011-08\Vacation Accrual - post-bonus-changes.txt C:\WSG\GL\2011-08\Vacation Accrual - pre-bonus-changes.txt C:\WSG\GL\2011-08\vacation accrual notes.txt I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have selected. The code I am using is: import os MainFolder=rD:/samples/ for (path, dirs, files) in os.walk(MainFolder): for dir in dirs: if dir=='01': print selected directories are:,dir for ncfile in dir: if ncfile[-3:]=='.nc': print ncfiles are:, ncfile Any feedback will be greatly appreciated!! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] select particular directories and files
It worked! thank you. This is the code I ended with: for dir in glob.glob(MainFolder + '*/01/'): print dir for ncfile in glob.glob(dir + '*.nc'): print ncfile can you choose more than one folder with glob? i.e. I tried: for dir in glob.glob(MainFolder + '*/01/', '*/02/', '*/03/'): but I received: TypeError: glob() takes exactly 1 argument (3 given) thanks On Tue, Aug 30, 2011 at 1:40 PM, Andre' Walker-Loud walksl...@gmail.comwrote: hello, yes, I would also try adding a wild card in the dir search for dir in glob.glob(MainFolder + '01\*'): to check if this is helps, in an interpreter (rather than script) try dirs = glob.glob(MainFolder + '\01\*'): print dirs if you get [] then this was not the answer, but if you get a list of directories, then this should work. Well, it should work with the correction for ncfile in glob.glob(dir+'\*.nc'): Cheers, Andre On Aug 29, 2011, at 8:35 PM, questions anon wrote: thanks, that was an error by me. but that still doesn't help me select the dir and files! Could it be because I am trying to select folders within other folders to then get a file from each of those folders? On Tue, Aug 30, 2011 at 1:30 PM, Andre' Walker-Loud walksl...@gmail.comwrote: Dear Anonymous Questioner, I am not sure how the Windows environment works, but in linux, I would replace for ncfile in glob.glob('.nc'): with for ncfile in glob.glob('*.nc'): ie, add the wild card '*' character to grab all files which end in '.nc' Andre On Aug 29, 2011, at 7:23 PM, questions anon wrote: Thanks for responding When I try glob.glob I receive no errors but nothing prints. MainFolder=rE:/Sample/ for dir in glob.glob(MainFolder + '01'): print my selected directories are:, dir for ncfile in glob.glob('.nc'): print my selected netcdf files are:, ncfile any suggestions? thanks On Tue, Aug 30, 2011 at 10:07 AM, Emile van Sebille em...@fenx.comwrote: On 8/29/2011 4:52 PM questions anon said... I am trying to select particular files within a particular subdirectory, You might find glob a better starting point: ActivePython 2.6.6.15 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import glob help(glob.glob) Help on function glob in module glob: glob(pathname) Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. for filename in glob.glob(r'C:\WSG\GL\2011-08\***.txt'): print filename ... C:\WSG\GL\2011-08\2011-01-WIP-**Details.txt C:\WSG\GL\2011-08\2011-02-WIP-**Details.txt C:\WSG\GL\2011-08\2011-03-WIP-**Details.txt C:\WSG\GL\2011-08\2011-04-WIP-**Details.txt C:\WSG\GL\2011-08\2011-05-WIP-**Details.txt C:\WSG\GL\2011-08\2011-06-WIP-**Details.txt C:\WSG\GL\2011-08\2011-07 - bankToRec.txt C:\WSG\GL\2011-08\2011-07 - vsdsToRec.txt C:\WSG\GL\2011-08\2011-07-WIP-**Details.txt C:\WSG\GL\2011-08\5790-00 RECONCILIATION.txt C:\WSG\GL\2011-08\**BankRecUtils.txt C:\WSG\GL\2011-08\**CapitalizationExamples.txt C:\WSG\GL\2011-08\DEALLOCATE-**2011-04.txt C:\WSG\GL\2011-08\dump glsmf1 data for 2004-2010.txt C:\WSG\GL\2011-08\MAR DEALLOCATION.txt C:\WSG\GL\2011-08\Notes.txt C:\WSG\GL\2011-08\shipping safety net util.txt C:\WSG\GL\2011-08\UNBILLED WIP.txt C:\WSG\GL\2011-08\Vacation Accrual - post-bonus-changes.txt C:\WSG\GL\2011-08\Vacation Accrual - pre-bonus-changes.txt C:\WSG\GL\2011-08\vacation accrual notes.txt I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have selected. The code I am using is: import os MainFolder=rD:/samples/ for (path, dirs, files) in os.walk(MainFolder): for dir in dirs: if dir=='01': print selected directories are:,dir for ncfile in dir: if ncfile[-3:]=='.nc': print ncfiles are:, ncfile Any feedback will be greatly appreciated!! __**_ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/**mailman/listinfo/tutorhttp://mail.python.org/mailman/listinfo/tutor __**_ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/**mailman/listinfo/tutorhttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___
Re: [Tutor] select particular directories and files
to have multiple dirs is simple, for dir in glob.glob(MainFolder + '*/01/') + glob.glob(MainFolder + '*/02/') + glob.glob(MainFolder + '*/03/'): there may be a better way, but this should work. By the way, not to discourage you from asking questions on the list, but many of these things can be deduced quickly by trial and error using the python interpreter (the interactive python shell). That is one thing I really like about python, you really can just play around with it. And with all things, if you figure it out on your own, then you will likely feel better about that, and also, you will retain the knowledge better and gain more confidence in trying new things. Cheers, Andre On Aug 29, 2011, at 9:18 PM, questions anon wrote: It worked! thank you. This is the code I ended with: for dir in glob.glob(MainFolder + '*/01/'): print dir for ncfile in glob.glob(dir + '*.nc'): print ncfile can you choose more than one folder with glob? i.e. I tried: for dir in glob.glob(MainFolder + '*/01/', '*/02/', '*/03/'): but I received: TypeError: glob() takes exactly 1 argument (3 given) thanks On Tue, Aug 30, 2011 at 1:40 PM, Andre' Walker-Loud walksl...@gmail.com wrote: hello, yes, I would also try adding a wild card in the dir search for dir in glob.glob(MainFolder + '01\*'): to check if this is helps, in an interpreter (rather than script) try dirs = glob.glob(MainFolder + '\01\*'): print dirs if you get [] then this was not the answer, but if you get a list of directories, then this should work. Well, it should work with the correction for ncfile in glob.glob(dir+'\*.nc'): Cheers, Andre On Aug 29, 2011, at 8:35 PM, questions anon wrote: thanks, that was an error by me. but that still doesn't help me select the dir and files! Could it be because I am trying to select folders within other folders to then get a file from each of those folders? On Tue, Aug 30, 2011 at 1:30 PM, Andre' Walker-Loud walksl...@gmail.com wrote: Dear Anonymous Questioner, I am not sure how the Windows environment works, but in linux, I would replace for ncfile in glob.glob('.nc'): with for ncfile in glob.glob('*.nc'): ie, add the wild card '*' character to grab all files which end in '.nc' Andre On Aug 29, 2011, at 7:23 PM, questions anon wrote: Thanks for responding When I try glob.glob I receive no errors but nothing prints. MainFolder=rE:/Sample/ for dir in glob.glob(MainFolder + '01'): print my selected directories are:, dir for ncfile in glob.glob('.nc'): print my selected netcdf files are:, ncfile any suggestions? thanks On Tue, Aug 30, 2011 at 10:07 AM, Emile van Sebille em...@fenx.com wrote: On 8/29/2011 4:52 PM questions anon said... I am trying to select particular files within a particular subdirectory, You might find glob a better starting point: ActivePython 2.6.6.15 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import glob help(glob.glob) Help on function glob in module glob: glob(pathname) Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. for filename in glob.glob(r'C:\WSG\GL\2011-08\*.txt'): print filename ... C:\WSG\GL\2011-08\2011-01-WIP-Details.txt C:\WSG\GL\2011-08\2011-02-WIP-Details.txt C:\WSG\GL\2011-08\2011-03-WIP-Details.txt C:\WSG\GL\2011-08\2011-04-WIP-Details.txt C:\WSG\GL\2011-08\2011-05-WIP-Details.txt C:\WSG\GL\2011-08\2011-06-WIP-Details.txt C:\WSG\GL\2011-08\2011-07 - bankToRec.txt C:\WSG\GL\2011-08\2011-07 - vsdsToRec.txt C:\WSG\GL\2011-08\2011-07-WIP-Details.txt C:\WSG\GL\2011-08\5790-00 RECONCILIATION.txt C:\WSG\GL\2011-08\BankRecUtils.txt C:\WSG\GL\2011-08\CapitalizationExamples.txt C:\WSG\GL\2011-08\DEALLOCATE-2011-04.txt C:\WSG\GL\2011-08\dump glsmf1 data for 2004-2010.txt C:\WSG\GL\2011-08\MAR DEALLOCATION.txt C:\WSG\GL\2011-08\Notes.txt C:\WSG\GL\2011-08\shipping safety net util.txt C:\WSG\GL\2011-08\UNBILLED WIP.txt C:\WSG\GL\2011-08\Vacation Accrual - post-bonus-changes.txt C:\WSG\GL\2011-08\Vacation Accrual - pre-bonus-changes.txt C:\WSG\GL\2011-08\vacation accrual notes.txt I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have selected. The code I am using is: import os MainFolder=rD:/samples/ for (path, dirs, files) in os.walk(MainFolder): for dir in dirs: if dir=='01': print selected directories are:,dir for ncfile in dir:
Re: [Tutor] select particular directories and files
ok, thanks for your help Andre On Tue, Aug 30, 2011 at 2:37 PM, Andre' Walker-Loud walksl...@gmail.comwrote: to have multiple dirs is simple, for dir in glob.glob(MainFolder + '*/01/') + glob.glob(MainFolder + '*/02/') + glob.glob(MainFolder + '*/03/'): there may be a better way, but this should work. By the way, not to discourage you from asking questions on the list, but many of these things can be deduced quickly by trial and error using the python interpreter (the interactive python shell). That is one thing I really like about python, you really can just play around with it. And with all things, if you figure it out on your own, then you will likely feel better about that, and also, you will retain the knowledge better and gain more confidence in trying new things. Cheers, Andre On Aug 29, 2011, at 9:18 PM, questions anon wrote: It worked! thank you. This is the code I ended with: for dir in glob.glob(MainFolder + '*/01/'): print dir for ncfile in glob.glob(dir + '*.nc'): print ncfile can you choose more than one folder with glob? i.e. I tried: for dir in glob.glob(MainFolder + '*/01/', '*/02/', '*/03/'): but I received: TypeError: glob() takes exactly 1 argument (3 given) thanks On Tue, Aug 30, 2011 at 1:40 PM, Andre' Walker-Loud walksl...@gmail.comwrote: hello, yes, I would also try adding a wild card in the dir search for dir in glob.glob(MainFolder + '01\*'): to check if this is helps, in an interpreter (rather than script) try dirs = glob.glob(MainFolder + '\01\*'): print dirs if you get [] then this was not the answer, but if you get a list of directories, then this should work. Well, it should work with the correction for ncfile in glob.glob(dir+'\*.nc'): Cheers, Andre On Aug 29, 2011, at 8:35 PM, questions anon wrote: thanks, that was an error by me. but that still doesn't help me select the dir and files! Could it be because I am trying to select folders within other folders to then get a file from each of those folders? On Tue, Aug 30, 2011 at 1:30 PM, Andre' Walker-Loud walksl...@gmail.comwrote: Dear Anonymous Questioner, I am not sure how the Windows environment works, but in linux, I would replace for ncfile in glob.glob('.nc'): with for ncfile in glob.glob('*.nc'): ie, add the wild card '*' character to grab all files which end in '.nc' Andre On Aug 29, 2011, at 7:23 PM, questions anon wrote: Thanks for responding When I try glob.glob I receive no errors but nothing prints. MainFolder=rE:/Sample/ for dir in glob.glob(MainFolder + '01'): print my selected directories are:, dir for ncfile in glob.glob('.nc'): print my selected netcdf files are:, ncfile any suggestions? thanks On Tue, Aug 30, 2011 at 10:07 AM, Emile van Sebille em...@fenx.comwrote: On 8/29/2011 4:52 PM questions anon said... I am trying to select particular files within a particular subdirectory, You might find glob a better starting point: ActivePython 2.6.6.15 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import glob help(glob.glob) Help on function glob in module glob: glob(pathname) Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. for filename in glob.glob(r'C:\WSG\GL\2011-08\***.txt'): print filename ... C:\WSG\GL\2011-08\2011-01-WIP-**Details.txt C:\WSG\GL\2011-08\2011-02-WIP-**Details.txt C:\WSG\GL\2011-08\2011-03-WIP-**Details.txt C:\WSG\GL\2011-08\2011-04-WIP-**Details.txt C:\WSG\GL\2011-08\2011-05-WIP-**Details.txt C:\WSG\GL\2011-08\2011-06-WIP-**Details.txt C:\WSG\GL\2011-08\2011-07 - bankToRec.txt C:\WSG\GL\2011-08\2011-07 - vsdsToRec.txt C:\WSG\GL\2011-08\2011-07-WIP-**Details.txt C:\WSG\GL\2011-08\5790-00 RECONCILIATION.txt C:\WSG\GL\2011-08\**BankRecUtils.txt C:\WSG\GL\2011-08\**CapitalizationExamples.txt C:\WSG\GL\2011-08\DEALLOCATE-**2011-04.txt C:\WSG\GL\2011-08\dump glsmf1 data for 2004-2010.txt C:\WSG\GL\2011-08\MAR DEALLOCATION.txt C:\WSG\GL\2011-08\Notes.txt C:\WSG\GL\2011-08\shipping safety net util.txt C:\WSG\GL\2011-08\UNBILLED WIP.txt C:\WSG\GL\2011-08\Vacation Accrual - post-bonus-changes.txt C:\WSG\GL\2011-08\Vacation Accrual - pre-bonus-changes.txt C:\WSG\GL\2011-08\vacation accrual notes.txt I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have selected. The code I am using is: import os MainFolder=rD:/samples/ for (path, dirs, files) in os.walk(MainFolder): for dir in dirs: if dir=='01': print selected
Re: [Tutor] select particular directories and files
Hello anonymous questioner, ok, thanks for your help Andre your welcome. hope you continue enjoying python. Andre On Tue, Aug 30, 2011 at 2:37 PM, Andre' Walker-Loud walksl...@gmail.com wrote: to have multiple dirs is simple, for dir in glob.glob(MainFolder + '*/01/') + glob.glob(MainFolder + '*/02/') + glob.glob(MainFolder + '*/03/'): there may be a better way, but this should work. By the way, not to discourage you from asking questions on the list, but many of these things can be deduced quickly by trial and error using the python interpreter (the interactive python shell). That is one thing I really like about python, you really can just play around with it. And with all things, if you figure it out on your own, then you will likely feel better about that, and also, you will retain the knowledge better and gain more confidence in trying new things. Cheers, Andre On Aug 29, 2011, at 9:18 PM, questions anon wrote: It worked! thank you. This is the code I ended with: for dir in glob.glob(MainFolder + '*/01/'): print dir for ncfile in glob.glob(dir + '*.nc'): print ncfile can you choose more than one folder with glob? i.e. I tried: for dir in glob.glob(MainFolder + '*/01/', '*/02/', '*/03/'): but I received: TypeError: glob() takes exactly 1 argument (3 given) thanks On Tue, Aug 30, 2011 at 1:40 PM, Andre' Walker-Loud walksl...@gmail.com wrote: hello, yes, I would also try adding a wild card in the dir search for dir in glob.glob(MainFolder + '01\*'): to check if this is helps, in an interpreter (rather than script) try dirs = glob.glob(MainFolder + '\01\*'): print dirs if you get [] then this was not the answer, but if you get a list of directories, then this should work. Well, it should work with the correction for ncfile in glob.glob(dir+'\*.nc'): Cheers, Andre On Aug 29, 2011, at 8:35 PM, questions anon wrote: thanks, that was an error by me. but that still doesn't help me select the dir and files! Could it be because I am trying to select folders within other folders to then get a file from each of those folders? On Tue, Aug 30, 2011 at 1:30 PM, Andre' Walker-Loud walksl...@gmail.com wrote: Dear Anonymous Questioner, I am not sure how the Windows environment works, but in linux, I would replace for ncfile in glob.glob('.nc'): with for ncfile in glob.glob('*.nc'): ie, add the wild card '*' character to grab all files which end in '.nc' Andre On Aug 29, 2011, at 7:23 PM, questions anon wrote: Thanks for responding When I try glob.glob I receive no errors but nothing prints. MainFolder=rE:/Sample/ for dir in glob.glob(MainFolder + '01'): print my selected directories are:, dir for ncfile in glob.glob('.nc'): print my selected netcdf files are:, ncfile any suggestions? thanks On Tue, Aug 30, 2011 at 10:07 AM, Emile van Sebille em...@fenx.com wrote: On 8/29/2011 4:52 PM questions anon said... I am trying to select particular files within a particular subdirectory, You might find glob a better starting point: ActivePython 2.6.6.15 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import glob help(glob.glob) Help on function glob in module glob: glob(pathname) Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. for filename in glob.glob(r'C:\WSG\GL\2011-08\*.txt'): print filename ... C:\WSG\GL\2011-08\2011-01-WIP-Details.txt C:\WSG\GL\2011-08\2011-02-WIP-Details.txt C:\WSG\GL\2011-08\2011-03-WIP-Details.txt C:\WSG\GL\2011-08\2011-04-WIP-Details.txt C:\WSG\GL\2011-08\2011-05-WIP-Details.txt C:\WSG\GL\2011-08\2011-06-WIP-Details.txt C:\WSG\GL\2011-08\2011-07 - bankToRec.txt C:\WSG\GL\2011-08\2011-07 - vsdsToRec.txt C:\WSG\GL\2011-08\2011-07-WIP-Details.txt C:\WSG\GL\2011-08\5790-00 RECONCILIATION.txt C:\WSG\GL\2011-08\BankRecUtils.txt C:\WSG\GL\2011-08\CapitalizationExamples.txt C:\WSG\GL\2011-08\DEALLOCATE-2011-04.txt C:\WSG\GL\2011-08\dump glsmf1 data for 2004-2010.txt C:\WSG\GL\2011-08\MAR DEALLOCATION.txt C:\WSG\GL\2011-08\Notes.txt C:\WSG\GL\2011-08\shipping safety net util.txt C:\WSG\GL\2011-08\UNBILLED WIP.txt C:\WSG\GL\2011-08\Vacation Accrual - post-bonus-changes.txt C:\WSG\GL\2011-08\Vacation Accrual - pre-bonus-changes.txt C:\WSG\GL\2011-08\vacation accrual notes.txt I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have selected. The code I am using is: import