语法建议。 [英] Syntax suggestion.

查看:91
本文介绍了语法建议。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Saluton!


我喜欢Python,我有这个想法:为什么不把Python变成Unix?

shell?


但是,经过一番思考,我发现当前语法可能很麻烦。


例如:列出文件bash我会做的

$ ls M *

当用于Python时它将是:


>> import UShell
UShell.ls(" M *")





>> UShell.exec (ls M *)



所以,为什么不在函数是一个内衬时使用括号? />
可选这样的命令:


>> UShell.ls" M *"



甚至


>> ls" M *"



那么,为什么在执行这样的

指令时也不要使逗号可选:


>> UShell.echo数字结果



而不是


>> UShell .echo号码,结果



最后,为什么不将字符串参数设为-less,当它是

唯一参数:


>> UShell.ls M *



而不是


>& gt; UShell.ls" M *"



Adiaux

Samir

解决方案

ls M *

对于Python,它将是:


>> import UShell
UShell.ls(" M *")





>> UShell.exec(" ls M * ")



那么,为什么不在函数为一个内衬时使用括号

可选的命令如下:


>> UShell.ls" M * "



甚至


>> ls" M *"



那么,为什么在执行这样的

指令时也不要使逗号可选:


>> UShell.echo数字结果



而不是


>> UShell .echo号码,结果



最后,为什么不将字符串参数设为-less,当它是

唯一参数:


>> UShell.ls M *



而不是


>& gt; UShell.ls" M *"



Adiaux

Samir


samir写道:


Saluton!


我喜欢Python,我有这个想法:为什么不做Python一个Unix

shell?



已经完成;它被称为IPython:
http: //ipython.scipy.org/doc/manual/manual.html

George


samir写道:


我喜欢Python,我有这个想法:为什么不把Python变成Unix?
shell?



[...]


那么,为什么不在函数使用时使用括号一个内衬的

可选择这样的命令:



[...]


那么,为什么在执行这样的

指令时也不要使逗号可选:



[...]


最后,为什么不将字符串参数设为-less,因为它只是

参数:



....所以最后你得到的东西与任何Unix shell完全一样,而且
与Python完全不同。如果你想让Python看起来像bash,那么像bash一样运行
并且有类似bash的语法,你应该考虑使用bash :)


-

Roberto Bonvallet


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:

>>import UShell
UShell.ls("M*")

or

>>UShell.exec("ls M*")

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

>>UShell.ls "M*"

or even

>>ls "M*"

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

>>UShell.echo number result

Instead of

>>UShell.echo number,result

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

>>UShell.ls M*

Instead of

>>UShell.ls "M*"


Adiaux
Samir

解决方案

ls M*
When for Python it will be:

>>import UShell
UShell.ls("M*")

or

>>UShell.exec("ls M*")

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

>>UShell.ls "M*"

or even

>>ls "M*"

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

>>UShell.echo number result

Instead of

>>UShell.echo number,result

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

>>UShell.ls M*

Instead of

>>UShell.ls "M*"


Adiaux
Samir


samir wrote:

Saluton!

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

It''s been done; it''s called "IPython":
http://ipython.scipy.org/doc/manual/manual.html

George


samir wrote:

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 :)

--
Roberto Bonvallet


这篇关于语法建议。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆