Re: [Tutor] I need to learn more about sorting!
On Tue, Jun 24, 2008 at 1:15 AM, Dick Moores [EMAIL PROTECTED] wrote: At 07:15 PM 6/23/2008, Kent Johnson wrote: You should learn how to use list comprehensions: alist_tup_elements_reversed.append = [ (x[1], x[0]) for x in alist ] Now, that's why I don't use them. They don't make sense, I thought. But that's a typo, or a paste-o, right? You meant alist_tup_elements_reversed = [ (x[1], x[0]) for x in alist ], which works. Yes, a paste-o. I have a short introduction to list comprehensions here: http://personalpages.tds.net/~kent37/kk/3.html Although the syntax takes a little getting used to, I think it is just because it is an unusual concept. I find list comps easier to write and understand than the equivalent loop. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Another Newbie question
Hi I got some problem about writting convention in python. Some tutorial ask me to write this : a = 1 s = 0 print 'Enter Numbers to add to the sum.' print 'Enter 0 to quit.' while a != 0: print 'Current Sum:', s a = int(raw_input('Number? ')) s = s + a print 'Total Sum =', s And the response must be like this : Enter Numbers to add to the sum. Enter 0 to quit. Current Sum: 0 Number? 200 Current Sum: 200 Number? -15.25 Current Sum: 184.75 Number? -151.85 Current Sum: 32.9 Number? 10.00 Current Sum: 42.9 Number? 0 Total Sum = 42.9 But when I write until this : a = 1 s = 0 print 'Enter Numbers to add the sum' I press enter, and alas my python response me : Enter Numbers to add the sum It didn't want waiting me until I finish writing the rest. I know there is some mistake about my writing convention, but what ??? Can you find it ?? But you know it's not finish,I ignore the error message and writng the rest, but until i write this: while a != 0: print 'Current Sum:', s a = int(raw_input('Number?')) s = s+a print 'Total Sum =', s Oh, man... another error message : File stdin, line 5 print 'Total Sum =', s ^ Can you help me guys ?? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Another Newbie question
Le Tuesday 24 June 2008 12:23:41 Danny Laya, vous avez écrit : Hi I got some problem about writting convention in python. Some tutorial ask me to write this : a = 1 s = 0 print 'Enter Numbers to add to the sum.' print 'Enter 0 to quit.' while a != 0: print 'Current Sum:', s a = int(raw_input('Number? ')) s = s + a print 'Total Sum =', s And the response must be like this : But when I write until this : a = 1 s = 0 print 'Enter Numbers to add the sum' I press enter, and alas my python response me : Enter Numbers to add the sum This is because you're doing this in an interactive session, so python interprets and runs each line immediately after you write them. I guess this example was supposed to be put in a file and executed from there, but you can also put all this in a function : def test_func() : a = 1 s = 0 print 'Enter numbers to add to the sum.' ... This won't do anything until you call the function: test_func() It didn't want waiting me until I finish writing the rest. I know there is some mistake about my writing convention, but what ??? Can you find it ?? But you know it's not finish,I ignore the error message and writng the rest, but until i write this: while a != 0: print 'Current Sum:', s a = int(raw_input('Number?')) s = s+a print 'Total Sum =', s Oh, man... another error message : File stdin, line 5 print 'Total Sum =', s ^ You just forgot the most important: the error message itself :) Probably an indentation error, but we'll need the full message to help (something like SomeError: blah blah...) -- Cédric Lucantis ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Another Newbie question
On Tue, Jun 24, 2008 at 6:23 AM, Danny Laya [EMAIL PROTECTED] wrote: Hi I got some problem about writting convention in python. Some tutorial ask me to write this : a = 1 s = 0 print 'Enter Numbers to add to the sum.' print 'Enter 0 to quit.' while a != 0: print 'Current Sum:', s a = int(raw_input('Number? ')) s = s + a print 'Total Sum =', s And the response must be like this : Enter Numbers to add to the sum. Enter 0 to quit. Current Sum: 0 Number? 200 Current Sum: 200 Number? -15.25 Current Sum: 184.75 Number? -151.85 Current Sum: 32.9 Number? 10.00 Current Sum: 42.9 Number? 0 Total Sum = 42.9 But when I write until this : a = 1 s = 0 print 'Enter Numbers to add the sum' Try putting the program in a function. A function is defined using: def functionName(): Everything inside the function is indented. For example: def main(): a = 1 s = 0 print 'Enter Numbers to add to the sum.' print 'Enter 0 to quit.' while a != 0: print 'Current Sum:', s a = int(raw_input('Number? ')) s = s + a print 'Total Sum =', s main() In this example, the function is called main() and it is defined with with the keyword 'def' followed by the name of the function, parentheses, and finally a colon (:). Don't forget the colon! The body of the function is indented. Make sure you indent the lines inside the function when you are entering it in the interactive interpreter. The while loop needs more indentation with the function body! Look at it carefully! Finally, call the function. In the above example, the function is called by entering: main() on a line by itself. It is NOT a part of the function body. I hope this is helpful. I remember when I was first starting out with the Python interactive interpreter. It wasn't easy. Good luck! Stick with it. It won't be long before you look back on these beginning days and laugh. Happy Programming! -- b h a a l u u at g m a i l dot c o m Kid on Bus: What are you gonna do today, Napoleon? Napoleon Dynamite: Whatever I feel like I wanna do. Gosh! I press enter, and alas my python response me : Enter Numbers to add the sum It didn't want waiting me until I finish writing the rest. I know there is some mistake about my writing convention, but what ??? Can you find it ?? But you know it's not finish,I ignore the error message and writng the rest, but until i write this: while a != 0: ... print 'Current Sum:', s ... a = int(raw_input('Number?')) ... s = s+a ... print 'Total Sum =', s Oh, man... another error message : File stdin, line 5 print 'Total Sum =', s ^ Can you help me guys ?? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] fibonacci.py task ???
Hi all, can you explain me what this code mean : Fibonacci.py # This program calculates the Fibonacci sequence a = 0 b = 1 count = 0 max_count = 20 while count max_count: count = count + 1 # we need to keep track of a since we change it old_a = a old_b = b a = old_b b = old_a + old_b # Notice that the , at the end of a print statement keeps it # from switching to a new line print old_a, Output: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 Do you understand it ??? Can you explain meahhh you know i'm a newbie so please explain it with a simple expalanation. And I got many tutorial with title *.py(e.g: Fibonacci.py and Password.py), can you explain me what *.py mean? Thank's for helping me. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] fibonacci.py task ???
Le Tuesday 24 June 2008 14:47:29 Danny Laya, vous avez écrit : Hi all, can you explain me what this code mean : Fibonacci.py # This program calculates the Fibonacci sequence a = 0 b = 1 count = 0 max_count = 20 while count max_count: count = count + 1 # we need to keep track of a since we change it old_a = a old_b = b a = old_b b = old_a + old_b # Notice that the , at the end of a print statement keeps it # from switching to a new line print old_a, Output: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 Do you understand it ??? Can you explain meahhh you know i'm a newbie so please explain it with a simple expalanation. see http://en.wikipedia.org/wiki/Fibonacci_number And I got many tutorial with title *.py(e.g: Fibonacci.py and Password.py), can you explain me what *.py mean? Thank's for helping me. .py is just the extension for python source files, so you're supposed to copy the example in a file called Fibonacci.py and run it with python Fibonacci.py but of course you can choose any name you want for it. -- Cédric Lucantis ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] fibonacci.py task ???
On Tue, Jun 24, 2008 at 8:47 AM, Danny Laya [EMAIL PROTECTED] wrote: Hi all, can you explain me what this code mean : Fibonacci.py # This program calculates the Fibonacci sequence a = 0 b = 1 count = 0 max_count = 20 while count max_count: count = count + 1 # we need to keep track of a since we change it old_a = a old_b = b a = old_b b = old_a + old_b # Notice that the , at the end of a print statement keeps it # from switching to a new line print old_a, Output: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 Do you understand it ??? Can you explain meahhh you know i'm a newbie so please explain it with a simple expalanation. You can start by using Google or Wikipedia to get basic definitions of things like Fibonacci sequence. It has to do with mathematics or something? http://www.google.com http://www.wikipedia.org/ And I got many tutorial with title *.py(e.g: Fibonacci.py and Password.py), can you explain me what *.py mean? Thank's for helping me. That is the file extention for a Python Script. The file extension for a BASIC script is BAS (Fibonacci.bas), for a Perl script is PL (Fibonacci.pl), for a Scheme script is SCM (Fibonacci.scm), for a Logo script is LG (Fibonacci.lg) . Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Happy Programming! -- b h a a l u u at g m a i l dot c o m Kid on Bus: What are you gonna do today, Napoleon? Napoleon Dynamite: Whatever I feel like I wanna do. Gosh! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] fibonacci.py task ???
Fibonacci.py calculates the Fibonacci numbers (the sum of the two previous numbers), also see http://en.wikipedia.org/wiki/Fibonacci_number Files that end in .py are python files. Much like .txt are text files and .odc is OpenOffice Calc file. Though you can name any file as you wish, the convention for the usual files is to use the correct extension, so to avoid confusion. (Sometimes it is preferable to use another extension, or to omit them altogether, but that's not the point I'm trying to make here) Fibonacci.py # This program calculates the Fibonacci sequence a = 0 We'll initialize the variable a as 0. Since the first element of the Fibonacci Sequence is 0 b = 1 We'll initialize the variable b as 1. Since the second element of the Fibonacci Sequence is 1 We have to supply 0 and 1 as starting values. Without these we wouldn't know where to start our sequence. (You could potentially start the sequence anywhere, e.g at a=5 and b=7, or over all prime numbers, it would still be a Fibonacci sequence, though not the one commonly known) count = 0 We'll initialize the variable count max_count = 20 We'll initialize the variable max_count while count max_count: While count is smaller then max_count do the following count = count + 1 Increase count # we need to keep track of a since we change it old_a = a old_b = b assign a and b to two help_variables, so we don't accidently change the values a = old_b a now holds the current sequence element b = old_a + old_b b holds the next element # Notice that the , at the end of a print statement keeps it # from switching to a new line print old_a, I guess this is supposed to show some of the programming basics, though I find the contents of the while-loop rather more confusing then necessary. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Hands-on beginner's project?
I'm very new to Python, and (to a slightly lesser extent) programming in general. I'd like to get some experience by practicing simple-yet-functional programs, with a bit of an emphasis on games. The first game I'd like to attempt would be a simple, non-linear story, similar to those choose-your-adventure books. I don't want to start with anything too complicated, like having mapped-out directions, or interactive objects, although I do eventually want to get into stuff like that. Python seems to me like it would be a good language for this sort of stuff. I figure I just need to use a lot of print, if/elif/else, raw_input(), and a ton and a half of variables. My problem at the moment is that I don't know how to get from one section of the story to the next. I vaguely remember reading about some language using a goto command for something like this, but I'm not sure how that would be handled in Python. A rough idea of what I'm trying to do (in a presumably hypothetical language) would be something like this: 0100 print Ahead of you, you see a chasm. 0200 jump = raw_input(Do you wish to try jumping over it? Y/N) 0300 if jump = Y: 0400 goto 1700 0500 if jump = N: 0600 goto 2100 Does this make any sense? Is there some way I could do this in Python? Any and all help is definitely appreciated! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hands-on beginner's project?
Take a look at this page, and see if it is what you're looking for: http://www.geocities.com/ek.bhaaluu/python/index.html I haven't worked on this project in awhile because I got sidetracked by other things, but it's still on the backburner. One day I'll pick it up again. I think Text Adventure Games are ripe for learning Python Object-Oriented Programming (something I'm interested in learning). Fell free to download the source code and play around with it, modify it, whatever. It is a beginner's learning project. Happy Programming! -- b h a a l u u at g m a i l dot c o m Kid on Bus: What are you gonna do today, Napoleon? Napoleon Dynamite: Whatever I feel like I wanna do. Gosh! On Tue, Jun 24, 2008 at 11:37 AM, nathan virgil [EMAIL PROTECTED] wrote: I'm very new to Python, and (to a slightly lesser extent) programming in general. I'd like to get some experience by practicing simple-yet-functional programs, with a bit of an emphasis on games. The first game I'd like to attempt would be a simple, non-linear story, similar to those choose-your-adventure books. I don't want to start with anything too complicated, like having mapped-out directions, or interactive objects, although I do eventually want to get into stuff like that. Python seems to me like it would be a good language for this sort of stuff. I figure I just need to use a lot of print, if/elif/else, raw_input(), and a ton and a half of variables. My problem at the moment is that I don't know how to get from one section of the story to the next. I vaguely remember reading about some language using a goto command for something like this, but I'm not sure how that would be handled in Python. A rough idea of what I'm trying to do (in a presumably hypothetical language) would be something like this: 0100 print Ahead of you, you see a chasm. 0200 jump = raw_input(Do you wish to try jumping over it? Y/N) 0300 if jump = Y: 0400 goto 1700 0500 if jump = N: 0600 goto 2100 Does this make any sense? Is there some way I could do this in Python? Any and all help is definitely appreciated! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hands-on beginner's project?
nathan virgil wrote: I'm very new to Python, and (to a slightly lesser extent) programming in general. I'd like to get some experience by practicing simple-yet-functional programs, with a bit of an emphasis on games. The first game I'd like to attempt would be a simple, non-linear story, similar to those choose-your-adventure books. I don't want to start with anything too complicated, like having mapped-out directions, or interactive objects, although I do eventually want to get into stuff like that. Python seems to me like it would be a good language for this sort of stuff. I figure I just need to use a lot of print, if/elif/else, raw_input(), and a ton and a half of variables. My problem at the moment is that I don't know how to get from one section of the story to the next. I vaguely remember reading about some language using a goto command for something like this, but I'm not sure how that would be handled in Python. A rough idea of what I'm trying to do (in a presumably hypothetical language) would be something like this: 0100 print Ahead of you, you see a chasm. 0200 jump = raw_input(Do you wish to try jumping over it? Y/N) 0300 if jump = Y: 0400 goto 1700 0500 if jump = N: 0600 goto 2100 Does this make any sense? Yes Is there some way I could do this in Python? Definitely. Python is a structured programming language. This means it has no GOTO statement. You could, for starters, use the following algorithm: room = 1 while True: # retrieve data for current room if room == 1: desc = Ahead of you, you see a chasm. ques = Do you wish to try jumping over it? Y/N destY = 2 destN = 3 elif room == 2: desc = Ahead of you, you see a warty green ogre. ques = Do you wish to eat it? Y/N destY = 4 destN = 5 # etc for the rest of the rooms # ask current question and move to next room print ques ans = raw_input(ques).upper() # allow for lower case input if ans == Y: room = destY elif ans == N: room = destN elif ans == Q: # give us a way out. break else: print Please answer Y or N Start with this. Try to get it running. Then come back with questions. Notice that I have separated the data (description of rooms and flow between rooms) from the program logic. This makes things a LOT easier. There are more complicated structures in Python that make game programming a LOT easier and more flexible that the above. -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] fibonacci.py task ???
On Tue, Jun 24, 2008 at 6:40 AM, John Patrick Gerdeman [EMAIL PROTECTED] wrote: (You could potentially start the sequence anywhere, e.g at a=5 and b=7, or over all prime numbers, it would still be a Fibonacci sequence, though not the one commonly known) Actually, a series that follows the same rule as the Fibonacci sequence (each member is the sum of the previous two members) but starts somewhere other than 0 and 1 is called a Lucas sequence, after a mathematician named Édouard Lucas. Put it another way: the Fibonacci sequence is just one of an infinite number of Lucas sequences. Sorry - just a bit of trivia I happened to recall. -- www.fsrtechnologies.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hands-on beginner's project?
Le Tuesday 24 June 2008 17:37:00 nathan virgil, vous avez écrit : I'm very new to Python, and (to a slightly lesser extent) programming in general. I'd like to get some experience by practicing simple-yet-functional programs, with a bit of an emphasis on games. The first game I'd like to attempt would be a simple, non-linear story, similar to those choose-your-adventure books. I don't want to start with anything too complicated, like having mapped-out directions, or interactive objects, although I do eventually want to get into stuff like that. Python seems to me like it would be a good language for this sort of stuff. I figure I just need to use a lot of print, if/elif/else, raw_input(), and a ton and a half of variables. My problem at the moment is that I don't know how to get from one section of the story to the next. I vaguely remember reading about some language using a goto command for something like this, but I'm not sure how that would be handled in Python. A rough idea of what I'm trying to do (in a presumably hypothetical language) would be something like this: 0100 print Ahead of you, you see a chasm. 0200 jump = raw_input(Do you wish to try jumping over it? Y/N) 0300 if jump = Y: 0400 goto 1700 0500 if jump = N: 0600 goto 2100 hmm, back to the 80's :) Hard-coding all your story would be a very bad method and a nightmare to maintain. Ideally, such a game would be written in two parts: an 'engine' which contains all the logic, and a set of datas, containing the story itself in some special form understood by the engine. One of the multiple advantages of this approach is that you will be able to easily write new stories by reusing the engine with different datas (this is what we call a 'mod' in modern games) Does this make any sense? Is there some way I could do this in Python? Any and all help is definitely appreciated! Python is a good choice to learn programing. Below is a simple example. It might look complicated to a beginner, but if you take the time to read the python tutorial you should be able to understand it. Of course feel free to ask for more help about it. # -- # --- GAME ENGINE --- # A global map of the nodes NODES = {} # Print one node's text and ask the user for a choice. # Return the next node or None if the game is over. # def process_node (node) : tag = node[0] text = node[1] options = node[2] # print the title print print tag print '-' * len(tag) print # print the node's text print text print # if there are no options, the game is over if not options : print 'GAME OVER' return None # print the various options index = 1 for opt in options : opt_text = opt[0] opt_tag = opt[1] print 'If you want to', opt_text, 'then press', index index = index + 1 # read the user's choice print choice = int(raw_input(Your choice: )) opt = options[choice-1] # -1 because an array starts at 0 return NODES[opt[1]] # Start the story. # def run () : # global initialisation for node in NODES_LIST : tag = node[0] NODES[tag] = node # find the starting node node = NODES[start] # let's play now while node : node = process_node(node) print See you for a new exciting adventure! # --- GAME DATAS --- # All your story goes here. A 'node' is a paragraph of the story and is made # of three things: # # * a 'tag' identifying the node and used to jump from one to another # (all tags must be unique) # # * the text of the paragraph # # * a list of user choices, each option being itself a list a two items: # - a text to display # - the name (tag) of the destination node # NODES_LIST =[ [ start, You're in front of a door., [[open the door, open_door], [go back, go_back]] ], [ open_door, Cool, you found the Holy Graal - YOU WON!, [] ], [ go_back, A troll is in the way, [[fight it, fight_troll], [run away, start]] ], [ fight_troll, Sorry, it's stronger than you and you die - YOU LOST!, [] ] ] # start the game run() # -- -- Cédric Lucantis ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 52, Issue 66
On Tue, 2008-06-24 at 15:26 +0200, [EMAIL PROTECTED] wrote: Message: 5 Date: Tue, 24 Jun 2008 05:47:29 -0700 (PDT) From: Danny Laya [EMAIL PROTECTED] Subject: [Tutor] fibonacci.py task ??? To: tutor@python.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=iso-8859-1 Hi all, can you explain me what this code mean : Fibonacci.py # This program calculates the Fibonacci sequence a = 0 b = 1 count = 0 max_count = 20 while count max_count: count = count + 1 # we need to keep track of a since we change it old_a = a old_b = b a = old_b b = old_a + old_b # Notice that the , at the end of a print statement keeps it # from switching to a new line print old_a, Output: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 Do you understand it ??? Can you explain meahhh you know i'm a newbie so please explain it with a simple expalanation. And I got many tutorial with title *.py(e.g: Fibonacci.py and Password.py), can you explain me what *.py mean? Thank's for helping me. If you have an algorithm to calculate the sum of exactly two(!) numbers you could do it in the Python prompt by: 3+4 7 ... or you could start you fire up a text editor (something like Notepad in Windows, or nano in Linux and type 3+4(without the quotes!), hmmm..., and save the file as anything you want, lets say for now you save the file as threePlusFour. Every time you invoke the python interpreter (do you know how to do that?) with threePlusFour, you will get the value seven! Because there are many programming languages, such as C, java, perl, ruby, haskell(!), you might want to be more specific as to what programming language you save saved your code in. .c for C, .rb for Ruby, .java for java and, of course .py for python. ... or you could define a function... One of the indefatigable contributors to this mailing list, Alan Gauld (where do you get the time?), has an excellent tutorial for beginners. Check it out at http://www.freenetpages.co.uk/hp/alan.gauld (correct?) Kinuthia... ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Astonishing timing result
I haven't done much timing using Timer from the timeit module, so maybe I haven't done this correctly, but I'm amazed at the difference in speed between importing a function and not importing it but instead putting it directly into a script. Please look at http://py77.python.pastebin.com/f152b6c14. You'll see three sections, plus some prints down below to get the results. The 3 are t1, t2, and t3. t2 has the sorting function the list helped me write yesterday, sort_tuple_list_by_2nd_elements(). t1 has the code of the function, but is not a function. t3 is exactly the same as t2, except that the function is imported from a module, mycalc.py, in which I have many functions I've written or stolen. I'll repeat the output here: Output: t1 is 0.000104, no function t2 is 5.87e-006, function explicit t3 is 0.000126, function imported t1/t2 is 17.8 t1/t3 is 0.827 t3/t2 is 21.5 Now, I'd heard that code in a function runs faster than the same code not in a function, but even so I was surprised at the t1/t2 ratio of 17.8. The astonishing (to me, anyway) result was the t3/t2 ratio. I had no idea that importing from mycalc slowed a script down at all, let alone by a factor of 21! Comments? Enlightenment? Dick Moores ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] closing a internet explorer com object
hello, I'm using internet explorer to print out html documents and I'm not sure how to close it once it is created. How do I do this? below is the simple bit of code I use to print documents. thanks! Jeff ie = win32com.client.Dispatch(InternetExplorer.Application) ie.Visible = 0 ie.Navigate(doc_name) if ie.Busy: sleep(1) # print the current IE document without prompting # the user for the printerdialog ie.ExecWB(win32com.client.constants.OLECMDID_PRINT, win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python to exe--how much work?
Hi All, Question: How hard is it to convert python code to an exe? Details: I've written some test software in python for my company. We'd like to be able to distribute the software without having to install python on the instrument computer. The software itself is several hundred lines of code, that imports and uses several modules: SciPy, NumPy, PIL (python imaging library) and matplotlib. My background is in ME, so I'm far from an expert at coding and I'd still consider myself a begginer when it comes to Python. My code is still a little cumbersome (due to my past experience in Matlab) and is far from pythonic. I've had some success generating .exe files using pyinstaller for a few simple python programs i've written (less than 100 lines of code, that just use the os module). How much harder will this be for longer code with more modules imported? In general I think we have a few options: 1) If it's easy I can do it myself. I'm just worried that including the modules will make things messy/impossible. 2) If it's too hard for me, but easy for an expert. We could probably hire a consultant to package. 3) If it's too hard for anybody (unlikely). We could have someone in-house port the code to C or VB. Any other general advice would be appreciated. Thanks, Keith ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Astonishing timing result
On Tue, Jun 24, 2008 at 1:43 PM, Dick Moores [EMAIL PROTECTED] wrote: Output: t1 is 0.000104, no function t2 is 5.87e-006, function explicit t3 is 0.000126, function imported t1/t2 is 17.8 t1/t3 is 0.827 t3/t2 is 21.5 Now, I'd heard that code in a function runs faster than the same code not in a function, but even so I was surprised at the t1/t2 ratio of 17.8. The astonishing (to me, anyway) result was the t3/t2 ratio. I had no idea that importing from mycalc slowed a script down at all, let alone by a factor of 21! Note that t1 and t3 are pretty close to each other. Perhaps you should be suspicious of t2. What if __name__ != '__main__' ? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hands-on beginner's project?
No, it was whether or not the engine and data could be separated into two different files, like most modern games. If I ever manage to make really complex stuff, I might want to take a page out of Id's book and make the engine open source. Yes that's what you should do. In python terms, they should go in different modules (and thus in different files) but don't worry too much about that for now, the most important being to keep them clearly separated in your mind. If your code is well written it won't require a lot of work to split it when you feel the need for it. (you'll learn more about modules in the tutorial and the library reference) This is an important concept in programing : separate the concerns. Each part of your code should focus on a simple and specific task, and should stay as independent as possible from the rest of the program. This makes the maintenance easier and improves reusability. And open source is a sure way to learn a lot and write great softwares :) -- Cédric Lucantis ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hands-on beginner's project?
On Tue, Jun 24, 2008 at 5:37 PM, nathan virgil [EMAIL PROTECTED] wrote: I'm very new to Python, and (to a slightly lesser extent) programming in general. I'd like to get some experience by practicing simple-yet-functional programs, with a bit of an emphasis on games. The first game I'd like to attempt would be a simple, non-linear story, similar to those choose-your-adventure books. I don't want to start with anything too complicated, like having mapped-out directions, or interactive objects, although I do eventually want to get into stuff like that. Slightly off-topic, but you might find Ren'Py interesting: http://www.renpy.org/wiki/renpy/Home_Page Ren'Py is a Python-driven engine for visual novels. ie, interactive stories with pictures, sound, music, etc. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] closing a internet explorer com object
Below is a bit of code that should work, you might want to change ieregex because right now it will close anything that has Microsoft Internet Explorer in the title bar. Have fun. import win32con import win32gui import win32process import re def getHwnds(): def callback(hwnd, hwnds): if win32gui.IsWindowVisible(hwnd) and win32gui.IsWindowEnabled(hwnd): _, found_pid = win32process.GetWindowThreadProcessId(hwnd) hwnds.append(hwnd) return True hwnds = [] win32gui.EnumWindows(callback, hwnds) return hwnds ieregex = re.compile(.*Microsoft Internet Explorer.*) for hwnd in getHwnds(): name = win32gui.GetWindowText(hwnd) if ieregex.match(name): print hwnd win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) On Tue, Jun 24, 2008 at 1:33 PM, Jeff Peery [EMAIL PROTECTED] wrote: hello, I'm using internet explorer to print out html documents and I'm not sure how to close it once it is created. How do I do this? below is the simple bit of code I use to print documents. thanks! Jeff ie = win32com.client.Dispatch(InternetExplorer.Application) ie.Visible = 0 ie.Navigate(doc_name) if ie.Busy: sleep(1) # print the current IE document without prompting # the user for the printerdialog ie.ExecWB(win32com.client.constants.OLECMDID_PRINT, win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- -John Chandler ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hands-on beginner's project?
nathan virgil [EMAIL PROTECTED] wrote I'm very new to Python, and (to a slightly lesser extent) programming in general. I'd like to get some experience by practicing simple-yet-functional programs, That is not a bad idea but... I figure I just need to use a lot of print, if/elif/else, raw_input(), and a ton and a half of variables. That's a terrible idea! :-) reading about some language using a goto command for something like this, but I'm not sure how that would be handled in Python. It's not. Goto is one of the bad ideas of programming from the 1960s and almost all modern languages do not support it. It leads to very unstructured programs that rapidly become unreadable and therefore unmaintainable. Python tries very hard to stop you writing bad code so it does not have a goto. A rough idea of what I'm trying to do (in a presumably hypothetical language) would be something like this: 0100 print Ahead of you, you see a chasm. 0200 jump = raw_input(Do you wish to try jumping over it? Y/N) 0300 if jump = Y: 0400 goto 1700 0500 if jump = N: 0600 goto 2100 Is there some way I could do this in Python? Fortunately not. However there are much better alternatives and if you take just a few hours to go through any of the non-programmers guides on the python web site you will find out what they are. I would recommend Josh Calgierri's(sp?) tutor since it is very hands-on which seems to be your preferred style but he will lead you through examples that show you how to structure your code much more effectively than using gotos. http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python/Contents In particular look at the Decisions and Defining Functions topics. I suspect you would find my tutorial to be too heavily biased to the theory and foundation stuff. But you can try it if you like, the Branching and Functions topics apply. Doing these tutorials may seem a bit slow and dry but they will save you a lot of time later and prevent you from learning a heap of bad habits that will make life harder inthe long run. (It will also save you posting lots of very basic questions here and then waiting for the replies!) -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 52, Issue 66
kinuthiA muchanE [EMAIL PROTECTED] wrote ... or you could start you fire up a text editor (something like Notepad in Windows, or nano in Linux and type 3+4(without the quotes!), Actually it would need to be print 3+4 otherwise Python would silently evaluate the expression but not display the result. One of the indefatigable contributors to this mailing list, Alan Gauld (where do you get the time?), With increasing difficulty! :-) Check it out at http://www.freenetpages.co.uk/hp/alan.gauld (correct?) Correct, thanks for the plug! Sadly it will need to move soon since Freenet have announced that they will soon be decommissioning their free web site(*). I'm trying to decide whether to go to another free site or spend the money for a proper hosted site with dedicated domain name etc... (*) They have already blocked ftp so I can't post updates anymore :-( -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Astonishing timing result
At 12:44 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 1:43 PM, Dick Moores [EMAIL PROTECTED] wrote: Output: t1 is 0.000104, no function t2 is 5.87e-006, function explicit t3 is 0.000126, function imported t1/t2 is 17.8 t1/t3 is 0.827 t3/t2 is 21.5 Now, I'd heard that code in a function runs faster than the same code not in a function, but even so I was surprised at the t1/t2 ratio of 17.8. The astonishing (to me, anyway) result was the t3/t2 ratio. I had no idea that importing from mycalc slowed a script down at all, let alone by a factor of 21! Note that t1 and t3 are pretty close to each other. Perhaps you should be suspicious of t2. What if __name__ != '__main__' ? With that, t1 is 0.000104, no function t2 is 0.000117, function explicit t3 is 0.000113, function imported t1/t2 is 0.885 t1/t3 is 0.914 t3/t2 is 0.969 Explain? Dick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Astonishing timing result
- Message from [EMAIL PROTECTED] - Date: Tue, 24 Jun 2008 13:44:00 -0700 From: Dick Moores [EMAIL PROTECTED] At 12:44 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 1:43 PM, Dick Moores [EMAIL PROTECTED] wrote: Output: t1 is 0.000104, no function t2 is 5.87e-006, function explicit t3 is 0.000126, function imported t1/t2 is 17.8 t1/t3 is 0.827 t3/t2 is 21.5 Now, I'd heard that code in a function runs faster than the same code not in a function, but even so I was surprised at the t1/t2 ratio of 17.8. The astonishing (to me, anyway) result was the t3/t2 ratio. I had no idea that importing from mycalc slowed a script down at all, let alone by a factor of 21! Note that t1 and t3 are pretty close to each other. Perhaps you should be suspicious of t2. What if __name__ != '__main__' ? With that, t1 is 0.000104, no function t2 is 0.000117, function explicit t3 is 0.000113, function imported t1/t2 is 0.885 t1/t3 is 0.914 t3/t2 is 0.969 Explain? Dick Hey Dick, I'm not too clear on what it is that you want explained. It seems to me that the difference between t2 and t3 is 1) is so small as to be most likely due to (effectively) random fluctuations of your environment (the demands that other processes were making on your system at the time) and 2) so small so as to not be worth worrying about (http://c2.com/cgi/wiki?PrematureOptimization). I'd further wager that if you repeat the timing a few times, you'll find that on some runs t2 is less than t3. Best, Brian vdB ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Astonishing timing result
At 02:06 PM 6/24/2008, [EMAIL PROTECTED] wrote: - Message from [EMAIL PROTECTED] - Date: Tue, 24 Jun 2008 13:44:00 -0700 From: Dick Moores [EMAIL PROTECTED] At 12:44 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 1:43 PM, Dick Moores [EMAIL PROTECTED] wrote: Output: t1 is 0.000104, no function t2 is 5.87e-006, function explicit t3 is 0.000126, function imported t1/t2 is 17.8 t1/t3 is 0.827 t3/t2 is 21.5 Now, I'd heard that code in a function runs faster than the same code not in a function, but even so I was surprised at the t1/t2 ratio of 17.8. The astonishing (to me, anyway) result was the t3/t2 ratio. I had no idea that importing from mycalc slowed a script down at all, let alone by a factor of 21! Note that t1 and t3 are pretty close to each other. Perhaps you should be suspicious of t2. What if __name__ != '__main__' ? With that, t1 is 0.000104, no function t2 is 0.000117, function explicit t3 is 0.000113, function imported t1/t2 is 0.885 t1/t3 is 0.914 t3/t2 is 0.969 Explain? Dick Hey Dick, I'm not too clear on what it is that you want explained. Well, Kent suggested trying if __name__ != '__main__' . Why would that make such a difference? It seems to me that the difference between t2 and t3 is 1) is so small as to be most likely due to (effectively) random fluctuations of your environment (the demands that other processes were making on your system at the time) and 2) so small so as to not be worth worrying about (http://c2.com/cgi/wiki?PrematureOptimization). Basically, I'm not worried, just curious. Not about the small differences, but why did the use of the standardif __name__ == '__main__' result it such speed? This was not a fluke. Before posting, I got similar results with different functions, albeit not quite as extreme. Am I not doing the timing correctly? Dick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] closing a internet explorer com object
On 25/06/2008, Jeff Peery [EMAIL PROTECTED] wrote: hello, I'm using internet explorer to print out html documents and I'm not sure how to close it once it is created. How do I do this? below is the simple bit of code I use to print documents. ie = win32com.client.Dispatch(InternetExplorer.Application) You may be able to call ie.Close(True) or ie.Exit(True) or something like that -- I'm not sure. If you run the MakePy utility (from the pythonwin tools menu, or just run the script) it will generate python code that includes effectively method signatures for the different COM objects you can control. By inspecting this, you may be able to learn what methods you can call on InternetExplorer.Application objects and what arguments you need to give them. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python to exe--how much work?
Keith Suda-Cederquist [EMAIL PROTECTED] wrote Question: How hard is it to convert python code to an exe? Not too hard if you know computers. Quite hard for a complete novice. py2exe seems to be the most popular option. Details: I've written some test software in python for my company. We'd like to be able to distribute the software without having to install python on the instrument computer. If you'd written it in Java would you use a native compiler for Java or just install the JRE on the target PC? If you used .NET would you insist on compiling the C# to exe or just install .NET on the target? Why not do the same for python? The software itself is several hundred lines of code, If you said 10s of thousands of lines I might be concerned. Hundreds is near trivial. that imports and uses several modules: SciPy, NumPy, PIL (python imaging library) and matplotlib. I'm not aware of anty issues with those modules/libraries but you never know till you try! harder will this be for longer code with more modules imported? For a few hundred lines it shouldn't be much harder. 3) We could have someone in-house port the code to C or VB. That shouldn't really be needed, it would be much cheaper and more reliable to just install Python - its not very big and thats all the exe 'copilers' do anyway. They just package the interpreter and libraries into a self launching file! In fact if you are going to have several such scripts you really should install Python, it will take up much less room and resource than installing a version of Python for each script! [ You may have gathered that I'm not a big fan of compiling python to exe's - I've rarely seen a valid case for it :-] -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Astonishing timing result
On Tue, June 24, 2008 2:06 pm, [EMAIL PROTECTED] wrote: - Message from [EMAIL PROTECTED] - Date: Tue, 24 Jun 2008 13:44:00 -0700 From: Dick Moores [EMAIL PROTECTED] At 12:44 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 1:43 PM, Dick Moores [EMAIL PROTECTED] wrote: Output: t1 is 0.000104, no function t2 is 5.87e-006, function explicit t3 is 0.000126, function imported t1/t2 is 17.8 t1/t3 is 0.827 t3/t2 is 21.5 Now, I'd heard that code in a function runs faster than the same code not in a function, but even so I was surprised at the t1/t2 ratio of 17.8. The astonishing (to me, anyway) result was the t3/t2 ratio. I had no idea that importing from mycalc slowed a script down at all, let alone by a factor of 21! Note that t1 and t3 are pretty close to each other. Perhaps you should be suspicious of t2. What if __name__ != '__main__' ? With that, t1 is 0.000104, no function t2 is 0.000117, function explicit t3 is 0.000113, function imported t1/t2 is 0.885 t1/t3 is 0.914 t3/t2 is 0.969 Explain? Does this mean that if __name__ == __main__ takes the extra time? and that that's brings t2 in line with the others? and that the difference represents the time it takes to set up a code-block? Something like that? Marilyn Davis Dick Hey Dick, I'm not too clear on what it is that you want explained. It seems to me that the difference between t2 and t3 is 1) is so small as to be most likely due to (effectively) random fluctuations of your environment (the demands that other processes were making on your system at the time) and 2) so small so as to not be worth worrying about (http://c2.com/cgi/wiki?PrematureOptimization). I'd further wager that if you repeat the timing a few times, you'll find that on some runs t2 is less than t3. Best, Brian vdB ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Astonishing timing result
At 04:49 PM 6/24/2008, Marilyn Davis wrote: Does this mean that if __name__ == __main__ takes the extra time? and that that's brings t2 in line with the others? I don't think so. Please refer to the code again: http://py77.python.pastebin.com/f152b6c14. Line 21 is if __name__ == '__main__': . Changing this line to if __name__ != '__main__': increases the time dramatically. But maybe you meant if __name__ != '__main__': ? If so, you must be correct. But what's going on here?? Hey, Kent? and that the difference represents the time it takes to set up a code-block? What's a code-block? Dick Something like that? Marilyn Davis ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Astonishing timing result
On Tue, Jun 24, 2008 at 5:20 PM, Dick Moores [EMAIL PROTECTED] wrote: Basically, I'm not worried, just curious. Not about the small differences, but why did the use of the standardif __name__ == '__main__' result it such speed? Because __name__ is not equal to __main__, so you were basically skipping the whole test. The most common cause of unexpected timing results is tests that don't do what you think they do. The test code is not run in the main module. You can dig into the timeit module if you want the details. Am I not doing the timing correctly? Right. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Astonishing timing result
At 05:35 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 5:20 PM, Dick Moores [EMAIL PROTECTED] wrote: Basically, I'm not worried, just curious. Not about the small differences, but why did the use of the standardif __name__ == '__main__' result it such speed? Because __name__ is not equal to __main__, so you were basically skipping the whole test. Ah. The most common cause of unexpected timing results is tests that don't do what you think they do. The test code is not run in the main module. You can dig into the timeit module if you want the details. OK, I'll dig. Thanks, Dick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python to exe--how much work?
On 25/06/2008, Alan Gauld [EMAIL PROTECTED] wrote: Keith Suda-Cederquist [EMAIL PROTECTED] wrote that imports and uses several modules: SciPy, NumPy, PIL (python imaging library) and matplotlib. I'm not aware of anty issues with those modules/libraries but you never know till you try! I've used PIL and py2exe -- PIL does some dynamic imports that confuse py2exe's module finder. From memory, it was easy enough to fix -- you just need to include extra import statements, so that the modules you need are in the bundle. (e.g. something like from PIL import GifImagePlugin if you will be using GIFs) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] python mechanize - clicking javascript button
Hi, I'm having a bit of a problem and am hoping that someone can assist (I realize this may be slightly off-topic, but I haven't found a good place to post this question, so... ;)) I'm writing a script to interact with a website. There's a form similar to the following in the website: form name=form method=post action=push.do ...stuff... input type=button name=button value=delete onclick=javascript:delete(); class=button ...stuff... Everything in this form is sent to the server and push.do is the script that runs in the backend. There is *one* button, however, will change the action on the form to delete.do, as can be seen in the javascript function definition below: function delete() { document.form.action = delete.do; document.form.submit(); } Seems simple enough, right? When I use mechanize and print the form that I'm working with (name=form), I see the following: br.select_form(name=form) print br.form form POST delete() application/x-www-form-urlencoded HiddenControl(number=2321) (readonly) HiddenControl(sessionIdentification=115) (readonly) IgnoreControl(button=None) TextControl(string=Hello World) SelectControl(code=[ code1, *code2, code3, code4, code5]) SelectControl(codeClass=[1, 2, 3, 4, 5, 6, *7, 8]) SubmitControl(button=Commit) (readonly) IgnoreControl(button=None) The only other button on this form is Commit, which apparently results in a POST to push.do. The javascript delete button is the *only* entity in the form that POSTs to delete.do. The Python mechanize website states that in this situation the best thing to do is set up a POST to the web server (since mechanize cannot interpret javascript). A few things boggle me: a) When submitting the form, how do I deal with cookies? I'm unsure about how to pass the web tool the appropriate cookie (I'm not even sure the web server wants a cookie in the first place) b) Do I have to pass *all* the values listed in the print br.form? If not, then how do I figure out what precisely the server requires from a POST? (TamperData seems to indicate that most of the stuff is sent to the server on *either* button click, but I'm not sure...is there a better way to find out?) d) Is POST my only option, or is there a simpler way? I realize the only thing the javascript snippet is doing is changing the form action from push.do to delete.do...seems like something simple enough to change without writing code to set up a POST. (I've tried, but have not had any success, unfortunately). Can I modify the form? (how would I go about modifying br.form, anyways?) ... I found a website that explains how to set up a POST in Python using urllib2, below: http://love-python.blogspot.com/2008/04/get-content-html-source-of-url-by-http.html It structures the post as follows: url = 'http://www.example.com' values = {'key1' : 'value1', 'key2' : 'value2', 'key3' : 'value3', } try: data = urllib.urlencode(values) req = urllib2.Request(url, data) response = urllib2.urlopen(req) the_page = response.read() print the_page except Exception, detail: print Err , detail Is this the best way to set up a POST? (by configuring a dictionary with all the values that are required for the post?) I believe the last time I tried doing this the server returned a 501 error. Any thoughts *greatly* appreciated! - j ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [Fwd: Re: Astonishing timing result]
On Tue, June 24, 2008 5:52 pm, Dick Moores wrote: At 05:35 PM 6/24/2008, Kent Johnson wrote: On Tue, Jun 24, 2008 at 5:20 PM, Dick Moores [EMAIL PROTECTED] wrote: Basically, I'm not worried, just curious. Not about the small differences, but why did the use of the standardif __name__ == '__main__' result it such speed? Because __name__ is not equal to __main__, so you were basically skipping the whole test. Ah. Ah. So the difference we see is the whole sort. That makes sense. Thank you for the understanding. Has anyone ever timed the difference between using a function that was imported with: from my_module import MyFunction and: import my_module and then my_module.MyFunction() Also, if anyone is still wondering, a code block is the stuff that is indented. The stuff between a ':' and the unindent. Marilyn Davis The most common cause of unexpected timing results is tests that don't do what you think they do. The test code is not run in the main module. You can dig into the timeit module if you want the details. OK, I'll dig. Thanks, Dick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] python web documentation ( without frameworks?)
Hi Everyone This is my first post here. I would like to switch from php/mysql to python(mod_python) and postgresql. There are several recent books on cherrypy, django and turbogears but for some reason I just don't want to use a framework. Are there any current books you could recommend for general python web programming? Most of the general web programming books seem to be from 2004 or before. Thanks-Patrick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Astonishing timing result
At 07:00 PM 6/24/2008, Marilyn Davis wrote: Has anyone ever timed the difference between using a function that was imported with: from my_module import MyFunction and: import my_module Here are 2 comparisons: http://py77.python.pastebin.com/f53ab3769, and http://py77.python.pastebin.com/f68346b28 I don't see a significant difference. Dick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor