Rule of order for dot operators?

C.D. Reimer chris at cdreimer.com
Sat May 16 15:20:38 EDT 2015


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



More information about the Python-list mailing list