Personal preferences aside, is there an optimal tab size (2 spaces? 3 spaces? 8 spaces?) for code readability? In the different projects I've worked on, people seem to have vastly different standards. I can't seem to read 2 space indents, but companies like Google use it as a standard.
Can anyone point to documentation, studies, or well...
What is the biggest software development team that uses Python? I am wondering how well the dynamic type system scales to large development teams.
It's pretty clear that at Google they have C++ and Java codebases with thousands of developers; their use of Python is much smaller.
Are there some huge companies that develop primarily in P...
I have two machines each, to the best of my knowledge, running python 2.5 and BeautifulSoup 3.1.0.1.
I'm trying to scrape http://utahcritseries.com/RawResults.aspx, using:
from BeautifulSoup import BeautifulSoup
import urllib2
base_url = "http://www.utahcritseries.com/RawResults.aspx"
data=urllib2.urlopen(base_url)
soup=BeautifulSo...
I've installed the latest SVN branch from Django which includes the new forms. I'm trying to use the SelectDateWidget from django.forms.extras.widgets but the field is showing up as a normal DateInput widget.
Here is the forms.py from my application:
from django import forms
from jacob_forms.models import Client
class ClientForm(forms...
Hello.
In python, strings may be unicode ( both utf-16 and utf-8 ) and single-byte with different encodings ( cp1251, cp1252 etc ). Is it possible to check what encoding string is? For example,
time.strftime( "%b" )
will return a string with text name of a month. Under MacOS returned string will be utf-16, under Windows with English ...
Hello, i have class
class SomeClass:
def __init__(self):
self.SomeFunction()
def SomeFunction(self):
try:
self.something = 5
except:
print 'error'
print self.something
tempObject = SomeClass()
And the last string occurs an error:
AttributeError: something
Why?
...
I have a model that has an ImageField. How can I manually assign an imagefile to it? I want it to treat it like any other uploaded file...
...
My next web application project will make extensive use of Unicode. I usually use PHP and CodeIgniter however Unicode is not one of PHP's strong points.
Is there a PHP tool out there that can help me get Unicode working well in PHP?
Or should I take the opportunity to look into alternatives such as Python?
...
While trying to make one of my python applications a bit more robust in case of connection interruptions I discovered that calling the read function of an http-stream made by urllib2 may block the script forever.
I thought that the read function will timeout and eventually raise an exception but this does not seam to be the case when t...
Hello together,
I wrote the following class for producing "monitoring" output within an extra window.
Unfortunately it doesn't scroll automatically down to the most recent line. What is wrong?
As I also have problems with Tkinter and ipython: how would an equivalent implementation with qt4 look like?
Here is the code:
import Tkinte...
I'm using sqlite3 in python 2.5. I've created a table that looks like this:
create table votes (
bill text,
senator_id text,
vote text)
I'm accessing it with something like this:
v_cur.execute("select * from votes")
row = v_cur.fetchone()
bill = row[0]
senator_id = row[1]
vote = row[2]
What I'd like to be able...
I'm responsible for developing a large Python/Windows/Excel application used by a financial institution which has offices all round the world. Recently the regulations in one country have changed, and as a result we have been told that we need to create a "locked-down" version of our distribution.
After some frustrating conversations wi...
I've been looking all over the place for a good timeout script that can kill a thread if it's been active for more than X seconds, but all the examples I've seen have flaws that don't always stop the thread. Using thread.join(x) ends up defeating the purpose of it being a thread.
The only decent example I've found is http://stackoverflo...
A Genshi template raises the following error:
TemplateSyntaxError: invalid syntax in expression "${item.error}" of "choose" directive
The part of the template code that the error specifies is the following ('feed' is a list of dictionary which is passed to the template):
<item py:for="item in feed">
<py:choose error="${item.error}...
In our group we primarily do search engine architecture and content integration work and most of that code base is in Python. All our build tools and Python module dependencies are in source control so they can be checked out and the environment loaded for use regardless of os/platform, kinda similar to the approach virtualenv uses.
Fo...
I'm trying to build a Python distribution with distutils. Unfortunately, my directory structure looks like this:
/code
/mypackage
__init__.py
file1.py
file2.py
/subpackage
__init__.py
/build
setup.py
Here's my setup.py file:
from distutils.core import setup
setup(
nam...
When I first learned Python, I got used to doing this:
print "text", lineNumber, "some dictionary", my_dict
When I wrote my own logging facility, I naturally wanted to be able to hand it an arbitrarily-sized list of items, so I did this:
def error(*args):
print ERR_PREFIX,
for _x in args:
print _x,
print "\r\n",
err...
Maybe it's just doesn't exist, as I cannot find it in pydoc. But using python's logging package, is there a way to query a Logger to find out how many times a particular function was called? For example, how many errors/warnings were reported?
...
Do you know of any Python module for resources (resx files) manipulation?
P.S.: I know I could write a custom wrapper on top of base XML processor available, I'm just checking out before going to hack my own code...
...
It seems that Python 2.6.1 doesn't compile bz2 library by default from source.
I don't have lib-dynload/bz2.so
What's the quickest way to add it (without installing Python from scratch)?
OS is Linux 2.4.32-grsec+f6b+gr217+nfs+a32+fuse23+tg+++opt+c8+gr2b-v6.194 #1 SMP Tue Jun 6 15:52:09 PDT 2006 i686 GNU/Linux
IIRC I used only --prefi...