python

Efficient way to store hash in a file

HI, I am implementing some unix userland tool, that needs to store hash on the disk. The hash will be read every run of a program, pretty frequently. To give you better insight, the hash needs to store "name:path" values only. I looked at bdbd module for python, but I can see it will be deprecated in Python 3. Also saw Pickle. Im not ...

Python: Uniqueness for list of lists

Hello I am curious what would be an effient way of uniquefying such data objects: testdata =[ ['9034968', 'ETH'], ['14160113', 'ETH'], ['9034968', 'ETH'], ['11111', 'NOT'], ['9555269', 'NOT'], ['15724032', 'ETH'], ['15481740', 'ETH'], ['15481757', 'ETH'], ['15481724', 'ETH'], ['10307528', 'ETH'], ['15481757', 'ETH'], ['15481724', 'ETH']...

Cross platform solution for getting current login name in Python

I'm looking for a cross platform solution for getting current login/username in Python. I was surprised that os.getlogin() is only supported under Unix and even there is not necessarly returning what you would expect. ...

Create one keybord shortcut for 2 objects in PyQt

How can i create for "Ctrl+C" bindings for 2 objects: self.table, self.editor I have: shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"), self.table, None, self.copyTable) shortcut2 = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"), self.editor, None, self.copyText) This works, but is toogled. If i have focus on self.editor and for...

CMS or Framework?

I'm looking to build a online store. However, the first question, past the idea of the store, is the platform. I've previously worked with Java and PHP and am quite comfortable with PHP. So my first considerations were Drupal or maybe CodeIgniter (which I have heard lots of good things about) On discussions with friends, they suggested...

Python ssl problem with multiprocessing

I want to send data from a client to the server in a TLS TCP socket from multiple client subprocesses so I share the same ssl socket with all subprocesses. Communication works with one subprocess, but if I use more than one subprocesses, the TLS server crashes with an ssl.SSLError (SSL3_GET_RECORD:decryption failed or bad record mac). M...

Python ctypes, C++ object destruction

Consider the following python ctypes - c++ binding: // C++ class A { public: void someFunc(); }; A* A_new() { return new A(); } void A_someFunc(A* obj) { obj->someFunc(); } void A_destruct(A* obj) { delete obj; } # python from ctypes import cdll libA = cdll.LoadLibrary(some_path) class A: def __init__(self): self.obj...

oocalc plugin - development step by step guide available?

I want to develop plugin for OoCalc Open Office, is there any good resource or link will help to start working on it. any existing article like step by step guide for developer would be great !! I want to develop the plugin based on Python Programming Language. ...

beep sound in python audiolab

How do i generate a gentle "beep" sound in python audiolab, without the use of external .wav files? I found the following example to generate random noise: play(0.05 * np.random.randn(2, 48000)) Unfortunately i do not have enough knowledge of audio representations to create a beep (of a certain frequency) and i have no idea where to f...

SCons configuration file and default values

Hi, I have a project which I build using SCons (and MinGW/gcc depending on the platform). This project depends on several other libraries (lets call them libfoo and libbar) which can be installed on different places for different users. Currently, my SConstruct file embeds hard-coded path to those libraries (say, something like: C:\lib...

Ruby's tap idiom in Python

There is a useful Ruby idiom that uses tap which allows you to create an object, do some operations on it and return it (I use a list here only as an example, my real code is more involved): def foo [].tap do |a| b = 1 + 2 # ... and some more processing, maybe some logging, etc. a << b end end >> foo => [1] With Rails...

Python package/module lazily loading submodules

Hello! Interesting usecase today: I need to migrate a module in our codebase following code changes. The old mynamespace.Document will disappear and I want to ensure smooth migration by replacing this package by a code object that will dynamically import the correct path and migrate the corresponding objects. In short: # instanciate a...

Python module for binary plist

Hi guys, Is there any Python project/module working on a binary plist writer? I need one for a REST implementation I'm doing. I would like the server to send a HTTP REsponse containing a binary plist instead of json, for example. The server is Apache with mod_python and django installed. Considering adding bplist format alongside json a...

numpy array <=> python DB-API adapter?

Dear All, Anyone knows is there any other adapter between numpy array and sqlite database besides the atpy? Thanks! Rgs, KC ...

Python httplib SSL client problems

Hello all, I have the following function: def soap(self, xml): """ Transport function """ slash = self.apiurl.find('/') addr = self.apiurl[:slash] path = self.apiurl[slash:] conn = httplib.HTTPSConnection(addr) conn.putrequest("POST", path) conn.putheader("Content-type", "text/xml; charset=\"UTF-8\"") c...

Python String split with multiple regex

Hi I have Python String as shown below: <html><table border = 1><tr><td>JDICOM</td><td>Thu Sep 16 10:13:34 CDT 2010</td></tr></html> From above string I am interested in two words JDICOM Thu Sep 16 10:13:34 CDT 2010 I tried find, findall, split but it did not help because of multiple regex. I am quite new to python. If anyone kno...

Is Zpsycopg2 compatible with zope 2??

I have zope 2.11 installed. Now i want to use Posgresql 7.4.13 DB with it. So i know i need to install psycopg2 Database Adapter. Can any one tell me Is psycopg2 compatible with zope2?? ...

regular expression help which includes "." in word sepration

expr = "name + partner_id.country_id.name + city + ' ' + 123 + '123' + 12*2/58%45" print re.findall('\w+[.]',expr) ['name', 'partner_id', 'country_id', 'name', 'city', '123', '123', '12', '2', '58', '45'] I want to include "." so result should be like ['name', 'partner_id.country_id.name', 'city', '123', '123', '12',...

How to call an executable as independent process using python in windows

After calling an exe using python script in windows, the exe should run independent of this python script and once it is initiated the control should comeback to python script and executes the further script and control of .py file will die. But on other side before finishing execution, the exe should call this python script. Ideas woul...

WSGI request and response wrappers for Python 3

Are there WSGI request and response wrappers for Python 3? WebOb looks nice (although there is some critique), but it seems to be written in Python <3. Werkzeug seems also to be written in Python <3. Should I write my own request and response wrappers for Python 3? Maybe this would be impossible, since WSGI seems to be somewhat broke...