How to delete last item in list?

If I understood the question correctly, you can use the slicing notation to keep everything except the last item: record = record[:-1] But a better way is to delete the item directly: del record[-1] Note 1: Note that using record = record[:-1] does not really remove the last element, but assign the sublist to record. … Read more

ImportError: No module named ‘django.core.urlresolvers’

Django 2.0 removes the django.core.urlresolvers module, which was moved to django.urls in version 1.10. You should change any import to use django.urls instead, like this: from django.urls import reverse Note that Django 2.0 removes some features that previously were in django.core.urlresolvers, so you might have to make some more changes before your code works. See … Read more

What does the slash mean in help() output?

It signifies the end of the positional only parameters, parameters you cannot use as keyword parameters. Before Python 3.8, such parameters could only be specified in the C API. It means the key argument to __contains__ can only be passed in by position (range(5).__contains__(3)), not as a keyword argument (range(5).__contains__(key=3)), something you can do with … Read more

Type hinting a collection of a specified type

Answering my own question; the TLDR answer is No Yes. Update 2 In September 2015, Python 3.5 was released with support for Type Hints and includes a new typing module. This allows for the specification of types contained within collections. As of November 2015, JetBrains PyCharm 5.0 fully supports Python 3.5 to include Type Hints … Read more

pip install – locale.Error: unsupported locale setting

The root cause is: your environment variable LC_ALL is missing or invalid somehow Short answer- just run the following command: $ export LC_ALL=C If you keep getting the error in new terminal windows, add it at the bottom of your .bashrc file. Long answer- Here is my locale settings: $ locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE=”C” LC_NUMERIC=”C” … Read more