Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; ';-)': 0.03; 'subject:Python': 0.06; 'perl,': 0.07; 'lines:': 0.09; 'python': 0.11; "','": 0.16; "':'": 0.16; 'element,': 0.16; 'length.': 0.16; 'all,': 0.19; 'trying': 0.19; 'split': 0.19; 'separate': 0.22; 'this:': 0.26; 'second': 0.26; '(this': 0.29; 'field,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'info.': 0.31; 'request,': 0.31; 'file': 0.32; 'text': 0.33; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'done': 0.36; 'subject:?': 0.36; 'hi,': 0.36; 'should': 0.36; 'easily': 0.37; 'thank': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'length': 0.61; 'you.': 0.62; 'address': 0.63; 'information': 0.63 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=Wv+rO3b95H2kEnzya/bUQo1KS1ybfAeSqeas4KY2LVc=; b=BRLbo2xfKycHcNNHGn0eyrEiz8bH/P8D5sRPLap7b78vPNAu1xuJe5p+aPyrYs2vBO DU+hUuIOEUGRgZL2weWpbE9BiRfPGorj/7P+4FHTy7wHpg5Tv+bJVRDqfNKG++n3SWTL BUibnegoPNd3FkpgMxTjWraoiKQL2keXWiUUjT2ovp3BR+XAJiVyoT7ukVNh4dG9E/On xwJvFagPN4IttgjV5QT57PFcVpTPFo0XNj4oimVdGHSSBzCNybDIGQrz5nEg8yC0j9nT buGtPA/aTGLjvIlgpo0a79GDrJhuIarpxj5evLsIHnHAbuouLUBuUa76GwhhP8DIikar pm2Q== MIME-Version: 1.0 X-Received: by 10.60.52.83 with SMTP id r19mr178144oeo.1.1389689216799; Tue, 14 Jan 2014 00:46:56 -0800 (PST) Date: Tue, 14 Jan 2014 00:46:56 -0800 Subject: What's correct Python syntax? From: Igor Korot To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389689219 news.xs4all.nl 2977 [2001:888:2000:d::a6]:55630 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63875 Hi, ALL, I'm trying to process a file which has following lines: 192.168.1.6 > 192.168.1.7: ICMP echo request, id 100, seq 200, length 30 (this is the text file out of tcpdump) Now I can esily split the line twice: once by ':' symbol to separate address and the protocol information and the second time by ',' to get information about the protocol. However, I don't need all the protocol info. All I'm interested in is the last field, which is length. Is there a way to write something like this: for data in f: (address,traffic) = string.split(data, ':') length = string.split(traffic, ',')[3] I'm interesred in only one element, so why should care about everything else? This can be easily done in Perl, but I'm stuck with Python now. ;-) Thank you.