Dupe: http://stackoverflow.com/questions/101268/hidden-features-of-python
What is a feature you could not live without when using Python?
If you don't mind bold face it at the top :) and the give a short explanation why you can't live without it or a short example of what it can do. If you see it already on the list, up vote that pe...
If I wanted to have Python distributed across multiple processors on multiple computers, what would my best approach be? If I have 3 eight-core servers, that would mean I would have to run 24 python processes. I would be using the multiprocessing library, and to share objects it looks like the best idea would be to use a manager. I want ...
I'm writing a program to manage orders and then print them.
An order is an object containing the ordering person, the date and the products this person orders. I'd like to add the amount of a certain product one orderer. E.g. 3 eggs, 2 breads.
Is there a simpler way doing this with storm (the ORM I'm using) than splitting the order int...
Is it possible to use the with statement directly with CSV files? It seems natural to be able to do something like this:
import csv
with csv.reader(open("myfile.csv")) as reader:
# do things with reader
But csv.reader doesn't provide the __enter__ and __exit__ methods, so this doesn't work. I can however do it in two steps:
impor...
I have a python datetime.datetime object. What is the best way to subtract one day?
...
I've compiled my Python program using Py2Exe, and on the client's computer we've satisfied all the dependencies using dependency walker, but we still get "The application configuration is incorrect. Reinstalling the application may correct the problem." I'm also using wxPython.
The client does not have administrator access.
Any ideas...
I am testing cogen on a Mac OS X 10.5 box using python 2.6.1. I have a simple echo server and client-pumper that creates 10,000 client connections as a test. 1000, 5000, etc. all work splendidly. However at around 10,000 connections, the server starts dropping random clients - the clients see 'connection reset by peer'.
Is there some...
When I add a "Repository" to a SConstruct file (link), if any target in my repository has been built in this other repository ( and the dependencies haven't changed), then SCons will not build the target -- which is really cool. Unfortunately, I have some tools which rely on the targets being placed in a certain location. How can I cr...
Hi Folks,
We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python script to dri...
Below is the base class of my pythoncard application
class MyBackground(model.Background):
def on_initialize(self, event):
# if you have any initialization
# including sizer setup, do it here
self.setLayout()
def setLayout(self):
sizer1 = wx.BoxSizer(wx.VERTICAL) # main sizer
for item...
It's seems rare to read of a Python "virtual machine" while in Java "virtual machine" is used all the time. Both interpret byte codes, why call one a virtual machine and the other an interpreter?
...
Has anyone tried ASP.NET MVC using IronPython? Having done a lot of Python development recently, it would be nice to continue with the language as I go into a potential ASP.NET MVC project.
I'm especially interested in exploiting the dynamic aspects of Python with .NET features such as LINQ and want to know if this will be possible. T...
Hi all,
I was just wondering what network libraries there are out there for Python for building a TCP/IP server. I know that Twisted might jump to mind but the documentation seems scarce, sloppy, and scattered to me.
Also, would using Twisted even have a benefit over rolling my own server with select.select()?
...
Which mp3/media player could I buy which will allow me to run an existing set of python scripts.
The existing scripts control xmms on linux: providing "next tracks" given data on ratings/last played/genre/how long since acquired/.... so that it all runs on a server upstairs somewhere, and I do not need to choose anything.
I'd like to u...
I want to avoid hardcoding the port number as in the following:
httpd = make_server('', 8000, simple_app)
The reason I'm creating the server this way is that I want to use it as a 'kernel' for an Adobe AIR app so it will communicate using PyAMF. Since I'm running this on the client side it is very possible that any port I define is al...
These functions (to name a few) exist in other languages for reading input from streams. I am trying to read from a socket and I want to use functions like these. Are they tucked away in Python somewhere under a different way or has someone made a library for it?
Also, their write*datatype*() counterparts too.
...
Let me illustrate this question with an example:
import numpy
matrix = numpy.identity(5, dtype=bool) #Using identity as a convenient way to create an array with the invariant that there will only be one True value per row, the solution should apply to any array with this invariant
base = numpy.arange(5,30,5) #This could be any 1-d arra...
I have some extremely weird behavior that seems to result in silent exceptions. How can I write a general try catch where I can debug all exceptions. Something along the lines of:
try:
# something that fails
except e:
print e
A bit more about the problem at hand in detail:
I have a Django app that on the my comp (Ubuntu Linux...
Hey guys. I am 12 years old and I have had a small amount of experience with BASIC. I am thinking about learning Python, but I’m not sure if I should learn the 2.6 version or the 3.0 version. I don’t really care about the support for libraries or anything along those lines quite yet. I was wondering if it is easier to code in 3.0 than 2....
I need to program kind of configuration registry for Django-based application.
Requirements:
Most likely param_name : param_value structure
Editable via admin interface
Has to work with syncdb. How to deal with a situation in which other apps depend on configuration model and the model itself has not been initialized yet in DB? Let's...