My PC

I built a computer sometime in 2006 and then subsequently upgraded several times along the way. Here are the specifications:

  • AMD Athlon 64 X2 Dual Core Processor 3800+ 2.01 Ghz
  • ASUS A8N-SLI Deluxe 939 NVIDIA nForce4 SLI Motherboard
  • CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM DDR 400 (PC 3200) TWINX2048-3200C2
  • Western Digital Caviar SE16 WD3200KS 320GB 7200 RPM
  • EVGA 256-P2-N363-TX GeForce 6600LE 256MB 128-bit DDR PCI Express x16 SLI

It’s been four years since then, and the machine still performs well and I can run all of the latest software that I use on a daily basis without difficulty.

Python Input/Output Idioms

Unlike the C programming language, Python assignments are statements, not expressions. Therefore the common C idiom of:

while (line = fgets(f)) {
    /* do something with the line */
}

is not possible to implement directly.

However, effbot.org provides several alternatives using iterators or the while True idiom. I recently discovered the built-in iter() function as well:

for line in iter(f.readline, "END"):
    ... do something with line ...

Command-Line Arguments in IDLE

Sometimes you want to be able to run a script through the interactive Python Shell that comes with IDLE, but using a different text editor (such as UltraEdit). In this case, you want to run IDLE from another program. To do so:

idle.py -r scriptname.py

or

idle.pyw -r scriptname.py

Strangely, the -r command-line argument doesn’t appear to be in the Python documentation for IDLE at all.

Note: The idle.py script is typically located at C:\Python31\Lib\idlelib, or very close to it.

Some other notes on specific to UltraEdit:

  • An example Command Line is: C:\Python31\Lib\idlelib\idle.pyw -r "%f".
  • For Program Type, set to Dos Program, not Windows Program.
  • Do not capture any Command Output.

NetBeans 6.8 and Python 3 Unit Tests

It looks like the NetBeans IDE is unable to do unit tests if you are developing your code using a Python 3 interpreter. You’ll hit the following wall when trying to run a test:

File "C:\Program Files\NetBeans 6.8\python\
\nb_test_runner.py", line 216
    except ValueError, e:
                 ^
SyntaxError: invalid syntax

Finished in 0.0 seconds.
0 tests, 0 failures, 0 errors

Perhaps NetBeans 7.0 will address this issue.