Hello, I am trying to obtain class information on a field inside a model, when I only know name of the field and name of the model (both plain strings). How is it possible?
I can load the model dynamically:
from django.db import models
model = models.get_model('myapp','mymodel')
Now I have field - 'myfield' - how can I get the class ...
Hi,
I have this mapper defined:
mapper(Resource, resource_table,
properties = {'type' : relation(ResourceType,lazy = False),
'groups' : relation(Group, secondary = model.tables['resource_group'],
backref = 'resources'),
'parent' : relation(Relation, uselist=False, primaryjoin =
and_(relation_table.c.res_id == resourc...
Hi, I tried urllib{2}, pycurl and I'm looking at twisted's new http client.
But:
I found urllib2 difficult to perform a file upload
pycurl multi looks right but unpythonic
twisted's http client does not support persistent connection (didn't check the file upload capability)
Is there any other alternative?
...
EDIT: TL;DR version
I typed this
CREATE INDEX IF NOT EXISTS IDX_FILE_SIZE table_name (file_size);
instead of this
CREATE INDEX IF NOT EXISTS IDX_FILE_SIZE ON table_name (file_size);
Don't do that.
...
It is object of the class A, in conteiner's class tmpA. Not all method
from A are in the tmpA. So for exapmle:
A + B is present , tmpA + B isn't present. I try to call method from A for tmpA. I
can to call simple method, such as change(), bit add - don't
work. If to remove inheritance from object, the code work's. Help me,
please.
...
I have WSGI middleware that needs to capture the HTTP status (e.g. 200 OK) that inner layers of middleware return by calling start_response. Currently I'm doing the following, but abusing a list doesn't seem to be the “right” solution to me:
class TransactionalMiddlewareInterface(object):
def __init__(self, application, **config):
...
Specifically for the ff: topics:
Windows installation
Using mod_wsgi/mod_python
Python best practices
Python security stuff
Using Pylons
Thanks
...
What's the best way to make a function that has pointer as argument work with boost python?
I see there are many possibilities for return values in the docs, but I don't know how to do it with arguments.
void Tesuto::testp(std::string* s)
{
if (!s)
cout << " NULL s" << endl;
else
cout << s << endl;
}
>>> t.testp...
I would like to use Python to simplify a series of partly manual multimedia processing steps. I'm aware of the possible performance issues but this would be partly a learning project, and partly for ease of maintenance. Specifically, I want to create enhanced podcasts from MP3 files, although starting from MP4 is reasonable given ease of...
Is there a way to get single regex to satisfy this condition??
I am looking for a "word" that has three letters from the set MBIPI, any order,
but MUST contain an I.
ie.
re.match("[MBDPI]{3}", foo) and "I" in foo
So this is the correct result (in python using the re module), but can I get this from a single regex?
>>> for foo in (...
Ok so I need to download some web pages using Python and did a quick investigation of my options.
Included with Python:
urllib - seems to me that I should use urllib2 instead. urllib has no cookie support, HTTP/FTP/local files only (no SSL)
urllib2 - complete HTTP/FTP client, supports most needed things like cookies, does not support ...
How do I find the total number of duplicates in a string?
i.e., if it was j= [1,1,1,2,2,2] it would find 4 duplicates?
I've only been able to find counting which shows how many times each individual number occurred.
...
I've looked at the example script of python-pam and linux pam pages, but it's a bit confusing, at least for a beginner in PAM (that I am):
http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/Linux-PAM_ADG.html
http://packages.ubuntu.com/python-pam
Is it possible to check if a user has or does not have access to login, without enteri...
The following code:
class MyClass():
def test(self):
self.__x = 0
def __setattr__(self, name, value):
print name
def __getattr__(self, name):
print name
raise AttributeError(name)
x = MyClass()
x.test()
x.__y
Outputs:
_MyClass__x
__y
Traceback (most recent call last):
...
AttributeError:...
Suppose I think I have a great idea for some feature that should be in python's standard library.
Not something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO.
How can I suggest such a feature to the consideration of the "python committee :)"?
...
How can I make a Django field that renders itself as a pair of input
fields?
Reasoning: I am trying to write a new custom field. I will use it for a
captcha-like service. The service works by requesting a question -
then receiving one and a token. The validation happens by sending the
answer along with the token. I want to write a form ...
It is recommended to not to use import * in python. Can anyone please share the reason for that, so that I can avoid it doing next time.
Thanks and Regards
...
I am trying to align my bitmap font text in my OpenGL application but I can't find anything on getting the width of each character. This is my renderText function:
def renderText( self, text, fontFace, position ):
..... (omitted code to make post shorter)
glRasterPos2i( position[0], self.windowSize[1] - position[1] )
glPushA...
I ran a build last night, successfully. I got up this morning and ran another without changing any configuration or modifying any source code. Now my build is failing with the message "No source for code" when running my nosetests with coverage.
NoSource: No source for code: '/home/matthew/.hudson/jobs/myproject/workspace/tests/unit/ut...
Dear all,
I'm reading in serial data using Pyserial, to populate a list of 17 values (1byte each) at a sampling rate of 256Hz.
The bytes I ultimately want to use are the 5th to 8th in the list. Providing no bytes are dropped, the first two values of the stream are always the same ('165','90'). I'm getting quite a few dropped values th...