Cyril Bazin wrote:
> I agree. None is an object! If you want to compare an object to another
> object why not using "=="?
The term "compare" is ambiguous. If you want to compare for *identity*,
you use "is". If you want to compare for equality, you use "==". In
most cases with None you are i
Bryan Olson wrote:
> Peter Hansen wrote:
>
>>The archives could tell you more, but basically on is usually interested
>>in *identity* with a singleton object (None), not in whether the object
>>on is examining happens to compare equal. A custom object could be
>>designed to compare equal to No
On 3/6/06, Bryan Olson <[EMAIL PROTECTED]> wrote:
Peter Hansen wrote:> The archives could tell you more, but basically on is usually interested> in *identity* with a singleton object (None), not in whether the object> on is examining happens to compare equal. A custom object could be
> designed to
Peter Hansen wrote:
> The archives could tell you more, but basically on is usually interested
> in *identity* with a singleton object (None), not in whether the object
> on is examining happens to compare equal. A custom object could be
> designed to compare equal to None in certain cases, eve
> yyy
> yyy
> yyy
> xxx.xxx.xxx.xxx
> xxx.xxx.xxx.xxx
of course you will get this result...
inside the loop, when line="xxx.xxx.xxx.xxx:yyy"
line.split(":") will give a list ["xxx.xxx.xxx.xxx", "yyy"], and
element -1 will be "yyy"
but when line="xxx.xxx.xxx.xxx"
line.split(":") will give a list
On Sat, 04 Mar 2006 08:54:33 -0800, ss2003 wrote:
> hi
>
> i have a file with
>
> xxx.xxx.xxx.xxx:yyy
> xxx.xxx.xxx.xxx:yyy
> xxx.xxx.xxx.xxx:yyy
> xxx.xxx.xxx.xxx
> xxx.xxx.xxx.xxx
> xxx.xxx.xxx.xxx:yyy
>
> i wanna split on ":" and get all the "yyy" and print the whole line out
> so i
Petr Jakes wrote:
>>I think you're getting caught by the classic and/or trap in Python,
>>trying to avoid using a simple if statement.
>
> What do you mean by "the classic and/or trap"? Can you give an example
> please?
Sure, see my subsequent reply to Cyril, elsewhere in this thread.
(In summar
Cyril Bazin wrote:
> Ok, ok, there was a mistake in the code.
> (Of course, it was done on prupose in order to verify if everybody is
> aware ;-)
> I don't know why it is preferable to compare an object to the object
> "None" using "is not".
> "==" is, IMHO, more simple. Simple is better than com
> I think you're getting caught by the classic and/or trap in Python,
> trying to avoid using a simple if statement.
What do you mean by "the classic and/or trap"? Can you give an example
please?
Petr Jakes
--
http://mail.python.org/mailman/listinfo/python-list
Ok, ok, there was a mistake in the code. (Of course, it was done on prupose in order to verify if everybody is aware ;-)I don't know why it is preferable to compare an object to the object "None" using "is not".
"==" is, IMHO, more simple. Simple is better than complex. So I use "==". The correct p
Cyril Bazin wrote:
> Your file looks like a list of IP adresses.
> You can use the urllib and urllib2 modules to parse IP adresses.
>
> import urllib2
> for line in open("fileName.txt"):
> addr, port = urllib2.splitport(line)
> print (port != None) and '' or port
Is this what you want to
Your file looks like a list of IP adresses. You can use the urllib and urllib2 modules to parse IP adresses.import urllib2for line in open("fileName.txt"): addr, port = urllib2.splitport(line)
print (port != None) and '' or portCyril
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> hi
>
> i have a file with
>
> xxx.xxx.xxx.xxx:yyy
> xxx.xxx.xxx.xxx:yyy
> xxx.xxx.xxx.xxx:yyy
> xxx.xxx.xxx.xxx
> xxx.xxx.xxx.xxx
> xxx.xxx.xxx.xxx:yyy
>
> i wanna split on ":" and get all the "yyy" and print the whole line out
> so i did
>
> print line.split(":")[-1]
[EMAIL PROTECTED] wrote:
> print line.split(":")[-1]
>
> but line 4 and 5 are not printed as there is no ":" to split. It should
> print a "blank" at least.
> how to print out lines 4 and 5 ?
> eg output is
>
> yyy
> yyy
> yyy
>
>
> yyy
if ":" in line:
print line.split(":")[-1]
else:
pr
hi
i have a file with
xxx.xxx.xxx.xxx:yyy
xxx.xxx.xxx.xxx:yyy
xxx.xxx.xxx.xxx:yyy
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx:yyy
i wanna split on ":" and get all the "yyy" and print the whole line out
so i did
print line.split(":")[-1]
but line 4 and 5 are not printed as there is no ":" t
15 matches
Mail list logo