New to Python
apt.shansen at gmail.com
Wed Feb 10 22:18:17 CET 2010
On Wed, Feb 10, 2010 at 2:21 AM, Quin <quindennis at grandecom.net> wrote:
> Well, PyScripter works find with that code. Furthermore, the
> un-intellisense in IronPython was problematic, inserting the wrong things,
> which I had to erase.
I think you're confused and are comparing apples to oranges. To define a
couple terms-- I'm starting at the basics, forgive me:
Python is a language; CPython is an implementation of that language, in C.
Often, Python and CPython are used interchangeably, but not always.
There are sort of two concurrent versions of Python available today, both
current; 2.6 and 3.1.
IronPython is an alternate implementation of the Python 2.6 language, built
upon the .NET platform. It's a language, not a tool. (Well, insofar as every
language is ultimately a tool). IronPython (like Jython, PyPy, and the other
Python alternate implementations) does not yet support Python 3.x.
PyScripter is an IDE for Python. IDE's have intellisense and such, languages
do not. I'm not sure what you were using as your IDE when you used
IronPython-- perhaps IronPython Studio? That's a distinct thing from
PyScripter can support both Python 2.x and 3.x, but I don't know if it
requires any settings to change between modes or if you have to select which
interpreter you want to use. We can only guess what actual version of Python
you're using from your comments, but it looks sort of like 2.x
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.
PyScripter is not a language, but a tool; in Python 3.x, print requires the
() as it is a function. Additionally, in Python 3.x, you have to say "not
equal" as !=, you can't use <> anymore.
In Python 2.x, print is a statement. You /may/ put () around an expression
but that isn't the same thing. For simple operations it frequently looks the
same and produces the same output, though. In Python 2.x, you can say "not
equal" as either != or <>.
The original code:
s = f.readline()
if 'mystring' in s: print 'foundit'
if 'mystring' not in s: print 'not found'
if 'mystring' in s:
... will only work on Python 2.x, as print is being used as a statement. If
you change print to a function, that code will work in either Python 2.x or
However, in both CPython and IronPython, the above is provably correct code.
It works fine: with those five lines alone, you are guaranteed to get
'foundit' followed by 'processing' if mystring is in s. With those five
lines alone, you must get that result. If you aren't, then there's something
else going on before or after-- and its not about IronPython vs CPython. To
help diagnose what's wrong, copy and paste -real- results from a command
prompt or interpreter when you run it, providing complete code. Something
else is going wrong, you're looking in the wrong place to find the solution.
If you're using an IDE, perhaps that IDE is doing something strange (though
I can't fathom what), or perhaps its pointing at a different version of
Python then you're expecting. We can't really tell from what you've said.
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.
The current version of IronPython (http://ironpython.net/) is 2.6, yes. They
have not yet made a Python 3.x port. Then again, much of the code you've
shown us seems to imply you're using Python 2.x, not 3.x.
So I can't quite make sense of your environment yet to offer more help--
specifically, you seem to be saying IronPython, but not actually -mean-
IronPython, but instead some IDE?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list