Re: Some C-API functions clear the error indicator?

2010-01-29 Thread Austin Bingham
That makes a lot of sense. And if I take the approach that any Py* function might do this, it actually looks like I can simplify my code (rather than managing some list of ill-behaved functions or something.) Thanks! On Fri, Jan 29, 2010 at 3:58 PM, Duncan Booth wrote: > Austin Bingham wrote: >

Re: Some C-API functions clear the error indicator?

2010-01-29 Thread Austin Bingham
The original post was, in a nutshell, the "use case"; it's very scaled down the from the real example, and not intended to "make sense". The notion on which I was (apparently incorrectly) basing my exception translation was that I could 1) get and reset references to the error indicators, 2) call o

Re: C API: module cleanup function

2010-01-29 Thread Stefan Behnel
Mr.M, 29.01.2010 23:50: > I can't figure out if there is a way to run a specialized cleanup > function when a module needs to be "unloaded" (i.e. just before a > reload() or when i quit the interpreter). > > I'm thinking of something like tp_dealloc. > > If I call Py_InitModule3 and look at modul

Code snippet: dualmethod descriptor

2010-01-29 Thread Steven D'Aprano
I came up with this descriptor a few years ago, but never used it for anything. I've just found an actual use for it in my own code, so I thought I'd make it public for anyone else who might have a use for it. Use-case: if you have a class without an __init__ or __new__ method, then this may be

Re: myths about python 3

2010-01-29 Thread Ben Finney
Blog writes: > (Debian does ship with 2.5, but the next major release "sid' is due > out in Q2) Sid is the perpetual development playground (“unstable”), never released as a suite, but a proving ground for packages to determine their fitness for going to the next level of testing. The next-to-b

Re: myths about python 3

2010-01-29 Thread Blog
On 1/28/2010 8:44 AM, Paul Rubin wrote: Steve Holden writes: Kindly confine your debate to the facts and keep the snide remarks to yourself. Like it or not Python 3 is the future, and unladen swallow's recent announcement that they would target only Python 3 represented a ground-breaking advanc

Re: myths about python 3

2010-01-29 Thread Blog
On 1/28/2010 2:56 AM, John Nagle wrote: Daniel Fetchinson wrote: 1. Python 3 is supported by major Linux distributions. FALSE - most distros are shipping with Python 2.4, or 2.5 at best. Where did you come up with that information? Almost all of the major distros ship with 2.6.x - CentOS, Ope

Re: Threading issue with SQLite

2010-01-29 Thread Stephen Hansen
On Fri, Jan 29, 2010 at 8:37 AM, Alan Harris-Reid < aharrisr...@googlemail.com> wrote: > Hi, > > I am creating a web application (using Python 3.1 and CherryPy 3.2) where a > SQLite connection and cursor object are created using the following code > (simplified from the original): > > class MainSi

Re: For loop searching takes too long!

2010-01-29 Thread Steven D'Aprano
On Fri, 29 Jan 2010 14:49:06 -0800, Jonathan Gardner wrote: > On Jan 28, 3:52 pm, elsa wrote: >> >> I've got a problem with my program, in that the code just takes too >> long to run. Here's what I'm doing. If anyone has any tips, they'd be >> much appreciated! >> >> > First of all, don't play wi

Re: Perl 6 [was Re: myths about python 3]

2010-01-29 Thread Carl Banks
On Jan 28, 9:34 pm, Steven D'Aprano wrote: > On Thu, 28 Jan 2010 21:21:05 -0800, Tim Roberts wrote: > > Perl 6, on the other hand, is still fantasyware a decade after its > > announcement.  It is, for the most part, THE canonical example of the > > wrong way to conduct a development effort. > > Ou

Re: Keyboard input

2010-01-29 Thread Steven D'Aprano
On Fri, 29 Jan 2010 18:38:47 -0300, Gabriel Genellina wrote: >> I'm using the raw_input method and it works fine, but I noted that I >> can't use backspace and when I accidentally press shift space (because >> I need to input uppercase letters separated by a space) it writes some >> strange charac

Re: myths about python 3

2010-01-29 Thread Benjamin Kaplan
On Fri, Jan 29, 2010 at 5:29 PM, Ben Finney wrote: > Duncan Booth writes: > >> Here's what I see in the Ubuntu packages. Python 3 seems only to be in the >> universe repositories so far. >> >> Dapper: Python 2.4.2 >> Hardy: Python 2.5.2 >> Intrepid: Python 2.5.2, 3.0~b3 (universe) >> Jaunty: Pyth

Re: image processing - inverse filtering

2010-01-29 Thread Aahz
In article <5bfefbb6-89a8-49f6-9f02-7d36dfbc0...@c29g2000yqd.googlegroups.com>, suresh.amritapuri wrote: > >If I am using scipy.ndimage.gaussian_filter() for filtering an image, >how to do the inverse filtering? In general how to do this using >scipy.ndimage? http://projects.scipy.org/mailman/lis

Re: Changing tab behavior in Python Interactive mode

2010-01-29 Thread Terry Reedy
On 1/29/2010 4:43 PM, Andrej Mitrovic wrote: On Jan 29, 10:07 pm, Steve Holden wrote: Andrej Mitrovic wrote: On Jan 29, 6:47 pm, Steve Holden wrote: Andrej Mitrovic wrote: I've noticed that when running Python in interactive mode (via cmd on windows), the first time I hit tab it will move 4

Re: Some C-API functions clear the error indicator?

2010-01-29 Thread Gabriel Genellina
En Fri, 29 Jan 2010 18:25:14 -0300, Austin Bingham escribió: Maybe I'm not following what you're saying. In my case, I already know that an exception has been thrown. In the course of processing that exception, I call another function which, for whatever reason and even when it succeeds, clea

Re: Python-list Digest, Vol 76, Issue 303

2010-01-29 Thread Gabriel Genellina
[top posting corrected] From: Steve Holden Date: Tue, 26 Jan 2010 11:54:23 -0500 Anyway, I suspect your error might go away if you turned the first argument of hte log.info() call into a format string such as log.info("refer: %s", ret) try: log.info("start") log.info("refer",ret)

Re: C API: module cleanup function

2010-01-29 Thread Mr.M
Gabriel Genellina ha scritto: I think what you want to do isn't possible with Python 2, and it's one of the reasons the module handling was redesigned in Python 3.x; see PEP 3121. Thank you Gabriel for your help. Unlucky I can't use Python 3.x in my project, sob! Luca. -- http://mail.python

Re: C API: module cleanup function

2010-01-29 Thread Gabriel Genellina
En Fri, 29 Jan 2010 19:50:52 -0300, Mr.M escribió: I can't figure out if there is a way to run a specialized cleanup function when a module needs to be "unloaded" (i.e. just before a reload() or when i quit the interpreter). I think what you want to do isn't possible with Python 2, and it'

C API: module cleanup function

2010-01-29 Thread Mr.M
Hi, I can't figure out if there is a way to run a specialized cleanup function when a module needs to be "unloaded" (i.e. just before a reload() or when i quit the interpreter). I'm thinking of something like tp_dealloc. If I call Py_InitModule3 and look at module->ob_type->tp_dealloc, I fin

Re: For loop searching takes too long!

2010-01-29 Thread Jonathan Gardner
On Jan 28, 3:52 pm, elsa wrote: > > I've got a problem with my program, in that the code just takes too > long to run. Here's what I'm doing. If anyone has any tips, they'd be > much appreciated! > First of all, don't play with large lists. Large lists have a tendency to grow larger over time, un

Re: myths about python 3

2010-01-29 Thread Ben Finney
Duncan Booth writes: > Here's what I see in the Ubuntu packages. Python 3 seems only to be in the > universe repositories so far. > > Dapper: Python 2.4.2 > Hardy: Python 2.5.2 > Intrepid: Python 2.5.2, 3.0~b3 (universe) > Jaunty: Python 2.6.2, 3.0.1 (universe) > Karmic: Python 2.6.4rc1, 3.1 (un

Re: which one is faster?

2010-01-29 Thread Jonathan Gardner
On Jan 28, 10:29 pm, "Stephen.Wu" <54wut...@gmail.com> wrote: > str.find(targetStr) > str.index(targetStr) with exception > str.count(targetStr) > targetStr in str > > which is the fastest way to check whether targetStr is in str? > The fastest way of all is to forget about this and finish the res

Re: myths about python 3

2010-01-29 Thread Carl Banks
On Jan 29, 12:25 am, "Martin v. Loewis" wrote: > > Well, I'd consider that an official release.  Note that I didn't claim > > there was no hope PSF wouldn't change it's mind on 2.8. > > I'd like to point out that the PSF formally doesn't have any say in > this. Doesn't PSF own the Python trademar

Re: Threading issue with SQLite

2010-01-29 Thread Jonathan Gardner
On Jan 29, 8:37 am, Alan Harris-Reid wrote: > > Questions... > 1.  Is there a large overhead in opening a new SQLite connection for > each thread (ie. within each method)? Yes, but not as bad as some other DBs. > 2.  Is there any way to use the same connection for the whole class (or > should I

Re: Keyboard input

2010-01-29 Thread Jonathan Gardner
On Jan 29, 8:53 am, "Mr.SpOOn" wrote: > Hi, > I need to get keyboard input in a python program. I need it to let the > user choose some options, for example: > > 1) option 1 > 2) option 2 > 3) option 3 > > and then to input some data to the program. > > I'm using the raw_input method and it works

Re: Keyboard input

2010-01-29 Thread rantingrick
On Jan 29, 3:38 pm, "Gabriel Genellina" wrote: > but it's a big   > move. wxPython would let you write a graphical interface (and it's a   > bigger move!) > > -- > Gabriel Genellina *ahem*!, tkinter is just a slightly medium move, and my god it's in the stdlib for crying out loud!! -- http://

Re: Data exchange between Delphi and Python (Win)

2010-01-29 Thread Gabriel Genellina
En Thu, 28 Jan 2010 05:07:00 -0300, Durumdara escribió: I have an exotic db, with exotic drivers, and it have buggy ODBC driver. But I have native driver - under Delphi. I need to access this DB under Pylons (or mod_python). [...] I think to COM/OLE, because it is accessable from all progr

Re: Changing tab behavior in Python Interactive mode

2010-01-29 Thread Andrej Mitrovic
On Jan 29, 10:07 pm, Steve Holden wrote: > Andrej Mitrovic wrote: > > On Jan 29, 6:47 pm, Steve Holden wrote: > >> Andrej Mitrovic wrote: > >>> I've noticed that when running Python in interactive mode (via cmd on > >>> windows), the first time I hit tab it will move 4 spaces to the right, > >>>

Re: Keyboard input

2010-01-29 Thread Gabriel Genellina
En Fri, 29 Jan 2010 13:53:43 -0300, Mr.SpOOn escribió: I need to get keyboard input in a python program. I need it to let the user choose some options, for example: 1) option 1 2) option 2 3) option 3 and then to input some data to the program. I'm using the raw_input method and it works f

Thread safe locale techniques?

2010-01-29 Thread python
We're currently writing a web application based on a threaded python web server framework (cherrypy) and would like to simultaneously support users from multiple locales. The locale module doesn't appear to be thread safe. Are there 3rd party libraries or modules that provide locale parsing and fo

Re: Some C-API functions clear the error indicator?

2010-01-29 Thread Austin Bingham
Maybe I'm not following what you're saying. In my case, I already know that an exception has been thrown. In the course of processing that exception, I call another function which, for whatever reason and even when it succeeds, clears the exception indicators. How can I address this issue by checki

Re: Killing a Thread

2010-01-29 Thread Gabriel Genellina
En Thu, 28 Jan 2010 10:25:30 -0300, Richard Lamboj escribió: which Method is better to kill a Thread? Using Thread Events, or a raising a Exception? Maybe someone has a small example for me? The best way is simply NOT to do that. You don't kill a thread, you ask it to commit suicide. T

Re: Changing tab behavior in Python Interactive mode

2010-01-29 Thread Steve Holden
Andrej Mitrovic wrote: > On Jan 29, 6:47 pm, Steve Holden wrote: >> Andrej Mitrovic wrote: >>> I've noticed that when running Python in interactive mode (via cmd on >>> windows), the first time I hit tab it will move 4 spaces to the right, >>> however each new tab will move 8 spaces instead of 4.

Re: python for net manager

2010-01-29 Thread Gabriel Genellina
En Wed, 27 Jan 2010 00:11:10 -0300, moon sky escribió: i just want to write a small tool to manage the network, including detect the ip addr,netmask, and send the arp request to find out locale's ip-mac turtple, is there any way to succeed this exlude 'subprocess call'? Try scapy: http://

Re: Changing tab behavior in Python Interactive mode

2010-01-29 Thread Andrej Mitrovic
On Jan 29, 6:47 pm, Steve Holden wrote: > Andrej Mitrovic wrote: > > I've noticed that when running Python in interactive mode (via cmd on > > windows), the first time I hit tab it will move 4 spaces to the right, > > however each new tab will move 8 spaces instead of 4. Why this > > inconsistent

Re: Function name unchanged in error message

2010-01-29 Thread Gabriel Genellina
En Fri, 29 Jan 2010 13:09:40 -0300, Michele Simionato escribió: On Jan 29, 2:30 pm, andrew cooke wrote: Is there any way to change the name of the function in an error message? In the example below I'd like the error to refer to bar(), for example (the motivation is related function decora

Re: SimpleXMLRPCServer daemon

2010-01-29 Thread Gabriel Genellina
En Fri, 29 Jan 2010 12:54:23 -0300, Thomas Allen escribió: I have a script that runs an instance of SimpleXMLRPCServer and in general it works as expected. In its __del__, it is supposed to clean up its PID file (written on boot). I have two problems with this server instance: The first is th

Re: site.py confusion

2010-01-29 Thread Gabriel Genellina
En Wed, 27 Jan 2010 15:48:23 -0300, George Trojan escribió: Arnaud Delobelle wrote: George Trojan writes: Inspired by the 'Default path for files' thread I tried to use sitecustomize in my code. What puzzles me is that the site.py's main() is not executed. My sitecustomize.py is That gave

Re: SimpleXMLRPCServer daemon

2010-01-29 Thread Sean DiZazzo
On Jan 29, 7:54 am, Thomas Allen wrote: > I have a script that runs an instance of SimpleXMLRPCServer and in > general it works as expected. In its __del__, it is supposed to clean > up its PID file (written on boot). I have two problems with this > server instance: The first is that tt doesn't al

Re: Some C-API functions clear the error indicator?

2010-01-29 Thread Gabriel Genellina
En Fri, 29 Jan 2010 11:37:09 -0300, Austin Bingham escribió: I've noticed that several (many?) python functions seem to clear the error/exception indicators when they're called from a C/C++ program. For example, both PyImport_ImportModule and traceback.extract_tb() (called via the function ca

Re: Processing XML File

2010-01-29 Thread Stefan Behnel
Sells, Fred, 29.01.2010 20:31: > Google is your friend. Elementtree is one of the better documented > IMHO, but there are many modules to do this. Unless the OP provides some more information, "do this" is rather underdefined. And sending someone off to Google who is just learning the basics of P

RE: Processing XML File

2010-01-29 Thread Sells, Fred
Google is your friend. Elementtree is one of the better documented IMHO, but there are many modules to do this. > -Original Message- > From: python-list-bounces+frsells=adventistcare@python.org > [mailto:python-list-bounces+frsells=adventistcare@python.org] On > Behalf Of Stefan B

Re: Processing XML File

2010-01-29 Thread Stefan Behnel
jakecjacobson, 29.01.2010 18:25: > I need to take a XML web resource and split it up into smaller XML > files. I am able to retrieve the web resource but I can't find any > good XML examples. I am just learning Python so forgive me if this > question has been answered many times in the past. > >

Re: Processing XML File

2010-01-29 Thread Adam Tauno Williams
On Fri, 2010-01-29 at 10:34 -0800, jakecjacobson wrote: > On Jan 29, 1:04 pm, Adam Tauno Williams > wrote: > > On Fri, 2010-01-29 at 09:25 -0800, jakecjacobson wrote: > > > I need to take a XML web resource and split it up into smaller XML > > > files. I am able to retrieve the web resource but I

Re: Processing XML File

2010-01-29 Thread jakecjacobson
On Jan 29, 1:04 pm, Adam Tauno Williams wrote: > On Fri, 2010-01-29 at 09:25 -0800, jakecjacobson wrote: > > I need to take a XML web resource and split it up into smaller XML > > files.  I am able to retrieve the web resource but I can't find any > > good XML examples.  I am just learning Python

Re: Sleep timer but still responsive?

2010-01-29 Thread JohnnyFive
On Jan 29, 9:33 am, Andreas Tawn wrote: > > On Jan 28, 4:55 pm, "Gabriel Genellina" > > wrote: > > > Please provide more details. What do you want your program to do > > while > > > sleeping? What kind of actions do you want a response to? > > > Do you have a GUI? A curses-based interfase? > > >

Re: Sleep timer but still responsive?

2010-01-29 Thread Gabriel Genellina
En Fri, 29 Jan 2010 14:39:31 -0300, MRAB escribió: JohnnyFive wrote: My app is purely console based. I just don't want the console to lock up (on Windows using time.sleep(x) causes the console to become unresponsive until the timer is done), and I want people to be able to CTRL+C to stop th

Re: Processing XML File

2010-01-29 Thread Adam Tauno Williams
On Fri, 2010-01-29 at 09:25 -0800, jakecjacobson wrote: > I need to take a XML web resource and split it up into smaller XML > files. I am able to retrieve the web resource but I can't find any > good XML examples. I am just learning Python so forgive me if this > question has been answered many

RE: Sleep timer but still responsive?

2010-01-29 Thread Andreas Tawn
> On Jan 28, 4:55 pm, "Gabriel Genellina" > wrote: > > Please provide more details. What do you want your program to do > while > > sleeping? What kind of actions do you want a response to? > > Do you have a GUI? A curses-based interfase? > > > > -- > > Gabriel Genellina > > My app is purely cons

Re: Changing tab behavior in Python Interactive mode

2010-01-29 Thread Steve Holden
Andrej Mitrovic wrote: > I've noticed that when running Python in interactive mode (via cmd on > windows), the first time I hit tab it will move 4 spaces to the right, > however each new tab will move 8 spaces instead of 4. Why this > inconsistent behavior? And how could I change this to be consist

Re: Sleep timer but still responsive?

2010-01-29 Thread MRAB
JohnnyFive wrote: On Jan 28, 4:55 pm, "Gabriel Genellina" wrote: Please provide more details. What do you want your program to do while sleeping? What kind of actions do you want a response to? Do you have a GUI? A curses-based interfase? -- Gabriel Genellina My app is purely console based

Changing tab behavior in Python Interactive mode

2010-01-29 Thread Andrej Mitrovic
I've noticed that when running Python in interactive mode (via cmd on windows), the first time I hit tab it will move 4 spaces to the right, however each new tab will move 8 spaces instead of 4. Why this inconsistent behavior? And how could I change this to be consistent and always move only 4 spac

Processing XML File

2010-01-29 Thread jakecjacobson
I need to take a XML web resource and split it up into smaller XML files. I am able to retrieve the web resource but I can't find any good XML examples. I am just learning Python so forgive me if this question has been answered many times in the past. My resource is like: ... ...

Re: get PyObject* knowing its string name

2010-01-29 Thread Robert Kern
On 2010-01-29 11:00 AM, Mr.M wrote: I think this sounds like a stupid question, but I searched the C/Api doc and google but I wasn't able to find any hint: how can I retrive PyObject pointer if I only know it's name? What I'd like to do is something like this: [code] PyObject* obj = PyFindWhat

Re: Sleep timer but still responsive?

2010-01-29 Thread JohnnyFive
On Jan 28, 4:55 pm, "Gabriel Genellina" wrote: > Please provide more details. What do you want your program to do while   > sleeping? What kind of actions do you want a response to? > Do you have a GUI? A curses-based interfase? > > -- > Gabriel Genellina My app is purely console based. I just do

get PyObject* knowing its string name

2010-01-29 Thread Mr.M
I think this sounds like a stupid question, but I searched the C/Api doc and google but I wasn't able to find any hint: how can I retrive PyObject pointer if I only know it's name? What I'd like to do is something like this: [code] PyObject* obj = PyFindWhatImLookingFor("w.z.y.x"); [/code] Of

Keyboard input

2010-01-29 Thread Mr.SpOOn
Hi, I need to get keyboard input in a python program. I need it to let the user choose some options, for example: 1) option 1 2) option 2 3) option 3 and then to input some data to the program. I'm using the raw_input method and it works fine, but I noted that I can't use backspace and when I ac

Threading issue with SQLite

2010-01-29 Thread Alan Harris-Reid
Hi, I am creating a web application (using Python 3.1 and CherryPy 3.2) where a SQLite connection and cursor object are created using the following code (simplified from the original): class MainSite: con = sqlite.connect('MyDatabase.db') cursor = con.cursor() def index_page():

Re: SimpleXMLRPCServer daemon

2010-01-29 Thread Tim Wintle
On Fri, 2010-01-29 at 07:54 -0800, Thomas Allen wrote: > The second is that when it does crash, I don't know about it...what > would be sufficient as a "keep-alive" script to restart it? I suppose > I could use something like EventMachine (already installed on my > server) to watch the PID file if

Re: Funny behaviour with __future__ and doctest between 2.6 and 3.1

2010-01-29 Thread Peter Otten
Mattsteel wrote: > Sadly (for me), you're right... then the only way to use doctest to > work both in 2.6 and 3.1 (without modifications between them) is > something like this: > > #!/usr/bin/env python > ''' str(concat('hello','world')) > 'hello world' > ''' > from __future__ import unicod

Re: Funny behaviour with __future__ and doctest between 2.6 and 3.1

2010-01-29 Thread Mattsteel
Hi Peter. Sadly (for me), you're right... then the only way to use doctest to work both in 2.6 and 3.1 (without modifications between them) is something like this: #!/usr/bin/env python ''' >>> str(concat('hello','world')) 'hello world' ''' from __future__ import unicode_literals def concat( firs

Re: Function name unchanged in error message

2010-01-29 Thread Michele Simionato
On Jan 29, 2:30 pm, andrew cooke wrote: > Is there any way to change the name of the function in an error > message?  In the example below I'd like the error to refer to bar(), > for example (the motivation is related function decorators - I'd like > the wrapper function to give the same name) Us

Re: SimpleXMLRPCServer daemon

2010-01-29 Thread Adam Tauno Williams
On Fri, 2010-01-29 at 07:54 -0800, Thomas Allen wrote: > I have a script that runs an instance of SimpleXMLRPCServer and in > general it works as expected. In its __del__, it is supposed to clean > up its PID file (written on boot). I have two problems with this > server instance: The first is that

SimpleXMLRPCServer daemon

2010-01-29 Thread Thomas Allen
I have a script that runs an instance of SimpleXMLRPCServer and in general it works as expected. In its __del__, it is supposed to clean up its PID file (written on boot). I have two problems with this server instance: The first is that tt doesn't always clean up its PID file; is there a more relia

Re: Funny behaviour with __future__ and doctest between 2.6 and 3.1

2010-01-29 Thread Peter Otten
Mattsteel wrote: > Hello all. > I'm using Python 2.6.4 and Python 3.1.1. > My wish is to code in a 3.1-compliant way using 2.6, so I'm importing > the __future__ module. > I've found a funny thing comparing the two folliwing snippets that > differ for one line only, that is the position of __futur

Re: myths about python 3

2010-01-29 Thread eric_dex...@msn.com
On Jan 27, 2:56 pm, John Nagle wrote: > Daniel Fetchinson wrote: > > Hi folks, > > > I was going to write this post for a while because all sorts of myths > > periodically come up on this list about python 3. I don't think the > > posters mean to spread false information on purpose, they simply ar

Re: python 3's adoption

2010-01-29 Thread Alf P. Steinbach
* Steven D'Aprano: On Fri, 29 Jan 2010 07:10:01 +0100, Alf P. Steinbach wrote: >>> L = ["æ", "ø", "å"] # This is in SORTED ORDER in Norwegian L [...] >>> L.sort( key = locale.strxfrm ) >>> L ['å', 'æ', 'ø'] >>> locale.strcoll( "å", "æ" ) 1 >>> locale.strcoll( "æ", "ø"

Re: python 3's adoption

2010-01-29 Thread Paul Boddie
On 29 Jan, 06:56, Terry Reedy wrote: > On 1/28/2010 6:47 PM, Paul Boddie wrote: > > > What would annoy me if I used Python 3.x would be the apparent lack of > > the __cmp__ method for conveniently defining comparisons between > > instances of my own classes. Having to define all the rich compariso

Funny behaviour with __future__ and doctest between 2.6 and 3.1

2010-01-29 Thread Mattsteel
Hello all. I'm using Python 2.6.4 and Python 3.1.1. My wish is to code in a 3.1-compliant way using 2.6, so I'm importing the __future__ module. I've found a funny thing comparing the two folliwing snippets that differ for one line only, that is the position of __future__ import (before or after th

Re: Some C-API functions clear the error indicator?

2010-01-29 Thread Duncan Booth
Austin Bingham wrote: > The functions that do this don't seem to indicate in their > documentation that this will happen. So first, does anyone know why > this is happening? Is it because of the context in which I'm making > the calls? Is there any pattern or reason behind which functions will >

Re: Function name unchanged in error message

2010-01-29 Thread exarkun
On 02:10 pm, c...@rebertia.com wrote: On Fri, Jan 29, 2010 at 5:30 AM, andrew cooke wrote: Is there any way to change the name of the function in an error message? �In the example below I'd like the error to refer to bar(), for example (the motivation is related function decorators - I'd like t

Re: Need help with a program

2010-01-29 Thread nn
Johann Spies wrote: > On Thu, Jan 28, 2010 at 07:07:04AM -0800, evilweasel wrote: > > Hi folks, > > > > I am a newbie to python, and I would be grateful if someone could > > point out the mistake in my program. Basically, I have a huge text > > file similar to the format below: > > > > AGACTC

Re: Python 3.1 simplejson install

2010-01-29 Thread Chris Rebert
On Fri, Jan 29, 2010 at 6:33 AM, Peter Otten <__pete...@web.de> wrote: > dirknbr wrote: >> I am trying to install simplejson on Python 3.1 on Windows. When I do >> 'python setup.py install' I get 'except DisutilsPlatformError, x: >> SyntaxError' with a dash under the comma. > > You are trying to in

Re: Python 3.1 simplejson install

2010-01-29 Thread Christian Heimes
dirknbr wrote: > I am trying to install simplejson on Python 3.1 on Windows. When I do > 'python setup.py install' I get 'except DisutilsPlatformError, x: > SyntaxError' with a dash under the comma. There is no need to install simplejson yourself. Python 3 and 2.6 already have a JSON package calle

Some C-API functions clear the error indicator?

2010-01-29 Thread Austin Bingham
I've noticed that several (many?) python functions seem to clear the error/exception indicators when they're called from a C/C++ program. For example, both PyImport_ImportModule and traceback.extract_tb() (called via the function call methods) do this: if error indicators are set prior to their cal

Re: Python 3.1 simplejson install

2010-01-29 Thread Peter Otten
dirknbr wrote: > I am trying to install simplejson on Python 3.1 on Windows. When I do > 'python setup.py install' I get 'except DisutilsPlatformError, x: > SyntaxError' with a dash under the comma. You are trying to install a package written for Python 2.x on 3.x, and some of the 2.x Syntax is

Re: Function name unchanged in error message

2010-01-29 Thread Peter Otten
andrew cooke wrote: > Is there any way to change the name of the function in an error > message? In the example below I'd like the error to refer to bar(), > for example (the motivation is related function decorators - I'd like > the wrapper function to give the same name) > def foo(): > ..

Re: Need help with a program

2010-01-29 Thread D'Arcy J.M. Cain
On Fri, 29 Jan 2010 11:23:54 +0200 Johann Spies wrote: > I know this is a python list but if you really want to get the job > done quickly this is one method without writing python code: > [...] > $ grep -v 0 /tmp/y > tmp/z There's plenty of ways to do it without writing Python. C, C++, Perl, Fo

Python 3.1 simplejson install

2010-01-29 Thread dirknbr
I am trying to install simplejson on Python 3.1 on Windows. When I do 'python setup.py install' I get 'except DisutilsPlatformError, x: SyntaxError' with a dash under the comma. Any ideas? Dirk -- http://mail.python.org/mailman/listinfo/python-list

Re: Function name unchanged in error message

2010-01-29 Thread Chris Rebert
On Fri, Jan 29, 2010 at 5:30 AM, andrew cooke wrote: > Is there any way to change the name of the function in an error > message?  In the example below I'd like the error to refer to bar(), > for example (the motivation is related function decorators - I'd like > the wrapper function to give the s

Re: python 3's adoption

2010-01-29 Thread Duncan Booth
Steven D'Aprano wrote: > If that's too verbose for you, stick this as a helper function in your > application: > > > def CmpToKey(mycmp): > 'Convert a cmp= function into a key= function' > class K(object): > def __init__(self, obj, *args): > self.obj = obj >

Re: myths about python 3

2010-01-29 Thread Benjamin Kaplan
On Fri, Jan 29, 2010 at 8:13 AM, Anssi Saari wrote: > Daniel Fetchinson writes: > >>> 1.  Python 3 is supported by major Linux distributions. >>> >>>      FALSE - most distros are shipping with Python 2.4, or 2.5 at best. >> >> This latter statement is false, Fedora 11 and 12 come with python 2.6

Re: myths about python 3

2010-01-29 Thread Duncan Booth
Anssi Saari wrote: > Daniel Fetchinson writes: > >>> 1. Python 3 is supported by major Linux distributions. >>> >>> FALSE - most distros are shipping with Python 2.4, or 2.5 at best. >> >> This latter statement is false, Fedora 11 and 12 come with python 2.6. > > How does your mention of

Re: Function name unchanged in error message

2010-01-29 Thread Jean-Michel Pichavant
andrew cooke wrote: Is there any way to change the name of the function in an error message? In the example below I'd like the error to refer to bar(), for example (the motivation is related function decorators - I'd like the wrapper function to give the same name) def foo(): ...

Function name unchanged in error message

2010-01-29 Thread andrew cooke
Is there any way to change the name of the function in an error message? In the example below I'd like the error to refer to bar(), for example (the motivation is related function decorators - I'd like the wrapper function to give the same name) >>> def foo(): ... return 7 ... >>> foo.__name

Re: Need help with a program

2010-01-29 Thread Johann Spies
On Fri, Jan 29, 2010 at 10:04:33AM +, Steven D'Aprano wrote: > > I know this is a python list but if you really want to get the job done > > quickly this is one method without writing python code: > > > > $ cat /tmp/y > > AGACTCGAGTGCGCGGA 0 > > AGATAAGCTAATTAAGCTACTGG 0 > >

Re: myths about python 3

2010-01-29 Thread Anssi Saari
Daniel Fetchinson writes: >> 1. Python 3 is supported by major Linux distributions. >> >> FALSE - most distros are shipping with Python 2.4, or 2.5 at best. > > This latter statement is false, Fedora 11 and 12 come with python 2.6. How does your mention of one distro counter that claim? Pe

Re: myths about python 3

2010-01-29 Thread Anssi Saari
Stefan Behnel writes: > 'Stable Debian' has a long tradition of being late and outdated on arrival. > That doesn't mean you can't use existing Debian packages on it. Yes, but that's beside the point. No released version of Debian ships with Python3 or even 2.6. Oh, and RHEL5 and CentOS5 ship wi

[OT] myths about python 3

2010-01-29 Thread Antoine Pitrou
Le Fri, 29 Jan 2010 13:16:11 +1100, Ben Finney a écrit : > > I think the reason “date” was initially used is because dates are most > familiar to us as fleshy, dark brown, wrinkled, compressed points. > > My interests in etymology and scatology unite here. Ah, I suppose it explains the strange A

Re: [OT] Perl 6 [was Re: myths about python 3]

2010-01-29 Thread Grant Edwards
On 2010-01-29, Neil Hodgson wrote: > Looks to me like the problem with Perl 6 was that it was too > ambitious, wanting to fix all perceived problems with the > language. I thought Python was Perl with all the perceived problems fixed. -- Grant -- http://mail.python.org/mailman/listinfo/pytho

Re: python 3's adoption

2010-01-29 Thread Steven D'Aprano
On Fri, 29 Jan 2010 07:10:01 +0100, Alf P. Steinbach wrote: >>>> L = ["æ", "ø", "å"] # This is in SORTED ORDER in Norwegian L [...] >>>> L.sort( key = locale.strxfrm ) >>>> L >['å', 'æ', 'ø'] >>>> locale.strcoll( "å", "æ" ) >1 >>>> locale.strcoll( "æ", "ø" ) >-1

Re: which one is faster?

2010-01-29 Thread Antoine Pitrou
Le Thu, 28 Jan 2010 22:39:32 -0800, alex23 a écrit : > On Jan 29, 4:29 pm, "Stephen.Wu" <54wut...@gmail.com> wrote: >> str.find(targetStr) >> str.index(targetStr) with exception >> str.count(targetStr) >> targetStr in str >> >> which is the fastest way to check whether targetStr is in str? > [...]

Thread get off from CPU occasionally. I suspect.

2010-01-29 Thread Rajat
Hi, I'm using Python 2.6 and using the threading module. In a python module (parent module) I'm importing main() function from another python module. I'm runnin this main() function on a Python thread so that I can periodically check in the parent thread/module if the new thread is up and running.

Re: which one is faster?

2010-01-29 Thread Bruno Desthuilliers
alex23 a écrit : On Jan 29, 4:29 pm, "Stephen.Wu" <54wut...@gmail.com> wrote: str.find(targetStr) str.index(targetStr) with exception str.count(targetStr) targetStr in str which is the fastest way to check whether targetStr is in str? It's generally a lot quicker to investigate this kind of q

Re: Need help with a program

2010-01-29 Thread Steven D'Aprano
On Fri, 29 Jan 2010 11:23:54 +0200, Johann Spies wrote: > On Thu, Jan 28, 2010 at 07:07:04AM -0800, evilweasel wrote: >> Hi folks, >> >> I am a newbie to python, and I would be grateful if someone could point >> out the mistake in my program. Basically, I have a huge text file >> similar to the f

Re: Need help with a program

2010-01-29 Thread Johann Spies
On Thu, Jan 28, 2010 at 07:07:04AM -0800, evilweasel wrote: > Hi folks, > > I am a newbie to python, and I would be grateful if someone could > point out the mistake in my program. Basically, I have a huge text > file similar to the format below: > > AGACTCGAGTGCGCGGA 0 > AGATAAGCTAATTAAG

Re: TypeError not caught by except statement

2010-01-29 Thread siddhartha veedaluru
Hi, Thats the output i got in output window.it is not listing the statement which caused it. copy paste and try it on you setup. it behaves the same way. I know that error is in log.info() function call.but it is not caught by "except". which is not getting logged using log.exception Thanks Sidd

Re: Python-list Digest, Vol 76, Issue 303

2010-01-29 Thread siddhartha veedaluru
Hi, Thats the output i got in output window.it is not listing the statement which caused it. copy paste and try it on you setup. it behaves the same way. I know that error is in log.info() function call.but it is not caught by "except". which is not getting logged using log.exception Thanks Sidd

Re: Wrap a function

2010-01-29 Thread Joan Miller
On 29 ene, 05:44, Dennis Lee Bieber wrote: > On Thu, 28 Jan 2010 11:24:28 -0800 (PST), Joan Miller > declaimed the following in > gmane.comp.python.general: > > > On 28 ene, 19:16, Josh Holland wrote: > > > On 2010-01-28, Joan Miller wrote: > > > > > I've to call to many functions with the form

Re: Sorting a list with entries of unequal types

2010-01-29 Thread Peter Otten
Ben Finney wrote: > Peter Otten <__pete...@web.de> writes: > >> I can't find the relevant part of the 2.6 documentation, but something >> like >> >> >>> def key(x): >> ... t = type(x) >> ... t = compat.get(t, t) >> ... return t.__name__, id(t), x >> ... >> >>> compat = {bool: float, i

  1   2   >