Re: [Tutor] a graceful program exit

2010-08-11 Thread Hugo Arts
On Wed, Aug 11, 2010 at 11:06 PM, James Mills wrote: > On Thu, Aug 12, 2010 at 1:42 PM, Bill Allen wrote: >> I have only learned a couple of ways to cause a Python program to exit: >> sys.exit(0)  &  raise.SystemExit .  I am using this in a try/except block. >> Which is preferred?  Are there othe

[Tutor] Performance list vs. deque for [-1]

2010-08-11 Thread Knacktus
Hi everyone, I'm wondering what's the fastet datatype in python to lookup the last element in an ordered collection. I know about lists, of course, and read about deques. As I understand deques have better performance for popping and adding elements, but I didn't understand what's the behavior

Re: [Tutor] Executing Python from TCL

2010-08-11 Thread Karim
Hello Alan, I want to take benefit of xml.etree.ElementTree and xml.etree.CElementTree, which are very good and do most of the job for me (create automatically database with lists and dictionary for me). My point is to do a same API used by team developing with Python and another team develop

Re: [Tutor] a graceful program exit

2010-08-11 Thread James Mills
On Thu, Aug 12, 2010 at 1:42 PM, Bill Allen wrote: > I have only learned a couple of ways to cause a Python program to exit: > sys.exit(0)  &  raise.SystemExit .  I am using this in a try/except block. > Which is preferred?  Are there other, better ways? The normal pattern is to have an entry poi

[Tutor] a graceful program exit

2010-08-11 Thread Bill Allen
I have only learned a couple of ways to cause a Python program to exit: sys.exit(0) & raise.SystemExit . I am using this in a try/except block. Which is preferred? Are there other, better ways? Thanks, Bill Allen ___ Tutor maillist - Tutor@python.

Re: [Tutor] problem loading and array from an external file

2010-08-11 Thread Bill Allen
On Wed, Aug 11, 2010 at 10:09 PM, Luke Paireepinart wrote: > Don't pass none. It's an optional parameter. It's accepted practice to not > pass optional parameters. > > Sent from my iPhone > > On Aug 11, 2010, at 6:46 PM, Bill Allen wrote: > > >> > >> You don't actually have to specify the None in

Re: [Tutor] problem loading and array from an external file

2010-08-11 Thread Luke Paireepinart
Don't pass none. It's an optional parameter. It's accepted practice to not pass optional parameters. Sent from my iPhone On Aug 11, 2010, at 6:46 PM, Bill Allen wrote: > On Tue, Aug 10, 2010 at 11:11 AM, Hugo Arts wrote: >> On Tue, Aug 10, 2010 at 9:59 AM, bob gailer wrote: >>> On 8/10/2010

Re: [Tutor] problem loading and array from an external file

2010-08-11 Thread Bill Allen
On Wed, Aug 11, 2010 at 6:59 PM, Alan Gauld wrote: > > > You will find a basic description in the Functional Programming > topic of my tutorial. > > HTH, > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > > Alan, Awesome website! Thanks! I have a buddy

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Alan Gauld
"Laurens Vets" wrote next to each other. I came up with the following (Please ignore the fact that I'm trying to avoid an IndexError in a stupid way :)): Others have answered your question. I'll suggest that instead of using indexes its easier to just cache the last two values in variable

Re: [Tutor] Executing Python from TCL

2010-08-11 Thread Alan Gauld
"Karim" wrote I want to know if there are modules or whatever to execute python functions inside TCL. Not that I know of, unless Google tells you something different. You can of course call Python programs from Tcl and vice-versa. If you use the Java versions of both you might succeed. O

Re: [Tutor] Module for browsing Windows?

2010-08-11 Thread Alan Gauld
"Chorn, Guillaume" wrote there is a Python module out there that allows you to browse to and select files using a Windows-style interface. Thanks! EasyGUI is designed for exactly that kind of mixed mode programming. You can find a basic intro in the Talking to the User topic of my tutori

Re: [Tutor] problem loading and array from an external file

2010-08-11 Thread Alan Gauld
"Bill Allen" wrote second method today on my own. That third method is fascinating. I have not heard of "list comprehension" before. That must be unique Python lingo. What is the principle behind that? Its not unique to Python, Haskell had it first. It is based on mathematical set notati

Re: [Tutor] Scripting Blender

2010-08-11 Thread Lee Harr
> Are there any Python modules to script Blender? For example, placing > predefined objects into a new Blender project to create a 3D model. If you are using 2.5, I saw this posted on blendernation.com just today: http://blenderartists.org/forum/showthread.php?t=193908

Re: [Tutor] problem loading and array from an external file

2010-08-11 Thread Bill Allen
On Tue, Aug 10, 2010 at 11:11 AM, Hugo Arts wrote: > On Tue, Aug 10, 2010 at 9:59 AM, bob gailer wrote: >> On 8/10/2010 10:42 AM, Bill Allen wrote: >>> >>> Bob, >>> >>> I was really off on that algorithm and had way over complicated it. >>> I have it working correctly now, but for the sake of tho

Re: [Tutor] problem loading and array from an external file

2010-08-11 Thread Bill Allen
On Tue, Aug 10, 2010 at 9:59 AM, bob gailer wrote: > On 8/10/2010 10:42 AM, Bill Allen wrote: >> >> Bob, >> >> I was really off on that algorithm and had way over complicated it. >> I have it working correctly now, but for the sake of those who saw my >> earlier really botched code, here is the re

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Steven D'Aprano
On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: > I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, > 4, 5 & 6. However, I cannot have more than 2 numbers which are the > same next to each other. I came up with the following (Please ignore > the fact that I'm trying to avo

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Emile van Sebille
On 8/11/2010 2:04 PM Laurens Vets said... Hello list, I'm learning Python and I'm currently facing an issue with a small script I'm writing. I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5 & 6. However, I cannot have more than 2 numbers which are the same next to each

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Evert Rol
> I'm learning Python and I'm currently facing an issue with a small script I'm > writing. > > I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5 & > 6. However, I cannot have more than 2 numbers which are the same next to each > other. I came up with the following (Plea

[Tutor] Need help understanding output...

2010-08-11 Thread Laurens Vets
Hello list, I'm learning Python and I'm currently facing an issue with a small script I'm writing. I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5 & 6. However, I cannot have more than 2 numbers which are the same next to each other. I came up with the following (P

[Tutor] Executing Python from TCL

2010-08-11 Thread Karim
Hello Tutors, I want to know if there are modules or whatever to execute python functions inside TCL. These functions should returns python lists as TCL lists and Python dictionary as TCL Hash tables. Existing (opensource) tools, packages are welcome! I want to avoid to do it myself (anyway I d

Re: [Tutor] Lost in the control flow

2010-08-11 Thread Eduardo Vieira
On Tue, Aug 10, 2010 at 1:56 PM, Adam Bark wrote: > > The problem is you don't call make_dict unless there's a "FUEL SURCHARGE" or > multiple pins. Also you don't add the first pin to mydict["tracking"] unless > there's a "FUEL SURCHARGE". > > HTH, > Adam. > __

Re: [Tutor] Scripting Blender

2010-08-11 Thread Mark Young
2010/8/11 Corey Richardson > Yes. It's called the Python API, it comes with Blender ;) bpy and Blender > are the top modules. There are submodules for everything. The reference is > here: http://www.blender.org/documentation/249PythonDoc/index.html > > HTH, > ~Corey Richardson > > aug dawg wrote:

Re: [Tutor] elif statement

2010-08-11 Thread Karim
Hello, This code works for me: >>> x=3 >>> if x==0: ... print "x is 0" ... elif x&1 ==1: ... print "x is a odd number" ... elif x&1==0: ... print "x is a even number" ... x is a odd number So I think you copied by error the string '-- Line 6' in you example given that has nothing

Re: [Tutor] import errors

2010-08-11 Thread Joel Goldstick
On Wed, Aug 11, 2010 at 12:06 PM, Emile van Sebille wrote: > On 8/11/2010 8:48 AM Pete said... > > Hi, >> >> A common line I've seen in Python code I come across is: >> >> #!/usr/bin/python >> import os >> import sys >> import errors >> > > > ... so there seem to be more than one 'errors.py' -

Re: [Tutor] import errors

2010-08-11 Thread Emile van Sebille
On 8/11/2010 8:48 AM Pete said... Hi, A common line I've seen in Python code I come across is: #!/usr/bin/python import os import sys import errors ... so there seem to be more than one 'errors.py' - one for the email module, one for Skype4Py, etc. How does the interpreter know which one t

Re: [Tutor] [SPAM]Re: O'Reilly is offering Learning Python (4th ed.), eBook form for USD 9.99

2010-08-11 Thread David Hutto
I thought the open source mentality of python was it own 'perpetual bible'. A building of disciples so to speak. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] import errors

2010-08-11 Thread Pete
Hi, A common line I've seen in Python code I come across is: #!/usr/bin/python import os import sys import errors I was wondering about the line that says, "import errors". I understand what it's for, but what I don't get is how Python knows which 'errors.py' to import. On my laptop: macbook:

Re: [Tutor] Module for browsing Windows?

2010-08-11 Thread Wayne Werner
On Tue, Aug 10, 2010 at 7:17 PM, Chorn, Guillaume wrote: > Hello, > > I'm pretty new to Python programming and it is my first programming > language. I made a script that uses data from two different .csv files to > make calculations and then spit the results out in a third .csv file. > However

Re: [Tutor] Scripting Blender

2010-08-11 Thread Corey Richardson
Yes. It's called the Python API, it comes with Blender ;) bpy and Blender are the top modules. There are submodules for everything. The reference is here: http://www.blender.org/documentation/249PythonDoc/index.html HTH, ~Corey Richardson aug dawg wrote: Are there any Python modules to script

Re: [Tutor] [SPAM]Re: O'Reilly is offering Learning Python (4th ed.), eBook form for USD 9.99

2010-08-11 Thread Todd Nannie
If you click on the ONE DAY DEAL on the front page it still list the Python book and several others. I just bought the python book for 9.99 Todd -Original Message- From: tutor-bounces+tnannie=strdetail@python.org [mailto:tutor-bounces+tnannie=strdetail@python.org] On Behalf Of Ben

Re: [Tutor] O'Reilly is offering Learning Python (4th ed.), eBook form for USD 9.99

2010-08-11 Thread Robert
Rather depressing to see what's generally considered "Bible on Python" among those other boring, nondescript books. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Scripting Blender

2010-08-11 Thread aug dawg
Are there any Python modules to script Blender? For example, placing predefined objects into a new Blender project to create a 3D model. Thanks! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org

Re: [Tutor] O'Reilly is offering Learning Python (4th ed.), eBook form for USD 9.99

2010-08-11 Thread Felix Santiago
On Aug 11, 2010, at 9:30 AM, Benjamin Castillo wrote: The site shows 39.99 for ebook. Ben --- On Wed, 8/11/10, Richard D. Moores wrote: From: Richard D. Moores Subject: [Tutor] O'Reilly is offering Learning Python (4th ed.), eBook form for USD 9.99 To: tutor@python.org Date: Wednesday

Re: [Tutor] O'Reilly is offering Learning Python (4th ed.), eBook form for USD 9.99

2010-08-11 Thread Benjamin Castillo
The site shows 39.99 for ebook. Ben --- On Wed, 8/11/10, Richard D. Moores wrote: > From: Richard D. Moores > Subject: [Tutor] O'Reilly is offering Learning Python (4th ed.), eBook form > for USD 9.99 > To: tutor@python.org > Date: Wednesday, August 11, 2010, 1:45 AM > I already own the PDF

Re: [Tutor] Indentation woes in elif statement

2010-08-11 Thread Joel Goldstick
On Tue, Aug 10, 2010 at 9:11 PM, rara avis wrote: > Hi: I am trying to teach myself Python, and am stuck at the indentation > with the elif statement. > This is what I am trying to type: > > x=3 > if x==0: > > > ___ > Tutor maillist - Tutor@python.org

Re: [Tutor] Making String

2010-08-11 Thread Joel Goldstick
On Tue, Aug 10, 2010 at 6:22 PM, Steven D'Aprano wrote: > On Wed, 11 Aug 2010 06:09:28 am Joel Goldstick wrote: > > The str part of str.join() is the string where the result is stored, > > so you can start off with an empty string: "" > > I don't understand what you mean by that. I can only imagin

Re: [Tutor] Indentation woes in elif statement

2010-08-11 Thread Andre Engels
On Wed, Aug 11, 2010 at 3:11 AM, rara avis wrote: > Hi: I am trying to teach myself Python, and am stuck at the indentation with > the elif statement. > This is what I am trying to type: > > x=3 > if x==0: What are you trying to accomplish? What result did you expect to get? What result did you a

[Tutor] O'Reilly is offering Learning Python (4th ed.), eBook form for USD 9.99

2010-08-11 Thread Richard D. Moores
I already own the PDF, as well as the paperback (1160 pages), but I thought I'd let the list know. See the deal, good for just today, on . The 4th edition covers both Python 2.6 and 3.x. So what does "today" mean? Beats me. O'Reilly's corporate headquarters ar

Re: [Tutor] elif statement

2010-08-11 Thread Dipo Elegbede
You need to check the indentation properly. In this case, elif has to be on the same indentation level with if. I should think so. If you're working straight from the python interactive console, like I think you're doing, you need to manually do the indentation thing by yourself. First, I don't und

Re: [Tutor] Module for browsing Windows?

2010-08-11 Thread Tim Golden
On 11/08/2010 01:17, Chorn, Guillaume wrote: Hello, I'm pretty new to Python programming and it is my first programming language. I made a script that uses data from two different .csv files to make calculations and then spit the results out in a third .csv file. However, the process of typing

[Tutor] Indentation woes in elif statement

2010-08-11 Thread rara avis
Hi: I am trying to teach myself Python, and am stuck at the indentation with the elif statement. This is what I am trying to type: x=3 if x==0: ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/

[Tutor] Module for browsing Windows?

2010-08-11 Thread Chorn, Guillaume
Hello, I'm pretty new to Python programming and it is my first programming language. I made a script that uses data from two different .csv files to make calculations and then spit the results out in a third .csv file. However, the process of typing in the path to each of the two input files and