Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'parameters': 0.04; 'element': 0.07; 'modify': 0.07; 'sys': 0.07; 'filename': 0.09; 'filenames': 0.09; 'filenames:': 0.09; 'newly': 0.09; 'spelled': 0.09; 'question.': 0.14; '%s\\n"': 0.16; 'filename)': 0.16; 'received:mac.com': 0.16; 'referencing': 0.16; 'index': 0.16; 'all.': 0.16; 'bit': 0.19; 'result.': 0.19; 'slightly': 0.19; 'import': 0.22; 'to:name:python- list@python.org': 0.22; 'print': 0.22; 'sean': 0.24; 'script': 0.25; 'shown': 0.26; 'array': 0.29; 'character': 0.29; 'code': 0.31; 'getting': 0.31; 'os,': 0.31; 'languages': 0.32; 'subject:with': 0.35; 'something': 0.35; 'but': 0.35; 'charset:us- ascii': 0.36; 'received:17': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'results.': 0.60; 'providing': 0.61; 'different': 0.65; 'results': 0.69; 'wish': 0.70 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.87,1.0.14,0.0.0000 definitions=2014-01-03_08:2014-01-03,2014-01-03,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1308280000 definitions=main-1401030228 From: Sean Murphy Content-type: text/plain; charset=us-ascii Content-transfer-encoding: quoted-printable Subject: Strange behaviour with a for loop. Date: Sat, 04 Jan 2014 15:03:35 +1100 To: "python-list@python.org" MIME-version: 1.0 (Mac OS X Mail 6.6 \(1510\)) X-Mailer: Apple Mail (2.1510) 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: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1388811827 news.xs4all.nl 2866 [2001:888:2000:d::a6]:49651 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63107 Hello all. This is a newly question. But I wish to understand why the below code is = providing different results. import os, sys if len(sys.argv) > 2: filenames =3D sys.argv[1:] else print ("no parameters provided\n") sys.edit() for filename in filenames: print ("filename is: %s\n" %filename) The above code will return results like: filename is test.txt If I modify the above script slightly as shown below, I get a completely = different result.=20 if len(sys.argv) > 2: filenames =3D sys.argv[1] else print ("no parameters provided\n") sys.exit() for filename in filenames: print ("filename is: %s\n" % filename) The result is the filename is spelled out a character at a time. The bit = I am missing is something to do with splicing or referencing in Python. Why am I getting different results? In other languages I would have got = the whole content of the element when using the index of the array = (list). Sean=20 filename is: t filename=20