New to Python
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: New to Python
Thanks guys, I'm thinking it's a problem with IronPython. I'm switching to PyScripter and will test tomorrow. "Larry Hudson" wrote in message news:ybmdnrfzz_3nvu_wnz2dnuvz_hgdn...@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 -=- -- http://mail.python.org/mailman/listinfo/python-list
Re: New to Python
Well, PyScripter works find with that code. Furthermore, the un-intellisense in IronPython was problematic, inserting the wrong things, which I had to erase. Also, there were some code constructs IronPython let pass that PyScripter didn't, namely, print(), PyScripter requires the () Something simple, like: n = -1 if n <> -1: print('fell through') falls through to the print. So, I don't know what the problem is with IronPython, perhaps it isn't compatible with Python v3, but on my machine, at least, it doesn't perform. "Steve Holden" wrote in message news:mailman.2272.1265774639.28905.python-l...@python.org... 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" wrote in message news:ybmdnrfzz_3nvu_wnz2dnuvz_hgdn...@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/ -- http://mail.python.org/mailman/listinfo/python-list
Re: New to Python
Well, now you know! "Jean-Michel Pichavant" wrote in message news:mailman.2286.1265797348.28905.python-l...@python.org... Quin wrote: Thanks guys, I'm thinking it's a problem with IronPython. I'm switching to PyScripter and will test tomorrow. I'm willing to bet money that it is not. If ironPython had a broken if statement, don't you think we would have known, already ? There's a rule when test writing/testing code: "if you think the compiler is wrong, then you are wrong twice." JM -- http://mail.python.org/mailman/listinfo/python-list
Re: New to Python
You know, Jack, that was the point of my original post: to determine why things weren't working. Do you still want to bet money that it is? I can screenshot you TD. "Jean-Michel Pichavant" wrote in message news:mailman.2288.1265799238.28905.python-l...@python.org... Quin wrote: Well, now you know! "Jean-Michel Pichavant" wrote in message news:mailman.2286.1265797348.28905.python-l...@python.org... Quin wrote: Thanks guys, I'm thinking it's a problem with IronPython. I'm switching to PyScripter and will test tomorrow. I'm willing to bet money that it is not. If ironPython had a broken if statement, don't you think we would have known, already ? There's a rule when test writing/testing code: "if you think the compiler is wrong, then you are wrong twice." JM All I know is that you are using a python implementation that does not support python 3. No wonder why your py3 code fails. Please do not top post. JM IronPython * Stable Version is 2.0.3 (targeting Python 2.5) * Developers Version is 2.6 Beta 3 (targeting Python 2.6) -- http://mail.python.org/mailman/listinfo/python-list