I have a command line server for which I want to create a wrapper in python.
The idea is that the wrapper receives commands like:
my_wrapper start
my_wrapper stop
my_wrapper restart
my_wrapper status
And handles the server in background, unlinked to the terminal that launched it from the wrapper.
I was about to start thinking on how ...
Question
What are the differences between a Framework build and a non-Framework build (i.e., standard UNIX build) of Python on Mac OS X? Also, what are the advantages and disadvantages of each?
Preliminary Research
Here is the information that I found prior to posting this question:
[Pythonmac-SIG] Why is Framework build of Python n...
Say I have the following simple models for some tagging application (this is simplified from the actual code):
# Model of tag templates
class TagTemplate(models.Model):
name = models.CharField()
content_type = models.ForeignKey(ContentType)
class Tag(models.Model):
template = models.ForeignKey(TagTemplate)
object_id = m...
Hi,
I've been -trying- to use pydev to do some python (can't say I'm having good times so far). I finally got code completion working for the libraries I'm using, but I'm still wondering about a couple of things...
So the library I'm using is called orange. Say I call the function orange.MakeRandomIndices2, but I'm not sure how it wor...
Updated:
Hi all,
Going through the Werkzeug link text tutorial, got stack with creating SQLAlchemy session using sessionmaker() instead of create_session() as recommended.
Note: it is not about SA, it is about Werkzeug.
Werkzeug tutorial:
session = scoped_session(lambda: create_session(bind=application.database_engine,
autoflush...
I'm writing a Python script that may or may not (depending on a bunch of things) run for a long time, and I'd like to make sure that multiple instances (started via cron) don't step on each others toes. The logical way to do this seems to be a PID-based lockfile… But I don't want to re-invent the wheel if there is already code to do this...
I have a ManyToMany relationship:
class Book:
title = models.CharField(...)
isbn = models.CharField(...)
def unicode(self):
return self.title
def ISBN(self):
return self.isbn
class Author:
name = models.CharField(...)
books = models.ManyToManyField(Book...)
In the admin interface for Author I get a multiple sel...
Google didn't turn up anything that seemed relevant.
I have a bunch of existing, working C++ code, and I'd like to use python to crawl through it and figure out relationships between classes, etc.
EDIT: Just wanted to point out: I don't think I need or want to parse every bit of C++; I just need something smart enough to pick up on cla...
A generic function is dispatched based on the type of all its arguments. The programmer defines several implementations of a function. The correct one is chosen at call time based on the types of its arguments. This is useful for object adaptation among other things. Python has a few generic functions including len().
These packages ten...
Why doesn't the following work in Python?
def make_class(a):
class A(object):
a=a
return A
...
Hi there,
I've been writing a time converter to take the systems time_t and convert it into human readable date/time. Oh, and this is my second python script ever. We'll leave that fact aside and move on.
The full script is hosted here.
Writing converters for the year and month were fairly easy, but I've hit a serious brick wall tryin...
I have a program that writes to stdout and possibly stderr. I want to run it from python, capturing the stdout and stderr. My code looks like:
from subprocess import *
p = Popen( exe, shell=TRUE, stdout=PIPE, stderr=PIPE )
rtrncode = p.wait()
For a couple of programs, this works fine, but when I added a new one, the new one hangs for...
I've had a search around but I haven't been able to find decent online tutorials for the recent clutter bindings. There are guides for 0.4 and 0.6 around but 0.8 is supposed to be very different making these guides kind of useless. Links or examples greatly appreciated!
...
I have a model that needs to have a field named complex and another one named type. Those are both python reserved names. According to PEP 8, I should name them complex_ and type_ respectively, but django won't allow me to have fields named with a trailing underscore. Whats the proper way to handle this?
...
I'm using Django and Apache to serve webpages. My JavaScript code currently includes a data object with values to be displayed in various HTML widgets based on the user's selection from a menu of choices. I want to derive these data from a Python dictionary. I think I know how to embed the JavaScript code in the HTML, but how do I emb...
Given this bug (Python Issue 4892) that gives rise to the following error:
>>> import multiprocessing
>>> multiprocessing.allow_connection_pickling()
>>> q = multiprocessing.Queue()
>>> p = multiprocessing.Pipe()
>>> q.put(p)
>>> q.get()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/.../python2.6/...
I am making a command line interface in Python 3.1.1 using the cmd module.
Is there a way to create a command with more than one name e.g. "quit" and "exit"?
Or would it just be a case of making a number of commands that all reference the same function?
...
I am using Selenium to run tests on a website. I have many individual test I need to run, and want to create a script that will run all of the python files in a certain folder. I can get the names, and import the modules, but once I do this I can't get the unittest to run the files. Here is some of the test code I have created. My pr...
Just what the title says.
$ ./configure --help | grep -i ucs
--enable-unicode[=ucs[24]]
Searching the official documentation, I found this:
sys.maxunicode: An integer giving the
largest supported code point for a
Unicode character. The value of this
depends on the configuration option
that specifies whether Unicode
cha...
I need identify which file is binary and which is a text in a directory.
I tried use mimetypes but it isnt a good idea in my case because it cant identify all files mimes, and I have strangers ones here... I just need know, binary or text. Simple ? But I couldn´t find a solution...
Thanks
...