Re: if the else short form

2010-10-09 Thread saeed.gnu
>>> True == 1
True
>>> False == 0
True
>>> int(True)
1
>>> int(False)
0
>>> bool(1)
True
>>> bool(0)
False


‌But:
str(fill==True)+','
is simpler than:
("False,", "True,")[fill==True]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python "why" questions

2010-08-09 Thread saeed.gnu
> > 1)  Why do Python lists start with element [0], instead of element
> > [1]?  "Common sense" would seem to suggest that lists should start
> > with [1].  

Because Zero is the neutral element of addition operation. And indexes
(and all adresses in computing) involve with addition much more than
multiplication! That's too clear i think and that's silly to use One
as first index of arrays/lists in a programming language!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: easy question on parsing python: "is not None"

2010-08-09 Thread saeed.gnu
On Aug 9, 3:41 pm, "saeed.gnu"  wrote:
> "x is y"          means   "id(y) == id(y)"
> "x is not y"      means   "id(x) != id(x)"
> "x is not None"   means   "id(x) != id(None)"
>
> "x is not None"  is a really silly statement!! because id(None) and id
> of any constant object is not predictable! I don't know whay people
> use "is" instead of "==". you should write "if x!=None" instead of "x
> is not None"

Although small objects are unique in the memory (with a unique id) and
using "is" works ok, but that's not logical to compare id's when we
actually want to compare values!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: easy question on parsing python: "is not None"

2010-08-09 Thread saeed.gnu
"x is y"  means   "id(y) == id(y)"
"x is not y"  means   "id(x) != id(x)"
"x is not None"   means   "id(x) != id(None)"

"x is not None"  is a really silly statement!! because id(None) and id
of any constant object is not predictable! I don't know whay people
use "is" instead of "==". you should write "if x!=None" instead of "x
is not None"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unicode issue

2009-09-30 Thread saeed.gnu
I recommend to use UTF-8 coding(specially in GNU/Linux) then write
this in the second line:
#-*- coding: latin-1 -*-
-- 
http://mail.python.org/mailman/listinfo/python-list