python

Which is the most recommended Python Twitter library for programmatically updating my own Twitter stream?

After Twitter discontinuing the Basic Auth, my program which updates my own Twitter stream (not others' Twitter streams.) has broken. I understand that OAuth is the way to go. I have set up a Twitter App for the same and have acquired the consumer tokens. Now I don't want to implement the OAuth for Twitter all by myself if someone has do...

Condition mako base template from inheriting one

I have a base.mako template with a if statement to include or not jQuery <head> % if getattr(c, 'includeJQuery', False): <script type="text/javascript" src="jquery.js"></script> % endif ... Several templates inherit from base.mako, someone needs jQuery, someone don't. At the moment I have to set the attribute in the controller be...

Py2Exe + FTDI driver

Is it at all possible to somehow include the FTDI driver in a py2exe installer? If not, are there any ways to combine the two together in one easy installer? ...

kmeans in opencv python interface

Hi I'm using v2.1 with the built-in python interface. I'm trying to load an image from a file, transform it to lab and get the clusters from the ab plane. I have a working matlab code but don't know how to do the same in opencv. How do I reshape a jpeg or png images and feed it to kmeans? Thanks The error I'm getting: OpenCV Error: ...

sqlalchemy Move mixin columns to end

I have a sqlalchemy model, where all most all tables/objects have a notes field. So to try follow the DRY principle, I moved the field to a mixin class. class NotesMixin(object): notes = sa.Column(sa.String(4000) , nullable=False, default='') class Service(Base, NotesMixin): __tablename__ = "service" service_id = sa.Colum...

Python solution to allow photo uploading via email to my Django website

I am learning Python/Django and my pet project is a photo sharing website. I would like to give users the ability to upload their photos using an email address like Posterous, Tumblr. Research has led me to believe I need to use the following: -- cron job -- python mail parser -- cURL or libcurl -- something that updates my database ...

how to use tempfile.NamedTemporaryFile() in python

Hi, I want to use tempfile.NamedTemporaryFile() to write some contents into it and then open that file. I have written following code: tf = tempfile.NamedTemporaryFile() tfName = tf.name tf.seek(0) tf.write(contents) tf.flush() but I am unable to open this file and see its contents in notepad or similar application. Is there any way ...

Subprocess in Python Add Variables

Subprocess in Python Add Variables import subprocess subprocess.call('Schtasks /create /sc ONCE /tn Work /tr C:\work.exe /st 15:42 /sd 13/10/2010') I want to be able to set the variables on the above command. the variables are the time '15:42' separated in 15 and 42 and the date '13/10/2010' separated in day , month and year any i...

Blender, Python Scripting Tutorials

I already know some Python and got interested in extending Blender using Python scripts. Can anyone suggest me some good tutorials or books to learn this subject further? I'm already looking at Blender documentation, but I would like to learn some more because I'm a newbie when it comes to 3D modeling. ...

FormEncode validate: words divided by a comma

Hi everyone ! How to validate words divided by a comma by FormEncode ? Something like this: "foo1, foo2, foo3" -> ["foo1", "foo2", "foo3"] ...

What is the easiest way to search through a list of dicts in Python?

My database currently returns a list of dicts: id_list = ({'id': '0c871320cf5111df87da000c29196d3d'}, {'id': '2eeeb9f4cf5111df87da000c29196d3d'}, {'id': '3b982384cf5111df87da000c29196d3d'}, {'id': '3f6f3fcecf5111df87da000c29196d3d'}, {'id': '44762370cf5111df87da000c29196d3d'}, ...

how to use paramiko to execute remote commands.

hi, I wanted to compress a folder on a remote namchine.For that i am using paramiko. But i don't know how to do that using paramiko. Any suggestions?? This is my code: dpath='/var/mysql/5.1/mysql.zip' port = 22 host = '10.88.36.7' transport = paramiko.Transport((host, port)) transport.connect(username = suser, password...

Problem displaying xfbml with pyfacebook

I'm using pyfacebook on my app but I'm having problems displaying xfbml For example I have to use iframes to display like buttons or like boxes. What's strange: 1) On the login page the appears correctly, I just have problems on other pages (once logged in) 2) The FB.init part I use is <script src="http://static.ak.connect.facebook.c...

Python Queue - Threads bound to only one core

Hello, I wrote a python script that: 1. submits search queries 2. waits for the results 3. parses the returned results(XML) I used the threading and Queue modules to perform this in parallel (5 workers). It works great for the querying portion because i can submit multiple search jobs and deal with the results as they come in. How...

Python webapp - moving from testing to production

I've made a small web app using web.py that I now want to put into production. I dont anticipate this will have very high concurrent use (probably max of 5 or so users at any given time, if that). That said, I dont want to go with the cherry.py server that comes with web.py (and which i have been using for debugging), because one of my ...

Python's list comprehension vs .NET LINQ

The following simple LINQ code string[] words = { "hello", "wonderful", "linq", "beautiful", "world" }; // Get only short words var shortWords = from word in words where word.Length <= 5 select word; // Print each word out shortWords.Dump(); can be translated into python using list comprehension as follows. words = ["hello",...

how to get only the lastname of the directory, in python

Hi, guys, I am using wxpython and python to develop a gui. If I use the wx.dirdialog to get the directory like this: /folderA/folderB/folderC/folderD/ how can I get string "folderD"? Thanks in advance. ...

print python stack trace without exception being raised

Something funky is happening with one of my class's instance variables. I want to make the variable a property, and whenever it is accessed I want to print out the stack trace of all the code leading up to that point, so I can see where it's being messed with. How do I print out the stack trace when no exception has been raised? I know i...

Repeating elements in list comprehension

I have this list comprehension: [[x,x] for x in range(3)] which results in this list: [[0, 0], [1, 1], [2, 2]] but what I want is this list: [0, 0, 1, 1, 2, 2] What's the easiest to way to generate this list? ...

Why it's needed to "source" some Vim plugins?

From autotag.vim: install details Simply source the file autoTag.vim from your .vimrc file. This utility will (obviously) only work when using vim that's been compiled with python support. Is this needed because this is a Python plugin in vim, instead of a vimscript? Aren't plugins in .vim/plugin loaded automatically?...