Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #104658

Perl to Python again

From Fillmore <fillmore_remove@hotmail.com>
Newsgroups comp.lang.python
Subject Perl to Python again
Date 2016-03-11 18:42 -0500
Organization Aioe.org NNTP Server
Message-ID <nbvl51$9ch$1@gioia.aioe.org> (permalink)

Show all headers | View raw


So, now I need to split a string in a way that the first element goes 
into a string and the others in a list:

while($line = <STDIN>) {

     my ($s,@values)  = split /\t/,$line;

I am trying with:

for line in sys.stdin:
     s,values = line.strip().split("\t")
     print(s)

but no luck:

ValueError: too many values to unpack (expected 2)

What's the elegant python way to achieve this?

Thanks

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Perl to Python again Fillmore <fillmore_remove@hotmail.com> - 2016-03-11 18:42 -0500
  Re: Perl to Python again sohcahtoa82@gmail.com - 2016-03-11 16:04 -0800
  Re: Perl to Python again Fillmore <fillmore_remove@hotmail.com> - 2016-03-11 19:15 -0500
    Re: Perl to Python again alister <alister.ware@ntlworld.com> - 2016-03-12 09:40 +0000
      Re: Perl to Python again Fillmore <fillmore_remove@hotmail.com> - 2016-03-12 08:10 -0500

csiph-web