Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90751 > unrolled thread
| Started by | "C.D. Reimer" <chris@cdreimer.com> |
|---|---|
| First post | 2015-05-16 12:20 -0700 |
| Last post | 2015-05-18 14:00 +0200 |
| Articles | 1 on this page of 21 — 9 participants |
Back to article view | Back to comp.lang.python
Rule of order for dot operators? "C.D. Reimer" <chris@cdreimer.com> - 2015-05-16 12:20 -0700
Re: Rule of order for dot operators? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-16 21:40 +0200
Re: Rule of order for dot operators? "C.D. Reimer" <chris@cdreimer.com> - 2015-05-16 12:55 -0700
Re: Rule of order for dot operators? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-17 19:17 +0200
Re: Rule of order for dot operators? Ned Batchelder <ned@nedbatchelder.com> - 2015-05-17 10:30 -0700
Re: Rule of order for dot operators? Rustom Mody <rustompmody@gmail.com> - 2015-05-17 12:13 -0700
Re: Rule of order for dot operators? "C.D. Reimer" <chris@cdreimer.com> - 2015-05-17 11:35 -0700
Re: Rule of order for dot operators? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-17 11:45 +1000
Re: Rule of order for dot operators? Rustom Mody <rustompmody@gmail.com> - 2015-05-16 22:06 -0700
Re: Rule of order for dot operators? Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-17 15:43 +0000
Re: Rule of order for dot operators? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-20 00:30 +0200
Re: Rule of order for dot operators? Ned Batchelder <ned@nedbatchelder.com> - 2015-05-19 18:36 -0700
Re: Rule of order for dot operators? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-20 04:24 +0200
Re: Rule of order for dot operators? Ned Batchelder <ned@nedbatchelder.com> - 2015-05-19 19:44 -0700
Re: Rule of order for dot operators? Chris Angelico <rosuav@gmail.com> - 2015-05-20 13:11 +1000
Re: Rule of order for dot operators? Ben Finney <ben+python@benfinney.id.au> - 2015-05-20 17:29 +1000
Re: Rule of order for dot operators? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-20 12:31 +1000
Re: Rule of order for dot operators? "C.D. Reimer" <chris@cdreimer.com> - 2015-05-17 10:50 -0700
Re: Rule of order for dot operators? Chris Angelico <rosuav@gmail.com> - 2015-05-18 17:40 +1000
Re: Rule of order for dot operators? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-17 11:31 +1000
Re: Rule of order for dot operators? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2015-05-18 14:00 +0200
Page 2 of 2 — ← Prev page 1 [2]
| From | Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> |
|---|---|
| Date | 2015-05-18 14:00 +0200 |
| Message-ID | <mjck8h$o18$1@r01.glglgl.de> |
| In reply to | #90751 |
Am 16.05.2015 um 21:20 schrieb C.D. Reimer:
> Does python perform the dot operators from left to right or according to
> a rule of order (i.e., multiplication/division before add/subtract)?
In this case, it does the only thing it can do:
title = slug.replace('-',' ').title()
is performed as
* take slug
* get its replace method
* call it and take the result
* get this result's title method
* call it and store its result into title.
OTOH,
title = slug.title().replace('-',' ')
is performed as
* take slug
* get its title method
* call it and take the result
* get this result's replace method
* call it and store its result into title.
Any other order would be unintuitive and just wrong.
The reason why the result is the same is because .title() title-cases
letters after a space as well as after a '-'.
In other cases, it wouldn't do so, so you have to take care what you do.
Thomas
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.python
csiph-web