Re: [Tutor] Active State Python with IDLE Python 2.5

2009-01-12 Thread Alan Gauld
Wayne Watson sierra_mtnv...@sbcglobal.net wrote I installed Python 2.5 a few months ago, and decided I'd like to try windowpy from ActiveState. Is having both of these installed going to cause me trouble? Multiple versions of Python should not be a problem provided you put them in

Re: [Tutor] 2to3 Help?

2009-01-12 Thread Alan Gauld
Marco Petersen marco.m.peter...@gmail.com wrote I have Python 3.0. I tried to use the 2to3 program included with the interpreter to convert some scripts for Python 2.5 to Python 3.0 ones. When I try to start it form the Python command line, it says it is a syntax error. Its always best to

Re: [Tutor] Active State Python with IDLE Python 2.5

2009-01-12 Thread Wayne Watson
Title: Signature.html Thanks. Is it possible to just disable the vanilla version? I may want to switch between the two. Most users of the program I'm about to modify use the vanilla version. At some point, I may want to go back to it to verify that in their world all is OK. Alan Gauld wrote:

Re: [Tutor] 2to3 Help?

2009-01-12 Thread Kent Johnson
On Mon, Jan 12, 2009 at 3:56 AM, Alan Gauld alan.ga...@btinternet.com wrote: Marco Petersen marco.m.peter...@gmail.com wrote This was the line of code: $ 2to3 testscript.py But I suspect... this will run your default python interpreter which is likely to still be your 2.5 version. THe

Re: [Tutor] 2to3 Help?

2009-01-12 Thread Vern Ceder
Marco Petersen marco.m.peter...@gmail.com wrote This was the line of code: $ 2to3 testscript.py But I suspect... this will run your default python interpreter which is likely to still be your 2.5 version. THe convertion scrpt is almost certainly 3.0. So I think you will need to explicitly

[Tutor] Selecting first matching element from a list

2009-01-12 Thread Noufal Ibrahim
Hello everyone, What is the pythonic was of selecting the first element of a list matching some condition? I often end up using [x for x in lst if cond(x)][0] This looks bad and raises IndexError if nothing is found which is ugly too. Thanks. -- ~noufal

Re: [Tutor] Selecting first matching element from a list

2009-01-12 Thread bob gailer
Noufal Ibrahim wrote: Hello everyone, What is the pythonic way of selecting the first element of a list matching some condition? I often end up using [x for x in lst if cond(x)][0] This looks bad and raises IndexError if nothing is found which is ugly too. 1)

Re: [Tutor] Selecting first matching element from a list

2009-01-12 Thread wesley chun
1) itertools.dropwhile(cond, lst) will return a list with the desired element first. i think in order to use this, the OP needs to invert his Boolean logic because it *drops* elements while the conditional is True. as soon as it hits False the 1st time, all remaining elements (including the

Re: [Tutor] Selecting first matching element from a list

2009-01-12 Thread Kent Johnson
On Mon, Jan 12, 2009 at 12:21 PM, bob gailer bgai...@gmail.com wrote: Noufal Ibrahim wrote: Hello everyone, What is the pythonic way of selecting the first element of a list matching some condition? I often end up using [x for x in lst if cond(x)][0] This looks

[Tutor] Deleting recursive folder definition

2009-01-12 Thread Alan Gauld
I've managed to do something incredibly stupid on my XP box. I've created a folder that is a link to itself - at least I think that's what has happened, it was a CASE tool that I was using that actually did the damage. The symptoms are that I can infinitely navigate down to the next level. I

Re: [Tutor] Deleting recursive folder definition

2009-01-12 Thread Lawrence Wickline
did you try rd /s /q from the root directory command prompt? -L On Jan 12, 2009, at 11:07 AM, Alan Gauld wrote: I've managed to do something incredibly stupid on my XP box. I've created a folder that is a link to itself - at least I think that's what has happened, it was a CASE tool that I

Re: [Tutor] Deleting recursive folder definition

2009-01-12 Thread Daniele
From: Alan Gauld alan.ga...@freenet.co.uk Date: Mon, 12 Jan 2009 19:07:23 - Subject: [Tutor] Deleting recursive folder definition I've managed to do something incredibly stupid on my XP box. I've created a folder that is a link to itself - at least I think that's what has happened, it

Re: [Tutor] Deleting recursive folder definition

2009-01-12 Thread Jerry Hill
On Mon, Jan 12, 2009 at 2:07 PM, Alan Gauld alan.ga...@freenet.co.uk wrote: I've managed to do something incredibly stupid on my XP box. I've created a folder that is a link to itself - at least I think that's what has happened, it was a CASE tool that I was using that actually did the damage.

Re: [Tutor] Deleting recursive folder definition

2009-01-12 Thread Mark Tolonen
Alan Gauld alan.ga...@freenet.co.uk wrote in message news:50c11a8b9db748fa9e6e892067cce...@xp... I've managed to do something incredibly stupid on my XP box. I've created a folder that is a link to itself - at least I think that's what has happened, it was a CASE tool that I was using that

[Tutor] Optional parameter passing

2009-01-12 Thread wormwood_3
Hello all, I have used *args and **kwargs to have a function accept optional parameters, but is there a lazy way to optionally pass parameters? For example, say my script can accept a number of parameters for a database connection, such as user, password, and database name. The function that

Re: [Tutor] Optional parameter passing

2009-01-12 Thread wormwood_3
A small correction to my code, although the point was hopefully still clear: if options.user: do_mysql_query(options.user) else: do_mysql_query() From: wormwood_3 wormwoo...@yahoo.com To: Python Tutorlist tutor@python.org Sent: Monday, January 12,

Re: [Tutor] Optional parameter passing

2009-01-12 Thread Kent Johnson
On Mon, Jan 12, 2009 at 4:39 PM, wormwood_3 wormwoo...@yahoo.com wrote: Hello all, I have used *args and **kwargs to have a function accept optional parameters, but is there a lazy way to optionally pass parameters? For example, say my script can accept a number of parameters for a database

[Tutor] HOW DO I PYTHONIZE A BASICALLY BASIC PROGRAM?

2009-01-12 Thread WM.
# The natural numbers(natnum), under 1000, divisible by 3 or by 5 are to be added together. natnum = 0 num3 = 0 num5 = 0 cume = 0 # The 'and' is the 15 filter; the 'or' is the 3 or 5 filter. while natnum = 999: num3 = natnum/3 num5 = natnum/5 if natnum - (num3 * 3) == 0 and natnum -

Re: [Tutor] Optional parameter passing

2009-01-12 Thread wormwood_3
You know, that's a great idea :-) Just using options I could keep my initial checks the same (e.g. making sure needed options were included by looking at options.foo) and pass it along without adding much to the query function. Thanks! ___ Samuel Huckins Homepage -

Re: [Tutor] HOW DO I PYTHONIZE A BASICALLY BASIC PROGRAM?

2009-01-12 Thread Emad Nawfal (عماد نوفل)
On Mon, Jan 12, 2009 at 5:23 PM, WM. wfergus...@socal.rr.com wrote: # The natural numbers(natnum), under 1000, divisible by 3 or by 5 are to be added together. natnum = 0 num3 = 0 num5 = 0 cume = 0 # The 'and' is the 15 filter; the 'or' is the 3 or 5 filter. while natnum = 999: num3 =

[Tutor] Modify a dictionary using csv.DictWriter

2009-01-12 Thread Judith Flores
Hello, I have been struggling a while trying to figure out how to modify a csv file using the csv.DictWriter class. Let's suppose I have the following code: import csv outfile=open('template.csv','w') # This is a pre-existing file that contains 3 variables (3 columns). The variables

Re: [Tutor] Modify a dictionary using csv.DictWriter

2009-01-12 Thread Alan Gauld
Judith Flores jur...@yahoo.com wrote I have been struggling a while trying to figure out how to modify a csv file using the csv.DictWriter class. Let's suppose I have the following code: I have never used DictWriter but... outfile=open('template.csv','w') # This is a pre-existing

Re: [Tutor] Modify a dictionary using csv.DictWriter

2009-01-12 Thread John Fouhy
2009/1/13 Judith Flores jur...@yahoo.com: Hello, Hi Judith, 1. When I run the code above for the first time, the contents of the pre-existing file disappear, if I run the script a second time, now I can see the value of x. This is a consequence of this line:

Re: [Tutor] HOW DO I PYTHONIZE A BASICALLY BASIC PROGRAM?

2009-01-12 Thread bob gailer
WM. wrote: # The natural numbers(natnum), under 1000, divisible by 3 or by 5 are to be added together. natnum = 0 num3 = 0 num5 = 0 cume = 0 # The 'and' is the 15 filter; the 'or' is the 3 or 5 filter. while natnum = 999: num3 = natnum/3 num5 = natnum/5 if natnum - (num3 * 3) == 0

[Tutor] A list of input arguments

2009-01-12 Thread Mr Gerard Kelly
I have a problem with understanding how lists, strings, tuples, number types and input arguments all interact with each other. I have this program, in which I can use the *a structure to input unlimited arguments. As an example, if I use three arguments, it looks like this: def main(): #Play