python做图片美化软件,Python源代码美化

python做图片美化软件,Python源代码美化

Hello, I did not find any reasonable pyhton source code beautifier

program (preferable gui).

Some would ask whyProgram it immediatly good.

(BTW: Would be a nice project, if I would have more spare time).

Ich have some foreign source, which are programed in a way

I don”t like, so I would like to have a tool, which automatically

processes following options:

Use Spaces, size: 4

convert structs like: if (a b): to if a b:

fill in spaces, but not in functions between operators:

a+=1 =a += 1

p(t + 1) =p(t+1)

convert:

self.scriptcount = self.scriptcount + 1 =self.scriptcount += 1

from “is” to “==” and “is not” to “!=” (ok a find replace could do that

easily also), but in a program that would be more comfortable.

break long lines (in a reasonable way)

make from:

if len(string) 0: =if string:

and

if if len(string)

detect mixed line ending

detect tabs mixed with space

trim trailing whitespaces.

…..

…..

Is there such a tool around/p>

Running Pylint or Pycheck automatically afterwards

would be the coronation. :)

解决方案Franz Steinhaeusler:

Hello, I did not find any reasonable pyhton source code beautifier

program (preferable gui).

convert:

from “is” to “==” and “is not” to “!=” (ok a find replace could do that

easily also), but in a program that would be more comfortable.

That”s an unsafe conversion. I don”t think it is possible for a

reasonable program to determine statically that “is” is equivalent to

“==” except for trivial pieces of code.

Neil

Franz Steinhaeusler wrote this on Tue, 27 Feb 2007 09:45:42 +0100. My

reply is below.

Hello, I did not find any reasonable pyhton source code beautifier

program (preferable gui).

-snip-

Is there such a tool around/p>

Why, yes! Yes, there is:

o http://lacusveris.com/PythonTidy/PythonTidy.python

It doesn”t have a graphical user interface, and it doesn”t do

everything you want, and it isn”t reasonable (It”s of an unreasonable

size.), but it is a beginning.

For future reference, look in:

o http://cheeseshop.python.org/pypi

…. under “reformat.”

… Chuck Rhode, Sheboygan, WI, USA

… Weather: http://LacusVeris.com/WX

… 26 a Wind WNW 5 mph a Sky overcast. Mist.

Il Tue, 27 Feb 2007 09:45:42 +0100, Franz Steinhaeusler ha scritto:

Hello, I did not find any reasonable pyhton source code beautifier

program (preferable gui).

Well, most of the things you ask should be written as such, not written and

then beautified!

Use Spaces, size: 4

Your editor should support this.

convert structs like: if (a b): to if a b:

Well… that”s a matter of fact, not just style. Sometimes parentheses help

the reading; if a,b are not just plain names but somewhat complex

instructions, parentheses should stay.

fill in spaces, but not in functions between operators:

a+=1 =a += 1

p(t + 1) =p(t+1)

Code should be written this way.

self.scriptcount = self.scriptcount + 1 =self.scriptcount += 1

the += operator is syntactic sugar just to save time… if one doesn”t use

it I don”t think it”s a matter of beauty.

>

from “is” to “==” and “is not” to “!=” (ok a find replace could do that

easily also), but in a program that would be more comfortable.

whatNo, I think you”re missing the difference between ”is” and ”==”. You

could say it the other way for None, True, False, e.g. if there”s a ”a ==

None” it could be safely converted to ”a is None”, but again: this should

be done while writing the code.

break long lines (in a reasonable way)

well… this could be useful sometimes, but again… ”reason” is usually

something human beings should employ, and shouldn”t be ”outsourced” to

computer programs.

make from:

if len(string) 0: =if string:

and

if if len(string)

That”s impossibile! Python is dynamically typed! How could the ”beautifier”

understand what the ”string” name is bound toIt could be whatever object!

detect mixed line ending

detect tabs mixed with space

trim trailing whitespaces.

Those are editor tasks.

Get a good Editor or IDE. You haven”t told us what OS are you on. If you”re

on Windows, UltraEdit can do most of the things you”d like. And don”t rely

on a software to correct human behaviours ^_^.

Alan Franzoni

Togli .xyz dalla mia email per contattarmi.

Remove .xyz from my address in order to contact me.

GPG Key Fingerprint (Key ID = FE068F3E):

5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E

文章知识点与官方知识档案匹配,可进一步学习相关知识Python入门技能树首页概览211477 人正在系统学习中 相关资源:我国某大型软件企业美国软件外包案例(44PPT)_业务外包案例-外包…

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年11月20日
下一篇 2020年11月20日

相关推荐