python

trying to install MySQL-python-1.2.3 but I get an error

Here tis the error I get while trying to install MySQL-python-1.2.3. any idea's? Traceback (most recent call last): File "C:\Documents and Settings\Desktop\MySQL-python-1.2.3\setup.py", line 15, in <module> metadata, options = get_config() File "C:\Documents and Settings\Desktop\MySQL-python-1.2.3\setup_windows.py", line 7, in get_c...

Line up columns of numbers

Hi, I have data (numbers) saved in the following format (example): 234 127 34 23 45567 23 12 4 4 45 23456 2 1 444 567 ... Is there any python-way method to line up the numbers and get them as 234 127 34 23 45567 23 12 4 4 45 23456 2 1 444 567 (I cannot predict the column size). ...

How to write a multidimensional array to a text file?

In another question, other users offered some help if I could supply the array I was having trouble with. However, I even fail at a basic I/O task, such as writing an array to a file. Can anyone explain what kind of loop I would need to write a 4x11x14 numpy array to file? This array consist of four 11 x 14 arrays, so I should format i...

WTForms extension for Django templates not working

I feel like I am missing something really obvious. I'm trying to use the WTForms template extensions with Django. I have a project on my development server which is working great (IE the extensions are working properly) but when I put it out on a test server, suddenly they are broken. Both servers have the same versions of Python, Dja...

Integration of Jython and Python

I have a Python application that is running as a console application. I did not like Python GUI libraries. That's why I want to use Java for GUI and python for application core. There are lots of details to read in the Jython documentation. I need a simple way to connect the GUI programmed in Java, and the core programmed in Python. What...

how to set a namespace prefix in an attribute value using the lxml?

I'm trying to create XML Schema using lxml. For the begining something like this: <xs:schema xmlns="http://www.goo.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.goo.com"&gt; <xs:element type="xs:string" name="name"/> <xs:element type="xs:positiveInteger" name="age...

MongoEngine vs MongoKit for Django

Have you used MongoEngine or MongoKit with Django? Which one do you prefer? Background: I'm developing a new site and have experience with normal Django development but for the kind of data I'll be using the MongoDB will be better suited than a SQL database. I'm using Python 2.7 and can compile/install anything on my host so that's no...

Given a list of words, make a subset of phrases with them

What is the best way performance wise to take a list of words and turn them into phrases in python. words = ["hey","there","stack","overflow"] print magicFunction(words) >>> ["hey","there","stack","overflow", "hey there stack","hey there", "there stack overflow","there stack", "stack overflow", "hey there stack overflow" ] Order does...

Python: Iterate a certain number of times without storing the iteration number anywhere

Hello... I was wondering if it is possible to perform a certain number of operations without storing the loop iteration number anywhere. For instance, let's say I want to print two "hello" messages on the console. Right now I know I can do: for i in range(2): print "hello" but then the "i" variable is going to take the values 0 ...

Problem adding to solr index from Django using zc.buildout

I'm trying to get Apache Solr running inside my zc.buildout environment. I've defined a simple model: class NewsItem(models.Model): title = models.CharField(blank=False, max_length=255, help_text=u"Title of this news item") slug = models.SlugField(blank=False, help_text=u"Slug will be automatically generated from the title") ...

ntop python api

hi can anyone give me some document and tutorial about using python api in ntop, Except luca deris present pdf. in web interface there is "about>online documention> python engine" but this link have error. can someone send me that document. excuse me for my bad english. ...

Python bytecode compiler; removes unnecessary variables?

Given the following: def foo(): x = a_method_returning_a_long_list() y = a_method_which_filters_a_list(x) return y will Python's bytecode compiler keep x & y in memory, or is it clever enough to reduce it to the following? def foo(): return a_method_which_filters_a_list(a_method_returning_a_long_list()) ...

IExplorerBrowser control in python

Hello, I'm try to embed a IExplorerBrowser (Windows Explorer) in a wxpython application but I cannot seem to get the IExplorerBrowser module opened in python I have the CLSID of IExplorerBrowser from the registry but when I try and open it with: from win32com import client client.gencache.GetModuleForCLSID(id) Nothing is returned.....

Python compatability issue - 'in <string>' requires character as left operand

Hi, I make no claims to know anything at all about writing Python scripts or programming in general, but I've been tasked with writing one anyway that will have to operate on a wide variety of Python versions. I wrote, and did my testing on versions 2.3, 2.4 and all went well. Version 2.2 though is giving me fits and my google-fu must...

Why can't django load multiple pages simultaneously ?

I have a django aplication with an admin panel. When i add some item (it takes about 10 seconds to add it), i can't load any other page. The page is waiting for the first page to load, and then it load itself. ...

Couldn't close file in functional way in python3.1?

I wrote a line of code using lambda to close a list of file objects in python2.6: map(lambda f: f.close(), files) It works, but doesn't in python3.1. Why? Here is my test code: import sys files = [sys.stdin, sys.stderr] for f in files: print(f.closed) # False in 2.6 & 3.1 map(lambda o : o.close(), files) for f in files: print(...

Including mercurial extensions from eggs

Is there some way to import an extension from an .egg file? For example hggit installs itself as hg_git-0.2.4-py2.5.egg, which cannot be listed under [extensions] directly, or it's interpreted as a standard .py file. Is there some way to include that file as an extension? Alternatively, is there some way to install hg-git manually in a...

Steps on howto install PySide on windows

I followed what they said at pyside.org but somehow i can't get it to work. I downloaded the two files that they are linking from their site (qt libraries and pyside for python 2.6) When I try one of their examples I get the following message: Traceback (most recent call last): File "2dpainting.py", line 28, in <module> from PySi...

How can I integrate Arecibo error reporting with Pylons?

I've written a very rudimentary attempt to integrate Arecibo reporting with Pylons, but the sad fact of the matter is that it basically doesn't work. I've conceived of this as middleware, but I'm not sure A) where to put it in the middleware stack without interfering with other aspects of the middleware, B) how to get at various bits of...

Flask/Werkzeug, how to return previous page after login

Hi, I am using the Flask micro-framework which is based on Werkzeug, which uses Python. Before each restricted page there is a decorator to ensure the user is logged in, currently returning them to the login page if they are not logged in, like so: # Decorator def logged_in(f): @wraps(f) def decorated_function(*args, **kwargs)...