Hi, I'm working on a project that outputs several languages including
(hopefully) python. My problem is that the generic backend architecture
has not been designed to output correctly indented code, and that would
be helpful if there were somewhere a python pre-processor that would take
python with braces as an input and output regular python code. I thought
that it must exists because everyone generating python code will
encounter more or less the same problem, but I didn't find any 'official'
thing on the subject. I mean that I wonder if there is a special mode of
the offcial parser that does such a thing. If not, do you know the most
reliable project that would do this ?
Thanks a lot.
Paul 5 1974
On Oct 22, 10:44 am, Paul Brauner <paul.brau...@loria.frwrote:
Hi, I'm working on a project that outputs several languages including
(hopefully) python. My problem is that the generic backend architecture
has not been designed to output correctly indented code, and that would
be helpful if there were somewhere a python pre-processor that would take
python with braces as an input and output regular python code. I thought
that it must exists because everyone generating python code will
encounter more or less the same problem, but I didn't find any 'official'
There's a tool in the standard Python distribution that processes code
with commented end statements. eg:
def my_funct():
pass
# end
or similar, and indents it correctly. This may be a possibility for
your purposes.
I'll look at that. Thanks a lot !
On Mon, 22 Oct 2007 09:44:27 +0000, Paul Brauner wrote:
Hi, I'm working on a project that outputs several languages including
(hopefully) python. My problem is that the generic backend architecture
has not been designed to output correctly indented code, and that would
be helpful if there were somewhere a python pre-processor that would take
python with braces as an input and output regular python code. I thought
that it must exists because everyone generating python code will
encounter more or less the same problem, but I didn't find any 'official'
thing on the subject.
Maybe (almost) nobody feels the need to generate Python source code. The
language is so dynamic that there are almost always ways to avoid
source code generation.
Maybe you can generate a token stream and use `tokenize.untokenize()` to
generate the source code!?
Ciao,
Marc 'BlackJack' Rintsch
On Oct 22, 10:58 am, Paul Brauner <paul.brau...@loria.frwrote:
I'll look at that. Thanks a lot !
I've just had a look, it's the pindent.py script in Tools/Scripts (at
least it is on Windows). It takes code of the following form:
def foobar(a, b):
if a == b:
a = a+1
elif a < b:
b = b-1
if b a: a = a-1
# end if
else:
print 'oops!'
# end if
# end def foobar
The help in the script looks pretty good.
--
Ant...
Le Mon, 22 Oct 2007 05:00:02 -0700, Ant a écritÂ*:
On Oct 22, 10:58 am, Paul Brauner <paul.brau...@loria.frwrote:
>I'll look at that. Thanks a lot !
I've just had a look, it's the pindent.py script in Tools/Scripts (at
least it is on Windows). It takes code of the following form:
def foobar(a, b):
if a == b:
a = a+1
elif a < b:
b = b-1
if b a: a = a-1
# end if
else:
print 'oops!'
# end if
# end def foobar
The help in the script looks pretty good.
Thanks,
actually i'm using it right now as a backend and it's helpful. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Anthony_Barker |
last post by:
I have been reading a book about the evolution of the Basic
programming language. The author states that Basic - particularly
Microsoft's version is full of compromises which crept in along the...
|
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro...
|
by: The Tao of Spike |
last post by:
I've recentlty been getting into programming. I was wondering what
language to learn first and after asking around I decided on Python.
I'm about half way through "Non-Programmers Tutorial For...
|
by: Michael |
last post by:
>>Right. Then we can have "does the brace go on the same line or the
>>next line" wars.
>>
>>
>
> int main (void)
> {
> if (true)
> {
> }
|
by: Sateesh |
last post by:
Hi,
I am a beginner in Python, and am wondering what is it about the indentation
in Python, without which python scripts do not work properly.
Why can't the indentation not so strict so as to give...
|
by: Nick Coghlan |
last post by:
GvR has commented that he want to get rid of the lambda keyword for Python 3.0.
Getting rid of lambda seems like a worthy goal, but I'd prefer to see it dropped
in favour of a different syntax,...
|
by: travis ray |
last post by:
Hi,
I have an extension in which a file object is created in python and
passed down to a c extension which attempts to read from it or write
to it. Writing to the file pointer seems to work...
|
by: Mark Tarver |
last post by:
How do you compare Python to Lisp? What specific advantages do you
think that one has over the other?
Note I'm not a Python person and I have no axes to grind here. This is
just a question for...
|
by: Gerald |
last post by:
Hi ,Im a BSc4 Maths/Computer Science student.Unfortunately my
curriculum did not include Python programming yet I see many vacancies
for Python developers.I studied programming Pascal,C++ and...
|
by: =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= |
last post by:
Within a few weeks, we will release Python 2.5.3. This will be the last
bug fix release of Python 2.5, afterwards, future releases of 2.5 will
only include security fixes, and no binaries (for...
|
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,...
|
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$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |