python

Cherrypy hanging on form post

I'm currently trying to remove a legacy python framework (webware 0.8.1) and layer cherrypy 3.1.2 on top of it. Instead of converting all the webware pages to cherrypy pages, I'm merely processing it through webware and passing it to cherrypy like so. def default(self, url, *suburl, **kwarg): ...snip... strmout = DispatcherIO() ...

Get remote MAC address using Python and Linux

How do I get the MAC address of a remote host on my LAN? I'm using Python and Linux. ...

How to implement a voice chat functionality using Python?

Hi guys! My goal is a cross-platform voice chat application. The part I am a bit confused about it's the voice transferring one : ) What can you suggest? Maybe a binding to some low-level library or even a framework? BTW, I don't have to use Python, so if you think that Python is not a good idea for this purpose, please show me the tr...

how to check the character count of a file in python

Hi ! I have a python code which reads many files. but some files are extremely large due to which i have errors coming in other codes. i want a way in which i can check for the character count of the files so that i avoid reading those extremely large files. Thanks. ...

creating and deploying a python chat application using twisted

i have created a chat server application using twisted framework .am running it on my local maching and now i want to go gloabal.The application is similar to omegle.com. How can i devlop on a third party commertial server so that it runs continuously. Do i need to get dedicated server for it? ...

Compiling Python 3.1.1 32-bit

We're using this configure script with an option we spotted in the configure help menu: ./configure --with-universal-archs=32-bit --prefix="$HOME/python" make make install But when all the dust is settled and we check out what it gives us: ✔python-3.1.1⤿ file ~/python/bin/python3 python/bin/python3: Mach-O 64-bit executable x86_64 ...

how can i get the value '111'

def a(): w='www' a.a='aaa' print a.__dict__ a.__dict__={'1':'111','2':'222'} print a.1#error print a['1']#error how can i get the value '111' thanks ...

Can I find out where a Python application crashed using the data dump?

My application crashed recently on a client's computer. I suspect it's because of PyQt's own memory management, which can lead to a invalid memory accesses when not properly handled. When Python crashes like this, no backtrace is printed, only a data dump is written to the disk. Is there a possibility to find out where in the Python co...

Display random choice (Python)

I have a list[] of items from which I'd like to display one randomly, but the displayed item must not repeat more than once in last x requests. list1 = item1, item2, item3, item4, item5, item6, item7, item8, item9, item 10 Display a random selection from the list above list2 = store the last displayed item in list2 which should only...

VIM Python Indentation not working?

So I have VIM7 (enhanced) on CentOS5 and it comes with all the usual VIM plugins/scripts ready to go. $ find /usr/share/vim/vim70/ -name \*python\* /usr/share/vim/vim70/syntax/python.vim /usr/share/vim/vim70/ftplugin/python.vim /usr/share/vim/vim70/indent/python.vim /usr/share/vim/vim70/autoload/pythoncomplete.vim I would think that w...

unicode error when saving an object in django admin

Hello, In my django app, I have some objects that cause the corresponding URL in the django admin to be non ascii. (for example: http://mysite/admin/myapp/myclass/Présentation/) I can edit the object without any problem but when I save it I have the following error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in p...

pycurl module not available after installation on Snow Leopard

I'm running Python 2.6.4 on Mac Snow Leopard. I installed pycurl using: sudo env ARCHFLAGS="-arch x86_64" easy_install setuptools pycurl==7.16.2.1 The installation completes with no issues and says pycurl is installed in subsequent installation attempts. However, when I try to "import pycurl" in a script, I get a message that pycurl i...

Django dynamic number of filter for a objects request

Hello How can I do something like this : products_list = Product.objects.all() for key in keywords: products_list = products_list.filter(name__icontains=q) This don't work. Thank you for your help ...

why my code error? I copied the 'memoize' function in django.utils.functional

my code: a=[1,2,3,4] b=a[:2] c=[] c[b]='sss'#error memoize function: def memoize(func, cache, num_args): def wrapper(*args): mem_args = args[:num_args]#<------this if mem_args in cache: return cache[mem_args] result = func(*args) cache[mem_args] = result#<-----and this return re...

Python or Ruby for web development?

I'm a web developer proficient in HTML, CSS and Javascript, but to be able to develop my own web applications, I'd like to learn a programming language besides PHP. I've been learning Python for a while now but it seems a general purpose language, a bit complex, and not suited for web-development I guess. So if my focus is creating we...

Changing schema using cx_Oracle

Well, I hope this is not a duplicate, the search did not yield anything useful. I have been toying with cx_Oracle for the past few days, installing and using it. Everything went fine until I reached my current problem: I'd like to change my schema. If I were using sqlplus a simple 'alter session set current_schema=toto;' would do, but I...

How to write last 50 lines from one file to another Python

Hello, I am creating an email response to an overnight build, I want to get the last 50 lines from the results file and place it into a summary file. The code that I have done is below, can anyone help? def email_success(): fp = open(results_file, 'r') sum_file = (fp.readlines()[-50:]) fp.close() myfile = open(resul...

python games problem

hi, I have made a mine sweeper game which fully works except for one key point, which is: Allow the player to place flags on cells to mark mine locations and to remove flags. if a cell is marked with a flag the player can not activate it by clicking on it. Now I don't know how to do this flag requirement. ...

any() function in Python with a callback

The Python standard library defines an any() function that Return True if any element of the iterable is true. If the iterable is empty, return False. It checks only if the elements evaluate to True. What I want it to be able so specify a callback to tell if an element fits the bill like: any([1, 2, 'joe'], lambda e: isinstance(e,...

Deleting files which start with a name Python

Hello, I have a few files I want to delete, they have the same name at the start but have different version numbers. Does anyone know how to delete files using the start of their name? Eg. version_1.1 version_1.2 Is there a way of delting any file that starts with the name version? Thanks ...