Python way to clone a git repository

There is GitPython. Haven’t heard of it before and internally, it relies on having the git executables somewhere; additionally, they might have plenty of bugs. But it could be worth a try. How to clone: (It’s not nice and I don’t know if it is the supported way to do it, but it worked.)

TemplateDoesNotExist at /

Hej! Many threads here had the same caption, but none of them solved my problem. I have a Django site an can access /admin (but it looks ugly). But on / there appears the following error page (DEBUG = True in settings.py): In fact, the file /home/django/django/templates/iecl_dev/index.html does exist and I also tried chmod o+r … Read more

Could not install packages due to an EnvironmentError: [Errno 13]

If you want to use python3+ to install the packages you need to use pip3 install package_name And to solve the errno 13 you have to add –user at the end EDIT: For any project in python it’s highly recommended to work on a Virtual enviroment, is a tool that helps to keep dependencies required by different projects separate by creating isolated python virtual environments … Read more

Inheritance and init method in Python

In the first situation, Num2 is extending the class Num and since you are not redefining the special method named __init__() in Num2, it gets inherited from Num. When a class defines an __init__() method, class instantiation automatically invokes __init__() for the newly-created class instance. In the second situation, since you are redefining __init__() in Num2 you need to explicitly call the one in the super class (Num) if you want … Read more

Play audio with Python

You can find information about Python audio here: http://wiki.python.org/moin/Audio/ It doesn’t look like it can play .mp3 files without external libraries. You could either convert your .mp3 file to a .wav or other format, or use a library like PyMedia.

Printing subscript in python

If all you care about are digits, you can use the str.maketrans() and str.translate() methods: Which will output: Note that this won’t work in Python 2 – see Python 2 maketrans() function doesn’t work with Unicode for an explanation of why that’s the case, and how to work around it.