New to Python

Steve Holden steve at holdenweb.com
Tue Feb 9 23:01:31 EST 2010


Quin wrote:
> Thanks guys, I'm thinking it's a problem with IronPython.  I'm switching
> to PyScripter and will test tomorrow.
> 
I'd be very surprised to find that something as basic as this was wrong
with IronPython. Complex commercial software has been built on it, so
there's little question that the platform is sound.

Are you *sure* you copied and pasted the session you listed?

regards
 Steve

> "Larry Hudson" <orgnut at yahoo.com> wrote in message
> news:ybmdnRFZZ_3nvu_WnZ2dnUVZ_hGdnZ2d at giganews.com...
>> Quin wrote:
>>> s = f.readline()
>>> if 'mystring' in s: print 'foundit'
>>> if 'mystring' not in s: print 'not found'
>>> if 'mystring' in s:
>>>    print 'processing'
>>>
>>> this generates output:
>>> not found
>>> processing
>>>
>>> so, it doesn't find the substring, but goes into processing code anyway.
>>>
>>> This is using IronPython
>>
>> As others have already said, this _does_ work properly.
>>
>> But a minor rearrangement is simpler, and IMHO clearer:
>>
>> if 'mystring' not in s:
>>     print 'not found'
>> else:
>>     print 'foundit'
>>     print 'processing'
>>
>>      -=- Larry -=- 
> 


-- 
Steve Holden           +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC                 http://www.holdenweb.com/
UPCOMING EVENTS:        http://holdenweb.eventbrite.com/




More information about the Python-list mailing list