Hi,
I would like to know the best practice about raising an exception without arguments.
In the official python documentation, you can see this :
try:
raise KeyboardInterrupt
(http://docs.python.org/tutorial/errors.html chap. 8.6)
and in some differents code, like Django or Google code, you can see this :
def AuthenticateAndRu...
I'm trying to get the name of all methods in my class.
When testing how the inspect module works, i extraced one of my methods by obj = MyClass.__dict__['mymethodname'].
But now inspect.ismethod(obj) returns False while inspect.isfunction(obj) returns True, and i don't understand why. Is there some strange way of marking methods as met...
I am reading in a csv file and dealing with each line as a list. At the end, I'd like to reprint to a .csv file, but the lines aren't necessarily even. I obviously cannot just go "print row", since this will print it as a list. How can I print it in .csv format?
...
Say I wanted to display the number 123 with a variable number of padded zeroes on the front.
For example, if I wanted to display it in 5 digits I would have digits = 5 giving me:
'00123'.
If I wanted to display it in 6 digits I would have digits = 6 giving: '000123'.
How would I do this in Python?
...
I am getting the ApplicationError: 2 nonnumeric port: '' randomly for about 1/10th of my url request, the rest work fine, I seen this is a bug but I have yet to find any solutions, anyone have any thoughts in why this is occurring? I am running python 2.5.4 and google app engine 1.3.3
here is some generic code the error is occuring w...
Sorry for the kind of general question. More details about what I want:
I want the user to be able to write some Python code and execute it. Once there is an exception which is not handled, I want the debugger to pause the execution, show information about the current state/environment/stack/exception and make it possible to edit the co...
Hello,
I have a few data loggers in the field. The manufacturer set them up as dial up ftp servers. I'm writing a python program that automagically downloads all the latest files from the server into a specified folder on my computer.
Which OS independent library do you recommend for dial up?
Do you have any suggestions, comments, or ...
How can I pretty print a dictionary with depth of ~4 in Python? I tried pretty printing with pprint but it did not work:
import pprint
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(mydict)
I simply want an identation ("\t") for each nesting, so that I get something like this:
key1
value1
value2
key2
value1
...
Let's say I have 2 lists in Python and I want to loop through each one in parallel - e.g. do something with element 1 for both lists, do something with element 2 for both lists... I know that I can do this by using an index:
for listIndex in range(len(list1)):
doSomething(list1[listIndex])
doSomething(list2[listIndex])
But is th...
I am running 64-bit Windows 7 and the ActiveState Python 2.5 installation (64-bit version). I just downloaded and installed the pyodbc 2.1.7 win32 package. When I run the installer as an admin it proceeds with no problem. When I run python and try
import pyodbc
I receive the following error:
ImportError: DLL load failed with
...
For those who know wget, it has a option --spider, which allows one to check whether a link is broke or not, without actually downloading the webpage. I would like to do the same thing in Python. My problem is that I have a list of 100'000 links I want to check, at most once a day, and at least once a week. In any case this will generate...
What would be the most efficient\elegant way in Python to find the index of the first non-empty item in a list?
For example, with
list_ = [None,[],None,[1,2],'StackOverflow',[]]
the correct non-empty index should be:
3
...
I know there is some really good django app libraries out there (other than the builtin django.contrib.*) but for some reason, my google search abilities are failing me.
I am thinking of one in particular that I cannot remeber the name of for the life of me. I keep wanting to call it pyrex or pixar or something. Obviously, neither of t...
Hi
If I have a list of say 'n' elements (each element is a single byte ) which represents a rectangular 2d matrix, how can I split this into rectangles of say w * h, starting from the first element of the list , just using the python standard functions
for example
l =
[ 1,2,3,4,5,6,7,8,9,10,
11,12,13,14,15....20.
21,22,2...
I am developing for appengine python on windows 7. I am looking for a set up that will allow me to debug my python scripts. I would prefer a GUI based defugger as opposed to command line one. Something like eclipse provides.
...
Is there a single method that returns the list of items contained in a wxPython listBox?
I cant seem to find anything anywhere in the documentation or anywhere for that matter. All that I can think to do is to set the selection to all of the items and then get the selected items, though seems like an ugly roundabout way of doing some...
I'm working with Django on Linux and I have an application that integrates with Active Directory. I'm seeking opinions and advice about whether or not it would be feasible or reasonable to access the HTTP headers from within the application to coordinate HTTP authentication.
The end goal would be to perform NTLM authentication without...
How can I know the (row, column) index of the minimum of a numpy array/matrix?
For example, if A = array([[1, 2], [3, 0]]), I want to get (1, 1)
Thanks!
...
I am using scipy-cluster in my application. It provides a function to plot a dendrogram of the hierarchical cluster tree. Looking at the source I find that it eventually plots the dendrogram by calling draw_if_interactive. As one would expect, this works fine in an interactive session, but when I run the script non-interactively, a windo...
I am trying to get the form preview django module example to work. In polls_app/mysite/urls.py:
from django.conf.urls.defaults import *
from mysite.preview import SomeModelFormPreview
from mysite.forms import SomeModelForm
from django import forms
In polls_app/mysite/SomeModelFormPreview.py:
from django.contrib.formtools.preview
imp...