Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Stephen Hansen Newsgroups: comp.lang.python Subject: Re: Most probably a stupid question, but I still want to ask Date: Sun, 10 Apr 2016 16:30:24 -0700 Lines: 47 Message-ID: References: <1460331024.3440141.574603049.214AD5E6@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de IwdkfS+GEoGf9NqwQfYeWAyTijT2R9GR/S8AbjCd8YOw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'subject:question': 0.08; 'received:internal': 0.09; 'subject:still': 0.09; 'tuple': 0.09; 'python': 0.10; 'weird': 0.15; 'eval': 0.16; 'expression.': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:66.111.4.27': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:out3-smtp.messagingengine.com': 0.16; 'received:psf.io': 0.16; 'surprising': 0.16; 'tuple,': 0.16; 'wrote:': 0.16; 'string': 0.17; 'language': 0.19; '>>>': 0.20; '(not': 0.20; 'tuples': 0.22; 'decide': 0.23; 'this:': 0.23; 'header:In-Reply- To:1': 0.24; 'linux': 0.26; 'least': 0.27; 'question': 0.27; "skip:' 10": 0.28; 'skip:[ 10': 0.31; 'point': 0.33; "skip:' 20": 0.34; 'besides': 0.35; 'something': 0.35; 'asking': 0.35; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'really': 0.37; 'doing': 0.38; 'received:66': 0.38; 'why': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'header:Message-Id:1': 0.61; 'more': 0.63; 'designers': 0.72; 'betray': 0.84; '2014,': 0.91; 'subject:want': 0.93 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=ixokai.io; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=eVO5mx2OAqGABaFMxUTrdZ6pe1I=; b=J9fYeM UuAyS3p8Qch/OYjhvj98K2+WV3cbU+aco6jWeBQ5mXHcNdNwo5/NqSJMtgkES0nw 3EMrUlfOITqccfHgWinpggpKNSGYGojS+0kCzoFziVLI4yM5u08RlMxSMQbwY4j4 B0CJACb5dfoMKv7NMedx5BCjJ+kh/04i5HoFU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=eVO5mx2OAqGABaF MxUTrdZ6pe1I=; b=oKWdez5NHqUVa2B+elaxGM4tNWfWFQOTYB67+mfAsqNw3ra 2HTr1H7WKlvtnbnGdzFmxjZQjf+ioeNwWNGZ91QB9L5HEH7Ra9GFE/FRwKgqLvDy z9sRWQiL2ckVWTI893Yc1/qzne1LqLoTJHAOpuuY1JbbnfgJV8r+Ox50X4DE= X-Sasl-Enc: pfX0FjUwwfalKQtm5aOKtl5I9nVy8qEU4ve+ZEs4Bgn4 1460331024 X-Mailer: MessagingEngine.com Webmail Interface - ajax-eadf0bcf In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <1460331024.3440141.574603049.214AD5E6@webmail.messagingengine.com> X-Mailman-Original-References: Xref: csiph.com comp.lang.python:106802 On Sun, Apr 10, 2016, at 03:51 PM, Fillmore wrote: > > let's look at this: > > $ python3.4 > Python 3.4.0 (default, Apr 11 2014, 13:05:11) > [GCC 4.8.2] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> line1 = '"String1" | bla' > >>> parts1 = line1.split(" | ") > >>> parts1 > ['"String1"', 'bla'] > >>> tokens1 = eval(parts1[0]) > >>> tokens1 > 'String1' > >>> tokens1[0] > 'S' > > and now this > > >>> line2 = '"String1","String2" | bla' > >>> parts2 = line2.split(" | ") > >>> tokens2 = eval(parts2[0]) I *THINK* what you're asking is why this returns a tuple, where in the first eval you got a string. The answer is because commas create tuples (not parens), so: "String1", "String2" is a tuple expression. Whereas: "String1" is a string expression. > the question is: at which point did the language designers decide to > betray the > "path of least surprise" principle and create a 'discontinuity' in the > language? There's nothing inconsistent or surprising going on besides you doing something vaguely weird and not really expressing what you find surprising. --Stephen m e @ i x o k a i . i o