Chris Mellon [EMAIL PROTECTED] (CM) wrote:
CM On 9/10/07, Neil Cerutti [EMAIL PROTECTED] wrote:
Agreed; but I prefer 'if y[0] == ', absent more context and
better names.
CM Probably should use u if you're going to take that route, as this
CM will fail spuriously if y[0] contains a unicode
Steve Holden wrote:
Neil Cerutti wrote:
y =
if y[0] == :
... print True
... else:
... print False
...
Traceback (most recent call last):
File stdin, line 1, in module
IndexError: string index out of range
Uhm, weren't we talking about a list of strings?
/W
--
On 2007-09-10, Steve Holden [EMAIL PROTECTED] wrote:
I have a quibble not with the functionality of the boolean check,
but with its expressiveness. if y[0] == expresses more, i.e.,
that I expect y[0] to contain a Python byte string.
I have a quibble with a test that will raise an exception
From: Steve Holden
Neil Cerutti wrote:
On 2007-09-10, Chris Mellon [EMAIL PROTECTED] wrote:
On 9/10/07, Neil Cerutti [EMAIL PROTECTED] wrote:
Agreed; but I prefer 'if y[0] == ', absent more context and
better names.
Probably should use u if you're going to take that route, as
this
Hamilton, William wrote:
From: Steve Holden
Neil Cerutti wrote:
On 2007-09-10, Chris Mellon [EMAIL PROTECTED] wrote:
On 9/10/07, Neil Cerutti [EMAIL PROTECTED] wrote:
Agreed; but I prefer 'if y[0] == ', absent more context and
better names.
Probably should use u if you're going to take that
Neil Cerutti wrote:
On 2007-09-10, Steve Holden [EMAIL PROTECTED] wrote:
I have a quibble not with the functionality of the boolean check,
but with its expressiveness. if y[0] == expresses more, i.e.,
that I expect y[0] to contain a Python byte string.
I have a quibble with a test that will
On 2007-09-08, Wildemar Wildenburger [EMAIL PROTECTED] wrote:
Lawrence D'Oliveiro wrote:
if y[0]:
Not a good idea.
Why not?
Because there is a situation where your version of the test
will fail even if the first element of y is non-null.
Such as? Seriously people, a little more verbosity
On 9/10/07, Neil Cerutti [EMAIL PROTECTED] wrote:
On 2007-09-08, Wildemar Wildenburger [EMAIL PROTECTED] wrote:
Lawrence D'Oliveiro wrote:
if y[0]:
Not a good idea.
Why not?
Because there is a situation where your version of the test
will fail even if the first element of y is
On 2007-09-10, Chris Mellon [EMAIL PROTECTED] wrote:
On 9/10/07, Neil Cerutti [EMAIL PROTECTED] wrote:
On 2007-09-08, Wildemar Wildenburger [EMAIL PROTECTED] wrote:
Lawrence D'Oliveiro wrote:
if y[0]:
Not a good idea.
Why not?
Because there is a situation where your version of the
On 9/10/07, Neil Cerutti [EMAIL PROTECTED] wrote:
On 2007-09-10, Chris Mellon [EMAIL PROTECTED] wrote:
On 9/10/07, Neil Cerutti [EMAIL PROTECTED] wrote:
On 2007-09-08, Wildemar Wildenburger [EMAIL PROTECTED] wrote:
Lawrence D'Oliveiro wrote:
if y[0]:
Not a good idea.
Why not?
On 2007-09-10, Chris Mellon [EMAIL PROTECTED] wrote:
On 9/10/07, Neil Cerutti [EMAIL PROTECTED] wrote:
Agreed; but I prefer 'if y[0] == ', absent more context and
better names.
Probably should use u if you're going to take that route, as
this will fail spuriously if y[0] contains a unicode
Neil Cerutti wrote:
On 2007-09-10, Chris Mellon [EMAIL PROTECTED] wrote:
On 9/10/07, Neil Cerutti [EMAIL PROTECTED] wrote:
Agreed; but I prefer 'if y[0] == ', absent more context and
better names.
Probably should use u if you're going to take that route, as
this will fail spuriously if y[0]
Steven D'Aprano wrote:
On Fri, 07 Sep 2007 11:12:05 +0200, Wildemar Wildenburger wrote:
Lawrence D'Oliveiro wrote:
In message [EMAIL PROTECTED], Chris
Mellon wrote:
On 9/5/07, Steve Holden [EMAIL PROTECTED] wrote:
Doran, Harold wrote:
Is there a way to check if the first element of y is
On Fri, 07 Sep 2007 11:12:05 +0200, Wildemar Wildenburger wrote:
Lawrence D'Oliveiro wrote:
In message [EMAIL PROTECTED], Chris
Mellon wrote:
On 9/5/07, Steve Holden [EMAIL PROTECTED] wrote:
Doran, Harold wrote:
Is there a way to check if the first element of y is null?
len(y[0]) == 0
Lawrence D'Oliveiro wrote:
In message [EMAIL PROTECTED], Chris Mellon
wrote:
On 9/5/07, Steve Holden [EMAIL PROTECTED] wrote:
Doran, Harold wrote:
Is there a way to check if the first element of y is null?
len(y[0]) == 0
Better spelled as
if y[0]:
Not a good idea.
Why not?
/W
--
In message [EMAIL PROTECTED], Wildemar
Wildenburger wrote:
Lawrence D'Oliveiro wrote:
In message [EMAIL PROTECTED], Chris
Mellon wrote:
On 9/5/07, Steve Holden [EMAIL PROTECTED] wrote:
Doran, Harold wrote:
Is there a way to check if the first element of y is null?
len(y[0]) == 0
Lawrence D'Oliveiro wrote:
if y[0]:
Not a good idea.
Why not?
Because there is a situation where your version of the test will fail even
if the first element of y is non-null.
Such as? Seriously people, a little more verbosity wouldn't hurt here.
This isn't a mystery game.
/W
--
In message [EMAIL PROTECTED], Chris Mellon
wrote:
On 9/5/07, Steve Holden [EMAIL PROTECTED] wrote:
Doran, Harold wrote:
Is there a way to check if the first element of y is null?
len(y[0]) == 0
would be the obvious way, assuming null means the null string.
Better spelled as
Dear list:
Suppose I have a string as follows
x = ' \t'ff'
I can split this up as
y = x.split('\t')
Which gives
[ ' ', 'ff']
len(y)
2
Is there a way to check if the first element of y is null?
--
http://mail.python.org/mailman/listinfo/python-list
Doran, Harold wrote:
Dear list:
Suppose I have a string as follows
x = ' \t'ff'
x = ' \t'ff'
File stdin, line 1
x = ' \t'ff'
^
SyntaxError: invalid syntax
I presume you meant
x = ' \t\'ff'
I can split this up as
y = x.split('\t')
Which gives
[ '
On 9/5/07, Steve Holden [EMAIL PROTECTED] wrote:
Doran, Harold wrote:
Is there a way to check if the first element of y is null?
len(y[0]) == 0
would be the obvious way, assuming null means the null string.
Better spelled as
if y[0]:
--
On 9/5/07, Chris Mellon [EMAIL PROTECTED] wrote:
On 9/5/07, Steve Holden [EMAIL PROTECTED] wrote:
Doran, Harold wrote:
Is there a way to check if the first element of y is null?
len(y[0]) == 0
would be the obvious way, assuming null means the null string.
Better spelled
Doran, Harold wrote:
I presume you meant
x = ' \t\'ff'
Is there a way to check if the first element of y is null?
You can use startswith() method of string objects.
if x.startswith(' '):
print True
--
O.R.Senthil Kumaran
http://uthcode.sarovar.org
--
23 matches
Mail list logo