python - Advanced slicing with tuple using *args -


According to

, you can do it in a simple way:

  & gt; & Gt; & Gt; A = Category (20)> gt; & Gt; & Gt; B = (5, 12)> gt; & Gt; & Gt;   

But what I need is advanced:

  a [5:] a [: 12] a [:] a [-1] a [-2:] A [: - 2] A [:: - 1]   

How to do it with Tupal and * args ?

  b = (5, :) & gt; & Gt; File "& lt; ipython-input-26-c4eae 928199d"; Line 1 & gt; & Gt; B = (5, :) & gt; & Gt; ^ & Gt; & Gt; Syntax error: invalid syntax    

For those options that you want to terminate, Replace with any . Generally, if any option is omitted, then it is not the default on any .

Such an option is piece (none, none, none) is equal to a [::] . Do not miss the start and step argument for any default .

for East.

  a [5:] - & gt; B = (5, none, none) one [: 12] - & gt; B = (none, 12) A [:] - & gt; B = (none, none)   

One thing to note is that the slicing action is different from the sequencing. You can not use slices if you intend to index.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -