LoginSignup
1
1

More than 5 years have passed since last update.

Python > 拡張スライスとは

Last updated at Posted at 2016-12-26

コメントにて教えていただいたPEP8での書き方。
https://pep8-ja.readthedocs.io/ja/latest/#id16

拡張スライスでは、両側に同じ数のスペースを置かなければなりません。

拡張スライスというのを分かっていなかった。

However, Python's built-in list, tuple, and string sequence types have never supported this feature, raising a TypeError if you tried it.

拡張スライスの「拡張」は、「list, tuple, string sequenceに対応した」という意味での「拡張」なのだろうか?

使い方は上記のページにいくつか例がある。

>>> L = range(10)
>>> L[::2]
[0, 2, 4, 6, 8]
>>> L[::-1]
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

https://pep8-ja.readthedocs.io/ja/latest/#id16
に記載の以下については分かった(と思う)。

拡張スライスでは、両側に同じ数のスペースを置かなければなりません。

1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1