473,569 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Alternate indent proposal for python 3000

I was considering putting together a proposal for an alternate block
syntax for python, and I figured I'd post it here and see what the
general reactions are. I did some searching, and while I found a lot
of tab vs space debates, I didn't see anything like what I'm thinking
of, so forgive me if this is a very dead horse.

Generally speaking, I like the current block scheme just fine. I use
python on a daily basis for system administration and text parsing
tasks, and it works great for me.

From time to time, though, I find myself needing a language for server-
side includes in web pages. Because of the need to indent (and
terminate indents), python seems an awkward choice for this, and it's
easy for me to see why php and perl are more popular choices for this
kind of task. Perhaps this is just my perception though.

I feel that including some optional means to block code would be a big
step in getting wider adoption of the language in web development and
in general. I do understand though, that the current strict indenting
is part of the core of the language, so... thoughts?
Jun 27 '08 #1
20 1385
Eric Wertman schrieb:
I was considering putting together a proposal for an alternate block
syntax for python, and I figured I'd post it here and see what the
general reactions are. I did some searching, and while I found a lot
of tab vs space debates, I didn't see anything like what I'm thinking
of, so forgive me if this is a very dead horse.
You are definitely too late to propose a change for py3k.
I feel that including some optional means to block code would be a big
step in getting wider adoption of the language in web development and
in general. I do understand though, that the current strict indenting
is part of the core of the language, so... thoughts?
Why should Python repeat the mistakes other languages did with SSI or
<?php ?inline code? Python favors the MVC separation of code and layout.

Christian

Jun 27 '08 #2
On Apr 20, 11:35*am, Eric Wertman <ewert...@gmail .comwrote:
I was considering putting together a proposal for an alternate block
syntax for python, and I figured I'd post it here and see what the
general reactions are. *I did some searching, and while I found a lot
of tab vs space debates, I didn't see anything like what I'm thinking
of, so forgive me if this is a very dead horse.
[with apologies to Monty Python]

This horse is no more! He has ceased to be! 'E's expired and gone to
meet 'is maker! 'E's a stiff! Bereft of life, 'e rests in peace! THIS
IS AN EX-HORSE!!

:)
Generally speaking, I like the current block scheme just fine. *I use
python on a daily basis for system administration and text parsing
tasks, and it works great for me.

From time to time, though, I find myself needing a language for server-
side includes in web pages. *Because of the need to indent (and
terminate indents), python seems an awkward choice for this, and it's
easy for me to see why php and perl are more popular choices for this
kind of task. *Perhaps this is just my perception though.
Look into any of the dozen Python-based template engines that are
typically used for such tasks; they offer many more features than a
way to indent blocks.

George
Jun 27 '08 #3
Look into any of the dozen Python-based template engines that are
typically used for such tasks; they offer many more features than a
way to indent blocks.

George
I definitely will.. could you throw out some examples though?
Thanks!

Eric
Jun 27 '08 #4
Christian Heimes <li***@cheimes. dewrote:
>I feel that including some optional means to block code would be a big
step in getting wider adoption of the language in web development and
in general. I do understand though, that the current strict indenting
is part of the core of the language, so... thoughts?
Why should Python repeat the mistakes other languages did with SSI or
<?php ?inline code? Python favors the MVC separation of code and layout.
An alternative scheme for describing the block structure could be
useful in other cases, though. For example, if you wanted to support
putting snippets of Python in configuration files, or spreadsheet
cells.

There's no need to support the new scheme in .py files, so it seems to
me that this doesn't have to be done in the core language. All that's
needed is a variant of 'eval' which expects the alternate scheme, and
that could be prototyped just using text manipulation and the normal
'eval'.

If someone wrote a library for this and it proved popular, I expect it
would be considered for the standard library.

-M-
Jun 27 '08 #5
On Apr 20, 5:42*pm, Matthew Woodcraft
<matth...@chiar k.greenend.org. ukwrote:
Christian Heimes *<li...@cheimes .dewrote:
I feel that including some optional means to block code would be a big
step in getting wider adoption of the language in web development and
in general. *I do understand though, that the current strict indenting
is part of the core of the language, so... thoughts?
Why should Python repeat the mistakes other languages did with SSI or
<?php ?inline code? Python favors the MVC separation of code and layout.

An alternative scheme for describing the block structure could be
useful in other cases, though. For example, if you wanted to support
putting snippets of Python in configuration files, or spreadsheet
cells.

There's no need to support the new scheme in .py files, so it seems to
me that this doesn't have to be done in the core language. All that's
needed is a variant of 'eval' which expects the alternate scheme, and
that could be prototyped just using text manipulation and the normal
'eval'.
By 'eval', I guess you mean 'exec' :)

--
Arnaud

Jun 27 '08 #6
Arnaud Delobelle <ar*****@google mail.comwrote:
By 'eval', I guess you mean 'exec' :)
Yes. Shows how often I use either.

-M-
Jun 27 '08 #7

"Matthew Woodcraft" <ma******@chiar k.greenend.org. ukwrote in message
news:X0*******@ news.chiark.gre enend.org.uk...
| There's no need to support the new scheme in .py files, so it seems to
| me that this doesn't have to be done in the core language. All that's
| needed is a variant of 'eval' which expects the alternate scheme, and
| that could be prototyped just using text manipulation and the normal
| 'eval'.

Eval() is for expressions, exec() is for general code. But you do not
really need a variant. Just define a preprocessor function 'blockify'
which converts code in an alternate syntax to regular indented block
syntax. Then

exec(blockify(a lt_code_string) )

I presume that this is more or less what the templating engines do.

Jun 27 '08 #8
En Sun, 20 Apr 2008 13:42:05 -0300, Matthew Woodcraft <ma******@chiar k.greenend.org. ukescribió:
An alternative scheme for describing the block structure could be
useful in other cases, though. For example, if you wanted to support
putting snippets of Python in configuration files, or spreadsheet
cells.
[...] If someone wrote a library for this and it proved popular, I expect it
would be considered for the standard library.
There is "pindent.py " in the Tools/scripts directory:

# ... When called as "pindent -r" it assumes its input is a
# Python program with block-closing comments but with its indentation
# messed up, and outputs a properly indented version.

# A "block-closing comment" is a comment of the form '# end <keyword>'
# where <keywordis the keyword that opened the block ...

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

--
Gabriel Genellina

Jun 27 '08 #9
Terry Reedy <tj*****@udel.e duwrote:
But you do not really need a variant. Just define a preprocessor
function 'blockify' which converts code in an alternate syntax to
regular indented block syntax. Then

exec(blockify(a lt_code_string) )
You can do it like that, but if it were to become part of the standard
distribution it would be nice to avoid having to tokenise the code
twice. (You could define the new block scheme in such a way that
'blockify' doesn't need to tokenise, but I think it would end up a bit
ugly.)

-M-

Jun 27 '08 #10

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

Similar topics

2
1699
by: Guido van Rossum | last post by:
Robert and Python-dev, I've read the J2 proposal up and down several times, pondered all the issues, and slept on it for a night, and I still don't like it enough to accept it. The only reason to accept it would be to pacify the supporters of the proposal, and that just isn't a good enough reason in language design. However, it got...
12
1452
by: John Salerno | last post by:
Is 'Python 3000' just a code name for version 3.0, or will it really be called that when it's released?
1
1223
by: gangesmaster | last post by:
typing "help(type)" gives the following documentation: >>> help(type) Help on class type in module __builtin__: class type(object) | type(object) -> the object's type | type(name, bases, dict) -> a new type "type" behaves both as a function, that reports the type of an object, and as a factory type for creating types, as used mainly...
14
1621
by: beliavsky | last post by:
At http://www-03.ibm.com/developerworks/blogs/page/davidmertz David Mertz writes "Presumably with 2.7 (and later 2.x versions), there will be a means of warning developers of constructs that are likely to cause porting issues . In the simplest case, this will include deprecated functions and syntax constructs. But presumably the warnings...
1
2072
by: Petr Prikryl | last post by:
Do you think that the following could became PEP (pre PEP). Please, read it, comment it, reformulate it,... Abstract Introduction of the mechanism for language extensions via modules written using other languages. Extensions of Python could be done via special interpreter extensions. From Python sources, the special modules would look...
34
3651
by: Anthony Irwin | last post by:
Hi All, I am currently trying to decide between using python or java and have a few quick questions about python that you may be able to help with. #1 Does python have something like javas .jar packages. A jar file contains all the program files and you can execute the program with java -jar program.jar I am sort of hoping python has...
0
1143
by: Guido van Rossum | last post by:
python-list@python.org] The first Python 3000 release is out -- Python 3.0a1. Be the first one on your block to download it! http://python.org/download/releases/3.0/ Excerpts: Python 3000 (a.k.a. "Py3k", and released as Python 3.0) is a new
25
3005
by: Lennart Benschop | last post by:
Python has had the Decimal data type for some time now. The Decimal data type is ideal for financial calculations. Using this data type would be more intuitive to computer novices than float as its rounding behaviour matches more closely what humans expect. More to the point: 0.1 and 0.01 are exact in Decimal and not exact in float. ...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.