On Sun, 17 May 2015 05:20 am, 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.
Technically, dot is not an operator, but even if it was, swapping the *dots* around makes no difference: slug.replace('-',' ').title() => slug.replace('-',' ').title() Because a dot is a dot, right? What you mean is that you're swapping the *methods* around, not just the dots: slug.replace('-',' ').title() => slug.title().replace('-',' ') > 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)? Left to right. -- Steven -- https://mail.python.org/mailman/listinfo/python-list