Skip to content

Commit d9e7122

Browse files
committed
Add minor example
1 parent 65c8a9e commit d9e7122

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -3437,6 +3437,16 @@ f()
34373437
[]
34383438
```
34393439
3440+
* Slicing an iterable not always creates a new object. For example,
3441+
```py
3442+
>>> some_str = "wtfpython"
3443+
>>> some_list = ['w', 't', 'f', 'p', 'y', 't', 'h', 'o', 'n']
3444+
>>> some_list is some_list[:] # False expected because a new object is created.
3445+
False
3446+
>>> some_str is some_str[:] # True because strings are immutable, so making a new object is of not much use.
3447+
True
3448+
```
3449+
34403450
* `int('١٢٣٤٥٦٧٨٩')` returns `123456789` in Python 3. In Python, Decimal characters include digit characters, and all characters that can be used to form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT ZERO. Here's an [interesting story](http://chris.improbable.org/2014/8/25/adventures-in-unicode-digits/) related to this behavior of Python.
34413451
34423452
* You can seperate numeric literals with underscores (for better readablity) from Python 3 onwards.

0 commit comments

Comments
 (0)