String Character Length: Difference between revisions

Content deleted Content added
→‎[[Python]]: adding note about Unicode string lengths
This is not the place to talk about __len__, and there is no need to link to the byte length from each language section
Line 300:
 
length = len("The length of this string will be determined")
# equivalent to length = "The length of this string will be determined".__len__()
 
Note: the Python ''len()'' built-in function is used on any sequence (strings, lists, tuples) and user defined classes can implement their own ''.__len__()'' (special) method which will be called by the ''len()'' function by any code which passes an instance of your object to ''len().'' Python strings objects support a hybrid of string methods (for converting to ''upper()'' ''lower()'' or ''title()'' case, for example) as well as a number of sequence methods (to support "slicing" for extracting substrings, etc).
 
Python Unicode string objects automatically return the proper '''string''' length. See [[String_Byte_Length#Python]] for details on getting byte lengths.
 
==[[Ruby]]==