if Request("something") == None: doesn't work

Sam Sungshik Kong ssk at chol.nospam.net
Wed May 12 20:26:22 EDT 2004


Thanks for the replies.

Based on the hints from the replies, I've tested some.

When there's no argument in the request,

Request("id") == None returns False
if Request("id"): returns True
str(Request("id")) returns "None"
repr(Request("id")) returns <COMObject<unknown>>

So my conclusion is that Request("id") is not None.
It's an object, str() of which is accidentally "None".
That confused me.

If it's not None, str(something) should not return "None".

ssk

"Sam Sungshik Kong" <ssk at chol.nospam.net> wrote in message
news:AVsoc.47661$FI7.6868 at newssvr29.news.prodigy.com...
> Hello!
>
> I use Python for ASP programming.
> I found something weird.
>
> Response.Write(Request("something"))
> It draws "None" when there's no value for something.
> Actually I expect "" instead of "None".
>
> So I changed it like
> if Request("something") == None:
>     Response.Write("")
> else:
>     Response.Write(Request("something"))
>
> Strangely, the result of comparison is False.
>
> if str(Request("something")) == "None":
> works!
>
> Also,
> if len(Request("something")) == 0:
> works!
>
> What's wrong?
>
> ssk
>
>





More information about the Python-list mailing list