Re: running python 2 vs 3

2014-03-20 Thread Eric Jacoboni
Le 20/03/2014 16:21, Marko Rauhamaa a écrit : All tutorials will tell you to start it with #!/usr/bin/env python which will start python2 on all (?) existing linux distros, but is expected to start python3 within the next decade. With Arch-Linux, python is python3... --

Re: Tuples and immutability

2014-03-02 Thread Eric Jacoboni
Le 02/03/2014 13:32, Ian Kelly a écrit : On Sat, Mar 1, 2014 at 7:04 PM, Eric Jacoboni eric.jacob...@gmail.com wrote: In fact, i think i'm gonna forget += on lists :) Well, do what you want, but I think you're taking the wrong lesson from this. Don't forget about using += on lists. Instead

Re: Tuples and immutability

2014-03-02 Thread Eric Jacoboni
Le 02/03/2014 15:05, Mark Lawrence a écrit : The behaviour is consistent except when you try to modify a tuple. Not in my opinion... li = [10, 30] li = li + spam -- TypeError: can only concatenate list (not str) li += spam -- Ok So, not, that's not what i call consistent. And it's

Re: Tuples and immutability

2014-03-01 Thread Eric Jacoboni
Le 01/03/2014 22:21, Mark H. Harris a écrit : The point I'm trying to make with this post is that s[2]+=[46] and s[2]=s[2]+[46] are handled inconsistently. For my own, the fact that, in Python, a_liste += e_elt gives a different result than a_list = a_list + e_elt is a big source of

Re: Tuples and immutability

2014-02-28 Thread Eric Jacoboni
Le 01/03/2014 01:22, Mark H. Harris a écrit : I'll address the second first by asking a question... should an immutable type (object) be able to hold (contain) mutable objects ... should tuples be allowed to hold lists? lists within a tuple should be converted to tuples.If you want

Tuples and immutability

2014-02-27 Thread Eric Jacoboni
Hi, I'm using Python 3.3 and i have a problem for which i've still not found any reasonable explanation... a_tuple = (spam, [10, 30], eggs) a_tuple[1] += [20] Traceback (most recent call last): File stdin, line 1, in module TypeError: 'tuple' object does not support item assignment Ok... I

Re: Tuples and immutability

2014-02-27 Thread Eric Jacoboni
Le 27/02/2014 17:13, Zachary Ware a écrit : You're not the first person to have this question :) http://docs.python.org/3/faq/programming.html#why-does-a-tuple-i-item-raise-an-exception-when-the-addition-works Oh yes, i was aware of this explanation (thanks to Chris for his answer, too)...

Python3, __slots__ and serialization

2014-02-08 Thread Eric Jacoboni
Hi, Say i want create a class with a __slots__ tuple in order to prevent creation of new attributes from outside the class. Say i want to serialize instances of this class... With pickle, all is ok : i can dump an object to a file, then reload it. With PyYAML, i can dump an object to a file,

Question about struct.unpack

2006-02-22 Thread Eric Jacoboni
a str.unpack(Z32dIc). So, i don't know why i need to pad the format string in Python. Any clue? BTW: how to get rid of all this stuff after the \0 in the first field in Python? (Ruby has Z and A, but it seems that the Python 's' specifier is like 'A' and there is no 'Z' equivalent) -- Eric

Re: Question about struct.unpack

2006-02-22 Thread Eric Jacoboni
\xa4\x00\x00.8\xfe\xfe\xfe\xff\x80\x80\x80\x80' -- Eric Jacoboni, ne il y a 1444080064 secondes -- http://mail.python.org/mailman/listinfo/python-list

Re: Underscores in Python numbers

2005-11-21 Thread Eric Jacoboni
[EMAIL PROTECTED] (Bengt Richter) writes: Eric Jacoboni, ne il y a 1435938104 secondes Um, about your sig ... ;-) Well, i confess it's Ruby code... Maybe, one day, i will try to write a Python Version (with DateTime, i guess?) but i'm afraid it doesn't change the result. -- Eric Jacoboni, ne

Re: about sort and dictionary

2005-11-20 Thread Eric Jacoboni
that they operate by side effect, they don't return the sorted or reversed list. -- Eric Jacoboni, ne il y a 1435934131 secondes -- http://mail.python.org/mailman/listinfo/python-list

Re: Underscores in Python numbers

2005-11-20 Thread Eric Jacoboni
grouping. The Ruby language allows also this notation. You may write 1_000_001 or 1000_001 or 10_00_001, etc. (the same for real numbers...). When you have the habit to represent literals like that, all other big numeric literals or workarounds to create grouping seem cryptic. -- Eric Jacoboni, ne il

Re: strip not working on strings?

2005-11-13 Thread Eric Jacoboni
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: I'm using Python 2.3.5 and when I type the following in the interactive prompt I see that strip() is not working as advertised: s = 'p p:p' s.strip(' :') 'p p:p' Is this just me or does it not work? I want to get rid of all ' ' and

Re: strip not working on strings?

2005-11-13 Thread Eric Jacoboni
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: I'm using Python 2.3.5 and when I type the following in the interactive prompt I see that strip() is not working as advertised: s = 'p p:p' s.strip(' :') 'p p:p' Is this just me or does it not work? I want to get rid of all ' ' and

Re: strip not working on strings?

2005-11-13 Thread Eric Jacoboni
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: I'm using Python 2.3.5 and when I type the following in the interactive prompt I see that strip() is not working as advertised: s = 'p p:p' s.strip(' :') 'p p:p' Is this just me or does it not work? I want to get rid of all ' ' and