Re: [Python-Dev] [Python-checkins] r53860 - peps/trunk/pep-0000.txt peps/trunk/pep-0358.txt
[-python-checkins, +python-dev]
On 2/22/07, Jim Jewett
__setitem__ __setslice__ append count + decode + endswith extend + find index insert + join + partition remove + replace + rindex + rpartition + split + startswith + rfind + rindex + rsplit + translate
What sort of arguments do they take?
You should be able to infer this from what the corresponding str or list methods do -- always substituting bytes for those, and int for the single element.
Other bytes objects? (Then the literal is more important.)
Unicode? With an extra decoding argument?
The only way to use unicode is to use bytes(<unicode>, <encoding>). The others methods barf on Unicode.
Sequences of integers? Is startswith(500) False or a ValueException?
TypeError.
Single integers? startswith(ord('A'))
TypeError (this is the same as the previous.)
+ Note the conspicuous absence of .isupper(), .upper(), and friends.
This does force the use of more regular expressions, by ruling out
data.upper().startswith("ERROR:")
Yeah, over dinner we started leaning towards perhaps supporting at least lower() and upper() (but acting only on the 2x26 ASCII letters). -- --Guido van Rossum (home page: http://www.python.org/~guido/)
On 2/22/07, Guido van Rossum
[-python-checkins, +python-dev]
On 2/22/07, Jim Jewett
wrote: __setitem__ __setslice__ append count + decode + endswith extend + find index insert + join + partition remove + replace + rindex + rpartition + split + startswith + rfind + rindex + rsplit + translate
What sort of arguments do they take?
You should be able to infer this from what the corresponding str or list methods do -- always substituting bytes for those, and int for the single element. ...
Single integers? startswith(ord('A'))
TypeError (this is the same as the previous.)
>>> "asdf".index("df") == "asdf".index("d") Assuming : >>> data = bytes("asdf", 'ASCII') Are you saying that, even for the single-char call, I must write: >>> data.index(bytes("d", 'ASCII')) instead of: >>> data.index("d") or even: >>> data.index(ord("d")) -jJ
The latest version of the PEP clarifies that both are allowed.
On 2/23/07, Jim Jewett
On 2/22/07, Guido van Rossum
wrote: [-python-checkins, +python-dev]
On 2/22/07, Jim Jewett
wrote: __setitem__ __setslice__ append count + decode + endswith extend + find index insert + join + partition remove + replace + rindex + rpartition + split + startswith + rfind + rindex + rsplit + translate
What sort of arguments do they take?
You should be able to infer this from what the corresponding str or list methods do -- always substituting bytes for those, and int for the single element. ...
Single integers? startswith(ord('A'))
TypeError (this is the same as the previous.)
>>> "asdf".index("df") == "asdf".index("d")
Assuming : >>> data = bytes("asdf", 'ASCII')
Are you saying that, even for the single-char call, I must write: >>> data.index(bytes("d", 'ASCII'))
instead of: >>> data.index("d")
or even: >>> data.index(ord("d"))
-jJ
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (2)
-
Guido van Rossum
-
Jim Jewett