Why is str.translate so fast in Python 3.5 compared to Python 3.4.1?
When you use
str.translate in Python 3.4 and then again in Python 3.5 the speed difference in the case of ascii strings is remarkable. It is because of a change in the underlying C code. To know More,
How does str(list) work?
str on any function usually calls the
__str__ function of the passed argument. However for a list there is no
__str__ method! What happens in this case then? To know More,
Tuple unpacking order changes values assigned
Usually while swapping two varaibles in python we use
a,b = b,a. But is this same as
b,a = a,b? No! Not in every case. The swapping too has an order that it follows. To know More,
How does the min/max function on a nested list works?
min and the
max function both use comparision operators to find the correct return value. But how does it decide when the lists are heterogeneous or when the list elements are strings. To know More,
How to specify multiple return types using type-hints
Type Hints were introduced in python 3.5. They specify the usage of datatypes for arguments and return values. However how should multiple return types be specified? To know More,
Deleting consonants from a string in Python
Deleting consonants from a string seems very easy. But how many ways can you do that using Python? Also which is the best way to remove them? To know More,
How to remove \n from a list element?
Stripping new lines from a list seems very easy. But how many ways can you do that using Python 3.0? What happens if you use
map(strip,l) directly? To know More,