Re: Indentations and future evolution of languages

2009-03-06 Thread Kay Schluehr
On 6 Mrz., 02:53, bearophileh...@lycos.com wrote: > This is an interesting post, it shows me that fitness plateau where > design of Python syntax lives is really small, you can't design > something just similar: > > http://unlimitednovelty.com/2009/03/indentation-sensitivity-post-mort... > > Living

Re: Translating pysnmp oids to human readable strings

2009-03-06 Thread Shantanu Joshi
SpamMePlease PleasePlease writes: > On Fri, Mar 6, 2009 at 6:56 AM, Shantanu Joshi wrote: >> You need to parse the MIB file to get the human-readable names >> corresponding to the OIDs. The pysnmp library already provides this >> functionality. I haven't used this feature myself (I mainly use p

Re: Translating pysnmp oids to human readable strings

2009-03-06 Thread birdsong
On Mar 5, 11:22 pm, SpamMePlease PleasePlease wrote: > On Fri, Mar 6, 2009 at 1:10 AM, birdsong wrote: > > On Mar 5, 2:30 pm, SpamMePlease PleasePlease > > wrote: > >> On Thu, Mar 5, 2009 at 10:12 PM, birdsong wrote: > >> > On Mar 5, 1:05 pm, birdsong wrote: > >> >> On Mar 5, 12:32 pm, SpamMeP

Re: Modify an exception before re-raising it

2009-03-06 Thread Steven D'Aprano
Gabriel Genellina wrote: > En Fri, 06 Mar 2009 04:29:16 -0200, Steven D'Aprano > escribió: ... >> The behaviour I want is from raise_example2, but I'm not sure if this is >> documented behaviour, or if it is something I can rely on. Is it >> acceptable to modify an exception before re-raising it?

Windows install to custom location after building from source

2009-03-06 Thread dan . erik . petersen
Hi all - I have succeeded in building Python 2.6.1 from source under Windows XP by running Visual C++ 2008 Express on the PCbuild/pcbuild.sln file both from the Visual C++ application as well as from the commandline using : vcbuild pcbuild.sln 'Release|Win32' This builds fine (allowing for error

Re: Modify an exception before re-raising it

2009-03-06 Thread Ben Finney
Steven D'Aprano writes: > Okay, if other people are doing it, I'm happy to rely on it as > something which shouldn't just go away without warning. Thanks to > everyone who replied. If you only want to modify the exception's message string, the ‘message’ attribute is standard IIRC. No need to re-

Re: Windows install to custom location after building from source

2009-03-06 Thread dan . erik . petersen
I suppose that what I am looking for is the Windows version of "make install" as we know it after running configure with -- prefix=custom_location --exec-prefix=custom_location flags and make on the Linux platform. Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Can Python do shopping cart?

2009-03-06 Thread Lie Ryan
Muddy Coder wrote: Hi Folks, I know PHP can do shopping cart, such as Zen Cart. I wonder can Python do such a thing? Thanks! Muddy Coder Python is Turing Complete -- http://mail.python.org/mailman/listinfo/python-list

Re: Help required to read and print lines based on the type of first character

2009-03-06 Thread Bruno Desthuilliers
abhinayaraj.r...@emulex.com a écrit : (snip) I need to have a look at that all those doc's you have mentioned. That should help. +1 QOTW !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Indentations and future evolution of languages

2009-03-06 Thread Marco Mariani
Steven D'Aprano wrote: You can have one, or the other, but not both, unless you're willing to have a "practicality beats purity" trade-off and create a second way of grouping blocks, I propose /* and */ as block delimiters. There, you have auto-documenting code, ahah! -- http://mail.python.o

how to prevent python import from looking into the current directory

2009-03-06 Thread TP
Hi everybody, I would like to prevent the loading of modules in the current directory. For example, if I have a personal module in the current directory named "os", when I do "import os", I would like Python to import os standard module, not my personal module of the current directory. Is this pos

Re: how to prevent python import from looking into the current directory

2009-03-06 Thread Chris Rebert
On Fri, Mar 6, 2009 at 1:33 AM, TP wrote: > Hi everybody, > > I would like to prevent the loading of modules in the current directory. > For example, if I have a personal module in the current directory > named "os", when I do "import os", I would like Python to import os > standard module, not my

Re: Can Python do shopping cart?

2009-03-06 Thread Paul Rubin
Muddy Coder writes: > I know PHP can do shopping cart, such as Zen Cart. I wonder can Python > do such a thing? Thanks! As they say in a certain other place--the answer is: yes! Python can do that. -- http://mail.python.org/mailman/listinfo/python-list

Re: logging.handlers.SocketHandler

2009-03-06 Thread Vinay Sajip
On Mar 5, 7:38 pm, writeson wrote: > Hi everyone, > > I wrote aloggingserver that receives messages > fromlogging.handlers.SocketHandler objects in client Python programs. This > works well so long as the client programs are start/stop affairs. > However, if the client is also a long running daem

Re: Can Python do shopping cart?

2009-03-06 Thread Ben Finney
Paul Rubin writes: > As they say in a certain other place--the answer is: yes! Python can > do that. Wow, you're right. They do sound quite certain in that place. -- \“Don't fight forces, use them.” —Richard Buckminster Fuller, | `\

Re: how to prevent python import from looking into the current directory

2009-03-06 Thread Christian Heimes
TP schrieb: > Hi everybody, > > I would like to prevent the loading of modules in the current directory. > For example, if I have a personal module in the current directory > named "os", when I do "import os", I would like Python to import os > standard module, not my personal module of the curren

Is there a better way of doing this?

2009-03-06 Thread mattia
Hi, I'm new to python, and as the title says, can I improve this snippet (readability, speed, tricks): def get_fitness_and_population(fitness, population): return [(fitness(x), x) for x in population] def selection(fitness, population): ''' Select the parent chromosomes from a popula

Error: invalid multibyte sequence

2009-03-06 Thread ganesh gajre
Hello all, I am trying to use gettext method for my one of program making i18N usable in Unicode. When i enter the text repalcement in .po file and try to create .mo file from that, it gives me error as : invalid multibyte sequence. I tried this for french language. e.g #: pywine.py:121

Re: Windows install to custom location after building from source

2009-03-06 Thread Christian Heimes
dan.erik.peter...@gmail.com schrieb: > I suppose that what I am looking for is the Windows version of "make > install" as we know it after running configure with -- > prefix=custom_location --exec-prefix=custom_location flags and make on > the Linux platform. The Windows build system doesn't have

Re: Can Python do shopping cart?

2009-03-06 Thread Bruno Desthuilliers
Dennis Lee Bieber a écrit : On Thu, 5 Mar 2009 14:30:54 -0800 (PST), Muddy Coder declaimed the following in comp.lang.python: I know PHP can do shopping cart, such as Zen Cart. I wonder can Python do such a thing? Thanks! Python is a general purpose, byte-code-compiled/interpreted, l

Re: Is there a better way of doing this?

2009-03-06 Thread Chris Rebert
On Fri, Mar 6, 2009 at 2:19 AM, mattia wrote: > Hi, I'm new to python, and as the title says, can I improve this snippet > (readability, speed, tricks): > > def get_fitness_and_population(fitness, population): >    return [(fitness(x), x) for x in population] > > def selection(fitness, population)

Re: Windows install to custom location after building from source

2009-03-06 Thread Gabriel Genellina
En Fri, 06 Mar 2009 06:52:00 -0200, escribió: I have succeeded in building Python 2.6.1 from source under Windows XP by running Visual C++ 2008 Express on the PCbuild/pcbuild.sln file both from the Visual C++ application as well as from the commandline [...] I would like to move this Python ins

Re: Translating pysnmp oids to human readable strings

2009-03-06 Thread SpamMePlease PleasePlease
On Fri, Mar 6, 2009 at 9:03 AM, Shantanu Joshi wrote: > > SpamMePlease PleasePlease writes: > >> On Fri, Mar 6, 2009 at 6:56 AM, Shantanu Joshi >> wrote: >>> You need to parse the MIB file to get the human-readable names >>> corresponding to the OIDs. The pysnmp library already provides this >>

Re: Can Python do shopping cart?

2009-03-06 Thread Marco Mariani
Lie Ryan wrote: Python is Turing Complete Well, actually no, because it doesn't support an infinite amount of memory. Add this to "things to check before wasting a lot of money in hardware". -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 10:19:22 +, mattia ha scritto: > Hi, I'm new to python, and as the title says, can I improve this snippet > (readability, speed, tricks): > > def get_fitness_and_population(fitness, population): > return [(fitness(x), x) for x in population] > > def selection(fitness,

Python evaluator

2009-03-06 Thread vedrandekovic
Hello, I have created a "Python evaluator" - system that evaluates python scripts.Better explanation (how does it work): 1.) You have to open task that you want to solve from evaluator task panel 2.) Solve task 3.) Send task on evaluator 4.) After few seconds you get your resul

Re: how to prevent python import from looking into the current directory

2009-03-06 Thread TP
Ben Finney wrote: > (Could you please set a valid email address for people to contact you > if necessary?) Thanks a lot for your help. My email address is in my signature: -- python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\ 9&1+,\'Z4(55l4('])" "When a distinguished but elderly

Re: Is there a better way of doing this?

2009-03-06 Thread Chris Rebert
On Fri, Mar 6, 2009 at 3:07 AM, mattia wrote: > Great, the for statement has not to deal with fap anymore, but with > another sequence, like this: > > def get_roulette_wheel(weight_value_pairs): >    roulette_wheel = [] >    for weight, value in weight_value_pairs: >        roulette_wheel += [valu

Re: alias method definitions / syntactic sugar suggestion

2009-03-06 Thread andrew cooke
[sorry for dup terry; prev not to list] Terry Reedy wrote: > @alias('justAsFantastic') > def someFantasticMethod(args): ... does this exist? i read the previous post and thought "i think a decorator could do that", but i haven't written one. the reason i ask is that for 3->2 backwards compatabi

Re: Windows install to custom location after building from source

2009-03-06 Thread dan . erik . petersen
On Mar 6, 11:21 am, Christian Heimes wrote: > dan.erik.peter...@gmail.com schrieb: > > > I suppose that what I am looking for is the Windows version of "make > > install" as we know it after running configure with -- > > prefix=custom_location --exec-prefix=custom_location flags and make on > > th

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 03:43:22 -0800, Chris Rebert ha scritto: > On Fri, Mar 6, 2009 at 3:07 AM, mattia wrote: >> Great, the for statement has not to deal with fap anymore, but with >> another sequence, like this: >> >> def get_roulette_wheel(weight_value_pairs): >>    roulette_wheel = [] >>    for

where is the PyString_AsString in Python 3.0?

2009-03-06 Thread BigHand
Guys: I know that there is no PyString_AsString in Python3.0, could you guys give me instruction about how can I do with the following ? PyObject *exc_type = NULL, *exc_value = NULL, *exc_tb = NULL; PyErr_Fetch(&exc_type, &exc_value, &exc_tb); how do I transfer the exc_type in a char* ? thanks i

Re: Can Python do shopping cart?

2009-03-06 Thread Tim Wintle
On Fri, 2009-03-06 at 11:59 +0100, Marco Mariani wrote: > Lie Ryan wrote: > > > Python is Turing Complete > > Well, actually no, because it doesn't support an infinite amount of memory. Surely you can address an infinite amount of storage using infinite length integers and a wrapper to files on

Re: Translating pysnmp oids to human readable strings

2009-03-06 Thread SpamMePlease PleasePlease
On Fri, Mar 6, 2009 at 11:37 AM, SpamMePlease PleasePlease wrote: > On Fri, Mar 6, 2009 at 9:03 AM, Shantanu Joshi wrote: >> >> SpamMePlease PleasePlease writes: >> >>> On Fri, Mar 6, 2009 at 6:56 AM, Shantanu Joshi >>> wrote: You need to parse the MIB file to get the human-readable names

Re: Is there a better way of doing this?

2009-03-06 Thread Chris Rebert
On Fri, Mar 6, 2009 at 3:52 AM, mattia wrote: > Il Fri, 06 Mar 2009 03:43:22 -0800, Chris Rebert ha scritto: > >> On Fri, Mar 6, 2009 at 3:07 AM, mattia wrote: >>> Great, the for statement has not to deal with fap anymore, but with >>> another sequence, like this: >>> >>> def get_roulette_wheel(w

Re: Python 3D CAD -- need collaborators, or just brave souls :)

2009-03-06 Thread Wesley Brooks
Greetings All, I've been watching this thread since it kicked off with interest. I'd be interested in being kept in the loop with the development of this project as I have made some very simple CAD like tools for Layer Manufacturing (also known as Rapid Prototyping) machines in the past and would

Re: where is the PyString_AsString in Python 3.0?

2009-03-06 Thread Benjamin Peterson
BigHand gmail.com> writes: > > Guys: > I know that there is no PyString_AsString in Python3.0, > could you guys give me instruction about how can I do with the > following ? There is no PyString_AsString. Everything string is unicode now. (PyUnicode API) -- http://mail.python.org/mailman/lis

Unusual Python interpreter problem with os.fork()

2009-03-06 Thread DLitgo
Hello everyone, I have a curious problem which I'm wondering if anyone here can shed some light on. I'm basically just following along with a guide which is going through some of the os module, and I'm running some examples in the python interpreter on mac os x (accessed through terminal/ bash).

Re: Is there a better way of doing this?

2009-03-06 Thread Peter Otten
mattia wrote: > Hi, I'm new to python, and as the title says, can I improve this snippet > (readability, speed, tricks): > > def get_fitness_and_population(fitness, population): > return [(fitness(x), x) for x in population] > > def selection(fitness, population): > ''' > Select the

Re: Can Python do shopping cart?

2009-03-06 Thread Marco Mariani
Tim Wintle wrote: Python is Turing Complete Well, actually no, because it doesn't support an infinite amount of memory. Surely you can address an infinite amount of storage using infinite length integers and a wrapper to files on disk - then it's just your OS's limits that hold it back - so p

Re: Is there a better way of doing this?

2009-03-06 Thread Paul Rubin
Chris Rebert writes: >for i in range(len(fap)): >selected_population.append(choice(rw)) "for i in range(len(something))" is a bit of a code smell. You could instead say: selected_population.extend(choice(rw) for x in fap) The unused "x" is also a slight code smell, but the most

Re: Can Python do shopping cart?

2009-03-06 Thread Paul Rubin
Tim Wintle writes: > Surely you can address an infinite amount of storage using infinite > length integers and a wrapper to files on disk - then it's just your > OS's limits that hold it back - so python is turing/register complete. Python doesn't have infinite length integers. It has long integ

Re: Unusual Python interpreter problem with os.fork()

2009-03-06 Thread Jean-Paul Calderone
On Fri, 6 Mar 2009 05:00:03 -0800 (PST), DLitgo wrote: Hello everyone, I have a curious problem which I'm wondering if anyone here can shed some light on. I'm basically just following along with a guide which is going through some of the os module, and I'm running some examples in the python in

Re: Inverse of dict(zip(x,y))

2009-03-06 Thread Tino Wildenhain
Andre Engels wrote: On Thu, Mar 5, 2009 at 6:01 PM, Tino Wildenhain wrote: Still I'd like to see an application where this really matters (that keys() and values() match in order) I think there are many such applications, but also that in each of those cases it's a mis-programming of somethi

create boolean

2009-03-06 Thread Fencer
Hi, I need a boolean b to be true if the variable n is not None and not an empty list, otherwise b should be false. I ended up with: b = n is not None and not not n which seems to work but is that normally how you would do it? It can be assumed that n is always None or a list that might be empty

Re: Inverse of dict(zip(x,y))

2009-03-06 Thread Tino Wildenhain
Hi, psykeedelik wrote: On Mar 5, 6:01 pm, Tino Wildenhain wrote: Piet van Oostrum wrote: Andre Engels (AE) wrote: AE> On Wed, Mar 4, 2009 at 11:02 AM, lone_eagle wrote: Can someone suggest a easy method to do the inverse of dict(zip(x,y)) to get two lists x and y? So, if x and y are two l

Re: Inverse of dict(zip(x,y))

2009-03-06 Thread Tino Wildenhain
Andre Engels wrote: On Thu, Mar 5, 2009 at 7:46 PM, Andre Engels wrote: If the dict = {key1: val1, key2: val2, ...}, you can do: for key in dict: plot(key,dictionary[key]) Of course I meant: for key in dict: plot(key,dict[key]) Which would be the verbose form of: for x,y in data

Re: create boolean

2009-03-06 Thread Christian Heimes
Fencer schrieb: > Hi, I need a boolean b to be true if the variable n is not None and not > an empty list, otherwise b should be false. > I ended up with: > b = n is not None and not not n > which seems to work but is that normally how you would do it? > It can be assumed that n is always None or a

Problem in accessing long paths.

2009-03-06 Thread venutaurus...@gmail.com
Hello All, I have a requirement where I've to access folders with path lengths >255 ( Windows only supports 255). To do this I've created junction points for the folders whose length is > 255. The problem is my python script is unable to recognize these junction points. As an example I

Re: Translating pysnmp oids to human readable strings

2009-03-06 Thread Shantanu Joshi
SpamMePlease PleasePlease writes: > > I actually tried to load the new file with following code: > > print builder.MibBuilder().getMibPath() > mibBuilder = builder.MibBuilder().loadModules('jnx-bgpmib2') > > but I am experiencing the error: > > rivendell # python snmp.py > ('/usr/lib/python2.4/s

This should be a simple question...

2009-03-06 Thread Neal Becker
Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common setting of these variables

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
if the values are related in meaning then it seems possible that they should be attributes on an object. in which case you would use an instance of the object in both cases and set the values in the objects constructor. if they are not related in meaning then you're not really repeating yourself

Re: This should be a simple question...

2009-03-06 Thread Diez B. Roggisch
Neal Becker schrieb: Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common set

Re: This should be a simple question...

2009-03-06 Thread Bruno Desthuilliers
Neal Becker a écrit : Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common se

Decorators

2009-03-06 Thread Johny
Hi, Can anyone explain to me what are decorators for? What are advantages of using them? Thanks L. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to import Python files in the other directories?

2009-03-06 Thread Vincent Davis
If the documentation is not clear to you as it was not to me, the following adds the search path, /Volumes/iDisk/match/python/matchmod, to the list of places python looks for modules, I have this included as an import statement at the beginning of a program. from sys import path path.append("/Vol

Re: monitoring/restarting an application

2009-03-06 Thread Giampaolo Rodola'
On 5 Mar, 15:37, Ghirai wrote: > Hello list, > > I need to keep x number of instances of an external applications > running, say /bin/x, but also kill and restart each one after y seconds. > > What would be the best way to do this (with python 2.5.x)? > > I'm thinking of having a list of running p

Re: This should be a simple question...

2009-03-06 Thread Neal Becker
Bruno Desthuilliers wrote: > Neal Becker a écrit : >> Maybe I'm missing something obvious here >> >> def A (...): >> #set a bunch of variables >> x = 1 >> b = 2 >> ... >> >> Do something with them >> >> def B (...): >> #set the same bunch of variables >> x = 1 >> b = 2 >> ... >>

Re: Can Python do shopping cart?

2009-03-06 Thread MRAB
Paul Rubin wrote: Tim Wintle writes: Surely you can address an infinite amount of storage using infinite length integers and a wrapper to files on disk - then it's just your OS's limits that hold it back - so python is turing/register complete. Python doesn't have infinite length integers. I

Re: Decorators

2009-03-06 Thread andrew cooke
the arguments are similar to aspect oriented programming (so you could google that). sometimes you want to do a similar thing in various places in your code. the classic example is logging when a method is called. rather than adding logging statements to every method, you can use a decorator -

Re: Decorators

2009-03-06 Thread Michiel Overtoom
Johnny wrote... >Can anyone explain to me what are decorators for? What are advantages >of using them? A tutorial article about decorators from Bruce Eckel: http://www.artima.com/weblogs/viewpost.jsp?thread=240808 -- "The ability of the OSS process to collect and harness the collective IQ of

Re: where is the PyString_AsString in Python 3.0?

2009-03-06 Thread BigHand
On 3月6日, 下午8时50分, Benjamin Peterson wrote: > BigHand gmail.com> writes: > > > > > Guys: > > I know that there is no PyString_AsString in Python3.0, > > could you guys give me instruction about how can I do with the > > following ? > > There is no PyString_AsString. Everything string is unicode no

wxPython fast and slow

2009-03-06 Thread iu2
Hi guys, Can you please help me with this: I wrote a little game in wxPython where I move small panels (showing bitmaps (100 x 100)) on the screen. This is similar to the code I wrote: for i in xrange(1, steps + 1): my_panel.SetPosition(...) time.sleep(0.1 / steps) I use PyScripter (Win

Re: Problem in accessing long paths.

2009-03-06 Thread Tim Golden
venutaurus...@gmail.com wrote: > Hello All, > I have a requirement where I've to access folders with > path lengths >255 ( Windows only supports 255). To do this I've > created junction points for the folders whose length is > 255. The problem is my python script is unable to recognize

Re: Decorators

2009-03-06 Thread Steven D'Aprano
Johny wrote: > Hi, > Can anyone explain to me what are decorators for? What are advantages > of using them? Decorators are for many things. One thing is for factoring out common functionality. Suppose, for example, you have a number of functions that all test that the argument is larger than zer

Re: wxPython fast and slow

2009-03-06 Thread Almar Klein
That's weird. It might have to do with the main loop. I am not familiar with pyscripter, but it might supply a wx mainloop. However, if that is the case, I would expect the app to run slower in pyscripter, not when run without it... So can you use wx interactively from pyscripter? In other words,

Winsound Problems on Vista 64

2009-03-06 Thread Casey
I have a new laptop that came with Vista 64 and I'm having problems with some of my older code that I use for multimedia processing. I narrowed the problem down to the winsound library; any attempt to play sounds results in a fatal error. The simplest case is: >>> from winsound import Beep >>> B

Re: This should be a simple question...

2009-03-06 Thread andrew cooke
Neal Becker wrote: > What if I had: > > my_obj = common_variables() > That set all these attributes, but then with function A I inject them into > A's scope (shouldn't be too hard to do, I think)? "DRY" is a shorthand for people to remember, but it's not a direct law. i am worried that you are tr

Re: Decorators

2009-03-06 Thread Philip Semanchuk
On Mar 6, 2009, at 9:13 AM, Michiel Overtoom wrote: Johnny wrote... Can anyone explain to me what are decorators for? What are advantages of using them? A tutorial article about decorators from Bruce Eckel: http://www.artima.com/weblogs/viewpost.jsp?thread=240808 Thanks for that, Michiel

Re: This should be a simple question...

2009-03-06 Thread Tim Chase
Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common setting of these variable

datetime question

2009-03-06 Thread jyoung79
Just curious if this is the best way to get the first 3 letters of the current month? >>> import datetime >>> >>> d = datetime.date.today() >>> m = d.strftime("%B")[:3].upper() >>> m 'MAR' Thanks. Jay -- http://mail.python.org/mailman/listinfo/python-list

Re: datetime question

2009-03-06 Thread Chris Rebert
On Fri, Mar 6, 2009 at 7:24 AM, wrote: > Just curious if this is the best way to get the first 3 letters of the > current month? > import datetime d = datetime.date.today() m = d.strftime("%B")[:3].upper() m > 'MAR' I believe you want the lowercase version, "%b" (Locale

Re: create boolean

2009-03-06 Thread Grant Edwards
On 2009-03-06, Fencer wrote: > Hi, I need a boolean b to be true if the variable n is not > None and not an empty list, otherwise b should be false. > I ended up with: > b = n is not None and not not n I'd do it like this: b = (n is not None) and (n != []) Your code doesn't meet your state

Re: This should be a simple question...

2009-03-06 Thread Steve Holden
Tim Chase wrote: >> Maybe I'm missing something obvious here >> >> def A (...): >> #set a bunch of variables >> x = 1 >> b = 2 >> ... >> >> Do something with them >> >> def B (...): >> #set the same bunch of variables >> x = 1 >> b = 2 >> ... >> >> Do something with them >> >> I wan

Re: Decorators

2009-03-06 Thread Michele Simionato
On Mar 6, 2:59 pm, Johny wrote: > Hi, > Can anyone explain to me what are decorators for? What are advantages > of using them? > Thanks > L. See http://pypi.python.org/pypi/decorator for many examples of useful decorators, or the references in the Wikipedia page: http://en.wikipedia.org/wiki/Pyt

Re: logging.handlers.SocketHandler

2009-03-06 Thread writeson
Vinay, Thanks for the quick response, very much appreciated. I tried the two scripts you pointed to, modifying the client so it produces log messages in an endless loop, and it worked fine. If I left the client running and stopped and started the server, the client would reconnect and messages wou

Re: Can Python do shopping cart?

2009-03-06 Thread Jason Scheirer
On Mar 6, 1:19 am, Lie Ryan wrote: > Muddy Coder wrote: > > Hi Folks, > > > I know PHP can do shopping cart, such as Zen Cart. I wonder can Python > > do such a thing? Thanks! > > > Muddy Coder > > Python is Turing Complete "Python is Turing complete" is c.l.p's equivalent to Godwin's law. >From

Re: Problem in accessing long paths.

2009-03-06 Thread venutaurus...@gmail.com
On Mar 6, 7:09 pm, "Tim Golden" wrote: > venutaurus...@gmail.com wrote: > > Hello All, > >             I have a requirement where I've to access folders with > > path lengths >255 ( Windows only supports 255). To do this I've > > created junction points for the folders whose length is > 255. The >

Re: Decorators

2009-03-06 Thread Aahz
In article , Johny wrote: > >Can anyone explain to me what are decorators for? What are advantages >of using them? Additional links that may be helpful: http://wiki.python.org/moin/PythonDecoratorLibrary http://mail.python.org/pipermail/baypiggies/2009-March/004448.html http://mail.python.org/p

Re: wxPython fast and slow

2009-03-06 Thread Mike Driscoll
On Mar 6, 8:41 am, iu2 wrote: > Hi guys, > > Can you please help me with this: > I wrote a little game in wxPython where I move small panels (showing > bitmaps (100 x 100)) on the screen. > > This is similar to the code I wrote: > > for i in xrange(1, steps + 1): >     my_panel.SetPosition(...) >

Re: Packaging modules with Bundlebuilder

2009-03-06 Thread Mike Driscoll
On Mar 4, 12:52 am, DLitgo wrote: > Hello everyone, > > I'm curious about creating .app files for the mac using bundlebuilder > (or py2app or even py2exe). I'm just about done creating a GUI for a > little set of scripts which basically perform batch image editing. > > If I send this app to friend

Re: Is there a better way of doing this?

2009-03-06 Thread mattia
Il Fri, 06 Mar 2009 14:06:14 +0100, Peter Otten ha scritto: > mattia wrote: > >> Hi, I'm new to python, and as the title says, can I improve this >> snippet (readability, speed, tricks): >> >> def get_fitness_and_population(fitness, population): >> return [(fitness(x), x) for x in population

Re: This should be a simple question...

2009-03-06 Thread Tim Chase
As Diez suggests, if you don't want to litter your global namespace, use a class: class Foo: x = 1 b = 2 @classmethod def A(cls, *args, **kwargs): do_stuff_with(Foo.x, Foo.b, args, kwargs) @classmethod def B(cls,*args, **kwargs): do_other_stuff_with(Foo.x, Fo

Re: logging.handlers.SocketHandler

2009-03-06 Thread Vinay Sajip
On Mar 6, 4:09 pm, writeson wrote: > To further complicate my original question, here is more information. > Theloggingserver I created uses Twisted (2.5.0) as it's network > framework and gets network log messages from the clients using Twisted > code. However, once a message is received it is pa

Re: question about ctrl-d and atexit with threads

2009-03-06 Thread Darren Dale
On Mar 5, 6:27 pm, "Gabriel Genellina" wrote: > En Thu, 05 Mar 2009 15:26:18 -0200, Darren Dale   > escribió: > > > > > On Mar 5, 12:02 pm, s...@pobox.com wrote: > >> What happens if you simply call > > >>     my_thread.setDaemon(True) > > >> (or in Python 2.6): > > >>     my_thread.daemon = True

Re: question about ctrl-d and atexit with threads

2009-03-06 Thread Darren Dale
On Mar 5, 6:27 pm, "Gabriel Genellina" wrote: > En Thu, 05 Mar 2009 15:26:18 -0200, Darren Dale   > escribió: > > > > > On Mar 5, 12:02 pm, s...@pobox.com wrote: > >> What happens if you simply call > > >>     my_thread.setDaemon(True) > > >> (or in Python 2.6): > > >>     my_thread.daemon = True

ANN: Dao, the official 1.0 version is released

2009-03-06 Thread Limin Fu
Hi, This is to announce the first official release of Dao. Dao is a simple yet powerful object-oriented programming language with many advanced features including, soft (or optional) typing, BNF-like macro system, regular expression, multi-dimensional numeric array, closure, coroutine, asynchrono

Re: Modify an exception before re-raising it

2009-03-06 Thread Terry Reedy
Steven D'Aprano wrote: Okay, if other people are doing it, I'm happy to rely on it as something which shouldn't just go away without warning. At least, it will not go away without fuss. I would guess that modifying the message is an intended use of bare 'raise', but that is not documented.

Re: Python evaluator

2009-03-06 Thread Mensanator
On Mar 6, 5:26 am, vedrandeko...@gmail.com wrote: > Hello, > > I have created a "Python evaluator" - system that evaluates python > scripts.Better explanation (how does it work): >      1.) You have to open task that you want to solve from evaluator > task panel >      2.) Solve task >      3.) Sen

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread skip
Limin> This is to announce the first official release of Dao. What's the connection to Python? -- Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: alias method definitions / syntactic sugar suggestion

2009-03-06 Thread Terry Reedy
andrew cooke wrote: [sorry for dup terry; prev not to list] Terry Reedy wrote: @alias('justAsFantastic') def someFantasticMethod(args): ... does this exist? i read the previous post and thought "i think a decorator could do that", but i haven't written one. Not that I know of -- an exercis

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread Tim Greer
Limin Fu wrote: > Hi, > > This is to announce the first official release of Dao. > > Dao is a simple yet powerful object-oriented programming language So, you pimp your language in news groups for other languages? I see your off topic post in 3 language groups I frequent, that's not the way to

Eclipse And PyDev

2009-03-06 Thread Steve Phillips
All, I realize this question may not belong here but I am going to ask anyway to the current users of Eclipse and PyDev. It's regarding the auto-complete feature. Say you want to type "sys.path.append('yada yada yada')", using say Komodo or IDLE. When you get to "sys.path.ap" and type a "(", it

Re: This should be a simple question...

2009-03-06 Thread Terry Reedy
Neal Becker wrote: Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common setti

Re: question about ctrl-d and atexit with threads

2009-03-06 Thread rdmurray
Darren Dale wrote: >On Mar 5, 6:27 pm, "Gabriel Genellina" wrote: >> En Thu, 05 Mar 2009 15:26:18 -0200, Darren Dale >> escribi�: >> >> > On Mar 5, 12:02�pm, s...@pobox.com wrote: >> >> What happens if you simply call >> >> >>my_thread.setDaemon(True) >> >> >> (or in Python 2.6): >> >>

Re: ANN: Dao, the official 1.0 version is released

2009-03-06 Thread andrew cooke
i agree it's not clear how this is related to python (although i can see the influence), but it does look like a nice language. one thing i was surprised to find missing was that the discussion of types doesn't include classes (the discussion of macros doesn't include types, but that is more unde

Re: Eclipse And PyDev

2009-03-06 Thread andrew cooke
ctrl-space? Steve Phillips wrote: > All, > I realize this question may not belong here but I am going to ask anyway > to > the current users of Eclipse and PyDev. It's regarding the auto-complete > feature. Say you want to type "sys.path.append('yada yada yada')", using > say Komodo or IDLE. W

Re: Threading and tkinter

2009-03-06 Thread Aahz
[posted and e-mailed -- please reply to the group] In article <492d5db9-3681-4ae8-827e-f2a4f66be...@v39g2000yqm.googlegroups.com>, gert wrote: > >After reading the docs and seeing a few examples i think this should >work ? This is a bit late, and I don't have time to review your code, but you s

Re: Reading from text

2009-03-06 Thread Aahz
In article , Tim Chase wrote: >> Assuming this is a real task and not a homework problem, then >> I'd do it this way: >> >> $ cd [directory containing 50 test files] >> $ (for file in *; do head -n11 $file | tail -n5; done) >> >/path/to/results-file.txt > >I'd use sed: > > sed -ns 7,11p /

Re: Decorators

2009-03-06 Thread Terry Reedy
Johny wrote: Hi, Can anyone explain to me what are decorators for? What are advantages of using them? There are two questions: why wrap or modify a function after it is modified? (others have answered this), and why the special syntax? As to the second: @deco def f(): pass is syntactic sug

  1   2   3   >