Re: python docs for beginner programmer?

2009-05-04 Thread Gabriel Genellina
En Sun, 03 May 2009 21:41:47 -0300, Deep_Feelings escribió: Do you think python online docs are good starting point for me? ( i experience with other programming languages ) or should i get giant book or something ? If you have some previous experience with other languages, I think that "

Re: What IDE support python 3.0.1 ?

2009-05-04 Thread JussiJ
On Apr 16, 1:26 pm, Brendon Wickham wrote: > I agree, no IDE needed. Just don't use Notepad! I'm on Mac, so > spoiled for choice of text editors, but I'm sure there's one > or 2 good uns if you're on Windows. The Zeus for Windows IDE is Python aware: http://www.zeusedit.com/python.html It d

Re: Threaded alternatives to smtplib?

2009-05-04 Thread Alex Jurkiewicz
Diez B. Roggisch wrote: Without more code, it's impossible to tell if there is anything peculiar in your usage of the lib. Maybe you close your connections to fast to see several open? Here's the relevant stuff from my (python2.6) code: CONCURRENCY = 3 def threadProcessRecipient(): # Eac

Re: Tkinter, Trouble with Message,Label widget

2009-05-04 Thread Hendrik van Rooyen
"norseman" wrote: > There has to be some way of using a Message or Label (or some) widget as > a simple posting board. There is - look at textvariable - an instance of StringVar that is associated with the widget. If all else fails, you can always use configure to change the text... hth - He

Re: Threaded alternatives to smtplib?

2009-05-04 Thread Gabriel Genellina
En Mon, 04 May 2009 04:19:21 -0300, Alex Jurkiewicz escribió: Diez B. Roggisch wrote: Without more code, it's impossible to tell if there is anything peculiar in your usage of the lib. Maybe you close your connections to fast to see several open? Here's the relevant stuff from my (python2

Re: Multiprocessing.Queue - I want to end.

2009-05-04 Thread Hendrik van Rooyen
"Luis Alberto Zarrabeitia Gomez" wrote: >Quoting Hendrik van Rooyen : >> In fact I happen to believe that anything that does any work needs >> one and only one input queue and nothing else, but I am peculiar >> that way. > >Well, I also need some output. In my case, the outputs are files with th

Re: Strange interaction between timeit and recursion

2009-05-04 Thread Hrvoje Niksic
Steven D'Aprano writes: > I don't understand why my recursive function hits the recursion > limit inside the timeit.Timer when it works outside of it. Probably because your test function is at the very edge of the recursion limit, and timeit.Timer triggers it because it calls it at a deeper stac

Re: Threaded alternatives to smtplib?

2009-05-04 Thread Alex Jurkiewicz
Gabriel Genellina wrote: Try logging the start/stop of your threads. It may be that your threads stop before you think. The above code works correctly only if you fill the queue before starting any thread - because as soon as a thread sees the queue empty, it finishes. You could use the sample

Re: Self function

2009-05-04 Thread bearophileHUGS
Arnaud Delobelle: > >>> def bindfunc(f): > ...     def boundf(*args, **kwargs): > ...         return f(boundf, *args, **kwargs) > ...     return boundf > ...>>> @bindfunc > ... def fac(self, n): > ...     return 1 if n <= 1 else n * self(n - 1) > ...>>> fac(5) > 120 This is cute, now I have two n

Re: Is it better to use threads or fork in the following case

2009-05-04 Thread Diez B. Roggisch
CTO wrote: >> In addition, the zip file format stores the directory at the end of the >> file. So you can't process it until it's completely downloaded. >> Concurrency doesn't help here. > > Don't think that's relevant, if I'm understanding the OP correctly. > Lets say you've downloaded the file

Re: Threaded alternatives to smtplib?

2009-05-04 Thread Diez B. Roggisch
Alex Jurkiewicz wrote: > Gabriel Genellina wrote: >> Try logging the start/stop of your threads. It may be that your >> threads stop before you think. The above code works correctly only if >> you fill the queue before starting any thread - because as soon as a >> thread sees the queue empty, it f

Re: Threaded alternatives to smtplib?

2009-05-04 Thread Diez B. Roggisch
Diez B. Roggisch wrote: > Alex Jurkiewicz wrote: > >> Gabriel Genellina wrote: >>> Try logging the start/stop of your threads. It may be that your >>> threads stop before you think. The above code works correctly only if >>> you fill the queue before starting any thread - because as soon as a >>>

Re: yet another list comprehension question

2009-05-04 Thread Arnaud Delobelle
Snorri H writes: > On May 3, 6:13 am, Ross wrote: >> I'm trying to set up a simple filter using a list comprehension. If I >> have a list of tuples, a = [(1,2), (3,4), (5,None), (6,7), (8, None)] >> and I wanted to filter out all tuples containing None, I would like to >> get the new list b = [(

Re: yet another list comprehension question

2009-05-04 Thread Snorri H
On May 3, 6:13 am, Ross wrote: > I'm trying to set up a simple filter using a list comprehension. If I > have a list of tuples, a = [(1,2), (3,4), (5,None), (6,7), (8, None)] > and I wanted to filter out all tuples containing None, I would like to > get the new list b = [(1,2), (3,4),(6,7)]. > > I

Re: yet another list comprehension question

2009-05-04 Thread David Robinow
On Mon, May 4, 2009 at 2:33 AM, namekuseijin wrote: ls = [(1,2), (3,4), (5, None), (6,7), (8, None)] [(x,y) for (x,y) in ls if y] > [(1, 2), (3, 4), (6, 7)] Nope. That filters out 0 as well as None. Not what the OP asked for. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to walk up parent directories?

2009-05-04 Thread Snorri H
On May 4, 5:04 am, Matthew Wilson wrote: > Is there already a tool in the standard library to let me walk up from a > subdirectory to the top of my file system? Never seen such a standard tool, yet it can be implemented in a way like this def walkup(path): aux = path.rsplit('/') while a

Re: What IDE support python 3.0.1 ?

2009-05-04 Thread Mark
On Wed, 15 Apr 2009 22:45:35 +, Benjamin Peterson wrote: > Why do you think you're wasting time with 2.x? I'm a relative newbie to python as well but I'd agree that there is at least a small degree of time "wasted" learning python 2.x simply because the standard library of python 3.x has been

find sublist inside list

2009-05-04 Thread Matthias Gallé
Hi. My problem is to replace all occurrences of a sublist with a new element. Example: Given ['a','c','a','c','c','g','a','c'] I want to replace all occurrences of ['a','c'] by 6 (result [6,6,'c','g',6]). If I do this with string ('acaccgac') I have the advantage of all the 'find' functions,

Re: Self function

2009-05-04 Thread BJörn Lindqvist
2009/5/4 : > An idea-syntax: > > def fact(n): >    return 1 if n <= 1 else n * inspect.self(n - 1) > > Or even a lambda, because you don't need the name anymore to call the > function: > > fact = lambda n: 1 if n <= 1 else n * self(n - 1) How would it work with methods? class Foo: def fac(se

replacing numbers in LARGE MATRIX with criterium in 2 columns (a--> b)

2009-05-04 Thread Alexzive
Hello, I have this matrix [20*4 - but it could be n*4 , with n~100,000] in file "EL_list" like this: 1, 1, 2, 3 2, 4, 1, 5 3, 5, 1, 6 4, 7, 5, 6 5, 8, 7, 9 6, 8, 5, 7 7,

Re: replacing numbers in LARGE MATRIX with criterium in 2 columns (a--> b)

2009-05-04 Thread Alessandro
On May 4, 2:38 pm, Alexzive wrote: > Hello, > I have this matrix [20*4 - but it could be n*4 , with n~100,000] in > file "EL_list" like this: > > 1, 1, 2, 3 > 2, 4, 1, 5 > 3, 5, 1, 6 > 4, 7, 5, 6 > 5, 8,

Re: find sublist inside list

2009-05-04 Thread bearophileHUGS
Matthias Gallé: > My problem is to replace all occurrences of a sublist with a new element. > Example: > Given ['a','c','a','c','c','g','a','c'] I want to replace all > occurrences of ['a','c'] by 6 (result [6,6,'c','g',6]). There are several ways to solve this problem. Representing a string as a

Re: find sublist inside list

2009-05-04 Thread John O'Hagan
On Mon, 4 May 2009, Matthias Gallé wrote: > Hi. > > My problem is to replace all occurrences of a sublist with a new element. > > Example: > Given ['a','c','a','c','c','g','a','c'] I want to replace all > occurrences of ['a','c'] by 6 (result [6,6,'c','g',6]). > li=['a', 'c', 'a', 'c', 'c', 'g', '

Re: find sublist inside list

2009-05-04 Thread Francesco Guerrieri
On Mon, May 4, 2009 at 3:01 PM, John O'Hagan wrote: > On Mon, 4 May 2009, Matthias Gallé wrote: > > Hi. > > > > My problem is to replace all occurrences of a sublist with a new element. > > > > Example: > > Given ['a','c','a','c','c','g','a','c'] I want to replace all > > occurrences of ['a','c']

Help in getting the IP address of client machines

2009-05-04 Thread M Kumar
Hi, I am using pylons web framework for my server. I need to get the ip address of the client machine which made a request to the server in my python code. How can I do that, I am new to pylons and the existing server has so many applications. looking forward to get some solutions from the kind fr

Default padding for Tkinter grid

2009-05-04 Thread Amr
Hello all, I've been spending the last few days experimenting with Tkinter. The grid manager is nice and easy to use, but I have found that I am often having to specify padx and pady options to every widget I add to my grid. The way I am doing it is to create a dictionary: paddding = {'padx': '1m

Re: [SPAM] Re: Threaded alternatives to smtplib?

2009-05-04 Thread MRAB
Diez B. Roggisch wrote: Alex Jurkiewicz schrieb: Hi all, I'm writing a Python script to do a "mail merge" style email distribution. I create a few python threads and in each one I call `smtpserver = smtplib.SMTP(our.smtpserver.com)`. However, during the sending process, there seems to be only

Re: Code works fine except...

2009-05-04 Thread Ross
On May 3, 10:16 pm, John Yeung wrote: > On May 3, 11:29 pm, Chris Rebert wrote: > > > Probably not the cause of the problem, but where > > did the magic numbers 1.072 and 1.08 come from? > > It is perhaps not the most direct cause of the problem, in the sense > that the magic numbers could take v

Re: find sublist inside list

2009-05-04 Thread bearophileHUGS
Matthias Gallé: >the int that can replace a sublist can be > 255,< You didn't specify your integer ranges. Probably there are many other solutions for your problem, but you have to give more information. Like the typical array size, typical range of the numbers, how much important is total memory

IDE for python 2.6 (auto complete)

2009-05-04 Thread Soumen banerjee
Hello, I have just installed and run python 2.6.2 from the sources available on the website. I notice that SPE (the editor which i used with python 2.5) is not displaying some of the functions new in 2.6 as autocomplete options. Is there any IDE with support for autocomplete in python 2.6 with all

Re: Default padding for Tkinter grid

2009-05-04 Thread Amr
On May 4, 3:57 pm, "Gabriel Genellina" wrote: > En Mon, 04 May 2009 10:27:49 -0300, Amr escribió: > > > I've been spending the last few days experimenting with Tkinter. The > > grid manager is nice and easy to use, but I have found that I am often > > having to specify padx and pady options to ev

Re: Self function

2009-05-04 Thread Steve Howell
On May 3, 3:39 pm, bearophileh...@lycos.com wrote: > Sometimes I rename recursive functions, or I duplicate&modify them, > and they stop working because inside them there's one or more copy of > their old name. > This happens to me more than one time every year. > So I have written this: > > from i

Re: find sublist inside list

2009-05-04 Thread MRAB
Matthias Gallé wrote: bearophileh...@lycos.com wrote: John O'Hagan: li=['a', 'c', 'a', 'c', 'c', 'g', 'a', 'c'] for i in range(len(li)): if li[i:i + 2] == ['a', 'c']: li[i:i + 2] = ['6'] Oh well, I have done a mistake, it seems. Another solution then: 'acaccgac'.replace("ac", c

Re: find sublist inside list

2009-05-04 Thread Matthias Gallé
bearophileh...@lycos.com wrote: John O'Hagan: li=['a', 'c', 'a', 'c', 'c', 'g', 'a', 'c'] for i in range(len(li)): if li[i:i + 2] == ['a', 'c']: li[i:i + 2] = ['6'] Oh well, I have done a mistake, it seems. Another solution then: 'acaccgac'.replace("ac", chr(6)) '\x06\x06cg\x06

Re: Code works fine except...

2009-05-04 Thread Ross
On May 4, 7:01 am, Ross wrote: > On May 3, 10:16 pm, John Yeung wrote: > > > > > On May 3, 11:29 pm, Chris Rebert wrote: > > > > Probably not the cause of the problem, but where > > > did the magic numbers 1.072 and 1.08 come from? > > > It is perhaps not the most direct cause of the problem, in

Re: IDE for python 2.6 (auto complete)

2009-05-04 Thread Mike Driscoll
On May 4, 10:13 am, Soumen banerjee wrote: > Hello, > I have just installed and run python 2.6.2 from the sources available > on the website. I notice that SPE (the editor which i used with python > 2.5) is not displaying some of the functions new in 2.6 as > autocomplete options. Is there any IDE

Re: How to walk up parent directories?

2009-05-04 Thread David Smith
Matthew Wilson wrote: > Is there already a tool in the standard library to let me walk up from a > subdirectory to the top of my file system? > > In other words, I'm looking for something like: > > >>> for x in walkup('/home/matt/projects'): > ... print(x) > /home/matt/projects >

Re: Default padding for Tkinter grid

2009-05-04 Thread Gabriel Genellina
En Mon, 04 May 2009 10:27:49 -0300, Amr escribió: I've been spending the last few days experimenting with Tkinter. The grid manager is nice and easy to use, but I have found that I am often having to specify padx and pady options to every widget I add to my grid. The way I am doing it is to cre

Re: Re: replacing numbers in LARGE MATRIX with criterium in 2 columns (a--> b)

2009-05-04 Thread Dave Angel
Alessandro wrote: On May 4, 2:38 pm, Alexzive wrote: Hello, I have this matrix [20*4 - but it could be n*4 , with n~100,000] in file "EL_list" like this: 1, 1, 2, 3 2, 4, 1, 5 3, 5, 1, 6 4, 7, 5, 6 5,

Re: if statement, with function inside it: if (t = Test()) == True:

2009-05-04 Thread Antoon Pardon
On 2009-04-24, Steven D'Aprano wrote: > On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: > >> Hello, >> >> I'm trying to do a if statement with a function inside it. I want to use >> that variable inside that if loop , without defining it. >> >> def Test(): >> return 'Vla' >> >> I sear

Re: fcntl and siginfo_t in python

2009-05-04 Thread ma
Ok! So, I decided to write a C-extension instead of using ctypes. So far, I create a module called dnotifier and the handler callback receives two arguments, the signal number and the respective file descriptor that was modified. This works beautifully. Now, I want to release this to the public, s

Re: Code works fine except...

2009-05-04 Thread Ross
On May 3, 8:29 pm, John Machin wrote: > On May 4, 12:36 pm, Ross wrote: > > > > > For the past couple weeks, I've been working on an algorithm to > > schedule tennis leagues given court constraints and league > > considerations (i.e. whether it's a singles or a doubles league). Here > > were my r

Re: replacing numbers in LARGE MATRIX with criterium in 2 columns (a--> b)

2009-05-04 Thread MRAB
Alexzive wrote: Hello, I have this matrix [20*4 - but it could be n*4 , with n~100,000] in file "EL_list" like this: 1, 1, 2, 3 2, 4, 1, 5 3, 5, 1, 6 4, 7, 5, 6 5, 8, 7, 9 6, 8, 5,

Re: How to walk up parent directories?

2009-05-04 Thread Matthew Wilson
On Sun 03 May 2009 09:24:59 PM EDT, Ben Finney wrote: > Not every simple function belongs in the standard library :-) Thanks for the help with this! Maybe I'm overestimating how often people need this walkup function. Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: How to walk up parent directories?

2009-05-04 Thread Diez B. Roggisch
Snorri H wrote: > On May 4, 5:04 am, Matthew Wilson wrote: >> Is there already a tool in the standard library to let me walk up from a >> subdirectory to the top of my file system? > > > Never seen such a standard tool, yet it can be implemented in a way > like this > > def walkup(path): >

Re: Your confirmation is required to join the Python-list mailing list

2009-05-04 Thread Allan Yuan
Hi, I just wanna know how to set SYSTEM variables and USER variables of windows, but got no way. Firstly I thought "os.environ + os.system" may work well, but found no way to let "os.environ" run to retrive USER variables. Then I tried win32api, finding the GetEnvironmentVariables() mixing SYSTEM

Re: AutoComplete in C++ Editor for Python

2009-05-04 Thread flamz3d
On May 3, 3:14 pm, Dave Angel wrote: > flam...@gmail.com wrote: > > Hello, > > I am embedding python support in my C++ application and was looking at > > adding "Intellisense" or "AutoComplete" support. > > > I found a way to do it using the "dir" function, but this creates a > > problem. Here's w

Re: Multiprocessing.Queue - I want to end.

2009-05-04 Thread Luis Zarrabeitia
On Monday 04 May 2009 04:01:23 am Hendrik van Rooyen wrote: > This will form a virtual (or real if you have different machines) > systolic array with producers feeding consumers that feed > the summary process, all running concurrently. Nah, I can't do that. The summary process is expensive, but

Re: Code works fine except...

2009-05-04 Thread Aahz
In article <8d4ec1df-dddb-469a-99a1-695152db7...@n4g2000vba.googlegroups.com>, Ross wrote: > >def test_round_robin(players, rounds, courts, doubles = False): >players = range(players) >for week in round_robin(players,rounds,courts): > if doubles == True: > doub

Re: find sublist inside list

2009-05-04 Thread Aahz
In article , =?ISO-8859-1?Q?Matthias_Gall=E9?= wrote: > >My problem is to replace all occurrences of a sublist with a new element. > >Example: >Given ['a','c','a','c','c','g','a','c'] I want to replace all >occurrences of ['a','c'] by 6 (result [6,6,'c','g',6]). What's your goal? After you do

How is the start of my server monitoring code?

2009-05-04 Thread Echo
I just started a project to monitor servers(load, memory, processes, etc) via ssh(using paramiko). And I was hoping to get some input on the design of my project, how pythonic it is, etc. It is quite basic right now. But it is currently able to get load and memory stats from any number of servers.

Re: [ANN] regobj - Pythonic object-based access to the Windows Registry

2009-05-04 Thread Glenn Linderman
On approximately 5/3/2009 7:35 AM, came the following characters from the keyboard of Ryan Kelly: Hi All, I've just released the results of a nice Sunday's coding, inspired by one too many turns at futzing around with the _winreg module. The "regobj" module brings a convenient and clean objec

Re: replacing numbers in LARGE MATRIX with criterium in 2 columns (a--> b)

2009-05-04 Thread Aahz
In article <68d22002-fc0a-4590-9395-c78b6ee41...@r34g2000vba.googlegroups.com>, Alexzive wrote: > >I have this matrix [20*4 - but it could be n*4 , with n~100,000] in >file "EL_list" like this: Take a look at NumPy -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/

Re: IDE for python 2.6 (auto complete)

2009-05-04 Thread Detlev Offenbach
Mike Driscoll wrote: > On May 4, 10:13 am, Soumen banerjee wrote: >> Hello, >> I have just installed and run python 2.6.2 from the sources available >> on the website. I notice that SPE (the editor which i used with python >> 2.5) is not displaying some of the functions new in 2.6 as >> autocompl

Re: find sublist inside list

2009-05-04 Thread John O'Hagan
On Mon, 4 May 2009, Francesco Guerrieri wrote: > On Mon, May 4, 2009 at 3:01 PM, John O'Hagan wrote: > > On Mon, 4 May 2009, Matthias Gallé wrote: > > > Hi. > > > > > > My problem is to replace all occurrences of a sublist with a new > > > element. > > > > > > Example: > > > Given ['a','c','a','c'

Re: Is it better to use threads or fork in the following case

2009-05-04 Thread CTO
> Which brings us backs to the "20 questions"-part of my earlier post. It > could be, but it could also be that processing takes seconds. Or it takes > so long that even concurrency won't help. Who knows? Probably the OP ;) Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list

Open a dialog from MainWindow - pyQT4 - Beginner :-)

2009-05-04 Thread Florian Wollenschein
Dear folks, I'm just working on a pyQT4 version of my txt to html converter thc (see listick.org for details). I created the MainWindow with QT Designer and then converted it to .py with pyuic4. It works well so far. Then I created a new UI for my abtDialog (about dialog for my application).

Personal recommendations for Python and Django on-boarding materials

2009-05-04 Thread Grant Rettke
Hi folks, >From one developer to another, I am looking for some personal recommendations on what are the best materials for fast tracking an on- boarding to Python and Django. I know how to program, get web apps and OO; this is the audience. I have found some good recommendations and stuff on Am

Re: find sublist inside list

2009-05-04 Thread mzdude
On May 4, 9:01 am, Matthias Gallé wrote: > bearophileh...@lycos.com wrote: > > John O'Hagan: > >> li=['a', 'c', 'a', 'c', 'c', 'g', 'a', 'c'] > >> for i  in range(len(li)): > >>     if li[i:i + 2] == ['a', 'c']: > >>         li[i:i + 2] = ['6'] > > > Oh well, I have done a mistake, it seems. > > A

improved search algorithm

2009-05-04 Thread grahamdick77
Hi I have an excel file that is read into python (8000 rows) from csvimport reader, writer incsv = reader(open(MY_FILE), dialect='excel') keys = incsv.next() There are mixed datatypes. the last column contains a cumulative frequency running in order 0. to 1. for the 8000 rows f

Re: Self function

2009-05-04 Thread bearophileHUGS
Steve Howell: >two methods with almost identical names, where one function is the public >interface and then another method that does most of the recursion.< Thanks Guido & Walter both Python and D support nested functions, so in such situations I put the recursive function inside the "public int

pychecker vs pychecker2

2009-05-04 Thread qhfgva
For my edification I was looking through the source code of pychecker. I noticed that there was also a pychecker2 directory (ubuntu). The pychecker command line tool points to pychecker (w/out the 2). Does anyone know off the top of their head what this second directory is about? thanks qhfgva

change some lines from a read file

2009-05-04 Thread utab
Dear all, I have to change some lines from a template file, which is rather long to paste here, but I would like to make some parts of some lines optional with my command line arguments but I could not see this directly, I can count the line numbers and decide on this basis to decide the lines to

Re: improved search algorithm

2009-05-04 Thread MRAB
grahamdic...@gmail.com wrote: Hi I have an excel file that is read into python (8000 rows) from csvimport reader, writer incsv = reader(open(MY_FILE), dialect='excel') keys = incsv.next() There are mixed datatypes. the last column contains a cumulative frequency running in order 0.000

Re: Self function

2009-05-04 Thread Arnaud Delobelle
bearophileh...@lycos.com writes: > Steve Howell: >>two methods with almost identical names, where one function is the >>public interface and then another method that does most of the >>recursion.< > > Thanks Guido & Walter both Python and D support nested functions, so > in such situations I put t

Re: change some lines from a read file

2009-05-04 Thread MRAB
utab wrote: Dear all, I have to change some lines from a template file, which is rather long to paste here, but I would like to make some parts of some lines optional with my command line arguments but I could not see this directly, I can count the line numbers and decide on this basis to decide

Re: Self function

2009-05-04 Thread bearophileHUGS
Arnaud Delobelle: > def fac(n): >     def rec(n, acc): >         if n <= 1: >             return acc >         else: >             return rec(n - 1, n*acc) >     return rec(n, 1) Right, that's another way to partially solve the problem I was talking about. (Unfortunately the performance in Python

Re: Self function

2009-05-04 Thread Aahz
In article , wrote: >Arnaud Delobelle: >> >> Bearophile, there is a thread on python-ideas about tail-call >> optimization at the moment. > >Someday I'll have to start following those mailing lists... >But I am not interested in such optimization. It's not going to help >me significantly. Most t

Re: Personal recommendations for Python and Django on-boarding materials

2009-05-04 Thread Arnaud Delobelle
Grant Rettke writes: > Hi folks, > > From one developer to another, I am looking for some personal > recommendations on what are the best materials for fast tracking an on- > boarding to Python and Django. > > I know how to program, get web apps and OO; this is the audience. > > I have found some

Re: change some lines from a read file

2009-05-04 Thread Anthra Norell
utab wrote: Dear all, I have to change some lines from a template file, which is rather long to paste here, but I would like to make some parts of some lines optional with my command line arguments but I could not see this directly, I can count the line numbers and decide on this basis to decide

Re: yet another list comprehension question

2009-05-04 Thread namekuseijin
On May 4, 9:15 am, David Robinow wrote: > On Mon, May 4, 2009 at 2:33 AM, namekuseijin > > wrote: > ls = [(1,2), (3,4), (5, None), (6,7), (8, None)] > [(x,y) for (x,y) in ls if y] > > [(1, 2), (3, 4), (6, 7)] > > Nope. That filters out 0 as well as None. Not what the OP asked for. True

Re: Self function

2009-05-04 Thread Tim Wintle
On Mon, 2009-05-04 at 19:51 +0100, Arnaud Delobelle wrote: > > Bearophile, there is a thread on python-ideas about tail-call > optimization at the moment. Oooh - haven't noticed that (and don't have time to follow it), but has anyone seen the results I got a week or so ago from briefly playing wi

Re: Self function

2009-05-04 Thread bearophileHUGS
Aahz: > When have you ever had a binary tree a thousand levels deep? Yesterday. >Consider how big 2**1000 is...< You are thinking just about complete binary trees. But consider that a topology like a single linked list (every node has 1 child, and they are chained) is a true binary tree still.

Re: Code works fine except...

2009-05-04 Thread Ross
On May 4, 12:15 pm, a...@pythoncraft.com (Aahz) wrote: > In article <8d4ec1df-dddb-469a-99a1-695152db7...@n4g2000vba.googlegroups.com>, > > Ross   wrote: > > >def test_round_robin(players, rounds, courts, doubles = False): > >    players = range(players) > >    for week in round_robin(players,round

Re: AutoComplete in C++ Editor for Python

2009-05-04 Thread Dave Angel
flam...@gmail.com wrote: On May 3, 3:14 pm, Dave Angel wrote: flam...@gmail.com wrote: Hello, I am embedding python support in my C++ application and was looking at adding "Intellisense" or "AutoComplete" support. I found a way to do it using the "dir" function, but this creates

Re: IDE for python 2.6 (auto complete)

2009-05-04 Thread Dave Angel
Soumen banerjee wrote: Hello, I have just installed and run python 2.6.2 from the sources available on the website. I notice that SPE (the editor which i used with python 2.5) is not displaying some of the functions new in 2.6 as autocomplete options. Is there any IDE with support for autocomplet

Re: How to walk up parent directories?

2009-05-04 Thread Dave Angel
Matthew Wilson wrote: On Sun 03 May 2009 09:24:59 PM EDT, Ben Finney wrote: Not every simple function belongs in the standard library :-) Thanks for the help with this! Maybe I'm overestimating how often people need this walkup function. Matt Look at os.path.normpath(os.path.j

Re: Threaded alternatives to smtplib?

2009-05-04 Thread Piet van Oostrum
> Alex Jurkiewicz (AJ) wrote: >AJ> def threadProcessRecipient(): [snip] >AJ> if __name__ == '__main__': >AJ>THREADS = [] >AJ>for i in range(CONCURRENCY): >AJ>THREADS.append(threading.Thread(target=threadProcessRecipient)) >AJ>for thread in THREADS: >AJ>thread.run()

Re: change some lines from a read file

2009-05-04 Thread norseman
watch out for: for i in file... often returns just one character at a time, meaning you will have to track EOL's yourself OR import the readline and use it to stand a better chance of getting what you expect from a read file function. Today: 20090504 Logic outline, No particular version

Re: change some lines from a read file

2009-05-04 Thread norseman
watch out for: for i in file... often returns just one character at a time, meaning you will have to track EOL's yourself OR import the readline and use it to stand a better chance of getting what you expect from a read file function. Today: 20090504 Logic outline, No particular versio

Re: Self function

2009-05-04 Thread Chris Rebert
On Mon, May 4, 2009 at 1:25 PM, wrote: > Aahz: >> When have you ever had a binary tree a thousand levels deep? > > Yesterday. > > >>Consider how big 2**1000 is...< > > You are thinking just about complete binary trees. > But consider that a topology like a single linked list (every node has > 1 c

Re: Is there is any way to send messages to chunk of emails ID's concurrently using smptlib

2009-05-04 Thread Piet van Oostrum
> gganesh (g) wrote: >g> Hi friends, >g> I suppose sendmail() can send mails one by one ,how to send mails >g> concurrently , >g> It would be very grateful,if someone could point out a solution. There is a discussion about this in the thread `Threaded alternatives to smtplib?' -- Piet van

Re: SYSTEM and USER environment (was Your confirmation is required to join the Python-list mailing list)

2009-05-04 Thread Dave Angel
Allan Yuan wrote: Hi, I just wanna know how to set SYSTEM variables and USER variables of windows, but got no way. Firstly I thought "os.environ + os.system" may work well, but found no way to let "os.environ" run to retrive USER variables. Then I tried win32api, finding the GetEnvironmentVaria

Re: Self function

2009-05-04 Thread Arnaud Delobelle
bearophileh...@lycos.com writes: > Aahz: >> When have you ever had a binary tree a thousand levels deep? > > Yesterday. > > >>Consider how big 2**1000 is...< > > You are thinking just about complete binary trees. > But consider that a topology like a single linked list (every node has > 1 child, a

Re: if statement, with function inside it: if (t = Test()) == True:

2009-05-04 Thread Rhodri James
On Mon, 04 May 2009 15:25:44 +0100, Antoon Pardon wrote: On 2009-04-24, Steven D'Aprano wrote: On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: Hello, I'm trying to do a if statement with a function inside it. I want to use that variable inside that if loop , without defining it

Re: find sublist inside list

2009-05-04 Thread Gabriel Genellina
En Mon, 04 May 2009 15:12:41 -0300, mzdude escribió: substring isn't limited to 0..255 substring = "\0x%d\0x%d" % (257,257) 'acaccgac'.replace("ac", substring) '\x00x257\x00x257\x00x257\x00x257cg\x00x257\x00x257' This isn't what you think it is. Look carefully: py> substring = "\0x%d\0x%d"

Re: Self function

2009-05-04 Thread Terry Reedy
bearophileh...@lycos.com wrote: Another possible syntax: def fact(n): return 1 if n <= 1 else n * return(n - 1) But I guess most people don't see this problem as important&common enough to justify changing the language. Actually, I would like a way to refer to the current function from

Re: find sublist inside list

2009-05-04 Thread Terry Reedy
Matthias Gallé wrote: Hi. My problem is to replace all occurrences of a sublist with a new element. Example: Given ['a','c','a','c','c','g','a','c'] I want to replace all occurrences of ['a','c'] by 6 (result [6,6,'c','g',6]). If I do this with string ('acaccgac') I have the advantage of all

exit a program gracefully

2009-05-04 Thread Robert . T . Lynch
In a python program I ask if the user wants to continue. If they answer 'no', what options do I have to halt execution? I can put the rest of the code inside an "if bContinue:" block, but that seems awkward. I have looked at raising an exception, and perhaps this is the preferred method, but

Re: exit a program gracefully

2009-05-04 Thread Chris Rebert
On Mon, May 4, 2009 at 3:02 PM, wrote: > > In a python program I ask if the user wants to continue.  If they answer > 'no', what options do I have to halt execution?  I can put the rest of the > code inside an "if bContinue:" block, but that seems awkward.  I have looked > at raising an exception

Re: if statement, with function inside it: if (t = Test()) == True:

2009-05-04 Thread MRAB
Rhodri James wrote: On Mon, 04 May 2009 15:25:44 +0100, Antoon Pardon wrote: On 2009-04-24, Steven D'Aprano wrote: On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: Hello, I'm trying to do a if statement with a function inside it. I want to use that variable inside that if loop , w

Re: AutoComplete in C++ Editor for Python

2009-05-04 Thread Scott David Daniels
flam...@gmail.com wrote: ... Using this code, I can get information like the name of the symbol (x), but I can't figure out how to get the type. If I knew how to get this it would solve 99% of my problems :) If Python were statically typed, you might be correct. A _value_ in python has a type,

Re: exit a program gracefully

2009-05-04 Thread MRAB
robert.t.ly...@seagate.com wrote: In a python program I ask if the user wants to continue. If they answer 'no', what options do I have to halt execution? I can put the rest of the code inside an "if bContinue:" block, but that seems awkward. I have looked at raising an exception, and perha

Re: Most Basic Question Ever - please help

2009-05-04 Thread seanm . py
On May 3, 12:22 am, CM wrote: > On May 2, 4:36 pm, seanm...@gmail.com wrote: > > > > > I am going to try posting here again with more detail to see if I can > > finally get my first program to work. > > > I am working on a MacBook Pro with OS X 10.4.11. I opened a new window > > in IDLE to create

Re: [ANN] regobj - Pythonic object-based access to the Windows Registry

2009-05-04 Thread Ryan Kelly
> > I've just released the results of a nice Sunday's coding, inspired by > > one too many turns at futzing around with the _winreg module. The > > "regobj" module brings a convenient and clean object-based API for > > accessing the Windows Registry. > > Sounds very interesting, Ryan. Just a c

Re: Self function

2009-05-04 Thread Scott David Daniels
Arnaud Delobelle wrote: In that case the following would not grow the stack, given tail-call optimization: def visit(node): print 'visiting', node if node.right is None: return visit(node.left) if node.left is not None: visit(node.left) return visit(node.right)

Re: exit a program gracefully

2009-05-04 Thread Gabriel Genellina
En Mon, 04 May 2009 19:14:53 -0300, Chris Rebert escribió: On Mon, May 4, 2009 at 3:02 PM, wrote: In a python program I ask if the user wants to continue.  If they answer 'no', what options do I have to halt execution?  I can put the rest of the code inside an "if bContinue:" block, but th

Re: if statement, with function inside it: if (t = Test()) == True:

2009-05-04 Thread Terry Reedy
Antoon Pardon wrote: On 2009-04-24, Steven D'Aprano wrote: On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: Hello, I'm trying to do a if statement with a function inside it. I want to use that variable inside that if loop , without defining it. def Test(): return 'Vla' I searching

Re: if statement, with function inside it: if (t = Test()) == True:

2009-05-04 Thread Scott David Daniels
MRAB wrote: If you're not limited to ASCII then there's '←' (U+2190, 'LEFTWARDS ARROW'). It's a little too late now, though. Well, if you are old enough, that was the ASCII graphic for the character now printed as '_' (ASCII), and SAIL used it for assignment statements, causing much consternatio

Re: Self function

2009-05-04 Thread Carl Banks
On May 4, 1:25 pm, bearophileh...@lycos.com wrote: > Aahz: > > > When have you ever had a binary tree a thousand levels deep? > > Yesterday. > > >Consider how big 2**1000 is...< > > You are thinking just about complete binary trees. > But consider that a topology like a single linked list (every no

  1   2   >