I'm trying to return a CSV from an action in my webapp, and give the user a prompt to download the file or open it from a spreadsheet app. I can get the CSV to spit out onto the screen, but how do I change the type of the file so that the browser recognizes that this isn't supposed to be displayed as HTML? Can I use the csv module for th...
Using PyObjC, is it possible to import a Python module, call a function and get the result as (say) a NSString?
For example, doing the equivalent of the following Python code:
import mymodule
result = mymodule.mymethod()
..in pseudo-ObjC:
PyModule *mypymod = [PyImport module:@"mymodule"];
NSString *result = [[mypymod getattr:"mymeth...
On localhost it worked easy. I send several django zip files to server:
with django folder
without django
folder without pyc files
But zipimport dont wonna work. Any suggestions? How you use it?
...
I have grown tired of all the little issues with paste template, it's horrible to maintain the templates, it has no way of updating an old project and it's very hard to test.
I'm wondering if someone knows of an alternative for quickstart generators as they have proven to be useful.
...
Is there possibility to add method to object class, to use method on all objects?
...
Currently I have tables like: Pages, Groups, GroupPage, Users, UserGroup. With pickled sets I can implement the same thing with only 3 tables: Pages, Groups, Users.
set seems a natural choice for implementing ACL, as group and permission related operations can be expressed very naturally with sets. If I store the allow/deny lists as pic...
If you want to indent several lines in Python you just mark the lines and hit Tab. But what if you want to remove the indent from several lines? Is there a quick way to do that?
Thanks
edit: I use IDLE.
...
I need a python system information library which
a) is written in python (no C extensions, may use ctypes)
b) is crossplatform (min. Linux, Windows, MacOSX - everything else is bonus)
c) provides at least amount of physically installed RAM, number of CPUs, size of maximum usable shared memory)
Is there such a library, or do I have to...
I have two files - prefix.txt and terms.txt both have about 100 lines. I'd like to write out a third file with the Cartesian product
http://en.wikipedia.org/wiki/Join_(SQL)#Cross_join
-about 10000 lines.
What is the best way to approach this in Python?
Secondly, is there a way to write the 10,000 lines to the third file in a rand...
Hi, this has been driving me crazy for the past 12 hours... I'm fairly new to Python, so pardon my ignorance. :)
I have a module that I want to parse a file everytime a new file is created in a certain directory. For this, I'm trying to use pyinotify to setup a directory to watch for IN_CREATE kernel events, and fire the parse() method....
Is it possible to do PyS60 development on Mac OS X? There is an XCode-plugin for Symbian C++ -development, but I don't know whether I can create Python-apps for my Nokia phone with that. I'm talking about a more thorough SDK experience than just editing files with Textmate/Emacs and copying them over to the device.
...
I'd like to produce sounds that would resemble audio from real instruments. The problem is that I have very little clue how to get that.
What I know this far from real instruments is that sounds they output are rarely clean. But how to produce such unclean sounds?
This far I've gotten to do this, it produces quite plain sound from whic...
I need to make one function in a module platform-independent by offering several implementations, without changing any files that import it. The following works:
do_it = getattr(__import__(__name__), "do_on_" + sys.platform)
...but breaks if the module is put into a package.
An alternative would be an if/elif with hard-coded calls to ...
I define some Entities wich works fine; for meta programming issues, i now need to reflect the field properties defined in the model.
For example:
class Foo(Entity):
bar = OneToMany('Bar')
baz = ManyToMany('Baz')
here i need the information which type of relation is set: "ManyToMany", "OneToMany" or even a plain "Field", ...
I want to build simple console applications, but want something like QT and not like ncurses. Is there such a thing or is it only my dream UI?
...
The official oauth guide makes this recommendation:
It is important not to try and perform
the sort operation on some combined
string of both name and value as some
known separators (such as '=') will
cause the sort order to change due to
their impact on the string value.
If this is the case, then what would be an efficie...
I am following the Getting Started guide for wxPython. But unfortunately the first 'Hello World' example crashes. The dialog window shows just fine, but as soon as I move my mouse over the window a "pythonw.exe has stopped working" Windows message appears.
I use:
Python 2.6.2
wxPython2.8-win32-unicode-2.8.9.2-py26
Vista (latest SP an...
I would like to use Python's JSON module. It was only introduced in Python 2.6 and I'm stuck with 2.5 for now. Is the particular JSON module provided with Python 2.6 available as a separate module that can be used with 2.5?
...
Could any one suggest good Python-related podcasts out there, it could be anything about Python or its eco-system (like django, pylons, etc).
...
I am attempting to take a list of objects, and turn that list into a dict. The dict values would be each object in the list, and the dict keys would be a value found in each object.
Here is some code representing what im doing:
class SomeClass(object):
def __init__(self, name):
self.name = name
object_list = [
SomeCla...