In my new job more people are using Python than Perl, and I have a very useful API that I wrote myself and I'd like to make available to my co-workers in Python.
I thought that a compiler that compiled Perl code into Python code would be really useful for such a task. Before trying to write something that parsed Perl (or at least, the ...
Looking thru decimal.py and it uses NotImplemented at many special methods e.g.
class A(object):
def __lt__(self, a):
return NotImplemented
def __add__(self, a):
return NotImplemented
Python docs says
NotImplemented:
Special value which can be returned by the “rich comparison”
special methods (eq()...
is it possible to ask parent for its refered collection_name based on one of its keys,
lets say i have a parent db model and its key, can i know ths children who refer to this parent through collection name or otherwise
class Parent(db.Model):
user = db.UserProperty()
class Childs(db.Model):
refer = db.ReferenceProperty(Parent,col...
Hello.
I need to access a third-party COM server with following interface definition (idl):
interface IDisplay : IDispatch
{
HRESULT getFramebuffer (
[in] ULONG aScreenId,
[out] IFramebuffer * * aFramebuffer,
[out] LONG * aXOrigin,
[out] LONG * aYOrigin );
};
As you can see, it returns 3 values via [out] parameter m...
OK guys/gals stuck again on something simple
I have a text file which has multiple lines per entry, the data is in the following format
firstword word word word
wordx word word word interesting1 word word word word
wordy word word word
wordz word word word interesting2 word word word lastword
this sequence repeats a hundred or so t...
Hi all,
I am writing python scripts and execute them in a Makefile. The python script is used to process data in a pipeline. I would like Makefile to execute the script every time I make a change to my python scripts.
Does anyone have an idea of how to do this?
Thanks a lot!
...
Hi,
I want to call a wrapped C++ function from a python script which is not returning immediately (in detail: it is a function which starts a QApplication window and the last line in that function is QApplication->exec()). So after that function call I want to move on to my next line in the python script but on executing this script and...
Take two lists, second with same items than first plus some more:
a = [1,2,3]
b = [1,2,3,4,5]
I want to get a third one, containing only the new items (the ones not repeated):
c = [4,5]
The solution I have right now is:
>>> c = []
>>> for i in ab:
... if ab.count(i) == 1:
... c.append(i)
>>> c
[4, 5]
Is there any other way...
I have the key pair generated by the GPG. Now I want to use the public key for encrypting the password. I need to make a function in Python. Can somebody guide me on how to do this?
I studied the Crypto package but was unable to find out how to encrypt the password using the public key.
I also read about the chilkat Python encryption l...
I have directory with subdirectories and I have to make a list like:
file_name1 modification_date1 path1
file_name2 modification_date2 path2
and write the list into text file
how can i do it in python?
...
Hi,
Update: This is, as I was told, no principle Python related problem, but seems to be more specific. See below for more explanations to my problem.
I have a custom exception (let's call it CustomException), that lives in a file named exceptions.py. Now imagine, that I can import this file via two paths:
import application.exception...
I'd like to store some data in Python in a similar form to a dictionary: {1:'a', 2:'b'}. Every value will be unique, not just among other values, but among keys too.
Is there a simple data structure that I can use to get the corresponding object no matter if I ask using the 'key' or the 'value'? For example:
>>> a = {1:'a', 2:'b'}
>>> ...
For our company I'd like to have a Python based IRC bot which checks whether the websites of our clients are still up and running. More specific: I want to list a number of URL which should be visited every, say, 15 minutes. If it fails, the URL should be checked again after 5 minutes. If retrieving the URL still doesn't result in an HTT...
I need to extract all MP3 titles from a fuzzy list in a list.
With Python this works for me fine:
import re
for i in re.compile('mmc.+?mp3').findall(open("tracklist.txt").read()): print i
How can I do that in Ruby?
...
Hi,
I'm new to python and have hit a problem with an SQL query I'm trying to perform.
I am creating an SQL SELECT statement that is populated with values from an array as follows:
ret = conn.execute('SELECT * FROM TestTable WHERE a = ? b = ? c = ?', *values)
This works ok where I have real values in the values array. However in some...
I have some french letters (é, è, à...) in a django template but when it is loaded by django, an UnicodeDecodeError exception is raised.
If I don't load the template but directly use a python string. It works ok.
Is there something to do to use unicode with django template?
...
I am attempting to reduce the amount of signals I have to use in my contextmenus. The menu consists of actions which switches the operation mode of the program, so the operation carried out by the slots is very simple. Quoting the documentation on QMenu::triggered,
Normally, you connect each menu action's triggered() signal to its ow...
I have a username which I must change in numerous (up to ~25) tables. (Yeah, I know.) An atomic transaction seems to be the way to go for this sort of thing. However, I do not know how to do this with pyodbc. I've seen various tutorials on atomic transactions before, but have never used them.
The setup: Windows platform, Python 2.6,...
Hi all!
Lets put it in parts.
I got a socket receiving data OK and i got it in the \x31\x31\x31 format.
I know that i can get the same number, ripping the \x with something like
for i in data: print hex(ord(i))
so i got 31 in each case.
But if I want to add 1 to the data (so it shall be "32 32 32")to send it as response, how can ...
Is there a way that I can add alias to python for encoding. There are sites on the web that are using the encoding 'windows-1251' but have their charset set to win-1251, so I would like to have win-1251 be an alias to windows-1251
...