Re: Inconsistent behaviour os str.find/str.index when providing optional parameters

2012-11-22 Thread Giacomo Alzetta
Il giorno giovedì 22 novembre 2012 09:44:21 UTC+1, Steven D'Aprano ha scritto: > On Wed, 21 Nov 2012 23:01:47 -0800, Giacomo Alzetta wrote: > > > > > Il giorno giovedì 22 novembre 2012 05:00:39 UTC+1, MRAB ha scritto: > > >> On 2012-11-22 03:41, Terry Reedy

Re: Inconsistent behaviour os str.find/str.index when providing optional parameters

2012-11-21 Thread Giacomo Alzetta
Il giorno giovedì 22 novembre 2012 05:00:39 UTC+1, MRAB ha scritto: > On 2012-11-22 03:41, Terry Reedy wrote: > It can't return 5 because 5 isn't an index in 'spam'. > > > > It can't return 4 because 4 is below the start index. Uhm. Maybe you are right, because returning a greater value would c

Re: Inconsistent behaviour os str.find/str.index when providing optional parameters

2012-11-21 Thread Giacomo Alzetta
Il giorno mercoledì 21 novembre 2012 20:25:10 UTC+1, Hans Mulder ha scritto: > On 21/11/12 17:59:05, Alister wrote: > > > On Wed, 21 Nov 2012 04:43:57 -0800, Giacomo Alzetta wrote: > > > > > >> I just came across this: > > >

Inconsistent behaviour os str.find/str.index when providing optional parameters

2012-11-21 Thread Giacomo Alzetta
I just came across this: >>> 'spam'.find('', 5) -1 Now, reading find's documentation: >>> print(str.find.__doc__) S.find(sub [,start [,end]]) -> int Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are

Re: Missing modules compiling python3.3

2012-11-04 Thread Giacomo Alzetta
Il giorno domenica 4 novembre 2012 15:56:03 UTC+1, mm0fmf ha scritto: > Giacomo Alzetta wrote: > > > I'm trying to compile python3.3 on my (K)ubuntu 12.04, but some modules are > > missing. > > > > > > In particular when doing make test I get: >

Missing modules compiling python3.3

2012-11-04 Thread Giacomo Alzetta
I'm trying to compile python3.3 on my (K)ubuntu 12.04, but some modules are missing. In particular when doing make test I get: Python build finished, but the necessary bits to build these modules were not found: _bz2 _curses_curses_panel _dbm _gdbm

Re: Add a "key" parameter to bisect* functions?

2012-09-12 Thread Giacomo Alzetta
Il giorno mercoledì 12 settembre 2012 18:05:10 UTC+2, Miki Tebeka ha scritto: > > I've just noticed that the bisect module lacks of the key parameter. > > > ... > > > Is there some reason behind this lack? > > See full discussion at http://bugs.python.org/issue4356. Guido said it's > going in,

Re: Add a "key" parameter to bisect* functions?

2012-09-12 Thread Giacomo Alzetta
Il giorno mercoledì 12 settembre 2012 17:54:31 UTC+2, Giacomo Alzetta ha scritto: > I've just noticed that the bisect module lacks of the key parameter. > > > > The documentation points to a recipe that could be used to handle a sorted > collection, but I think it

Add a "key" parameter to bisect* functions?

2012-09-12 Thread Giacomo Alzetta
I've just noticed that the bisect module lacks of the key parameter. The documentation points to a recipe that could be used to handle a sorted collection, but I think it's an overkill if I want to bisect my sequence only once or twice with a key. Having something like `bisect(sequence, key=my_k

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread Giacomo Alzetta
Il giorno domenica 19 agosto 2012 22:42:16 UTC+2, kj ha scritto: > As far as I've been able to determine, Python does not remember > > (immutably, that is) the working directory at the program's start-up, > > or, if it does, it does not officially expose this information. > > > > Does anyone k

Re: in-place exponentiation incongruities

2012-08-14 Thread Giacomo Alzetta
Il giorno domenica 12 agosto 2012 23:53:46 UTC+2, Terry Reedy ha scritto: > > Are you actually planning to do this, or is this purely theoretical? > Yes, I do plan to implement ipow. > > Not true. Whether the function is coded in Python or C > > cls.__ipow__(base, exp, mod) # or > > base.__i

Re: in-place exponentiation incongruities

2012-08-12 Thread Giacomo Alzetta
Il giorno domenica 12 agosto 2012 13:03:08 UTC+2, Steven D'Aprano ha scritto: > On Sun, 12 Aug 2012 00:14:27 -0700, Giacomo Alzetta wrote: > > > > > From The Number Protocol(http://docs.python.org/c-api/number.html). The > > > full text is: > > >

Re: in-place exponentiation incongruities

2012-08-12 Thread Giacomo Alzetta
Il giorno domenica 12 agosto 2012 06:28:10 UTC+2, Steven D'Aprano ha scritto: > On Sat, 11 Aug 2012 09:54:56 -0700, Giacomo Alzetta wrote: > > > > > I've noticed some incongruities regarding in-place exponentiation. > > > > > > On the C sid

in-place exponentiation incongruities

2012-08-11 Thread Giacomo Alzetta
I've noticed some incongruities regarding in-place exponentiation. On the C side nb_inplace_power is a ternary function, like nb_power (see here: http://docs.python.org/c-api/typeobj.html?highlight=numbermethods#PyNumberMethods). Obviously you can't pass the third argument using the usual in-pla

Re: [c-api]Transmutation of an extension object into a read-only buffer adding an integer in-place.

2012-08-11 Thread Giacomo Alzetta
Il giorno sabato 11 agosto 2012 08:40:18 UTC+2, Stefan Behnel ha scritto: > Giacomo Alzetta, 11.08.2012 08:21: > > > I'd prefer to stick to Python and C, without having to put cython > > > sources or cython-generated c modules (which I know are almost > > >

Re: [c-api]Transmutation of an extension object into a read-only buffer adding an integer in-place.

2012-08-10 Thread Giacomo Alzetta
Il giorno venerdì 10 agosto 2012 20:50:08 UTC+2, Stefan Behnel ha scritto: > Giacomo Alzetta, 10.08.2012 10:20: > > > I'm trying to implement a c-extension which defines a new > > class(ModPolynomial on the python side, ModPoly on the C-side). > > > At the

Re: [c-api]Transmutation of an extension object into a read-only buffer adding an integer in-place.

2012-08-10 Thread Giacomo Alzetta
Il giorno venerdì 10 agosto 2012 14:21:50 UTC+2, Hans Mulder ha scritto: > On 10/08/12 11:25:36, Giacomo Alzetta wrote: > > > Il giorno venerdì 10 agosto 2012 11:22:13 UTC+2, Hans Mulder ha scritto: > > [...] > > > Yes, you're right. I didn't tho

Re: [c-api]Transmutation of an extension object into a read-only buffer adding an integer in-place.

2012-08-10 Thread Giacomo Alzetta
Il giorno venerdì 10 agosto 2012 11:22:13 UTC+2, Hans Mulder ha scritto: > On 10/08/12 10:20:00, Giacomo Alzetta wrote: > > > I'm trying to implement a c-extension which defines a new > > class(ModPolynomial on the python side, ModPoly on the C-side). > > >

[c-api]Transmutation of an extension object into a read-only buffer adding an integer in-place.

2012-08-10 Thread Giacomo Alzetta
I'm trying to implement a c-extension which defines a new class(ModPolynomial on the python side, ModPoly on the C-side). At the moment I'm writing the in-place addition, but I get a *really* strange behaviour. Here's the code for the in-place addition: #define ModPoly_Check(v) (PyObject_TypeCh