I'm implementing a cross-tabulation library in Python as a programming exercise for my new job, and I've got an implementation of the requirements that works but is inelegant and redundant. I'd like a better model for it, something that allows a nice, clean movement of data between the base model, stored as tabular data in flat files, a...
I want to create a Web app which would allow the user to upload some C code, and see the results of its execution (the code would be compiled on the server). The users are untrusted, which obviously has some huge security implications.
So I need to create some kind of sandbox for the apps. At the most basic level, I'd like to restrict a...
I'm curious as to why it's so much faster to multiply than to take powers in python (though from what I've read this may well be true in many other languages too). For example it's much faster to do
x*x
than
x**2
I suppose the ** operator is more general and can also deal with fractional powers. But if that's why it's so much slowe...
For example, I want to split
str = '"a,b,c",d,e,f'
into
["a,b,c",'d','e','f']
(i.e. don't split the quoted part) In this case, this can be done with
re.findall('".*?"|[^,]+',str)
However, if
str = '"a,,b,c",d,,f'
I want
["a,,b,c",'d','','f']
i.e. I want a behavior that is like python's split function. Is there any way ...
Playing around with Python - tkInter - Entry widget - when I use validatecommand (below), the check happens the first time the string > Max, but when I continue to enter text the check steps - there's no delete or insert after the first time? Any advice? (outside of not building a desktop app via python)
#!/usr/bin/env python
from Tk...
This solves my issue. No subclassing needed.
class DrvCrystalfontzProxy(Text):
@classmethod
def get(cls, model, visitor, obj=None, config=None):
if model not in Models.keys():
error("Unknown Crystalfontz model %s" % model)
return
model = Models[model]
if model.protocol == 1:
...
When your application takes a few (~ 5) configuration parameters, and the application is going
to be used by non-technology users (i.e. KISS), how do you usually handle reading
configuration options, and then passing around the parameters between objects/functions
(multiple modules)?
Options examples: input and output directories/file ...
Hi,
There is simple JSON serialization module with name "simplejson" which easily serializes Python objects to JSON.
I'm looking for similar module which can serialize to XML.
Thank you
...
I've been trying to think of a way to traverse a hierarchical structure, like a linked list, using a list expression, but haven't come up with anything that seems to work.
Basically, I want to convert this code:
p = self.parent
names = []
while p:
names.append(p.name)
p = p.parent
print ".".join(names)
into a one-liner like:
pri...
[Please note that this is a different question from the already answered How to replace a column using Python’s built-in .csv writer module?]
I need to do a find and replace (specific to one column of URLs) in a huge Excel .csv file. Since I'm in the beginning stages of trying to teach myself a scripting language, I figured I'd try to i...
is there any way to reference a class name from within the class declaration? an example follows:
class Plan(SiloBase):
cost = DataField(int)
start = DataField(System.DateTime)
name = DataField(str)
items = DataCollection(int)
subPlan = ReferenceField(Plan)
i've got a metaclass that reads this information and does ...
I'm making a program in Python to be distributed to windows users via an installer.
The program needs to be able to download a file every day encrypted with the user's public key and then decrypt it.
So I need to find a Python library that will let me generate public and private PGP keys, and also decrypt files encrypted with the publi...
django-admin.py makemessages dies with errors "warning: unterminated string" on cases where really long strings are wrapped:
string = "some text \
more text\
and even more"
These strings don't even need to be translated - e.g. sql query strings.
The problem goes away when I concatenate the string, but the result l...
I apologize if this question is long. This was part of a blog post I did some time ago, and a reader suggested me to post it on stackoverflow. I trimmed it a bit though.
Suppose you have the following situation
#include <iostream>
class Animal {
public:
virtual void speak() = 0;
};
class Dog : public Animal {
void speak() { s...
I have tried Pamie a browser automation library for internet explorer. It interfaces IE using COM, pretty neat:
import PAM30
ie = PAM30.PAMIE("http://user-agent-string.info/")
ie.clickButton("Analyze my UA")
Now I would like to do the same thing using PyXPCOM with similar flexibility on Firefox. How can I do this? Can you provide samp...
I was sure that there would be a one liner to convert a list to a dictionary where the items in the list were keys and the dictionary had no values.
The only way I could find to do it was argued against
"Using list comprehensions when the result is ignored is misleading and inefficient. A for loop is better"
myList=['a','b','c','d...
Does anyone know or know of somewhere I can learn how to create a custom authentication process using python and google app engine?
I don't want to use google accounts for authentication and want to be able to create my own users.
If not specifically for google app engine, any resource on how to implement authentication using python an...
Hi,
I have been building business database applications such as finance, inventory and other business requirement applications. I am planning to shift to Python. What would be the tools to start with best. I would need to do master, transaction forms, processing (back end), reports and that sort of thing. The database would be postgress ...
When you write an HTML/CSS/JavaScript app for Adobe AIR, the source files sit in a directory visible to anyone who looks.
Appcelerator Titanium lets you code in JavaScript, Python, and Ruby. Is the bundling similar to AIR, with all the source exposed?
...
I study network programming and would like to write a simple command-line chat in Python.
I'm wondering how make receving constant along with inputing available for sending at any time.
As you see, this client can do only one job at a time:
from socket import *
HOST = 'localhost'
PORT = 21567
BUFSIZE = 1024
ADDR = (HOST, PORT)
tcpC...