RE: What is wrong with this code?

2011-09-19 Thread Shambhu Rajak
I think you cannnot use "\" as normal string ,it’s a metacharacter, u can use it like this: '\\begin{document}' -Shambhu -Original Message- From: Steven D'Aprano [mailto:steve+comp.lang.pyt...@pearwood.info] Sent: Monday, September 19, 2011 3:31 AM To: python-list@python.org Subject: Re:

Re: Killing threads (was Re: Cancel or timeout a long running regular expression)

2011-09-19 Thread Antoon Pardon
On Sun, Sep 18, 2011 at 07:35:01AM +1000, Chris Angelico wrote: > On Sun, Sep 18, 2011 at 5:00 AM, Nobody wrote: > Forking a thread to discuss threads ahem. > > Why is it that threads can't be killed? Do Python threads correspond > to OS-provided threads (eg POSIX threads on Linux)? Every OS

Operator commutativity

2011-09-19 Thread Henrik Faber
Hi there, when I have a python class X which overloads an operator, I can use that operator to do any operation for example with an integer y = X() + 123 however, say I want the "+" operator to be commutative. Then y = 123 + X() should have the same result. However, since it does not call __ad

Re: Operator commutativity

2011-09-19 Thread Arnaud Delobelle
On 19 September 2011 12:11, Henrik Faber wrote: > Hi there, > > when I have a python class X which overloads an operator, I can use that > operator to do any operation for example with an integer > > y = X() + 123 > > however, say I want the "+" operator to be commutative. Then > > y = 123 + X() >

Re: Operator commutativity

2011-09-19 Thread Paul Rudin
Henrik Faber writes: > How can I make this commutative? Incidentally - this isn't really about commutativity at all - the question is how can you define both left and right versions of add, irrespective of whether they yield the same result. I think __radd__ is what you're after. -- http://ma

Re: Operator commutativity

2011-09-19 Thread Duncan Booth
Henrik Faber wrote: > Hi there, > > when I have a python class X which overloads an operator, I can use that > operator to do any operation for example with an integer > > y = X() + 123 > > however, say I want the "+" operator to be commutative. Then > > y = 123 + X() > > should have the sam

Re: Operator commutativity

2011-09-19 Thread Henrik Faber
On 19.09.2011 13:23, Paul Rudin wrote: > Henrik Faber writes: > >> How can I make this commutative? > > Incidentally - this isn't really about commutativity at all - the > question is how can you define both left and right versions of add, > irrespective of whether they yield the same result. R

Re: Operator commutativity

2011-09-19 Thread Roy Smith
In article , Henrik Faber wrote: > On 19.09.2011 13:23, Paul Rudin wrote: > > Henrik Faber writes: > > > >> How can I make this commutative? > > > > Incidentally - this isn't really about commutativity at all - the > > question is how can you define both left and right versions of add, > > ir

help needed on decimal formatting issue

2011-09-19 Thread Robin Becker
I'm not really very used to the decimal module so I'm asking here if any one can help me with a problem in a well known third party web framework The code in question is def format_number(value, max_digits, decimal_places): """ Formats a number into a string with the requisite number of

Re: Operator commutativity

2011-09-19 Thread Ethan Furman
Roy Smith wrote: In article , Henrik Faber wrote: On 19.09.2011 13:23, Paul Rudin wrote: Henrik Faber writes: How can I make this commutative? Incidentally - this isn't really about commutativity at all - the question is how can you define both left and right versions of add, irrespectiv

Re: Python bug in Windows 8--report now, or later?

2011-09-19 Thread Brian Curtin
On Sat, Sep 17, 2011 at 13:01, Kevin Walzer wrote: > I have been testing my Python application on the just-released developer > preview of Windows 8 and have noted an error: the application does not > create an app folder in the user's "application data" directory. This causes > the app to crash o

Re: Operator commutativity

2011-09-19 Thread Terry Reedy
On 9/19/2011 8:48 AM, Ethan Furman wrote: Roy Smith wrote: __radd__() only solves the problem if the left-hand operand has no __add__() method itself. Only true if the left-hand operand is so ill-behaved it doesn't check to see if it makes sense to add itself to the right-hand operand. If it

help for the parse of encrypted excel

2011-09-19 Thread Christian Ren
I used xlrd library for the parse of excel before. But now, I encounter a problem that the file has been encrypted for some security reason. On the official website, i found "xlrd will not attempt to decode password-protected (encrypted) files. " :(( And I also tried another library called pyExcele

Re: help needed on decimal formatting issue

2011-09-19 Thread Mark Dickinson
On Sep 19, 1:42 pm, Robin Becker wrote: > I'm not really very used to the decimal module so I'm asking here if any one > can > help me with a problem in a well known third party web framework > > The code in question is > > def format_number(value, max_digits, decimal_places): >      """ >      F

Re: Operator commutativity

2011-09-19 Thread Westley Martínez
On Mon, Sep 19, 2011 at 01:11:51PM +0200, Henrik Faber wrote: > Hi there, > > when I have a python class X which overloads an operator, I can use that > operator to do any operation for example with an integer > > y = X() + 123 > > however, say I want the "+" operator to be commutative. Then >

Re: Python bug in Windows 8--report now, or later?

2011-09-19 Thread Andrew Berg
On 2011.09.19 09:00 AM, Brian Curtin wrote: > You said "the application does not create an app folder in the user's > 'application data' directory" -- what does this mean, or rather, what > is the specific folder you're expecting to have? If Python can't > create the directory but you can do it man

Re: Killing threads (was Re: Cancel or timeout a long running regular expression)

2011-09-19 Thread Nobody
On Sun, 18 Sep 2011 23:41:29 -0600, Ian Kelly wrote: >> If the transaction object doesn't get its commit() called, it does no >> actions at all, thus eliminating all issues of locks. > > And what if the thread gets killed in the middle of the commit? The essence of a commit is that it involves a

Re: Killing threads (was Re: Cancel or timeout a long running regular expression)

2011-09-19 Thread Ian Kelly
On Mon, Sep 19, 2011 at 12:25 AM, Chris Angelico wrote: > On Mon, Sep 19, 2011 at 3:41 PM, Ian Kelly wrote: >> And what if the thread gets killed in the middle of the commit? >> > > Database managers solved this problem years ago. It's not done by > preventing death until you're done - death can

logging.config and {-style formatting

2011-09-19 Thread Andrew Berg
Is it possible to use {-style formatting with a logging config file? I can add style='{' to a logging.Formatter() call and it works fine, but I see no way of doing this from a config file. I tried adding a style option in the config file, but it has no effect. I see no mention of the {-style in the

Dynamically Cause A Function To Return

2011-09-19 Thread Jordan Evans
I want dynamically place the 'return' statement in a function via user input or achieve the same through some other means. If some other means, the user must be able initiate this at runtime during a raw_input(). This is what I have so far, this would be an awesome command line debugging tool if

ANN: ActivePython 3.2.2.3 is now available

2011-09-19 Thread Sridhar Ratnakumar
ActiveState is pleased to announce ActivePython 3.2.2.3, a complete, ready-to-install binary distribution of Python 3.2. http://www.activestate.com/activepython/downloads What's New in ActivePython-3.2.2.3 == New Features & Upgrades --- -

Re: Killing threads (was Re: Cancel or timeout a long running regular expression)

2011-09-19 Thread Chris Angelico
On Tue, Sep 20, 2011 at 8:04 AM, Ian Kelly wrote: > "PowerCordRemoved" is not relevant here, as that would kill the entire > process, which renders the issue of broken shared data within a > continuing process rather moot. > Assuming that the "broken shared data" exists only in RAM on one single

Re: Killing threads (was Re: Cancel or timeout a long running regular expression)

2011-09-19 Thread Gregory Ewing
Antoon Pardon wrote: int PyThreadState_SetAsyncExc(long id, PyObject *exc) To prevent naive misuse, you must write your own C extension to call this. Not if we use ctypes! Muahahahaaa! -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Operator commutativity

2011-09-19 Thread Steven D'Aprano
Westley Martínez wrote: > def __radd__(self, other): > return self.__add__(self, other) Which, inside a class, can be simplified to: __radd__ = __add__ -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Operator commutativity

2011-09-19 Thread Roy Smith
In article <4e77eae1$0$29978$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Westley Martínez wrote: > > > def __radd__(self, other): > > return self.__add__(self, other) > > Which, inside a class, can be simplified to: > > __radd__ = __add__ Ooh, I could see that lead

Re: Operator commutativity

2011-09-19 Thread Westley Martínez
On Mon, Sep 19, 2011 at 10:26:30PM -0400, Roy Smith wrote: > In article <4e77eae1$0$29978$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > > > Westley Mart??nez wrote: > > > > > def __radd__(self, other): > > > return self.__add__(self, other) > > > > Which, inside a class,