when i run this code an icon for the image is created but when clicked it says that no preview is availeble any help would be grately apretiated. heres the code.

from Image import *
import ImageDraw


win=new('RGB', (400,400), 'rgb(255,255,255)')
win.save('c:\\Documents and Settings\\bradley\\desktop\\python programs\\frac.png')

while z < 100000:

    frac=open('c:\\Documents and Settings\\bradley\\desktop\\python programs\\frac.png')


    frac.save('c:\\Documents and Settings\\bradley\\desktop\\python programs\\frac.png')


print 'im working'

Edited by bmanzana: n/a

7 Years
Discussion Span
Last Post by bmanzana

You really want to open the file 100000 times in the loop?
You need to close the open file it before you save to it.


no i dont want to open the file 100000 times i want the result of the function to be used as the variable z and then run through the function again and again until the value of z = 100000, which sence were talking about exponential growth shouldnt take all that long probably something like 100 iterations if that maby more like 50. and what do you mean i need to close the open file befor i save to it ? The file needs to be opend and writen befor being closed and this open then save pattern has worked for other pictures in the past i.e. ellipses and padles for a version of pong. i just want to know why its opening and saving an icon but aperrently none of the other data?


well i figured it out it was a simple syntactical error i just forgot to give the value i was raising it to after the **, that and i moved the functions inside the while loop and the open comands outside it. so i got the code working now.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.