memory error

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jun 2009
Posts: 5
Reputation: iliketacos is an unknown quantity at this point 
Solved Threads: 0
iliketacos iliketacos is offline Offline
Newbie Poster

memory error

 
0
  #1
Jul 1st, 2009
this script give me a memory error in parse()...what is a memory error and how can i fix it?
  1. import cgi
  2.  
  3. class COM:
  4. def __init__(self):
  5. f=open('C:/site/commentlog.txt', 'r')
  6. self.lines=f.readlines()
  7. f.close()
  8.  
  9.  
  10. def writecom(self, post):
  11. f=open('C:/site/commentlog.txt', 'a')
  12. f.write(post)
  13. f.close()
  14.  
  15. def getcom(self):
  16. try:
  17. form=cgi.FieldStorage()
  18. q=form.getvalue("posts")
  19. if q:
  20. writecom(q)
  21. return q
  22. except:
  23. return 0
  24.  
  25.  
  26. def parse(self, post):
  27. b=[]
  28. while post>65:
  29. c=post[:64]
  30. post=post[64:]
  31. b.append(c)
  32. b.append(post)
  33. return b
  34.  
  35.  
  36. def postline(self, post):
  37. print "<textarea readonly name=\"posts\" rows=\"10\" cols=\"65\">"
  38. print post
  39. print "</textarea>"
  40.  
  41. def postlines(self, posts):
  42. print "<textarea readonly name=\"posts\" rows=\"10\" cols=\"65\">"
  43. for line in posts:
  44. print line
  45. print "</textarea>"
  46. def main(self):
  47. self.getcom()
  48. self.postit()
  49. if self.lines:
  50.  
  51. for a in self.lines:
  52. if a>65:
  53. b=self.parse(a)
  54. self.postlines(b)
  55. else:
  56. self.postline(a)
  57. else:
  58. pass
  59. print "</body>"
  60. print "</html>"
  61.  
  62.  
  63.  
  64.  
  65. def postit(self):
  66. print "Content-type: text/html\r\n\r\n"
  67. print "<style type=\"text/css\">"
  68. print "h2 {"
  69. print "color : green;"
  70. print "}"
  71. print "textarea {"
  72. print " color : black;"
  73. print " background-color : #00f000;"
  74. print "}"
  75. print "body {"
  76. print " background-color : black; } "
  77. print "</style>"
  78. print "<html>"
  79. print "<head>"
  80. print "<img src=\" \" width=\"240\" height=\"230\" align=\"right\">"
  81. print "</head>"
  82. print "<body>"
  83. print "<h2>This is my second page anyone can post comments anonymously<br>"
  84. print "<form action=\"comments.py.py\" method=\"POST\">"
  85. print "<textarea name=\"posts\" rows=\"10\" cols=\"65\">"
  86. print "</textarea>"
  87. print "<input type=\"submit\" value=\"post\">"
  88. print "</form>"
  89. print "<hr>"
  90.  
  91.  
  92.  
  93. c=COM()
  94. c.main()
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 269
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: memory error

 
0
  #2
Jul 1st, 2009
Define "memory error". How about pasting your traceback.
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 5
Reputation: iliketacos is an unknown quantity at this point 
Solved Threads: 0
iliketacos iliketacos is offline Offline
Newbie Poster

Re: memory error

 
0
  #3
Jul 2nd, 2009
nevermind i got it i forgot to specify len(post) in parse
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,145
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 949
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: memory error

 
0
  #4
Jul 8th, 2009
Originally Posted by iliketacos View Post
nevermind i got it i forgot to specify len(post) in parse
Thanks for letting us know!
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum


Views: 426 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC