python

WxPython - Resize WxFrame when adding new content?

Pretty much exactly as it sounds. I have buttons in a Wx.Frame that are created on the fly and I'd like the parent frame to increase in height as I add new buttons. The height is already being acquire from the total number of buttons multiplied by an integer equal the each button's height, but I don't know how to get the frame to change ...

How to use delete() method in Google App Engine Python's request handler

In GAE Python, I could use class MyRequestHandler(webapp.RequestHandler): def get(self): pass #Do Something... def post(self): pass #Do Something... To handle GET and POST request. But how can I handle DELETE and PUT? I see delete() and put() in API documentation, but I don't know how to write a form to simula...

Python Dbus : How to export Interface property

Hello, In all python dbus documentations there are info on how to export objects, interfaces, signals, but there is nothing how to export interface property. Any ideas how to do that ? Regards, Levon ...

Python. Showing text from a file in fragments of 20 lines every time ENTER is pressed.

This is the code i have at the moment print "Please input the filename:" n = raw_input() f = open(n,"r") x = 0 for line in f.readlines(): print line x+=1 if x % 20 == 0: break q = raw_input() if q == "": x+= 20 continue Things the program should do: 1) Ask for a filename 2) Read...

Total number of live sessions on GAE

Hi, Is there a way to count total number of active sessions (e.g. in 10 minutes) on Google App Engine (Python)? I want to show something on frontpage like, This site currently haz 200 people online ...

Crawling a social network in python

I would like to write a python script to crawl a social network website. The aim of the script should be to retrieve a piece of the social graph (friendships relationship). The website does not provide any API. The problem is: how can i crawl a website in python which pretends a login session to access the contact pages (for example, ...

Raw input and printing simultaneously

So I have a threaded Python program that takes input from a user and prints data simultaneously. The problem is that when the program is sitting at raw_input(), it won't print anything and will print it all after the user presses enter. Is there any way to have user input and print at the same time? ...

How to validate the form in pylons in the same controller action that initially rendered it?

I have the following controller: class FormtestController(BaseController): def form(self): return ender('/simpleform.html') @validate(schema=EmailForm(state=c), form='form', post_only=False, on_get=True, auto_error_formatter=custom_formatter) def submit(self): return 'Your email is: %s and th...

how to avoid noise in voice chat by programming techniques?

I'm using python & UDP to develop a voice chat application.I got the voice result in two way. But the problem is noise in audio so that we can't hear properly.Help me to avoid this challenge. I'm looking for a programming technique to avoid noise.If anyone has experienced the same & solved that plz give me your valuable information. TH...

counterintuitive slow Python regex search performance when providing a start of a String char

I've written a Python utility to scan log files for known error patterns. I was trying to speed up the search by providing the regex engine with additional pattern info. For example, not only that I'm looking for lines with "gold", I require that such line must start with an underscore, so: "^_.*gold" instead of "gold". As 99% of the lin...

Python Script Fails To Run When Launched From Shell File, But Works When Launched From Terminal

If I launch the Google Code upload Python script from Terminal, it works as expected, but when I launch it using the code below in a Bourne Shell Script file, it fails with the error "close failed in file object destructor: Error in sys.excepthook: Original exception was:". #!/bin/sh BUILD_FOLDER="/Users/James/Documents/Xcode Projects/U...

Python Vs Ruby on rails

Hi , This is the question , I asked many . But didn't get a satisfactory answer . Hope I'll get it from Stackoverflow folks . What is the advantage of Ruby on Rail have over python or perl ? I have django and GAE with python . Then why should I go for Heroku/Engineyard with Ruby on Rails ? Thanks J ...

How to create a new instance of the same class as the other object?

Having a object x which is an instance of some class how to create a new instance of the same class as the x object, without importing that all possible classes in the same namespace in which we want to create a new object of the same type and using isinstance to figure out the correct type. For example if x is a decimal number: >>> fr...

Python print works differently on different servers

When I try to print an unicode string on my dev server it works correctly but production server raises exception. File "/home/user/twistedapp/server.py", line 97, in stringReceived print "sent:" + json File "/usr/lib/python2.6/dist-packages/twisted/python/log.py", line 555, in write d = (self.buf + data).split('\n') exceptions.U...

Adding magic global methods to modules

I'm starting to get into the Python logging module, but unless I want all messages to say "root" I have to create a logger for each module, and it's kind of a pain to do that over and over again. I was thinking it would be handy if there were a magic __logger__() method that would return a logger for the current module, creating it if n...

Python, why elif keyword?

Hi! I just started python programming! There's one thing I wondered about, the "elif" keyword. Any other programming languages I used before use simply the "else if" syntax. Does anyone have an idea why the python developers add the additional "elif" keyword? Why not: if a: print("a") else if b: print("b") else: print("c"...

Read EXE, MSI, and ZIP file metadata in Python in Linux

I am writing a Python script to index a large set of Windows installers into a DB. I would like top know how to read the metadata information (Company, Product Name, Version, etc) from EXE, MSI and ZIP files using Python running on Linux. Software I am using Python 2.6.5 on Ubuntu 10.04 64-bit with Django 1.2.1. Found so far: Window...

Learning Pylons - Where to start

I decided to take the leap in to lower level things last night. I've been working with Django for years now, and I feel after all this time that it is simply not made for software outside of the blog/news/social networking sector. Pylons seems to offer flexibility to do anything you want at the expense of being much more complicated to u...

Why does "python -mtimeit" show less time when the code contains some module imports ?

On my single core 1.4 GHz computer, I ran the following 2 timeit codes: suzan:~$ python -mtimeit " def count(n): while n > 0: n -= 1 count(10000000) " 10 loops, best of 3: 1.73 sec per loop suzan:~$ suzan:~$ python -mtimeit " import os def count(n): while n > 0: n -= 1 count(10000000) " 10 loops, best of 3...

Django restart server or httpd

In django framework,When there are changes in urls.py or model.py or views.py .We would restart httpd. But as the documentation says we could restart runserver to get the latest changes. Which is the best efficient way for doing the above ...