Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; '16,': 0.03; 'second.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'capitalizes': 0.16; 'dashes': 0.16; 'subject:operators': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'example': 0.22; 'cc:addr:python.org': 0.22; 'rid': 0.24; 'switched': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'first,': 0.26; 'right.': 0.26; 'second': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'character': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'operators': 0.31; 'second,': 0.31; 'url:python': 0.33; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'example,': 0.37; 'thank': 0.38; '(i.e.,': 0.38; 'pm,': 0.38; 'does': 0.39; 'according': 0.40; 'url:mail': 0.40; 'around.': 0.60; 'first': 0.61; '("this': 0.84; '2015': 0.84; 'joel': 0.91; 'to:none': 0.92 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:cc :content-type; bh=aA2xIFMHUmxbbDqIMmY4p+HBSqhyo6ssPIyvwrLr/3g=; b=KLQ9/AdvkMfzclZaOIx1QF6MoM3nS1P24OWePH3Nj2PApdeKKt778S7oXJV1DRe2P7 NmGg49NV0Mp6etOTR5Q2pqwJiIblCeKA/xTw3Mkr1nLX7i5DD6Xw3xViAwsHcpberk2p 00DjT+nWUJIE4P85atRr5y8ghOegHUVHoz62e90Ww2JPjasdu0WJB07lSKJIPAms3v+U +2J7YCbS4rqMqjQlb//u6mw3v50Yo0p643S4I6GRcB04jEl5QTAlO/UhpEO9b+8iEjom cHS+EwKc9x0VRMZgcBI1GN9gTagE5ec8i69KIQ4C1k5qHOxwVqRRw9cvVunZRKJdneeq SkxQ== MIME-Version: 1.0 X-Received: by 10.50.30.202 with SMTP id u10mr5749635igh.28.1431804822999; Sat, 16 May 2015 12:33:42 -0700 (PDT) In-Reply-To: <55579886.3010001@cdreimer.com> References: <55579886.3010001@cdreimer.com> Date: Sat, 16 May 2015 15:33:42 -0400 Subject: Re: Rule of order for dot operators? From: Joel Goldstick Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1431804831 news.xs4all.nl 2958 [2001:888:2000:d::a6]:34546 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90753 On Sat, May 16, 2015 at 3:20 PM, C.D. Reimer wrote: > Greetings, > > Noobie question regarding a single line of code that transforms a URL slug > ("this-is-a-slug") into a title ("This Is A Slug"). > > title = slug.replace('-',' ').title() > > This line also works if I switched the dot operators around. > > title = slug.title().replace('-',' ') > > I'm reading the first example as character replacement first and title > capitalization second, and the second example as title capitalization first > and character replacement second. > > Does python perform the dot operators from left to right or according to a > rule of order (i.e., multiplication/division before add/subtract)? > > Thank you, > > Chris Reimer > -- > https://mail.python.org/mailman/listinfo/python-list >From left to right. So in your first example it replaces - with space, then capitalizes each word. In your second example, it does the caps first, then gets rid of the dashes -- Joel Goldstick http://joelgoldstick.com