Syntax suggestion.

S

samir

Saluton!

Being a fond of Python, I had this idea: Why not making Python a Unix
shell?

But, after a little thinking, i found that the current syntax may be
troublesome.

For example: to list files in bash I'll do
$ ls M*
When for Python it will be:

So, why not making the use of parentheses when a function is one lined
optional to have commands like this:

or even

Then, why not making the comma optional too when executing such
instructions:

Instead of

And finally, why not making the string parameter "-less when it is the
only parameter:

Instead of


Adiaux
Samir
 
R

Roberto Bonvallet

samir said:
Being a fond of Python, I had this idea: Why not making Python a Unix
shell? [...]
So, why not making the use of parentheses when a function is one lined
optional to have commands like this: [...]
Then, why not making the comma optional too when executing such
instructions: [...]
And finally, why not making the string parameter "-less when it is the
only parameter:

....so finally you get something that is exactly like any Unix shell, and
completely different to Python. If you want Python to look like bash, work
like bash and have bash-like syntax, you should really consider using bash :)
 
S

samir

Bonan tagon!

George said:

Thank you for the link! It's just what I've needed but...

Roberto Bonvallet wrote :
...so finally you get something that is exactly like any Unix shell, and
completely different to Python. If you want Python to look like bash, work
like bash and have bash-like syntax, you should really consider using bash :)

I'm fedup of typing over and over parentheses around function calls
every time I call a single ligne function call or when it is inside an
"if" statement. So i thought that ommiting the parentheses and, why
not, the commas in such cases will be a sort of beautiful/easier :)

Adiaux
Samir
 
S

Simon Forman

samir said:
Bonan tagon!



Thank you for the link! It's just what I've needed but...

Roberto Bonvallet wrote :


I'm fedup of typing over and over parentheses around function calls
every time I call a single ligne function call or when it is inside an

But think of all the curly braces around code blocks that you've never
had to type! ;-)
 
E

Eirikur Hallgrimsson

This actually exists.
The language which omits punctuation not actually required to resolve
ambiguity is called Ruby.
Ruby is subject to a lot of love/hate over this.

Eirikur
 
S

Sybren Stuvel

samir enlightened us with:
I'm fedup of typing over and over parentheses around function calls
every time I call a single ligne function call or when it is inside
an "if" statement.

But how would you discern between a function reference and a function
call?

Sybren
 
S

samir

Saluton!

Simon said:
But think of all the curly braces around code blocks that you've never
had to type! ;-)

That's why I left java to jython!

Eirikur said:
This actually exists.
The language which omits punctuation not actually required to resolve ambiguity is called Ruby.
Ruby is subject to a lot of love/hate over this.

It's late, now I talk Python HSSSHSSHS HSSHSS HS :)

I think that Ruby is a good scripting language for game engines but not
as good as Python to do some serious scientific processes (or, at least
Ruby doesn't have all the necessary "batteries").

Talking of games, "Blade of Darkness" was scripted entirely in Python
(1.5 I think)
:)

Sybren said:
But how would you discern between a function reference and a function
call?

That would be a problem with two solutions:
1- If the function doesn't have any parameters, it will be called with
the empty parentheses (just like usual!);
2- to indicate that this is a function call, we would be adding a $ at
the end of the statement.

Gxis la reskribo
Samir
 
A

Alex Martelli

samir said:
That would be a problem with two solutions:
1- If the function doesn't have any parameters, it will be called with
the empty parentheses (just like usual!);
2- to indicate that this is a function call, we would be adding a $ at
the end of the statement.

What a mess it would be to disambiguate statements such as

x = foo bar baz bat

is it x = (foo, bar, baz, bat)
or x = foo(bar, baz, bat)
or x = foo(bar(baz), bat)
or x = foo(bar, baz(bat))
or x = foo(bar(baz, bat))
or ... [even ignoring the possibility that one or more of these might be
functions callable without arguments...!!!]...

iPython has some heuristics that may be reasonable for the commandline
(and are, in any case, at least simple), but in practice I find that I
go back to using the good old interactive Python interpreter rather than
putting up with even those simple heuristics.


Alex
 
S

samir

Alex said:
What a mess it would be to disambiguate statements such as

x = foo bar baz bat

is it x = (foo, bar, baz, bat)
or x = foo(bar, baz, bat)
or x = foo(bar(baz), bat)
or x = foo(bar, baz(bat))
or x = foo(bar(baz, bat))

It will be x=foo(bar,baz,bat). The parenthese ommition would only be
valable for the first function call in the statement.
or ... [even ignoring the possibility that one or more of these might be
functions callable without arguments...!!!]...

That won''t be a problem: "x=foo bar(baz) bat" would be equivalent to
"x=foo(bar(baz),bat)".
Or, but least realistic, it would be in the scheme trend. For example:

a=b(c,d(e,f(g,h,i,j,k))) <==> a=b c (d e (f g h i j k))

It looks nicer, isn't it? :)
iPython has some heuristics that may be reasonable for the commandline
(and are, in any case, at least simple), but in practice I find that I
go back to using the good old interactive Python interpreter rather than
putting up with even those simple heuristics.

That depends of your need to such tools. For example if you need to
copy a file, then, resolve a linear system then chroot and set the
password as de hexadecimal representation of the hash function of pi
multiplied by the averge of the solution coordinations +_+, you'll need
IPython ;)
 
A

Alex Martelli

samir said:
That depends of your need to such tools. For example if you need to
copy a file, then, resolve a linear system then chroot and set the
password as de hexadecimal representation of the hash function of pi
multiplied by the averge of the solution coordinations +_+, you'll need
IPython ;)

GVIM (and the normal Python interpreter) work better for me: to perform
such a task, I would always write (and run) a script, of course (the
purpose of the chroot step is somewhat mysterious here, btw). If I have
to perform a strange and complex task once, it's likely that I will have
to perform some variant of it again in the future, and having the script
around will make it easy to edit and tweak. Furthermore, having the
script around can be a useful indicator when I'm later trying to
reconstruct exactly what it is that I did.


Alex
 
S

samir

Saluton!

Alex said:
GVIM (and the normal Python interpreter) work better for me: to perform
such a task, I would always write (and run) a script, of course (the
purpose of the chroot step is somewhat mysterious here, btw). If I have
to perform a strange and complex task once, it's likely that I will have
to perform some variant of it again in the future, and having the script
around will make it easy to edit and tweak. Furthermore, having the
script around can be a useful indicator when I'm later trying to
reconstruct exactly what it is that I did.

And that's what any concious humain will do in such situation. What I
ment is that, sometimes, you have to work in real time and have no time
to code->test->debug->... cycle. For example when monitoring or forging
some IP packets (you can fake a "fantom" Sun workstation in your home
network like that ;) and need a realtime custom check function or when
you're using your computer as a "desk scientific calculator" you'd like
to have a flexible, powerfull and light-weight-syntax interpretted
programming language.

That language would be with no doubt Python! But, why not, with lighter
syntax.

Adiaux!
Samir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top