Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '16,': 0.03; 'languages.': 0.04; 'syntax': 0.04; 'subject:Python': 0.06; 'string': 0.09; 'python': 0.11; '"d"': 0.16; '"def"': 0.16; 'confuse': 0.16; 'decimal.': 0.16; 'escapes': 0.16; 'fancy': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'half.': 0.16; 'iteration,': 0.16; 'normally,': 0.16; 'octal': 0.16; 'operator.': 0.16; 'ought': 0.16; 'personally,': 0.16; 'record,': 0.16; 'subject:Java': 0.16; 'substring': 0.16; 'elements': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'examples': 0.20; 'seems': 0.21; '(the': 0.22; '>>>': 0.22; 'error': 0.23; 'basis,': 0.24; 'removed.': 0.24; "shouldn't": 0.24; 'looks': 0.24; 'equivalent': 0.26; 'world,': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'array': 0.29; 'character': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'clever': 0.31; "d'aprano": 0.31; 'division': 0.31; 'steven': 0.31; 'this.': 0.32; 'languages': 0.32; 'maybe': 0.34; 'subject: (': 0.35; 'something': 0.35; '(2)': 0.35; 'done.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'done': 0.36; 'too': 0.37; 'being': 0.38; 'implement': 0.38; 'loss': 0.38; 'problems': 0.38; '(3)': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'free': 0.61; 'first': 0.61; 'happen': 0.63; 'more': 0.64; 'talking': 0.65; 'worth': 0.66; 'here': 0.66; 'direct': 0.67; 'lose': 0.68; 'about?': 0.84; 'pray': 0.84; 'do:': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=mXjU0ke/RxQA5GjywZVLFVCnPMeT7Vs3Ww00aiT+gFc=; b=b513VYiFuQ3WvFQdNPgYJ7aYAXyjkJdP+EGd3Hm7XjBMbJgc/mK6lwu2i8bMma1D2u K0zH+wVH3vqnycBr5P0UOCqoha49s2z93Pq77DcQk9IVP6Ia4tbCpip0iAIfZYZACulE frm2FMfWbiLuWvWlvJ5iXq/a6+676B+Zv/GmQk7Dx6jqlTFij2xs53FqLYgXc8jTnpuw 6Clws1GruIuaF+KLki21iOch7KsUocFZjJVGjUPDy7zK96EVhG1kc6YE0119QW7oC9pw PCUK7bMULDcAoum9fjSs7DLrwGOAvDU+kIOiBdKnRtomaaiVdq7T/LR/2XkAUl7XrpEt sbmQ== MIME-Version: 1.0 X-Received: by 10.68.234.165 with SMTP id uf5mr43442672pbc.41.1381864146845; Tue, 15 Oct 2013 12:09:06 -0700 (PDT) In-Reply-To: <525d58e6$0$29984$c3e8da3$5496439d@news.astraweb.com> References: <525CF350.7070909@rece.vub.ac.be> <525d58e6$0$29984$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 16 Oct 2013 06:09:06 +1100 Subject: Re: Python was designed (was Re: Multi-threading in Python vs Java) From: Chris Angelico 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: 78 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381864150 news.xs4all.nl 15994 [2001:888:2000:d::a6]:44470 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56857 On Wed, Oct 16, 2013 at 2:01 AM, Steven D'Aprano wrote: > On Tue, 15 Oct 2013 19:57:50 +1100, Chris Angelico wrote: >> Python doesn't happen to implement str-str or str/str, but some >> languages do: > > Which languages are you talking about? > > For the record, if PHP is one of them, I consider that a good sign that > it shouldn't be done :-) My examples here are from Pike. >>> "abc"+"def"-"abc"; >> (1) Result: "def" > > Eww. What would "xyz" - "abc" give? How about "cba" - "abc"? > > And "abcdabc" - "abc"? > > Justify your answers. > "xyz" - "abc"; (1) Result: "xyz" > "cba" - "abc"; (2) Result: "cba" > "abcdabc" - "abc"; (3) Result: "d" Every instance of the subtracted-out string is removed. It's something like x.remove(y) in many other languages. >>> "abc"-"b"; >> (2) Result: "ac" >>> "foo bar asdf qwer"/" "*"##"; >> (3) Result: "foo##bar##asdf##qwer" > > And what, pray tell, would "foo bar" / " " be on its own? A two-element array "foo","bar": > "foo bar" / " "; (4) Result: ({ /* 2 elements */ "foo", "bar" }) > How about "foo bar" * "*"? That's an error (the equivalent of TypeError). > Seems to me that using s/t*u as a way to perform substring replacement is > too clever by half. Maybe :) It looks fancy for something like this. Normally, I use string division with iteration, but there is a more direct "replace" function for when that's being done. > Personally, I think string and array concatenation ought to be & rather > than +. That would free up + for element-wise addition for arrays, while > still allowing & for concatenation. Of course, the cost would be the loss > of an element-wise bit-and operator. You win some, you lose some. I don't know who was first to implement string+string --> concat, but since it's swept the world, it's worth keeping just on that basis, in the same way that the use of octal for character escapes like "\123" is worth keeping: >>> ord("\123") 83 >>> 0o123 83 Confused me no end when I came across BIND's use of that syntax to mean decimal. So if & has its problems and + has its problems, go with +, as it'll confuse less people. ChrisA