1

In python I have e.g. the following string

433 65040    9322 /opt/conda/envs/python2/bin/python -m ipykernel_launcher 

which I can split according to the following code in python 3:

text = " 433 65040    9322 /opt/conda/envs/python2/bin/python -m ipykernel_launcher"
pid,rss,etime,*remainder = text.split()

However, when I try the same in python 2.7.12, I get a SyntaxError:

In [1]: text = " 433 65040    9322 /opt/conda/envs/python2/bin/python -m ipykernel_launcher"

In [2]: a,b,c,*d = text.split()
   File "<ipython-input-2-a87c46b7bdb7>", line 1
    a,b,c,*d = text.split()
          ^
SyntaxError: invalid syntax

How can I do that in python2?

Alex
  • 41,580
  • 88
  • 260
  • 469

0 Answers0