473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Re: Compiler, ast and forwards/backwards compatibility

On Tue, Oct 7, 2008 at 5:39 PM, Terry Reedy <tj*****@udel.eduwrote:
Orestis Markou wrote:
>>
Hello,

I'm the developer of PySmell ( http://github.com/orestis/pysmell ), a
static analysis/intellisense provider for Python. I am targeting
Python 2.4 code so I'm using the compiler package.

I've been toying around yesterday with the ast module in Python 2.6
and it seems much more cleaner. One thing I don't understand is how
should one handle backwards and forwards compatibility.

My impression is that the 2.6 ast package is quite different from the 2.4
compiler package, but I have not looked at it (in its 3.0 version) yet. If
the 2.4 code you are analyzing is syntactically and sematically valid as 2.6
code, which I believe is usual, then of course there is no problem. If it
is not, then I would not be sure.
The ast module is indeed very different from the compiler package, as
it depends on the exact grammar definition that the interpreter is
using, rather a re-implementation (which I understand the compiler.ast
is).

My confusion starts with the fact that I'm not sure if all Python 2.4
code is going to be syntactically valid 2.6 code. I guess 2.3 is valid
2.4 is valid 2.5, which should be valid 2.6 (but not valid 3.0) - I
think it's the lockstep of 2.6 and 3.0 that's misleading me...
>
>I guess that Python 2.6 can target Python 2.3-6, and with specific
compiler flags it can also target 3.0, so it seems that the correct
thing to do is to use that.

If you want to target 2.3 to 3.0, 2.6 is the only option as far as I know.
I expect you will want to run your code through 2to3 (still being improved)
and run under 3.0 to properly handle 3.0 code.
That sounds correct. It's annoying that I have to require Python 2.6
for this - I guess that since the compiler module is there in 2.6 I'm
not compelled to use ast until I want to run under 3.0...
>
Maybe someone else can give a better answer.

tjr

--
http://mail.python.org/mailman/listinfo/python-list


--
or*****@orestis.gr
http://orestis.gr
Oct 7 '08 #1
1 1835
My confusion starts with the fact that I'm not sure if all Python 2.4
code is going to be syntactically valid 2.6 code.
That's not so much a matter of confusion, but of careful research.

I *think* all code that is syntactically correct in 2.4 is also
syntactically correct in 2.6 - but only because

raise "Hello"

is still syntactically correct in 2.6 - it's a TypeError, not a
SyntaxError. The other case would be assignment to None, but that
was banned in 2.4 already.
I guess 2.3 is valid
2.4 is valid 2.5
I think not so: assignment to None got disallowed, syntactically
(can't test 2.3, at the moment).

Regards,
Martin
Oct 8 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jason Mobarak | last post by:
Greetings! Say that it's desirable to provide backwards compatibility for methods of an object, consider the case where... class Foo: def bar (self, a, b): pass ....is a defined class...
0
by: flat_ross | last post by:
If there was one thing nice about "Binary Compatibility" in VB6, it would tell you at compile time that you changed your public interface. I am looking for the same functionality in .NET. I know...
7
by: Sonny | last post by:
I need to port a library that is written entirely in C to C++. The library is supported on quite a few platforms (windows, Solaris, Linux, AIX, HP-UX, OSX, etc...) and there's quite an existing...
19
by: Canonical Latin | last post by:
"Leor Zolman" <leor@bdsoft.com> wrote > "Canonical Latin" <javaplus@hotmail.com> wrote: > > > ... > >But I'm still curious as to the rational of having type >...
70
by: py | last post by:
I have function which takes an argument. My code needs that argument to be an iterable (something i can loop over)...so I dont care if its a list, tuple, etc. So I need a way to make sure that...
150
by: tony | last post by:
If you have any PHP scripts which will not work in the current releases due to breaks in backwards compatibility then take a look at http://www.tonymarston.net/php-mysql/bc-is-everything.html and...
1
by: Orestis Markou | last post by:
Hello, I'm the developer of PySmell ( http://github.com/orestis/pysmell ), a static analysis/intellisense provider for Python. I am targeting Python 2.4 code so I'm using the compiler package. ...
0
by: Terry Reedy | last post by:
Orestis Markou wrote: The lockstep stuff is either new stuff which does not (at least, is intended not to) affect old code, or changes that you have to request via __future__ imports. Much 1.5...
18
by: MyWaterloo | last post by:
I quickly put this code together to test if it would disable some of my functions OnChange when my text box (purchase order number) is empty...and if it would enable those functions when I added data...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.