A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-September/056472.html below:

[Python-Dev] list splicing

[Python-Dev] list splicingKarl Chen quarl at NOSPAM.quarl.org
Mon Sep 19 03:50:14 CEST 2005
Hi, has anybody considered adding something like this:
    a = [1, 2]
    [ 'x', *a, 'y']

as syntactic sugar for
    a = [1, 2]
    [ 'x' ] + a + [ 'y' ].

Notes:
- This is a common operation
- To me, the splicing form looks much better than the
  concatenation form
- It can be implemented more efficiently than a bunch of list
  concatenations
- This would be similar to the "apply" feature [ foo(*a) ].  The
  '*' operator is reminiscent of dereferencing operators in
  C-derived languages.  Alternatively it could be '@', like perl's
  implicit array splicing, and Lisp's ',@' in backquoted lists.
- (I know "splicing" traditionally refers to something else in
  Python, but other languages refer to this as splicing, and the
  English definition of "splice" applies better to this.)

-- 
Karl 2005-09-18 18:26

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4