My guess is that zero is not being printed because the internals of self.response.out.write probably look something like this:
def write(output): if output: # Spit it out else: # Do not spit out anything Since your zero effectively returns false in the above if condition, nothing is printed out. Conclusion: Always convert the final output to a string before sending it to self.response.out.write (since it's sent to the browser as a string anyway). On Dec 22, 9:44 pm, Phoenix <peece...@gmail.com> wrote: > Thanks for your concern Wesley.. > > Yes.. by "screen" I meant "browser" > > As I had said in my first message, printing the 0 on browser isn't my > objective. I am actually write services in which I just get the input, > process it and send the processed output in JSON format. So, in this I > do not need to write anything on the browser using "server side > script". > > But the thing is, the code I wrote didn't work and I needed it debug > it by writing each and every relevant thing on the browser. And > printing that zero comes here.. > > I tried something like self.response.out.write(str(0)) and 0 is there > on the screen.. but I generally do not need to do this with any other > value.. let it be a python list or dictionary.. so I'm just not able > to know the reason or logic behind this.. > > By the way, a good news.. ! That service for which I was writing that > code is done. It's working.. :) But that cofusion of mine is still > intact.. :( > > "why" that zero is not coming? > > Thanks, > Chirag S Pithadiya. > > On Dec 22, 2:47 pm, Wesley Chun <wesc+...@google.com> wrote: > > > greetings! i've read your messages and would like to find out more > > about what you are trying to do. i will try to help anyway, based on > > what you have written so far. > > > if you are explicitly writing out a response as text/plain, you still > > need to write out a string, regardless of the value. you mention using > > "print" vs. "write." when you're developing a web application, you > > cannot simply use "print" because that is intended for a user and *is* > > output to the screen. > > > with Google App Engine, you're writing a *web application*, and in > > such cases, there is no "screen output." rather than a terminal > > window, the end consumer of the data you "write" out is to a web > > browser. now if by "screen," you mean web browser, then please > > disregard what i just said above, because it wasn't clear what you > > meant by "screen." > > > for web applications, you must output either plain text (MIME file > > type text/plain) or standard HTML (MIME type text/html). regardless of > > whether you use 0, 1, 100, or 1000, as integer literals, or as a value > > of a variable 'new_index', you need to convert it to a string first, > > i.e., str(0), str(100), str(new_index). > > > also, if you write this out directly, then the output will be > > text/plain. if you want it to look nice in a web browser, you need to > > enclose the value in valid HTML: > > self.response.out.write('<HTML><BODY>%d</BODY></HTML>' % new_index) or > > something similar. > > > if this doesn't answer your question, hopefully it will help you get > > started. or if your problem is completely different, please give us > > more information so we can help you better. > > > thanks! > > -wesley > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > "Core Python Programming", Prentice Hall, (c)2007,2001 > > "Python Fundamentals", Prentice Hall, (c)2009 > > http://corepython.com > > > wesley.j.chun :: wesc+...@google.com > > developer relations :: google app engine > > > On Mon, Dec 21, 2009 at 11:47 PM, Phoenix <peece...@gmail.com> wrote: > > > It works.. but it's of no use to me.. I need to use a variable which > > > can have 0 as a value and while debugging I need to be sure whether > > > the value of this variable is coming correctly or not.. > > > It works with "print" but not working with "write".. > > > print the "0" isn't my objective.. but I'm just confused why I can't > > > print 0...) > > > Any other integer is being printed.. then why this issue with 0? > > > > thanks for your reply.. > > > > On Dec 22, 12:43 pm, Nickolas Daskalou <n...@daskalou.com> wrote: > > >> Have you tried: > > > >> self.response.out.write(str(0)) > > > >> ? > > > >> On Dec 22, 5:11 pm, Phoenix <peece...@gmail.com> wrote: > > > >> > Hi.. this is the code I'm using.. > > > >> > self.response.out.write(0) and "0" is not being on screen.. even if > > >> > this "0" an Integer is in some variable.. like this.. > > >> > new_index = 0 > > >> > self.response.out.write(new_index) > > > >> > and nothing comes on screen.. > > > >> > can anyone have any idea? > > > >> > thanks in advance.. > > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.