Re: is there enough information?

2008-02-25 Thread castironpi
> Clarify: > > def thdloop( thd ): >    while thd.cont: >       thd.sig1event.wait() >       ret= thd.cmd() thd.result= ret >       thd.sig2event.set() >       thd.seg3event.wait() > > and def consumer( thd ): thd.cmd= function thd.sig1event.set() thd.sig2event.wait() ret= thd.

Re: is there enough information?

2008-02-25 Thread castironpi
On Feb 25, 11:52 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Feb 25, 9:30 pm, [EMAIL PROTECTED] wrote: > > > > > Is it enough? > > (Reminds me of the movie Marathon Man, in which Dustin Hoffman is > repeatedly asked by Laurence Olivier, "Is it safe?"  Hoffman had no > idea what Olivier was tal

Re: property data-descriptor - how to pass additional constants to the get/set method

2008-02-25 Thread Gabriel Genellina
En Mon, 25 Feb 2008 18:50:20 -0200, <[EMAIL PROTECTED]> escribió: > Hi, > I would like to pass additional constants to the property data- > descriptor, so it is not necessary to write many methods which differ > just by constant defined in the method body. > Till now I can do this: > > class MyCla

Re: print help content in a Command Prompt

2008-02-25 Thread Gabriel Genellina
En Mon, 25 Feb 2008 10:18:19 -0200, <[EMAIL PROTECTED]> escribió: > On Feb 25, 12:59 pm, Necmettin Begiter <[EMAIL PROTECTED]> > wrote: >> 25 February 2008 Monday 11:15:14 tarihinde [EMAIL PROTECTED] şunları >> yazmıştı: >> >> > Hi, >> > This is a basic problem, but I want to print help content

Re: running a daemon in python

2008-02-25 Thread rishi pathak
Use the function goDaemon just before starting the server loop: ###Begin Module### import os import sys # Default daemon parameters. # File mode creation mask of the daemon. UMASK = 0 # Default working directory for the daemon. WORKDIR = "/" # Default maximum for th

Re: pprint, __repr__ and inheritance, how does it works?

2008-02-25 Thread Gabriel Genellina
En Mon, 25 Feb 2008 10:19:43 -0200, Jorge Vargas <[EMAIL PROTECTED]> escribió: > Hello list, I'm having a little bit of trouble making this all work > together. > > I have a base class in which I want to define the __repr__ for all > subclasses which in this case will be to output all the __di

Re: PHP Developer highly interested in Python (web development) with some open questions...

2008-02-25 Thread Gabriel Genellina
En Mon, 25 Feb 2008 06:42:39 -0200, Bruno Desthuilliers <[EMAIL PROTECTED]> escribió: > Diez B. Roggisch a écrit : >>> >>> It's also some kind of a Rube Goldberg thingie... >>> http://en.wikipedia.org/wiki/Rube_Goldberg_machine >>> >>> If you're into web applications, better to have a look at Py

running a daemon in python

2008-02-25 Thread bharath venkatesh
hi .. hi i want a program to start running as daemon in background .. my program is server listen to a client ... so i want to make that program run as daemon .. when i execute the program the program for ex server.py it should automatically start running as daemon in the background even if

Re: is there enough information?

2008-02-25 Thread Paul McGuire
On Feb 25, 9:30 pm, [EMAIL PROTECTED] wrote: > > Is it enough? (Reminds me of the movie Marathon Man, in which Dustin Hoffman is repeatedly asked by Laurence Olivier, "Is it safe?" Hoffman had no idea what Olivier was talking about. So Olivier tortured Hoffman some more to get the answer.) Enou

Re: How to make "rainbow" RGB values?

2008-02-25 Thread Andrew McNamara
>>Consider using an HSV->RGB conversion function. Saturation (S) and value >>(V) should remain constant, while Hue (H) varies to get your rainbow >>effect. > >Hey thank you very much, that worked like a charm! :] > >There's even a library function in the colorsys module (http:// >docs.python.org/l

Re: Is crawling the stack "bad"? Why?

2008-02-25 Thread Russell Warren
Thanks Ian... I didn't know about threading.local before but have been experimenting and it will likely come in quite handy in the future. For this particular case it does basically seem like a replacement for the threadID indexed dictionary, though. ie: I'll still need to set up the RpcContainer,

Re: network programming: how does s.accept() work?

2008-02-25 Thread Steve Holden
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > Steve Holden <[EMAIL PROTECTED]> wrote: > >> TCP guarantees >> that no two ephemeral port connections from the same client will use the >> same port. > > Where "client" is defined as "IP Address". You could certainly have a > remote machi

Re: network programming: how does s.accept() work?

2008-02-25 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > TCP guarantees > that no two ephemeral port connections from the same client will use the > same port. Where "client" is defined as "IP Address". You could certainly have a remote machine that has multiple IP addresse

freeze.py - resolving dependencies

2008-02-25 Thread Rakesh Kumar
hi - I wrote a wxWidgets program and was trying to convert the python script to native python code. After running freeze.py on my source file - I am getting the following unknown modules error. Warning: unknown modules remain: _bisect _heapq _locale _random _socket _ssl _struct _tkinter array

Re: python based BB system

2008-02-25 Thread amar888
On Feb 26, 12:10 pm, CE <[EMAIL PROTECTED]> wrote: > Hi, > I have been searching for a while for a complete and fast Bulletin Board > System for a mature community. > > any recommendation guys? AFAIK pocoo is one good choice but it lacks alot of primitive functionalities like image attachments or

Re: network programming: how does s.accept() work?

2008-02-25 Thread Steve Holden
7stud wrote: > On Feb 25, 10:56 am, Thomas Bellman <[EMAIL PROTECTED]> wrote: >> 7stud <[EMAIL PROTECTED]> wrote: >>> The question I'm really trying to answer is: if a client connects to a >>> host at a specific port, but the server changes the port when it >>> creates a new socket with accept(), h

Re: network programming: how does s.accept() work?

2008-02-25 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Mon, 25 Feb 2008 20:03:02 -0200, 7stud <[EMAIL PROTECTED]> > escribió: > > On Feb 25, 10:56 am, Thomas Bellman <[EMAIL PROTECTED]> wrote: > >> 7stud <[EMAIL PROTECTED]> wrote: > > > In either case, there are st

Re: network programming: how does s.accept() work?

2008-02-25 Thread Roy Smith
In article <[EMAIL PROTECTED]>, 7stud <[EMAIL PROTECTED]> wrote: > But your claim that the server doesn't change its port flies in the > face of every description I've read about TCP connections and > accept(). The articles and books I've read all claim that the server > port 5053 is a 'listeni

Re: Odd behaviour of *.pth files and Apache

2008-02-25 Thread Gabriel Genellina
En Sat, 23 Feb 2008 12:52:45 -0200, D'Arcy J.M. Cain <[EMAIL PROTECTED]> escribió: > On Thu, 21 Feb 2008 13:55:25 -0500 > "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote: >> I tried searching the archives for information on this but nothing >> seemed to be germane. I am running Python sripts as CG

What does this bogus code in urlparse do?

2008-02-25 Thread John Nagle
See "http://svn.python.org/view/python/trunk/Lib/urlparse.py?rev=60163&view=markup"; Look at "urljoin". What does the code marked "# XXX The stuff below is bogus in various ways..." do? I think it's an attempt to remove leading "../" components in URLs, which are generally ignored. But it also

Re: __getattribute__ meta class?

2008-02-25 Thread Carl Banks
On Feb 25, 9:43 pm, "bambam" <[EMAIL PROTECTED]> wrote: > I have a class containing a series of classes like this: > > class Th(Externaldevice): > class _Communicate(commandset2.CommandSet_Communicate): > def __getattribute__(self,attrname): > attr = > commandset2.CommandSet_Communicate

Re: network programming: how does s.accept() work?

2008-02-25 Thread Gabriel Genellina
En Mon, 25 Feb 2008 20:03:02 -0200, 7stud <[EMAIL PROTECTED]> escribió: > On Feb 25, 10:56 am, Thomas Bellman <[EMAIL PROTECTED]> wrote: >> 7stud <[EMAIL PROTECTED]> wrote: > In either case, there are still some things about the output that > don't make sense to me. Why does the server initiall

python based BB system

2008-02-25 Thread CE
Hi, I have been searching for a while for a complete and fast Bulletin Board System for a mature community. any recommendation guys? -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for up to date documentation for Python/Tkinter

2008-02-25 Thread Gabriel Genellina
En Thu, 21 Feb 2008 13:47:35 -0200, Kintaro <[EMAIL PROTECTED]> escribió: > Please speak unto me the URL which contain the latest documentation on > Python/Tkinter programming. For Python itself, the starting points are http://docs.python.org and http://wiki.python.org/moin/ -- Gabriel Gene

Fwd: Problem with threads in python????????

2008-02-25 Thread Manikandan R
Hai, Is it possible to share a single variable between multiple threads. For eg: Class A: thread_init() def run(): fun1() def fun(): assume some arithmatic operation is going on according to the input given and each fun will *give different outp

buliding log files

2008-02-25 Thread diljeet kaur
hi im working on pyqt environment i want to know how to take log or how to build log files of the output - Looking for last minute shopping deals? Find them fast with Yahoo! Search.-- http://mail.python.org/mailman/listinfo/python-list

Re: iter(lambda:f.read(8192),'')

2008-02-25 Thread Gabriel Genellina
En Sun, 24 Feb 2008 10:18:31 -0200, Dustan <[EMAIL PROTECTED]> escribió: > On Feb 24, 5:11 am, gert <[EMAIL PROTECTED]> wrote: >> what is the difference between iter(lambda:f.read(8192), ') and >> iter(f.read(8192),'') ? > > iter(lambda:f.read(8192), '') (what you probably meant) is what it > lo

is there enough information?

2008-02-25 Thread castironpi
Specify def thloop( th ): while th.cont: with th.step[2]: th.ret= th.cmd+ 1 def acq( th ): with th.step[1]: th.cmd= 100 with th.step[3]: ret1= th.ret th.step.reset() assert ret1== 101 Is it enough? -- http://mail.python.org/mailman/listin

Re: how to flush child_stdin

2008-02-25 Thread Gabriel Genellina
En Fri, 22 Feb 2008 17:53:55 -0200, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > On Feb 22, 2:01 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: >> On Fri, 22 Feb 2008 08:35:03 -0800 (PST), "[EMAIL PROTECTED]" >> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: >> >> > I don

Re: exchange service side rules

2008-02-25 Thread bambam
Wrong message, wrong group. Sorry. "bambam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Junk E-Mail Options, Protection is set to High. All of my messages are > coming through with a SCL of 9 (I checked), but none of them are going to > the Junk E-Mail folder. > > I thought th

__getattribute__ meta class?

2008-02-25 Thread bambam
I have a class containing a series of classes like this: class Th(Externaldevice): class _Communicate(commandset2.CommandSet_Communicate): def __getattribute__(self,attrname): attr = commandset2.CommandSet_Communicate.__getattribute__(self,attrname) if "__call__" in dir(attr):

exchange service side rules

2008-02-25 Thread bambam
Junk E-Mail Options, Protection is set to High. All of my messages are coming through with a SCL of 9 (I checked), but none of them are going to the Junk E-Mail folder. I thought this was a server-side rule? Can anyone explain, and also tell me what I need to do? -- http://mail.python.org/ma

Re: Web site for comparing languages syntax

2008-02-25 Thread Mel
Sebastian Bassi wrote: > I know there is one site with wikimedia software installed, that is > made for comparing the syntax of several computer languages (Python > included). But don't remember the URL. Anyone knows this site? http://99-bottles-of-beer.net/ is one such site, though I don't know

along the lines, hash and obj. id.

2008-02-25 Thread castironpi
I'd like to do this: a= list( range( 5 ) ) assert a== [ 0, 1, 2, 3, 4 ] for i in ref( a ): i.ref*= 2 a= deref( a ) assert a== [ 0, 2, 4, 6, 8 ] In the for loop, i objects maintain their identities, while still being reassigned. The first way I think of is this: class Ref: def __init__(

Re: Reading a keypress

2008-02-25 Thread Jeff Schwab
Dennis Lee Bieber wrote: > On Mon, 25 Feb 2008 10:35:54 -0800 (PST), wyleu > <[EMAIL PROTECTED]> declaimed the following in > comp.lang.python: > >> I'm trying to read a single keypress on Linux but expect to have the >> programme running on Windows platform as well and find the mention in >> the

Re: object identity and hashing

2008-02-25 Thread Jeff Schwab
[EMAIL PROTECTED] wrote: > On Feb 24, 9:28 pm, George Sakkis <[EMAIL PROTECTED]> wrote: >> >> [1]http://www.martinfowler.com/eaaCatalog/identityMap.html > > [1] illustrates a case in which 'a is a' returns False, and in the > other corner of the DeMorgan table, there is 'a is b' returns True for >

Re: distutils and data files

2008-02-25 Thread Gabriel Genellina
En Fri, 22 Feb 2008 05:28:22 -0200, Sam Peterson <[EMAIL PROTECTED]> escribió: > Robert Bossy <[EMAIL PROTECTED]> on Wed, 20 Feb 2008 09:29:12 > +0100 didst step forth and proclaim thus: > >> Sam Peterson wrote: >>> I've been googling for a while now and cannot find a good way to deal >>> with th

boost and ctypes

2008-02-25 Thread zaley
I am a newbie to python .I know it is easy to access Windows API and DLL using ctypes in python .And it is easy to access python class and function using boost libs in C. Can boost and ctypes work together? -- http://mail.python.org/mailman/listinfo/python-list

Unsubscribing from python-list (was Re: Python code for 2.5 and 2.4?)

2008-02-25 Thread Robert Kern
Bhatt, Omkar wrote: > PLEASE TAKE ME OFF THIS LIST! You can unsubscribe yourself using the link at the bottom of every message: http://mail.python.org/mailman/listinfo/python-list -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terr

Re: Backup Script over ssh

2008-02-25 Thread Gabriel Genellina
En Thu, 21 Feb 2008 09:32:23 -0200, Christian Kortenhorst <[EMAIL PROTECTED]> escribió: > I am new to python and the list. Welcome? > I want to create backup script for my windows PC and upload to Linux > server > over ssh but whats the best way to go about this. rsync? No need to reinvent

Re: Reading a keypress

2008-02-25 Thread Rolf van de Krol
wyleu wrote: > Aaah it doesn't work from idle but it does from the command line... > > You are right. You can't read STDIN from IDLE. There has been a topic about that before: http://groups.google.com/group/comp.lang.python/browse_thread/thread/9f9c90cfe52378fe -- http://mail.python.org/mail

RE: Python code for 2.5 and 2.4?

2008-02-25 Thread Bhatt, Omkar
PLEASE TAKE ME OFF THIS LIST! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Rubin Sent: Monday, February 25, 2008 5:47 PM To: python-list@python.org Subject: Re: Python code for 2.5 and 2.4? Arnaud Delobelle <[EMAIL PROTECTED]> writes: > Ok. In th

Re: Hyphenation module PyHyphen-0.3 released

2008-02-25 Thread thebjorn
On Feb 25, 3:56 am, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > > I don't know if I'm just doing it wrong, or if I can't use extensions > > compiled with mingw32 with the standard distribution Python > > executable? > > I was able to install on Windows XP with mingw: > > setup.py build -c mingw32

Re: Python code for 2.5 and 2.4?

2008-02-25 Thread Paul Rubin
Arnaud Delobelle <[EMAIL PROTECTED]> writes: > Ok. In that case, the following is probably faster (in fact for long > iterables it may be equivalent to the builtin all): > > from itertools import ifilterfalse... Nice. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python code for 2.5 and 2.4?

2008-02-25 Thread Arnaud Delobelle
On Feb 25, 11:17 pm, Paul Rubin wrote: > Arnaud Delobelle <[EMAIL PROTECTED]> writes: > >     def all(iterable): > >         for x in iterable: > >             if not x: return False > >         return True > > from itertools import imap > def all(iterable): >    return F

Re: Python code for 2.5 and 2.4?

2008-02-25 Thread Paul Rubin
Arnaud Delobelle <[EMAIL PROTECTED]> writes: > def all(iterable): > for x in iterable: > if not x: return False > return True from itertools import imap def all(iterable): return False not in imap(bool, iterable) def any(iterable): return True in imap(bool, i

Re: PyEuler

2008-02-25 Thread bearophileHUGS
Arnaud Delobelle: > I disagree; the generator function has no right to keep a and b to > itself. a and b cry out to be function parameters. I see. Then that's a generator for a generalized Fibonacci sequence :-) Your version too is useful. Bye, bearophile -- http://mail.python.org/mailman/listi

Re: Accessing "sub elements" with xml.sax ?

2008-02-25 Thread Diez B. Roggisch
erikcw schrieb: > Hi, > > I'm trying to use xml.sax (from xml.sax.handler import ContentHandler) > to processes the following data: > > > masterAccountName="CraftShowSuccess.Com-US" > dateStart="2008-02-24-0600" dateEnd="2008-02-24-0600" > booksClosedTimestamp="2008-02-25T01:15:00.000-0600" boo

Re: PyEuler

2008-02-25 Thread Arnaud Delobelle
On Feb 25, 10:52 pm, [EMAIL PROTECTED] wrote: > Arnaud Delobelle: > > > In this case why not: > > > def xfib(a=1, b=1): > >     while True: > >         yield a > >         a += b > >         yield b > >         b += a > > That's a bit less easy to understand than my version, for me. > In my version

Re: Reading a keypress

2008-02-25 Thread wyleu
Aaah it doesn't work from idle but it does from the command line... -- http://mail.python.org/mailman/listinfo/python-list

Re: PyEuler

2008-02-25 Thread bearophileHUGS
Arnaud Delobelle: > In this case why not: > > def xfib(a=1, b=1): > while True: > yield a > a += b > yield b > b += a That's a bit less easy to understand than my version, for me. In my version is easy to see the values of the variables. And using a longer funct

Web site for comparing languages syntax

2008-02-25 Thread Sebastian Bassi
Hello, I know there is one site with wikimedia software installed, that is made for comparing the syntax of several computer languages (Python included). But don't remember the URL. Anyone knows this site? -- Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología. Curso Biologia molecular

Re: PyEuler

2008-02-25 Thread Arnaud Delobelle
On Feb 25, 10:25 pm, [EMAIL PROTECTED] wrote: > Paul Rubin: > > >     def ggenfib(): > >       a,b = 1,2 > >       while True: > >          yield a > >          a,b = b, a=b > > Your version is the nice basic generator version (the last line > contains a +, I presume), but I like this other version

Re: Python code for 2.5 and 2.4?

2008-02-25 Thread Joseph Turian
On 25 fév, 16:02, Robert Kern <[EMAIL PROTECTED]> wrote: > Joseph Turian wrote: > > I was given code that was written for python 2.5, and uses simple > > functions like 'all' which are not present in 2.4 > > > I want to make the code 2.4 compatible. What is the best way to do > > this? > > If it's

Re: Embedding a literal "\u" in a unicode raw string.

2008-02-25 Thread rmano
On Feb 25, 11:27 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > Raw > > should be raw... > > Right. IMO, this is just a plain design mistake in the Python Unicode > handling. Unfortunately, there was discussion about this specific issue > in the past, and the proponent of the status quo alway

Re: Weird cgi error

2008-02-25 Thread gherzig
> >> This is some kind of crooked game, right? Your code works fine on a >> local server, and there's no reason why it shouldn't work just fine on >> yours either. All you are changing is the standard input to the process. >> >> Since you claim to have spotted this specific error, perhaps you'd lik

Re: network programming: how does s.accept() work?

2008-02-25 Thread Grant Edwards
On 2008-02-25, 7stud <[EMAIL PROTECTED]> wrote: > On Feb 25, 10:56 am, Thomas Bellman <[EMAIL PROTECTED]> wrote: >> 7stud <[EMAIL PROTECTED]> wrote: >> > The question I'm really trying to answer is: if a client connects to a >> > host at a specific port, but the server changes the port when it >> >

Re: Embedding a literal "\u" in a unicode raw string.

2008-02-25 Thread Martin v. Löwis
> Yes, I think I will do something like that, although... I really do > not understand why \x5c is not interpreted in a raw string but \u005c > is interpreted in a unicode raw string... is, well, not elegant. Raw > should be raw... Right. IMO, this is just a plain design mistake in the Python Uni

Re: PyEuler

2008-02-25 Thread bearophileHUGS
Paul Rubin: > def ggenfib(): > a,b = 1,2 > while True: > yield a > a,b = b, a=b Your version is the nice basic generator version (the last line contains a +, I presume), but I like this other version too: def xfibonacci(): a = b = 1 yield a yield b

Re: Weird cgi error

2008-02-25 Thread Jesse Aldridge
> This is some kind of crooked game, right? Your code works fine on a > local server, and there's no reason why it shouldn't work just fine on > yours either. All you are changing is the standard input to the process. > > Since you claim to have spotted this specific error, perhaps you'd like > to

Re: float / rounding question

2008-02-25 Thread John Machin
On Feb 26, 7:14 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | Hi I'm very much a beginner with Python. > | I want to write a function to convert celcius to fahrenheit like this > | one: > | > | def celciusToFahrenheit(tc): > |

Re: Python code for 2.5 and 2.4?

2008-02-25 Thread Mike Driscoll
Joseph, On 2/25/08, Joseph Turian <[EMAIL PROTECTED]> wrote: > > > Seehttp://docs.python.org/lib/built-in-funcs.htmlwhich shows the > > current built-ins for Python. It also shows an equivalent function for > > all() that should work in 2.4. > > Yes, I see that. > > > You can do a check at th

Re: network programming: how does s.accept() work?

2008-02-25 Thread 7stud
On Feb 25, 10:56 am, Thomas Bellman <[EMAIL PROTECTED]> wrote: > 7stud <[EMAIL PROTECTED]> wrote: > > The question I'm really trying to answer is: if a client connects to a > > host at a specific port, but the server changes the port when it > > creates a new socket with accept(), how does data sen

Re: Python code for 2.5 and 2.4?

2008-02-25 Thread Arnaud Delobelle
On Feb 25, 8:47 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > > You can do a check at the beginning of your file by importing the sys > module. Something like this: > > > # untested > import sys > version = sys.version.split(' ')[0] > > if '2.5' not in version: >    # use custom all() script > >

ANN: Python cgkit v2.0.0alpha8

2008-02-25 Thread matthias . baas
The eigth alpha release of cgkit2 is available at http://cgkit.sourceforge.net What is it? --- The Python Computer Graphics Kit is an Open Source software package containing a collection of Python modules, plugins and utilities that are meant to be useful for any domain where you have to

Re: PyEuler

2008-02-25 Thread Mark Dickinson
On Feb 25, 4:24 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > def genfib(a=0, b=1): >     for a, b in iter(lambda:(b, a+b), None): >         yield a > > ;-) > > Ahem.  I admit that somehow, I am proud of this. You're one sick puppy dog. :-) (P.S. Your mother was a hamster, and your father s

Re: How to manipulate elements of a list in a single line of code?

2008-02-25 Thread mrstephengross
> Yes, it's called a "list comprehension", and is many people's favourite Awesome! Thanks, --Steve -- http://mail.python.org/mailman/listinfo/python-list

Re: How to manipulate elements of a list in a single line of code?

2008-02-25 Thread Paulo da Costa
mrstephengross wrote: > 1 list1 = ['a', 'b', 'c'] > 2 list2 = [] > 3 for item in list1: list2.append(item + 'foo') > > Is there a way to express lines 2-3 sort-of ilke this: > > list2 = [ for item in list1: item + 'foo' ] list2 = [ item + 'foo' for item in list1 ] Paulo -- http://mail.pyt

Re: How to manipulate elements of a list in a single line of code?

2008-02-25 Thread D'Arcy J.M. Cain
On Mon, 25 Feb 2008 13:39:26 -0800 (PST) mrstephengross <[EMAIL PROTECTED]> wrote: > 1 list1 = ['a', 'b', 'c'] > 2 list2 = [] > 3 for item in list1: list2.append(item + 'foo') > > Is there a way to express lines 2-3 sort-of ilke this: > > list2 = [ for item in list1: item + 'foo' ] You almo

Re: How to manipulate elements of a list in a single line of code?

2008-02-25 Thread Ben C
On 2008-02-25, mrstephengross <[EMAIL PROTECTED]> wrote: > I would like to translate the contents of a list. For instance, let's > say I've got a list of strings and I want to append "foo" to each > element. I might do the following; > > list1 = ['a', 'b', 'c'] > for i in range(0, len(list1)):

Re: How to manipulate elements of a list in a single line of code?

2008-02-25 Thread Dan
On Feb 25, 4:39 pm, mrstephengross <[EMAIL PROTECTED]> wrote: > I would like to translate the contents of a list. For instance, let's > say I've got a list of strings and I want to append "foo" to each > element. I might do the following; > > list1 = ['a', 'b', 'c'] > for i in range(0, len(list

Re: Order of evaluation in conditionals

2008-02-25 Thread Karlo Lozovina
Paul Hankin wrote: > Did you try to find the answer to your question in the python > reference manual? The relevant page is > http://docs.python.org/ref/Booleans.html Of course I first Googled (even Google Groups-ed) it, but I didn't notice that in the results. > To quote it: > The expression '

Re: urllib slow on Leopard

2008-02-25 Thread mark
mark wrote: > I've recently switched from Ubuntu to OS X Leopard. I have some python > scripts which download info from the web. The scripts were working fine > before on Ubuntu, but urllib seems to work really slowly on Leopard. > > I tried an example from the docs: > > >>> import urllib2 >

How to manipulate elements of a list in a single line of code?

2008-02-25 Thread mrstephengross
I would like to translate the contents of a list. For instance, let's say I've got a list of strings and I want to append "foo" to each element. I might do the following; list1 = ['a', 'b', 'c'] for i in range(0, len(list1)): list1[i] += 'foo' Ok, that much works. But what if I don't want to

Re: Is there any method to urlretrieve to a file the html source from a url with "Transfer-encoding": chunked

2008-02-25 Thread 7stud
On Feb 25, 8:25 am, Aldo Ceccarelli <[EMAIL PROTECTED]> wrote: > Thank you All for your suggestions: > > I could finally assess that > > besides partial read from chunked url - by-passed thanks to a socket > approach: > > f.i. this was good for > me:http://python.about.com/od/networkingwithpython/

Re: Order of evaluation in conditionals

2008-02-25 Thread Tim Chase
> if () and () and (): > do_something() > > Is there a guarantee that Python will evaluate those conditions in order (1, > 2, 3)? I know I can write that as a nested if, and avoid the problem > altogether, but now I'm curious about this ;). Yes, Python does short-circuit evaluation, from left-t

Re: network programming: how does s.accept() work?

2008-02-25 Thread Thomas Bellman
7stud <[EMAIL PROTECTED]> wrote: > The question I'm really trying to answer is: if a client connects to a > host at a specific port, but the server changes the port when it > creates a new socket with accept(), how does data sent by the client > arrive at the correct port? Won't the client be sen

Re: Order of evaluation in conditionals

2008-02-25 Thread Paul Hankin
On Feb 25, 9:18 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > Hi all! Here is what's bugging me: let's say I have this code: > > if () and () and (): >   do_something() > > Is there a guarantee that Python will evaluate those conditions in order (1, > 2, 3)? I know I can write that as a nested if

Re: PyEuler

2008-02-25 Thread Arnaud Delobelle
On Feb 25, 7:25 pm, Paul Rubin wrote: > Are you kidding? >     def ggenfib(): >       a,b = 1,2 >       while True: >          yield a >          a,b = b, a=b Or: def genfib(a=0, b=1): for a, b in iter(lambda:(b, a+b), None): yield a ;-) Ahem. I admit tha

Re: String compare question

2008-02-25 Thread Robert Dailey
Thanks for your help. I knew of a way to solve this issue, but being a C++ programmer I tend to think of the expanded solutions for things. I wasn't sure if there was a more compact solution for python. Thanks again! On Mon, Feb 25, 2008 at 11:27 AM, Tim Chase <[EMAIL PROTECTED]> wrote: > >> igno

Order of evaluation in conditionals

2008-02-25 Thread Karlo Lozovina
Hi all! Here is what's bugging me: let's say I have this code: if () and () and (): do_something() Is there a guarantee that Python will evaluate those conditions in order (1, 2, 3)? I know I can write that as a nested if, and avoid the problem altogether, but now I'm curious about this ;). Th

Re: Article of interest: Python pros/cons for the enterprise

2008-02-25 Thread Paul Rubin
Robert Brown <[EMAIL PROTECTED]> writes: > > Python's dynamic typing is just fine. But if I know the type, I want > > the ability to nail it. ...local variables, arguments, return values, > > etc And if I don't know or care, I'd leave it to dynamic typing. > > This is the approach taken by Comm

Re: Python code for 2.5 and 2.4?

2008-02-25 Thread Robert Kern
Joseph Turian wrote: > I was given code that was written for python 2.5, and uses simple > functions like 'all' which are not present in 2.4 > > I want to make the code 2.4 compatible. What is the best way to do > this? If it's a single file, put something like the following code near the top. If

Accessing "sub elements" with xml.sax ?

2008-02-25 Thread erikcw
Hi, I'm trying to use xml.sax (from xml.sax.handler import ContentHandler) to processes the following data: I've figured out how to access the attributes in "row" - but I want to also access the "analytics" child element. I've tried: class YahooHandler(ContentHandler): ccountNum) def

Re: Reading a keypress

2008-02-25 Thread wyleu
> > A recipe that supposedly does this in a cross-platform > way:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892 class _Getch: """Gets a single character from standard input. Does not echo to the screen.""" def __init__(self): try: self.impl = _GetchWi

property data-descriptor - how to pass additional constants to the get/set method

2008-02-25 Thread petr . jakes . tpc
Hi, I would like to pass additional constants to the property data- descriptor, so it is not necessary to write many methods which differ just by constant defined in the method body. Till now I can do this: class MyClass(object): def _getValue(self, myConstant): print 'myConstant:', m

Re: Python code for 2.5 and 2.4?

2008-02-25 Thread Mike Driscoll
On Feb 25, 2:40 pm, Joseph Turian <[EMAIL PROTECTED]> wrote: > I was given code that was written for python 2.5, and uses simple > functions like 'all' which are not present in 2.4 > > I want to make the code 2.4 compatible. What is the best way to do > this? > If I define function 'all', then won'

Re: Article of interest: Python pros/cons for the enterprise

2008-02-25 Thread Robert Brown
Larry Bugbee <[EMAIL PROTECTED]> writes: > Python's dynamic typing is just fine. But if I know the type, I want > the ability to nail it. ...local variables, arguments, return values, > etc And if I don't know or care, I'd leave it to dynamic typing. This is the approach taken by Common Lisp.

Python code for 2.5 and 2.4?

2008-02-25 Thread Joseph Turian
I was given code that was written for python 2.5, and uses simple functions like 'all' which are not present in 2.4 I want to make the code 2.4 compatible. What is the best way to do this? If I define function 'all', then won't I break 2.5 compatability? Thanks, Joseph -- http://mail.python.or

Re: Using lambda [was Re: Article of interest: Python pros/cons fortheenterprise]

2008-02-25 Thread Terry Reedy
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On Sun, 24 Feb 2008 21:13:08 -0500, Terry Reedy wrote: | | > | I even use "named anonymous functions" *cough* by assigning lambda | | > functions to names: | > | | > | foo = lambda x: x+1 | > | > Even though I conside

Re: Article of interest: Python pros/cons for the enterprise

2008-02-25 Thread Aahz
In article <[EMAIL PROTECTED]>, Jeff Schwab <[EMAIL PROTECTED]> wrote: >Bruno Desthuilliers wrote: >> >> Stating the obvious is not bashing. In my last shop I was working with >> (very talented BTW) Perl programmer, and he was the first to make jokes >> on Perl's abuse of cryptic syntax. > >It'

Re: bin2chr("01110011") # = 15 function ?

2008-02-25 Thread Tim Chase
> I'm searching for a simple > bin2chr("01110011") function that can convert all my 8bit data to a > chr so I can use something like this: > print ord("s") # = 115 > print bin(ord("s")) # = 01110011 > > test= open('output.ext,'wb') > test.write(bin2chr("01110011")) > test.write(bin2chr("0011"

bin2chr("01110011") # = 15 function ?

2008-02-25 Thread gcmartijn
H! I'm searching for a simple bin2chr("01110011") function that can convert all my 8bit data to a chr so I can use something like this: def bin(i): l = ['', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '']

Re: float / rounding question

2008-02-25 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Hi I'm very much a beginner with Python. | I want to write a function to convert celcius to fahrenheit like this | one: | | def celciusToFahrenheit(tc): |tf = (9/5)*tc+32 |return tf Unless you are importing 'integer division'

Re: PyEuler

2008-02-25 Thread Paul Rubin
[EMAIL PROTECTED] writes: > def takenth(n, iterable): > "Returns the nth item" > return list(islice(iterable, n, n+1))[0] > return islice(iterable, n).next() > isanymultiple = lambda x: any((x % y == 0) for y in nums) > return sum(filter(isanymultiple, xrange(end))) This isn't

Re: Reading a keypress

2008-02-25 Thread Mike Driscoll
On Feb 25, 12:35 pm, wyleu <[EMAIL PROTECTED]> wrote: > I'm trying to read a single keypress on Linux but expect to have the > programme running on Windows platform as well and find the mention in > the FAQ: > > import termios, fcntl, sys, os > fd = sys.stdin.fileno() > > oldterm = termios.tcgetatt

Re: PyEuler

2008-02-25 Thread Mark Dickinson
On Feb 25, 11:25 am, [EMAIL PROTECTED] wrote: > This is the first time I write something that looks like a little > rant :-) Surely I'll be wrong in many points, but I presume this isn't > going to damage people, so... Agreed on all points. :-) This looks a lot like someone trying to write Haskel

Re: Article of interest: Python pros/cons for the enterprise

2008-02-25 Thread Nicola Musatti
On Feb 25, 3:17 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Feb 25, 8:29 am, Nicola Musatti <[EMAIL PROTECTED]> wrote: > > > On Feb 24, 9:14 pm, Larry Bugbee <[EMAIL PROTECTED]> wrote: > > > Corporate marketing, and corporate attention in general, saw to it > > > that Java was well equipped with

Reading a keypress

2008-02-25 Thread wyleu
I'm trying to read a single keypress on Linux but expect to have the programme running on Windows platform as well and find the mention in the FAQ: import termios, fcntl, sys, os fd = sys.stdin.fileno() oldterm = termios.tcgetattr(fd) newattr = termios.tcgetattr(fd) newattr[3] = newattr[3] & ~ter

Re: os.fork() not working on windows (help)

2008-02-25 Thread Ian Clark
On 2008-02-25, A. Joseph <[EMAIL PROTECTED]> wrote: > Please i`m trying to create a process using the os.fork() but it keep If you're not trying to clone your current process, just make a new one, you should look at the subprocess module. http://docs.python.org/lib/module-subprocess.html Ian --

  1   2   3   >