Does Jinja2 support template-relative paths e.g. %(here)s/other/template.html, to include other templates relative to the current template's place in the filesystem?
...
Does python's random.random() ever return 1.0 or it only returns up until 0.9999..?
...
I've got a nice database I've created in Django, and I'd like to interface with through some python scripts outside of my website stuff, so I'm curious if it's possible to use the Django database API outside of a Django site, and if so does anyone have any info on how it can be done? Google hasn't yielded many hits for this.
...
In the SQLAlchemy ORM tutorial, it describes the process of creating object relations roughly as follows. Let's pretend I have a table Articles, a table Keywords, and a table Articles_Keywords which creates a many-many relationship.
article = meta.Session.query(Article).filter(id=1).one()
keyword1 = meta.Session.query(Keyword).filter(i...
I wrote a program that takes in a partial rss feed and outputs a full one, but it is one a case by case basis. The recipe for one site is not the same as the recipe for the other. So what I do is look at the domain basename(for instance nyt or wsj) and choose a module based on that. Though I need to load each and every module before h...
Is it OK to raise a built-in exception with a custom text? or to raise a built-in warning also with custom text?
The documentation reads:
exception ValueError: Raised when a built-in operation or function receives an argument (…)
Is it implied that only built-in operations should raise a ValueError exception?
In practice, I unde...
I've already looked at this question: http://stackoverflow.com/questions/1152238/python-iterators-how-to-dynamically-assign-self-next-within-a-new-style-class
but this doesn't help me because I want to iterate of an attribute of the error which is a list (ie, already iterable) without having to use the attribute explicitly. I'm looking ...
Hi.
i'm creating a dialog that finds out what is focused element.
that's what i wrote:
import gtk
import gobject
class FocusedElementPath(gtk.Dialog):
def __init__(self, parent, title=None):
gtk.Dialog.__init__(self, title or 'Show path', parent)
self.catch_within = parent
self.catch_focus = True
...
I am trying to find all the inputs/outputs of all MATLAB functions in our internal library. I am new (first time) to regex and have been trying to use the multiline mode in Python's re library.
The MATLAB function syntax looks like:
function output = func_name(input)
where the signature can span multiple lines.
I started with a patt...
Here's my exception class that is using raise:
class SCE(Exception):
"""
An error while performing SCE functions.
"""
def __init__(self, value=None):
"""
Message: A string message or an iterable of strings.
"""
if value is None:
self._values = []
elif isinstance(value, ...
I have an Article model which has a date field. I want to query against all Article objects, and have a datatype returned with each distinct year, and then each distinct month within that.
for instance
archives = {
2009: {12, [, , ...], 11: [...]},
2008: {12, [...], 11: [...]},
}
is this possible?
...
Hi, I am trying to use this package: http://pypi.python.org/pypi/guess-language/0.1
I've read the documentation/wiki, but can't find the solution.
Basically, this package allows you to pass in a string, and it will return a "language".
I'm able to make it print out "en".
htmlSource = download('http://feeds.feedburner.com/nchild')
soup ...
As I look at what features I want in a programming language, I notice that many of them are more related to the development environment then the actual language, the best one I have encountered so far being Visual Studio.
As I am considering Python development in the future, I would like to know of IDE's that could represent comparable ...
Please observe the following behavior:
a = u"foo"
b = u"b\xe1r" # \xe1 is an 'a' with an accent
s = [a, b]
print a, b
print s
for x in s: print x,
The result is:
foo bár
[u'foo', u'b\xe1r']
foo bár
When I just print the two values sitting in variables a and b, I get what I expect; when I put the string values in a list and print...
I create a file called foo_module.py containing the following code:
import shelve, whichdb, os
from foo_package.g import g
g.shelf = shelve.open("foo_path")
g.shelf.close()
print whichdb.whichdb("foo_path") # => dbhash
os.remove("foo_path")
Next to that file I create a directory called foo_package than contains an empty __init__....
Is it possible to use a generic view with additional parameters in the URL mapping - i.e. I got the following model:
class Route(models.Model):
area = models.ForeignKey(Area)
slug = models.SlugField(null=True,blank=True)
@models.permalink
def get_absolute_url(self):
return ('route_details', (), {'area': self.are...
Hello,
class A:
def __get(self):
return self._x
def __set(self, y):
self._x = y
def __delete_x(self):
print('DELETING')
del self._x
x = property(__get,__set,__delete_x)
b = A()
# Here, when b is deleted, i'd like b.x to be deleted, i.e __delete_x()
# called (and for immediate consequence, "DELETING" printed)
del b
Tha...
Hello,
i am trying to subistute a small bit of Python Code with Cython for a speed up. While Cython itself dosen't complain, but gcc does.
from __future__ import division
import numpy
cimport numpy
cimport cython
def calc_shg(numpy.ndarray[numpy.complex128_t, ndim = 1] par,
numpy.ndarray[numpy.complex128_t, ndim = 1]...
As in the title: how can I access the url hash/fragment (the part following the dash #) from a Django view and so, I suppose, from a Django Request object?
I've not found enough information on the documentation here available: http://docs.djangoproject.com/en/dev/ref/request-response/
P.S.
Suppose that the fragment part is sent to the ...
Does anyone know of an easy way to set the niceness value of a Process or Pool when it is created in multiprocessing?
...