python

Assign output of os.system to a variable and prevent it from being displayed on the screen

Hello, I want to assign the output of a command i run using os.system to a variable and prevent it from being output to the screen But, in the below code,the output is sent to the screen and the value printed for var is 0,which i guess signifies whether the command ran successfully or not. Any way to assign the command output to the var...

Make Python ignore .pyc files

Is there a way to make Python ignore any .pyc files that are present and always interpret all the code (including imported modules) directly? Google hasn't turned up any answers, so I suspect not, but it seemed worth asking just in case. (Why do I want to do this? I have a large pipeline of Python scripts which are run repeatedly over ...

Help On Python program that can use to compile python coding into a standalone .exe file

Hi all, I am currently working on a python program with the use of wxpython to make out a gui application. However, i wish to compile my application to be like a standalone application where people can just get the .exe file and run it without installing python and wxpython. I am not sure if it is possible, thus i hope that someone can g...

SQLCLR & IronPython

Hi, Im feeling crazy and I've decided I would really like to write a User-Defined Function in Python that would run in SQL Server 2008. I am interested in doing this as I have a few thousand lines of PL/Python functions written for PostgreSQL and I am interested to know if I can get the project running on SQL Server instead. I am looki...

Problem with inheritance and "self" reference

Hello everybody! This is my first post, so first of all I want to say a giant "Thank you!" to the community of stackoverflow for all the time an answer did the trick for me :) I have a problem while dealing with python's inheritance. I have a parent class which contains the following code: def start(self): pid = os.fork() if (p...

Finding out how many lines can be displayed in wx.richtext.RichTextCtrl without scrolling

I'm writing an e-book reader in Python + wxPython, and I'd like to find out how many lines of text can be displayed in a given RichTextCtrl with the current formatting without scrolling. I thought of using and dividing the control's height by RichTextCtrl.GetFont().GetPixelSize(), but it appears that the pixel size parameter of wx.Font...

How to best organize the rules component of a Django system?

I'm designing (and ultimately writing) a system in Django that consists of two major components: A Game Manager: this is essentially a data-entry piece. Trusted (non-public) users will enter information on a gaming system, such as options that a player may have. The interface for this is solely the Django admin console, and it doesn'...

Recommend a python library to read Excel xls files

Anyone doing this currently? What do you use? ...

best way to parse a language that's ALMOST Python?

I'm working on a domain-specific language implemented on top of Python. The grammar is so close to Python's that until now we've just been making a few trivial string transformations and then feeding it into ast. For example, indentation is replaced by #endfor/#endwhile/#endif statements, so we normalize the indentation while it's still ...

twisted + gtk: should I run GUI things in threads, or in the reactor thread?

From what I understand about twisted, nothing running in the reactor thread should block. All blocking activities should be delegated to other threads, to fire callbacks back into the reactor thread when they're done. So does this apply to gtk things as well? For example, I want to display a "connection failed" message if the connection...

Screen capture in python

This isn't a HTML parsing Question. This is about taking a look at pixels on the screen itself. How would I, with python, look at all the pixels in a programs window. Following advice, I am narrowing my OS field to win32. If a X-Platform solution exists, this is the place. ...

What are the most interesting projects surrounding python?

There are many neat projects around that are extending the usefulness of python inside and outside the core language and standard library. Some that come to mind are: pypy stackless twisted unladen swallow web frameworks numpy function annotations other interesting ideas What are some of the projects that get you excited, on and off...

Using RSA in Python

Hi , I am using RSA to encrypt/decrypt my session keys in Python. I am using Pycrypto library. After generating the keypair, I want to extract the private key and public key from that generated key and store them in different files. How can I do this? I can see the has Private method which can tell that the generated keypair has private...

python beautifulsoup adding extra end tags

I'm using Beautifulsoup to parse a website request = urllib2.Request(url) response = urllib2.urlopen(request) soup = BeautifulSoup.BeautifulSoup(response) I am using it to traverse a table. The problem I am running into is that BS is adding an extra end tag for the table into the html which doesn't exist, which I verified with...

Extending the code of Python - adding language features

I have been programming in python exclusively for 4 years and have never really looked under the hood at the C code in which python is written. I have recently been looking into a problem that would involve modifying python at that level. The code seems pretty consistent, and thus relatively easily understood. However, it's complex en...

PyGTK TreeColumns all exact duplicates

I wrote a simple PyGTK script to show some basic process information in a TreeView: import gtk import os import pwd import grp class ProcParser: """ Parses the status file of a particular process """ def __init__(self, fname): self.lines = map(lambda x: x[:-1], open(fname).readlines()) def get_by_val(self, ...

Dynamically loading Python application code from database under Google App Engine

Hi, I need to store python code in a database and load it in some kind of bootstrap.py application for execution. I cannot use filesystem because I'm using GAE, so this is my only choice. However I'm not a python experienced user. I already was able to load 1 line of code and run it using eval, however a piece of code with two lines o...

Django: How to 'scrub' list of users

This is my code that fails: dashboard = Dashboard.objects.get(slug=slug) users = User.objects.all() # list of users for editor in dashboard.dashboardeditor_set.iterator: users.remove(editor.user) The error: 'instancemethod' object is not iterable From models.py: class DashboardEditor(models.Model): dashboard = models.Foreig...

Django maximum recursion depth exceeded

I'm building a small web project using Django that has one model (Image) that contains an ImageField. When I try to upload an image using the admin interface I am presented with this problem (personally identifying information removed): RuntimeError at /admin/main/image/add/ maximum recursion depth exceeded Request Method: POST Re...

Python: Undo a Python file readline() operation so file pointer is back in original state

I'm browsing through a Python file pointer of a text file in read-only mode using file.readline() looking for a special line. Once I find that line I want to pass the file pointer to a method that is expecting the file pointer to be at the START of that readline (not right after it.) How do I essentially undo one file.readline() operat...