Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77714
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'read.': 0.03; 'argument': 0.05; '"""': 0.07; 'context': 0.07; '[1,': 0.09; 'constructor': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rows': 0.09; 'separating': 0.09; 'subject:into': 0.09; 'subject:method': 0.09; 'wrote': 0.14; 'creates': 0.14; "'b',": 0.16; '(1,': 0.16; "['a',": 0.16; '[*]': 0.16; 'brackets': 0.16; 'brackets,': 0.16; 'commas:': 0.16; 'denote': 0.16; 'elements,': 0.16; 'given,': 0.16; "gmane's": 0.16; 'ie.': 0.16; 'iterable': 0.16; 'iteration,': 0.16; 'iterator': 0.16; 'message- id:@post.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'returned,': 0.16; 'sequence,': 0.16; 'ways:': 0.16; 'elements': 0.16; 'items.': 0.19; 'passing': 0.19; 'header:User-Agent:1': 0.23; 'subject: .': 0.24; 'equivalent': 0.26; 'header:X-Complaints-To:1': 0.27; 'fixed': 0.29; 'list:': 0.30; 'subject:list': 0.30; "i'm": 0.30; 'reply.': 0.31; 'container': 0.31; 'object.': 0.31; 'writes:': 0.31; 'lists': 0.32; 'worked': 0.33; 'but': 0.35; 'add': 0.35; 'method': 0.36; 'charset:us-ascii': 0.36; "i'll": 0.36; 'similar': 0.36; 'example,': 0.37; 'requirements': 0.37; 'list': 0.37; 'clear': 0.37; 'thank': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'little': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'subject: ': 0.61; 'new': 0.61; "you've": 0.63; 'making': 0.63; 'here': 0.66; 'frank': 0.68; 'construction': 0.72; 'square': 0.74; 'experiment': 0.84; 'received:fios.verizon.net': 0.84; 'received:lsanca.fios.verizon.net': 0.84; 'received:108': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | JBB <jeanbigboute@gmail.com> |
| Subject | Re: Passing a list into a list .append() method |
| Date | Tue, 9 Sep 2014 07:08:57 +0000 (UTC) |
| References | <loom.20140909T073428-713@post.gmane.org> <lum84s$f9u$1@ger.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | sea.gmane.org |
| User-Agent | Loom/3.14 (http://gmane.org/) |
| X-Loom-IP | 108.47.76.172 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:25.0) Gecko/20100101 Firefox/25.0) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13888.1410246550.18130.python-list@python.org> (permalink) |
| Lines | 59 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1410246550 news.xs4all.nl 2917 [2001:888:2000:d::a6]:42381 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:77714 |
Show key headers only | View raw
Frank Millman <frank <at> chagford.com> writes:
>
>
> "JBB" <jeanbigboute <at> gmail.com> wrote in message
> news:loom.20140909T073428-713 <at> post.gmane.org...
> >I have a list with a fixed number of elements which I need to grow; ie. add
> > rows of a fixed number of elements, some of which will be blank.
...
> I am sure that someone will give you a comprehensive answer, but here is a
> quick clue which may be all you need.
>...
[ Deletia per gmane's requirements ]
> Wrapping a list with 'list()' has the effect of making a copy of it.
>
> This is from the docs (3.4.1) -
>
> """
> Lists may be constructed in several ways:
>
> - Using a pair of square brackets to denote the empty list: []
> - Using square brackets, separating items with commas: [a], [a, b, c]
> - Using a list comprehension: [x for x in iterable]
> - Using the type constructor: list() or list(iterable)
>
> The constructor builds a list whose items are the same and in the same order
> as iterable's items.
> iterable may be either a sequence, a container that supports iteration, or
> an iterator object.
> If iterable is already a list, a copy is made and returned, similar to
> iterable[:]. [*]
> For example, list('abc') returns ['a', 'b', 'c'] and list( (1, 2, 3) )
> returns [1, 2, 3].
> If no argument is given, the constructor creates a new empty list, [].
> """
>
> I marked the relevant line with [*]
>
> HTH
>
> Frank Millman
Ok, this does clear up why the list() construction worked in this context -
I wasn't aware that it would create a copy.
I'm still a little confused by why passing the list as an argument causes
the list to change. But, I was not aware of the id() method to see what's
equivalent to what. I'll experiment with this and you've given me some good
ideas on other docs I need to read.
Thank you for the quick reply.
JBB
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Passing a list into a list .append() method JBB <jeanbigboute@gmail.com> - 2014-09-09 07:08 +0000
csiph-web