Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
Just an update of my output after Carsten and company's advice:


C:\Python25\rg.py>help.py -h

help.py Version 1.0 Copyright RDEG (c) 2007


Options : -h, --help -- display this message
Progam Exit (0)

C:\Python25\rg.py>help.py -i
print arg ['-i']
type(arg): 
arg is True? False
help.py version 1.0 Copyright RDEG (c) 2007
 ['-i'] is an unrecognized option.
Progam Exit (0)

C:\Python25\rg.py>help.py -i
help.py version 1.0 Copyright RDEG (c) 2007
 ['-i'] is an unrecognized option.
Progam Exit (0)

C:\Python25\rg.py>help.py
No Option provided
help.py version 1.0 Copyright RDEG (c) 2007
 No Option is an unrecognized option.
Progam Exit (0)


Thanks again.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
On May 11, 5:19 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-05-11 at 14:12 -0700, [EMAIL PROTECTED] wrote:
> > However, how would you test for the falsness of the object arg?
>
> if not arg:
># stuff
>
> --
> Carsten Haesehttp://informixdb.sourceforge.net

I think that is the ticket Carsten! Thanks for all the good
information all y'all.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
On May 11, 5:12 pm, [EMAIL PROTECTED] wrote:
> On May 11, 5:07 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On Fri, 2007-05-11 at 12:28 -0700, [EMAIL PROTECTED] wrote:
> > > Hello all,
>
> > > First let me appologise if this has been answered but I could not find
> > > an acurate answer to this interesting problem.
>
> > > If the following is true:
> > > C:\Python25\rg.py>python
> > > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
> > > bit (Intel)] on
> > > win32
> > > Type "help", "copyright", "credits" or "license" for more
> > > information.
> > > >>> [] == []
> > > True
> > > >>> ['-o'] == []
> > > False
> > > >>> ['-o'] == False
> > > False
>
> > Your confusion stems from the fact that for a given object, the answer
> > to the following three questions can be vastly different:
> > a) Is the object identical to True?
> > b) Is the object equal to True?
> > c) Is the object considered to be True in an "if" statement?
>
> > Observe:
>
> > >>> def check_trueness(obj):
>
> > ...if obj is True: print repr(obj), "is identical to True."
> > ...else: print repr(obj), "is not identical to True."
> > ...if obj == True: print repr(obj), "is equal to True."
> > ...else: print repr(obj), "is not equal to True."
> > ...if obj: print repr(obj), "is considered to be True by if."
> > ...else: print repr(obj), "is not considered to be True by if."
> > ...>>> check_trueness(True)
>
> > True is identical to True.
> > True is equal to True.
> > True is considered to be True by if.>>> check_trueness(1)
>
> > 1 is not identical to True.
> > 1 is equal to True.
> > 1 is considered to be True by if.>>> check_trueness([1])
>
> > [1] is not identical to True.
> > [1] is not equal to True.
> > [1] is considered to be True by if.>>> check_trueness([])
>
> > [] is not identical to True.
> > [] is not equal to True.
> > [] is not considered to be True by if.
>
> > Testing whether an object is equal to True is a much stronger test than
> > whether it is considered to be True in an 'if' statement, and the test
> > for identity is stronger still. Testing whether an object is equal to
> > True or identical to True is useless in most Python programs.
>
> > So, rather than doing this:
>
> > if thing==True:
> ># blah
>
> > Just do this:
>
> > if thing:
> ># blah
>
> > Hope this helps,
>
> > --
> > Carsten Haesehttp://informixdb.sourceforge.net-Hide quoted text -
>
> > - Show quoted text -
>
> Thanks Carsten (& all), I will give the if thing: # blah trick. I
> guess I am starting to seem my own confusion. As Grant mentioned, I
> was comparing ['-o'] to True which of course is False :o)
>
> However, how would you test for the falsness of the object arg?- Hide quoted 
> text -
>
> - Show quoted text -

Would that be arg is not True: # blah.?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
On May 11, 5:07 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-05-11 at 12:28 -0700, [EMAIL PROTECTED] wrote:
> > Hello all,
>
> > First let me appologise if this has been answered but I could not find
> > an acurate answer to this interesting problem.
>
> > If the following is true:
> > C:\Python25\rg.py>python
> > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
> > bit (Intel)] on
> > win32
> > Type "help", "copyright", "credits" or "license" for more
> > information.
> > >>> [] == []
> > True
> > >>> ['-o'] == []
> > False
> > >>> ['-o'] == False
> > False
>
> Your confusion stems from the fact that for a given object, the answer
> to the following three questions can be vastly different:
> a) Is the object identical to True?
> b) Is the object equal to True?
> c) Is the object considered to be True in an "if" statement?
>
> Observe:
>
> >>> def check_trueness(obj):
>
> ...if obj is True: print repr(obj), "is identical to True."
> ...else: print repr(obj), "is not identical to True."
> ...if obj == True: print repr(obj), "is equal to True."
> ...else: print repr(obj), "is not equal to True."
> ...if obj: print repr(obj), "is considered to be True by if."
> ...else: print repr(obj), "is not considered to be True by if."
> ...>>> check_trueness(True)
>
> True is identical to True.
> True is equal to True.
> True is considered to be True by if.>>> check_trueness(1)
>
> 1 is not identical to True.
> 1 is equal to True.
> 1 is considered to be True by if.>>> check_trueness([1])
>
> [1] is not identical to True.
> [1] is not equal to True.
> [1] is considered to be True by if.>>> check_trueness([])
>
> [] is not identical to True.
> [] is not equal to True.
> [] is not considered to be True by if.
>
> Testing whether an object is equal to True is a much stronger test than
> whether it is considered to be True in an 'if' statement, and the test
> for identity is stronger still. Testing whether an object is equal to
> True or identical to True is useless in most Python programs.
>
> So, rather than doing this:
>
> if thing==True:
># blah
>
> Just do this:
>
> if thing:
># blah
>
> Hope this helps,
>
> --
> Carsten Haesehttp://informixdb.sourceforge.net- Hide quoted text -
>
> - Show quoted text -

Thanks Carsten (& all), I will give the if thing: # blah trick. I
guess I am starting to seem my own confusion. As Grant mentioned, I
was comparing ['-o'] to True which of course is False :o)

However, how would you test for the falsness of the object arg?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
On May 11, 4:32 pm, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On Fri, May 11, 2007 at 01:20:44PM -0700, [EMAIL PROTECTED]
> wrote:
>
> > On May 11, 3:55 pm, Grant Edwards <[EMAIL PROTECTED]> wrote:
> > > You got those results because that's what your program does.
>
> > > Were you intending it to do something else?  If so, you're
> > > going to have to explain what you wanted, because we can't
> > According to my output, it seems that arg is False even when I
> > give an option of '-o' which according to the book should be
> > True. No?
>
> '-o' is not equal to True.  However, that does not mean it
> evaluates to false when tested by an if or while statement.
>
> > If arg == ['-o'] then shouldn't arg == True return True and
> > skip the if?
>
> No.  See the folloing link regarding the "truth value" of an
> object:
>
> http://docs.python.org/lib/truth.html
>
> There are many objects other than True that evaluate to "true"
> in the context of an if/while statement.  Just because an
> objecty has a "true" truth-value doesn't mean that it is equal
> to the True object.
>
> --
> Grant Edwards   grante Yow! Why don't you ever
>   at   enter any CONTESTS,
>visi.comMarvin??  Don't you know
>your own ZIPCODE?

OK. Then how would you differenciate between a call with an option
versus one without (e.g. help.py -o (where arg == ['-o']) Vs. help.py
(where arg == []))?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
 On May 11, 2:28 pm, [EMAIL PROTECTED] wrote:
>
>
>
>
>
> > Hello all,
>
> > First let me appologise if this has been answered but I could not find
> > an acurate answer to this interesting problem.
>
> > If the following is true:
> > C:\Python25\rg.py>python
> > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
> > bit (Intel)] on
> > win32
> > Type "help", "copyright", "credits" or "license" for more
> > information.
> > >>> [] == []
> > True
> > >>> ['-o'] == []
> > False
> > >>> ['-o'] == False
> > False
>
> > Then why do I get the following results:
> > C:\Python25\rg.py>help.py -o
> > print arg ['-o']
> > type(arg): 
> > arg is True? False
> > help.py version 1.0 Copyright RDEG (c) 2007
> > ['-o'] is an unrecognized option.
> > Progam Exit (0)
>
> > 
> > import sys
>
> > _ver_ = 1.00
>
> > if '-h' in sys.argv or '--help' in sys.argv:
> > print
> > print "help.py Version", _ver_, "Copyright RDEG (c) 2007"
> > print '''
>
> > Options : -h, --help -- display this message
> > Progam Exit (0)'''
> > sys.exit(0)
> > else:
> > arg = sys.argv[1:]
> > print 'print arg', arg
> > print 'type(arg):', type(arg)
> > print 'arg is True?', arg == True
> > print "help.py version", _ver_, "Copyright RDEG (c) 2007"
> > print "", arg, "is an unrecognized option."
> > print "Progam Exit (0)"
> > sys.exit(0)
> > 
>


I hope this helps (I have tried to post this twice already but it
seems to be going somewhere else) you help me.

What I would like to happen is:
else:
arg = sys.argv[1:]
print 'print arg', arg
print 'type(arg):', type(arg)
print 'arg is True?', arg == True
if arg != True:
print "No Option Provided"
print "help.py version", _ver_, "Copyright RDEG (c) 2007"
print "", arg, "is an unrecognized option."
print "Progam Exit (0)"
sys.exit(0)

But as you can see by my output ['-o'] seems to be False as well as []
so the if happens regardless.

According to the "Book", ['-o'] should return True which should fail
the if, no?

-- 
http://mail.python.org/mailman/listinfo/python-list


Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
Hello all,

First let me appologise if this has been answered but I could not find
an acurate answer to this interesting problem.

If the following is true:
C:\Python25\rg.py>python
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> [] == []
True
>>> ['-o'] == []
False
>>> ['-o'] == False
False
>>>

Then why do I get the following results:
C:\Python25\rg.py>help.py -o
print arg ['-o']
type(arg): 
arg is True? False
help.py version 1.0 Copyright RDEG (c) 2007
['-o'] is an unrecognized option.
Progam Exit (0)


import sys

_ver_ = 1.00

if '-h' in sys.argv or '--help' in sys.argv:
print
print "help.py Version", _ver_, "Copyright RDEG (c) 2007"
print '''

Options : -h, --help -- display this message
Progam Exit (0)'''
sys.exit(0)
else:
arg = sys.argv[1:]
print 'print arg', arg
print 'type(arg):', type(arg)
print 'arg is True?', arg == True
print "help.py version", _ver_, "Copyright RDEG (c) 2007"
print "", arg, "is an unrecognized option."
print "Progam Exit (0)"
sys.exit(0)


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: preferred windows text editor?

2007-05-09 Thread nufuhsus
On May 9, 3:30 pm, Trent Mick <[EMAIL PROTECTED]> wrote:

> There is an ActivePython 2.5.1 
> now:http://www.activestate.com/products/activepython/
>
> You should give Komodo Edit a try 
> too:http://www.activestate.com/products/komodo_edit/

Thanks for the heads up Trent.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: preferred windows text editor?

2007-05-09 Thread nufuhsus
On May 9, 2:06 pm, "T. Crane" <[EMAIL PROTECTED]> wrote:
> Right now I'm using Notepad++.  What are other people using?
>
> trevis

I am very noob to this Python game and currently (I was using
ActivePython and then IDLE) I have been using a combination of
Notepad2 and the interpreter (Python 2.5) on a Windblows
X[crement]P[roblem] SP2 machine.

Get Notepad2 http://www.flos-freeware.ch/notepad2.html

I like IDLE but it seems to stop working after the first few times and
I would then re-install it and it would work a few times more.
ActivePython was cool but I could not find a version of it that used
Python 2.5 (as far as I can see, it only uses 2.4)

Notepad2 allows you to launch your script directly from the editor
(just like IDLE) and has configurable code highlighting. And it is
FREE.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: preferred windows text editor?

2007-05-09 Thread nufuhsus
On May 9, 2:06 pm, "T. Crane" <[EMAIL PROTECTED]> wrote:


> Right now I'm using Notepad++.  What are other people using?


I am very noob to this Python game (though it has been around since
1995 me thinks) and currently (I was using ActivePython and then
IDLE)
I have been using a combination of Notepad2 and the interpreter
(Python 2.5) on a
Windblows X[crement]P[roblem] SP2 machine.
http://www.flos-freeware.ch/notepad2.html

I like IDLE but it seems to stop working after the first few times
and
I would then re-install it and it would work a few times more.
ActivePython was cool but I could not find a version of it that used
Python 2.5 (as far as I can see, it only uses 2.4)

Notepad2 allows you to launch your script directly from the editor
(just like IDLE) and has configurable code highlighting. And it is
FREE.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: preferred windows text editor?

2007-05-09 Thread nufuhsus
On May 9, 2:06 pm, "T. Crane" <[EMAIL PROTECTED]> wrote:
> Right now I'm using Notepad++.  What are other people using?

I am very noob to this Python game (though it has been around since
1995 me thinks) and currently (I was using ActivePython and then IDLE)
I have been using a combination of Notepad2 http://www.flos-
freeware.ch/notepad2.html and the interpreter (Python 2.5) on a
Windblows X[crement]P[roblem] SP2 machine.

I like IDLE but it seems to stop working after the first few times and
I would then re-install it and it would work a few times more.
ActivePython was cool but I could not find a version of it that used
Python 2.5 (as far as I can see, it only uses 2.4)

Notepad2 allows you to launch your script directly from the editor
(just like IDLE) and has configurable code highlighting. And it is
FREE.

-- 
http://mail.python.org/mailman/listinfo/python-list