Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #90752

Re: Rule of order for dot operators?

Date 2015-05-16 12:32 -0700
From Gary Herron <gherron@digipen.edu>
Subject Re: Rule of order for dot operators?
References <55579886.3010001@cdreimer.com>
Newsgroups comp.lang.python
Message-ID <mailman.81.1431804776.17265.python-list@python.org> (permalink)

Show all headers | View raw


On 05/16/2015 12: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)?

Yes, that's correct.

Gary Herron



>
> Thank you,
>
> Chris Reimer


-- 
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Rule of order for dot operators? Gary Herron <gherron@digipen.edu> - 2015-05-16 12:32 -0700

csiph-web