python

Can't get custom slot working in PyQT4 with QT4 designer

Hey, I am new to PyQT4. After some tuts I decided to make a simple GUI in which I will enter text in first line and on clicking of Reverse button ,it will show reversed string on second line. I made a custom slot for this,by defining the function in my class.But when I click reverse nothing happens. I have used in-bilt slots for Clear...

Searching for duplicate records within a text file where the duplicate is determined by only two fields.

First, Python Newbie; be patient/kind. Next, once a month I receive a large text file (think 7 Million records) to test for duplicate values. This is catalog information. I get 7 fields, but the two I'm interested in are a supplier code and a full orderable part number. To determine if the record is dupliacted, I compress all special...

Python-based password tracker (or dictionary)

Hello: Where we work we need to remember about 10 long passwords which need to change every so often. I would like to create a utility which can potentially save these passwords in an encrypted file so that we can keep track of them. I can think of some sort of dictionary passwd = {'host1':'pass1', 'host2':'pass2'}, etc, but I don't kn...

Using upload_data on Google AppEngine doesn't let me update entities with id based keys

This seems so basic - I must be missing something. I am trying to download my entities, update a few properties, and upload the entities. I'm using the Django nonrel & appengine projects, so all the entities are stored as id rather than name. I can download the entities to csv fine, but when I upload (via appcfg.py upload_data ...), t...

What is the best way to start learning how to program?

Possible Duplicate: Whats the Easiest Way to Learn Programming? I'm very new to programming, but it has always interested me. I've tried to learn a couple of times except I don't know where to begin. What's a good language to learn first? What is a good website that can help me learn it? I once partitioned my hard drive and i...

Ubuntu quickly (python/gtk) - how to monitor stdin?

I'm starting to work with Ubuntu's "quickly" framework, which is python/gtk based. I want to write a gui wrapper for a textmode C state-machine that uses stdin/stdout. I'm new to gtk. I can see that the python print command will write to the terminal window, so I assume I could redirect that to my C program's stdin. But how can I get m...

Calculating the null space of a matrix

I'm attempting to solve a set of equations of the form Ax = 0. A is known 6x6 matrix and I've written the below code using SVD to get the vector x which works to a certain extent. The answer is approximately correct but not good enough to be useful to me, how can I improve the precision of the calculation? Lowering eps below 1.e-4 causes...

Django snippet with logic

Hi, is there a way to create a Django snippet that has logic? I think about something like contact template tag: {% contact_form %} with template: <form action="send_contact_form" method="POST">...</form> with logic: def send_contact_form(): ... I want to be able to use it anywhere in my projects. It should work only by sp...

log2 in python math module

why doesn't it exist? import math [x for x in dir(math) if 'log' in x] ['log', 'log10', 'log1p'] I know I can do log(x,2), but log2 is really common, so I'm kind of baffled. Oh, it looks like it's only defined in C99, not C90, I guess that answers my question. Still seems kind of silly. ...

how to create a theme with QT

hello im looking for a way to make my pyqt interface look nicer by adding a theme to it. im new to Qt and i still have no idea how to add a custom theme for widgets.. so how is that possible ? and is it possible through qt designer ? sorry for my bad english , its my third language. i hope the idea is clear enough . please let me kn...

Python - how to check if weak reference is still available

Hi all, I am passing some weakrefs from Python into C++ class, but C++ destructors are actively trying to access the ref when the real object is already dead, obviously it crashes... Is there any Python C/API approach to find out if Python reference is still alive or any other known workaround for this ? Thanks ...

how to set a pop up menu on a particular table view item

hello i have a QTableView , and i need to show a popup menu that shows the item properties . i need to set the context menu to apear only when you right click over a particular items in that tableview. but coudln't find a way to do it . i can set the context menu to appear when your over the table . i cant have it for each item . so ho...

Spawning and waiting for child processes in Python

The relevant part of the code looks like this: pids = [] for size in SIZES: pids.append(os.spawnv(os.P_NOWAIT, RESIZECMD, [RESIZECMD, lotsOfOptions])) # Wait for all spawned imagemagick processes to finish while pids: (pid, status) = os.waitpid(0, 0) if pid: pids.remove(pid) What this should be doing is spawning ...

django-admin - how to modify ModelAdmin to create multiple objects at once?

let's assume that I have very basic model class Message(models.Model): msg = models.CharField(max_length=30) this model is registered with admin module: class MessageAdmin(admin.ModelAdmin): pass admin.site.register(Message, MessageAdmin) Currently when I go into the admin interface, after clicking "Add message" I have on...

Is PHP enough to be a great developer or do you have to learn Rails/Python?

My question really is can you do EVERYTHING in PHP that you can do in (Ruby)Rails/Django(python)? By me just concentrating on PHP (Framworks too) will i be losing out in someway? I prefer PHP but everyone tells me Rails is better? Any advice? Thank you in advance ;-) ...

Gstreamer of python's gst.LinkError problem

I am wiring a gstreamer application with Python. And I get a LinkError with following code: import pygst pygst.require('0.10') import gst import pygtk pygtk.require('2.0') import gtk # this is very important, without this, callbacks from gstreamer thread # will messed our program up gtk.gdk.threads_init() def main(): pipeline = ...

Display constantly updating information in-place in command-line window using python?

I am essentially building a timer. I have a python script that monitors for an event and then prints out the seconds that have elapsed since that event. Instead of an ugly stream of numbers printed to the command line, I would like to display only the current elapsed time "in-place"-- so that only one number is visible at any given tim...

deleting all the file of certain size

i have bunch of log files and I have to delete the files of some small sizes, which were erroneous files that got created. ( 63bytes ). I have to copy only those files which have data in it . ...

Efficient and accurate way to compact and compare Python lists?

Hi folks, I'm trying to a somewhat sophisticated diff between individual rows in two CSV files. I need to ensure that a row from one file does not appear in the other file, but I am given no guarantee of the order of the rows in either file. As a starting point, I've been trying to compare the hashes of the string representations of the...

Efficient way to maintain a sorted list of access counts in Python

Let's say I have a list of objects. (All together now: "I have a list of objects.") In the web application I'm writing, each time a request comes in, I pick out up to one of these objects according to unspecified criteria and use it to handle the request. Basically like this: def handle_request(req): for h in handlers: if h....