Happy Christmas!! :)

On Dec 22, 11:41 pm, Phoenix <[email protected]> wrote:
> yeah.. Nickolas.. You'r right.. :)
> I tried self.response.out.write(False) and nothing printed on
> browser..
> and tried this as well:
> class test(webapp.RequestHandler):
>     def testDef(self):
>         v = 2
>         if v == 1:
>             return 1
>         else:
>             return 0
>
>     def get(self):
>         p = self.testDef()
>         self.response.out.write(p)
> Again, the browser window is blank..
> So this is something which I haven't read in any book or tutorial that
> a "False" value without explicitly converted to a String does not get
> printed on browser.. :)
>
> Thanks for your reply.. Happy Christmas.. :)
>
> On Dec 22, 4:46 pm, Nickolas Daskalou <[email protected]> wrote:
>
> > 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 <[email protected]> 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 <[email protected]> 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 :: [email protected]
> > > > developer relations :: google app engine
>
> > > > On Mon, Dec 21, 2009 at 11:47 PM, Phoenix <[email protected]> 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 <[email protected]> wrote:
> > > > >> Have you tried:
>
> > > > >> self.response.out.write(str(0))
>
> > > > >> ?
>
> > > > >> On Dec 22, 5:11 pm, Phoenix <[email protected]> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.


Reply via email to