Skip to content
Advertisement

What is the path that Django uses for locating and loading templates?

I’m following this tutorial on a Windows 7 environment. My settings file has this definition: I got the base_template from the template admin/base_site.html from within the default Django admin template directory in the source code of Django itself (django/contrib/admin/templates) into an admin subdirectory of myapp directory as the tutorial instructed, but it doesn’t seem to take affect for some reason.

Matrix in python

I am very new to Python, I need to read numbers from a file and store them in a matrix like I would do it in fortran or C; How can I do the same in Python? I read a bit but got confused with tuples and similar things If you could point me to a similar example it would

How do I debug a HTTP 502 error?

I have a Python Tornado server sitting behind a nginx frontend. Every now and then, but not every time, I get a 502 error. I look in the nginx access log and I see this: and in the error log: I don’t think any errors show up in the Tornado log. How would you go about debugging this? Is there

Python – calendar.timegm() vs. time.mktime()

I seem to have a hard time getting my head around this. What’s the difference between calendar.timegm() and time.mktime()? Say I have a datetime.datetime with no tzinfo attached, shouldn’t the two give the same output? Don’t they both give the number of seconds between epoch and the date passed as a parameter? And since the date passed has no tzinfo,

built in function for computing overlap in Python

is there a built in function to compute the overlap between two discrete intervals, e.g. the overlap between [10, 15] and [20, 38]? In that case the overlap is 0. If it’s [10, 20], [15, 20], the overlap is 5. Answer You can use max and min:

Pinging servers in Python

In Python, is there a way to ping a server through ICMP and return TRUE if the server responds, or FALSE if there is no response? Answer This function works in any OS (Unix, Linux, macOS, and Windows) Python 2 and Python 3 EDITS: By @radato os.system was replaced by subprocess.call. This avoids shell injection vulnerability in cases where your

Kill process by name?

I’m trying to kill a process (specifically iChat). On the command line, I use these commands: Then: However, I’m not exactly sure how to translate these commands over to Python. Answer Assuming you’re on a Unix-like platform (so that ps -A exists), gives you ps -A’s output in the out variable (a string). You can break it down into lines

Advertisement