Pass list as argument to Python C module?
I found this nice example of a Python C Module, where a single integer is passed along as the only argument. How can I instead pass a python list as argument? ...
I found this nice example of a Python C Module, where a single integer is passed along as the only argument. How can I instead pass a python list as argument? ...
I want to unique duplicate values in a dict. It looks like this: d = { "a":1, "b":2, "c":2, "d":3, "e":4, "f":5, "g":1, "h":2, "i":2, "j":1, "k":1} Here is what I did: # sort and unique the dict values obj = d.values() K = [] K = sorted(list(zip(*[(x,K.append(x)) for x in obj if not x in K])[0] V=[] for v1 in L: V.append([k f...
I've got to know and love the Django Test client. I'd really like to use it to test external sites and URLs outside of the current project. Is this possible? If not, is there something similar I could use? (ideally in Python) I don't need to do anything dramatic, just, say, grab a URL and check the status code, check that it took le...
Hello, How can I achieve such job: def get_foo(someobject, foostring): return someobject.foostring IE: if I do get_foo(obj, "name") it should be calling obj.name (see input as string but I call it as an attritube. Thanks ...
I want to get "Main content" instead of < tag> Main content , where the latter is html code and could be retrieved using urllib.urlopen(url). Just as you open the url in browser, select all text and then copy&paste. Is there a possible way for this with Python? Thanks. ...
My Python application is constructed as such that some functionality is available as plugins. The plugin architecture currently is very simple: I have a plugins folder/package which contains some python modules. I load the relevant plugin as follows: plugin_name = blablabla try: module = __import__(plugin_name, fromlist='do_somethi...
HI, I get the following error on executing a script: [Thu Jul 15 17:32:02 2010] [error] [client 127.0.0.1] mod_python.publisher: nothing to publish., referer: http://localhost/test/mptest.py/ff What does this mean and how can I resolve this? ...
Hello - newbie question. I have these lines in Python: page = lxml.html.parse(URL).getroot() table = only(page.cssselect('table[width=510]')) What is the only method doing? I can't find it in the Python docs (though that might just be because it's very hard to search for!) thanks. ...
from django.utils.simplejson import dumps, loads # -*- coding: utf-8 -*- def index(request): return render_to_response('test2/index.html') def add_lang(request): logging.debug("Got request") a = request.POST logging.debug(a["lang"]) lang=dumps(a["lang"]) l = Language(code=lang) l.save() lang=loads(lang) lo...
This is a question about Python Mixins that might be useful in general. I'm just using Django models as that is the use-case I'm most familiar with. Should a mixin inherit from the class it is designed to mix-in with or from 'object'? Examples by code, what is more correct or better, or better depending on what you want to achieve? Th...
Hi. I want to save gtk.DrawingArea() object contents to jpeg file using PIL. Particularly I want add to this script possibility to make photo. I found how to save image to jpeg. All I need - get pixbuf object from gtk.DrawingArea() object. How can I do this? ...
Hi all! I am new to java.I have written some python scripts and need to run them from java as desired by my mentor(these scripts are to be deployed on a server).So I have installed Jepp on my windows xp.However when I run C:\Program Files\Jepp>java -classpath jep.jar jep.Run console.py I get java.lang.UnsatisfiedLinkError: C:\WINDOW...
i have 2 tables one market, another brand , so when a client search for a brand i need to return all the markets where he can find that brand. ...
I am looking to generate passwords using strings typed by the user, the book I am reading recommends using sha over md5 because it is considered stronger. sha however has been deprecated and I am now using the hashlib module to encrypt me strings in a similar way to that shown here: http://docs.python.org/py3k/library/hashlib.html#modul...
Hello, django newbie here, I'm trying to insert a foreign language characters into a django model, and get this warning: *Incorrect string value: '\xD7\x90\xD7\x9E\xD7\xAA...' for column 'first_name' at row 1* What should I do to solve this? ...
This is an annoying problem I am having with Twisted.web. Basically, I have a class that inherits from twisted.web.resource.Resource and adds some default stuff to Mako templates: from twisted.web.resource import Resource from mako.lookup import TemplateLookup from project.session import SessionData from project.security import make_non...
Hi all. I am using this "key = RSA.gen_key(2048, 65537,genPass)" for RSA key generation, It is asking to enter a passphrase. How can i generate it without passphrase from user?and put some known passphrase automaticlly? Thanks. ...
We need to be able to inform a Delphi application in case there are changes to some of our tables in MySQL. Delphi clients are in the Internet behind a firewall, and they have to be authenticated before connecting to the notification server we need to implement. The server can be programmed using for example Java, PHP or Python, and it ...
Is there a framework to develop Desktop Database applications (some screens with CRUD screens) for Python? I am looking for something similar to Windows Forms, with the ability to associate TextField, Combos and other UI metaphors with datasets connected to relational databases such as MySQL, SQLServer, Oracle or PostgreSQL. Thanks! ...
I have the following numpy array: # A B C Y my_arr = np.array([ [.20, .54, .26], # <0 [.22, .54, .24], # 1 [.19, .56, .25], # 2 [.19, .58, .23], # 3 [.17, .62, .21] ]) # 4+ if a user enters a y (example,...