Dev] / as path join operator (was: Re: The path module PEP) (original) (raw)
John J Lee jjl at pobox.com
Thu Jan 26 01:43:29 CET 2006
- Previous message: [Python-Dev] / as path join operator (was: Re: The path module PEP)
- Next message: [Python-Dev] / as path join operator (was: Re: The path module PEP)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[John J Lee]
But it's a very readable way to write a common operation. Perhaps one reason the discrepancy you point out doesn't bother me is that division is the least-used of the +-*/ arithmetic operations.
[Tony Meyer]
Do you have evidence to back that up?
No. :)
[Ian Bicking]
of mine, and in 12k lines there were 34 uses of join, and 1 use of division. In smaller scripts os.path.join tends to show up a lot more
[Tony]
The problem with these sorts of guesses is that there's no evidence. (Maybe the suggestion that Brett's PhD should collect a corpus of Python scripts was a good one ). Are mathematicians that under represented? Is file processing that highly represented? I have no idea.
A second data point: I looked at ~10k lines of physical data analysis code I have lying around -- presumably a relatively rare and extreme example as the Python-world in general goes. Result:
140 occurences of os.path.join
170 physical lines (as opposed to syntactical lines) containing / as a division operator (very few lines contained > 1 use of '/', so you can multiply 170 by 1.25 to get an upper bound of 213 uses in total)
(To get the second number, I used find and grep heavily but very cautiously, and final manual count of stubborn lines of grep output with no use of '/' as division operator)
The fact that even in this extreme case os.path.join is close on the tail of '/' strongly backs up Ian's guess that, in most Python code, / as division is rare compared to path joining.
Should we deprecate use of '/' and '//' for division in Python 3.0?
is-he-joking?-ly y'rs
John
- Previous message: [Python-Dev] / as path join operator (was: Re: The path module PEP)
- Next message: [Python-Dev] / as path join operator (was: Re: The path module PEP)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]