[sf-perl] Python indentation grumble
Rich Morin
rdm at cfcl.com
Sun Apr 2 00:16:16 PST 2006
pywikipediabot is (fairly obviously) a Python-based framework
for writing bots to crawl Wikipedia (or really, MediaWiki)
pages. In trying to configure this, I found myself writing
tiny bits of Python, commenting out some lines, etc:
vvvv
family = 'ontiki'
usernames['ontiki']['en'] = 'RichMorinBot'
# usernames['None']['en'] = 'RichMorinBot'
^^^^
Because I don't like the way this looks, I tried indenting
all of the code to a consistent base level, as:
vvvv
family = 'ontiki'
usernames['ontiki']['en'] = 'RichMorinBot'
# usernames['None']['en'] = 'RichMorinBot'
^^^^
However, this offends the interpreter quite drastically:
vvvv
...
family = 'ontiki'
^
SyntaxError: invalid syntax
^^^^
So, I get to decide whether to give up on my preferred
style of indentation or hack around the interpreter. As
you might expect, I chose the latter:
vvvv
if 1 == 1: # Kludge around indentation brain-damage.
family = 'ontiki'
usernames['ontiki']['en'] = 'RichMorinBot'
# usernames['None' ]['en'] = 'RichMorinBot'
^^^^
!@#$%
-r
--
http://www.cfcl.com/rdm Rich Morin
http://www.cfcl.com/rdm/resume rdm at cfcl.com
http://www.cfcl.com/rdm/weblog +1 650-873-7841
Technical editing and writing, programming, and web development
More information about the SanFrancisco-pm
mailing list