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

2014-04-24 Thread Chris Angelico
On Thu, Apr 24, 2014 at 1:59 PM, Łukasz Langa luk...@langa.pl wrote: On Apr 17, 2014, at 11:49 AM, Brett Cannon bcan...@gmail.com 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

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 chris.bar...@noaa.gov 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

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 bcan...@gmail.com 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

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

2014-04-22 Thread Raymond Hettinger
On Apr 18, 2014, at 1:21 AM, Jeff Allen ja...@farowl.co.uk 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

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 FROM

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

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 algorithm,

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

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 ja...@farowl.co.uk 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

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 gu...@python.org 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

[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

[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.

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

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 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 gu...@python.org escreveu: It's definitely something that