Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-24 Thread Chris Barker
Ooops, Forgot "reply all" last time -- here it is again. On Wed, Apr 23, 2014 at 3:17 PM, Chris Barker wrote: > On Mon, Apr 21, 2014 at 11:39 PM, Raymond Hettinger < > raymond.hettin...@gmail.com> wrote: > >> In fact, the distinction is extrinsic to their implementations. It is >> only importa

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-23 Thread Chris Angelico
On Thu, Apr 24, 2014 at 1:59 PM, Łukasz Langa wrote: > On Apr 17, 2014, at 11:49 AM, Brett Cannon wrote: > >> Think of tuples like a struct in C, lists like an array. > > > I generally agree but it’s a bit more complex, for instance when you have a > homogenous sequence but want it to be hashable

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-23 Thread Łukasz Langa
On Apr 17, 2014, at 11:49 AM, Brett Cannon wrote: > Think of tuples like a struct in C, lists like an array. I generally agree but it’s a bit more complex, for instance when you have a homogenous sequence but want it to be hashable. I just hit that today and felt a little bad using tuple becau

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-22 Thread Stephen J. Turnbull
Leandro Pereira de Lima e Silva writes: >> In teaching Python, I find that analogs to other languages are >> helpful in explaining Python even if a person doesn't know the other >> language. >>    sorted(set(open(somefile))) >> is like: >>    cat somefile | sort | uniq       # different al

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-22 Thread Leandro Pereira de Lima e Silva
That's rather vague, isn't it? "Usually contains" isn't nearly as prescriptive as "should be used for". A co-worker with whom I discussed the matter these days also argued that a language shouldn't prescribe as one uses a data structure, although I do think conventions in semantics helps maintaina

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-22 Thread Leandro Pereira de Lima e Silva
> > In teaching Python, I find that analogs to other languages are helpful > in explaining Python even if a person doesn't know the other language. > sorted(set(open(somefile))) > is like: > cat somefile | sort | uniq # different algorithm, same outcome > or: >SELECT DISTINCT line

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-21 Thread Raymond Hettinger
On Apr 18, 2014, at 1:21 AM, Jeff Allen wrote: > The "think of tuples like a struct in C" explanation immediately reminded me > that ... > > On 16/04/2014 21:42, Taavi Burns wrote (in his excellent notes from the > language summit): >> The demographics have changed. How do >> we change the d

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-18 Thread Ezio Melotti
Hi, On Thu, Apr 17, 2014 at 10:23 PM, Guido van Rossum wrote: > It's definitely something that should be put in some documentation, see http://bugs.python.org/issue14840 and https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences : """ Though tuples may seem similar to lists,

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-18 Thread Nick Coghlan
On 18 April 2014 04:21, Jeff Allen wrote: > > The "think of tuples like a struct in C" explanation immediately reminded me > that ... > > On 16/04/2014 21:42, Taavi Burns wrote (in his excellent notes from the > language summit): > > The demographics have changed. How do > we change the docs and

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-18 Thread Jeff Allen
The "think of tuples like a struct in C" explanation immediately reminded me that ... On 16/04/2014 21:42, Taavi Burns wrote (in his excellent notes from the language summit): The demographics have changed. How do we change the docs and ecosystem to avoid the assumption that Python program

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-17 Thread Leandro Pereira de Lima e Silva
This looks like an issue to be addressed at PEP-8 since it looks like a styling issue. I haven't seen any other recommendations there on how to use a certain data structure, though. Cheers, Leandro Em 17/04/2014 16:24, "Guido van Rossum" escreveu: > It's definitely something that should be put

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-17 Thread Guido van Rossum
No, I don't think it belongs in the style guide. It is not about code formatting or naming, it is about data structure design and API design. On Thu, Apr 17, 2014 at 12:49 PM, Leandro Pereira de Lima e Silva < leandro...@cpti.cetuc.puc-rio.br> wrote: > This looks like an issue to be addressed at

Re: [Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-17 Thread Guido van Rossum
It's definitely something that should be put in some documentation, probably at the point when people have learned enough to be designing their own programs where this issue comes up -- before they're wizards but well after they have learned the semantic differences between lists and tuples. On T

[Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-17 Thread Brett Cannon
On Thu Apr 17 2014 at 2:43:35 PM, Leandro Pereira de Lima e Silva < leandro...@cpti.cetuc.puc-rio.br> wrote: > Hello there! > > I've stumbled upon this discussion on python-dev about what the choice > between using a list or a tuple is all about in 2003: > 1. https://mail.python.org/pipermail/pyth

[Python-Dev] List vs Tuple / Homogeneous vs Heterogeneous / Mutable vs Immutable

2014-04-17 Thread Leandro Pereira de Lima e Silva
Hello there! I've stumbled upon this discussion on python-dev about what the choice between using a list or a tuple is all about in 2003: 1. https://mail.python.org/pipermail/python-dev/2003-March/033962.html 2. https://mail.python.org/pipermail/python-dev/2003-March/034029.html There's a vague c