1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Iterating over a file breaks line()

Posted by Bryce on May 22, 2009

Try running this script. The first line is drawn, but the second line gives an error:

Traceback (most recent call last):
File "nodebox/gui/mac/__init__.pyo", line 358, in _execScript
File "/test.py", line 10, in
TypeError: 'str' object is not callable

This is on a fresh copy of 1.9.4.

stroke(0)
line(10, 10, 20, 20)
f = open("anyfile", "r")
for line in f:
    pass
f.close()
line(10, 10, 30, 30)


 
Posted by Stefan on May 22, 2009

By "for line in f" you assign line to be a string, so its previous meaning gets overwritten, try "for l in f" or something like that.



Posted by Bryce on May 25, 2009

Oh man I feel like a bonehead. Thanks :)