Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; ';-)': 0.03; 'languages.': 0.04; 'subject:Python': 0.06; 'string': 0.09; 'python:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '"d"': 0.16; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'readable': 0.16; 'sense,': 0.16; 'subject:Java': 0.16; 'subtraction': 0.16; 'elements': 0.16; 'wrote:': 0.18; "python's": 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'removed.': 0.24; 'replace': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'array': 0.29; 'matching': 0.30; "i'm": 0.30; 'code': 0.31; 'division': 0.31; 'skip:d 20': 0.34; 'subject: (': 0.35; 'something': 0.35; '(2)': 0.35; 'charset:us-ascii': 0.36; '(3)': 0.38; 'delete': 0.39; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'theoretical': 0.74; 'glad': 0.83; 'flexible,': 0.84; 'pray': 0.84; 'received:50.22': 0.84 Date: Tue, 15 Oct 2013 16:17:33 -0500 From: Tim Chase To: Chris Angelico Subject: Re: Python was designed (was Re: Multi-threading in Python vs Java) In-Reply-To: References: <525CF350.7070909@rece.vub.ac.be> <525d58e6$0$29984$c3e8da3$5496439d@news.astraweb.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: none Cc: python-list@python.org 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: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381871752 news.xs4all.nl 15928 [2001:888:2000:d::a6]:42493 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56861 On 2013-10-16 06:09, Chris Angelico wrote: > > "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. Or as one might write x.remove(y) in Python: for demo in ("xyz", "cba", "abcdabc"): print repr(demo), "->", repr(demo.replace("abc", "")) > >>> "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" > }) which in Python sounds suspiciously like dividend.split(divisor) So Python's giving both functionalities in ways that are more readable (and in the case of "-", more flexible, as you can replace with anything, not just delete the matching content). While subtraction and division of strings make theoretical sense, I'm glad I don't have to think about them in my Python code ;-) -tkc