Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90754 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2015-05-16 21:34 +0200 |
| Last post | 2015-05-16 21:34 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Rule of order for dot operators? Peter Otten <__peter__@web.de> - 2015-05-16 21:34 +0200
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2015-05-16 21:34 +0200 |
| Subject | Re: Rule of order for dot operators? |
| Message-ID | <mailman.83.1431804873.17265.python-list@python.org> |
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)?
You can find out yourself by using operations where the order does matter:
"Test".upper().lower()
Back to top | Article view | comp.lang.python
csiph-web