Here is a python session.
>>> class Z(type):
def __new__(cls, name, bases, attrs):
print cls
print name
return type(name, bases, attrs)
...
>>> class Y(object):
__metaclass__ = Z
...
<class '__main__.Z'>
Y
>>> class X(Y):
... pass
...
>>> class W(Y):
... __metaclass__ = Z
...
<clas...
Hello,
I made some bindings from my C++ app for python.
The problem is that I use pointers to members (It's for computing shortest path and giving the property to minimize as parameter).
This is the C++ signature:
std::vector<Path> martins(int start, int dest, MultimodalGraph & g, float Edge::*)
This is what I did (from what I unde...
I'm currently using an application in python which works quite well but when I'm converting it with py2exe, the application seems to be suspended at the first "reactor.iterate"
Each time I press Ctrl+C to stop the application, the error is always the same and the application seems to be bloqued on a "reactor.iterate(4)"
This problem ne...
Hello everyone. Are there any Python tools to create fixtures on Google App Engine? I tried Fixture(http://farmdev.com/projects/fixture/). It is the most awesome tool I have come across. I love the clean approach and the consistency of the APIs. But it is LGPL licensed. Our project is licensed under Apache License 2.0 and AFAIK LGPL is i...
Thank you for bobince in solving the first bugs!
How can you use *pg.escape_bytea* or *pg.escape_string* in the following?
#1 With both pg.escape_string and pg.escape_bytea
con1.query(
"INSERT INTO files (file, file_name) VALUES ('%s', '%s')" %
(pg.escape_bytea(pg.espace_string(f.read())), pg.espace_string(...
I'm trying to write a python script which follows the common unix command line pattern of accepting input from stdin if no file name is given. This is what I've been using:
if __name__ == "__main__":
if len(sys.argv) > 1:
stream = open(sys.argv[1])
else:
stream = sys.stdin
Is there a more pythonic way to do th...
I have a file in CSV format where the delimiter is the ASCII unit separator ^_ and the line terminator is the ASCII record separator ^^ (obviously, since these are nonprinting characters, I've just used one of the standard ways of writing them here). I've written plenty of code that reads and writes CSV files, so my issue isn't with Pyt...
Following imports:
import pyodbc, sys, smtplib, os
from datetime import date
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
import email.iterators
import email.generator
from email import Encoders
Works ok when creating exe with py2exe in Python2.6 but does not ...
Hai friends,
I've installed boost python from ubuntu 9.04 repositories.. I've successfully run the
Build a Simple Program Using Boost
from the tutorial http://www.boost.org/doc/libs/1%5F41%5F0...-variants.html . So i ensured that boost python is installed in my system..
But for the program below
#include <string>
namespace { // Avoid ...
One of the features of my project is to allow users to create their own little .txt file, put it somewhere on their HDD, which can then be used as criteria for a part of my application.
Is there a Fixed, 'generic'(?) path for most OSs that I could use? Or does anyone have any kind of advice or guidance that could help me?
FYI, during d...
Hello,
I am studying the Scrapy tutorial. To test the process I created a new project with these files:
See my post in Scrapy group for links to scripts, I cannot post more than 1 link here.
The spider runs well and scrapes the text between title tags and puts it in FirmItem
[whitecase.com] INFO: Passed FirmItem(title=[u'White & ...
Here is the problem. We have 100s of external 500gb USB drives. Each drive will travel to a new location through the year. What is the best way to automatically detect that a USB drive has been plugged into a Windows system, then assign a Z:\ drive letter? These USB drives will be plugged into lots of different computers so a script like...
I have a two lists with values that I want to compare. If the value can be converted to a float, I want to compare the floats else I just want to compare the values as strings. How can I make that distinction to check whether a value can be converted to float or not?
...
I would like to popup a menu, when user clicks on an object in QTreeWidgetItem. I though about catching signal contextMenuRequested from QWidget and then retrieving index from the view using itemAt. But this doesn't seem very pretty. Is there any easier way to be able to call a menu on an item inside a view?
...
Hi,
I'm going to be running some large scale usability tests of my software for a science project. We have a lab of about 30 computers running Windows XP. Our application is written in Python and PyGTK.
We want to be able to collect the following without staff intervention (automatically on our application start):
A recording of the...
Hello, I want to write a following script: given a text file with the list of actions to be executed on a certain site it would use some browser's (IE probably, because I don't know anything about other drive-able ones) CSS rendering and JS executing capabilities to imitate a user doing those actions on a site.
So I've found this page ...
I'm trying to get Python 2.6 to communicate with MySQL Server 5.1, under Windows XP, but I keep getting a strange error, "SystemError: NULL object passed to Py_BuildValue":
>>> import MySQLdb as mysql
>>> db = mysql.connect(user = "root", passwd="whatever", db="mysql", host="localh
ost")
>>> cu = db.cursor()
>>> cu.execute("show tables"...
I have an application where I've been using html5lib to liberally parse html. I use the minidom interface, because I need a real DOM API and ElementTree is not appropriate for what I'm doing.
Here's how I do this:
parser = html5lib.XHTMLParser(tree=html5lib.treebuilders.getTreeBuilder('dom'))
parser.parse(html)
However, parsing huge ...
I have the following code:
TYPES = {'hotmail':{'type':'hotmail', 'lookup':'mixed', 'dkim': 'no', 'signatures':['|S|Return-Path: [email protected]','|R|^Return-Path:\s*[^@]+@(?:hot|msn)','^Received: from .*hotmail.com$']},
'gmail':{'type':'gmail', 'lookup':'mixed', 'dkim': 'yes', 'signatures':['|S|Subject: unsubscri...
I want to be able to do this:
def asdf():
print __method__
"asdf"
Thanks,
Noah
...