一般编码问题 - 编码风格...... [英] general coding issues - coding style...

查看:97
本文介绍了一般编码问题 - 编码风格......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


因为我只是一个''手工艺''/初学者左右,


可以任何人提供我有一些(粗略)提示,关于如何增强代码

这里:

http://calmar.ws/tmp/cal.html


干杯并非常感谢

calmar

-

calmar


(o_岩石:LINUX +命令行界面

// \

V _ / _ http:/ /www.calmar.ws

Hi all,

since I''m just a ''handicraft''/beginner or so,

could anybody provide me with some (rough) hints, about how to enhance the code
here:

http://calmar.ws/tmp/cal.html

Cheers and thanks a lot
calmar
--
calmar

(o_ It rocks: LINUX + Command-Line-Interface
//\
V_/_ http://www.calmar.ws

推荐答案

calmar schrieb:
calmar schrieb:
大家好,
<因为我只是一个''手工艺''/初学者左右,

任何人都可以提供一些(粗略的)提示,关于如何增强代码
Hi all,

since I''m just a ''handicraft''/beginner or so,

could anybody provide me with some (rough) hints, about how to enhance the code
here:




- 为什么这些{{{thingies there?


- u se字符串插值,如Foo%s%i %(bar,1)而不是

连接字符串。


- 似乎你可以从一个类而不是一堆<中受益br />
功能&很少全局。没有必要对OO过于疯狂,但它有其优点


- 尝试使用像glade这样的东西 - 手工创建GUI很糟糕

big-timer :)


- 阅读有关unicode和编码,它们的含义以及为什么以及何时以及b / b
使用什么。真。那个领域的大多数问题源于人们对这个话题一无所知,只是在时间里扭动自己 - 最后,把事情弄得乱七八糟。它真的不那么复杂。


- 当创建字符串键盘时,成语


dict(foo =" bar" ;,

baz =" pillepalle")


有它的优点。


除此之外 - 看起来还不错给我。


Diez



- why are these {{{ thingies there?

- use string interpolation like "Foo %s %i" % ("bar", 1) instead of
concatenating strings.

- it seems that you could benefit from a class instead of a bunch of
functions & few globals. No need to go too crazy about OO, but it has
its merits

- try using something like glade - creating GUIs by hand sucks
big-timer :)

- read up about unicode and encodings, what they mean and why and when
to use what. Really. Most problems in that field stem from people being
sort of ignorant on that topic and just wiggling themselves through all
the time - in the end, messing up stuff. It really _isn''t_ that complicated.

- when creating string-keyed dicts, the idiom

dict(foo="bar",
baz="pillepalle")

has its merits.

Besides that - looks ok to me.

Diez


2006-02-18,Diez B. Roggisch< de *** @ nospam .web.de>写道:


嗨Diez,
On 2006-02-18, Diez B. Roggisch <de***@nospam.web.de> wrote:

Hi Diez,
- 为什么这些{{{thingies那里?


用于折叠vim的标记
http://www.calmar.ws/tmp/sc.png

- 使用字符串插值,如Foo%s%i %(bar,1)而不是串联字符串。


我看,得到'更短,所以,我可以打破线。

(在我看来,(或者[或者,我]可以使用一个没有

的新线来担心)

- 似乎你可以从一个类而不是一堆
函数和几个全局变量中受益。不需要对OO过于疯狂,但它有它的优点


我明白了。也许我可以为那个编程构建一些类,

特别是因为我只使用一个文件,它可能会让

获得更好的结构。

- 尝试使用像glade这样的东西 - 手工创建GUI很糟糕
big-timer :)


我应该(严重)检查出来。

- 阅读关于unicode和编码,他们的意思和为什么以及何时使用什么。真。这个领域的大多数问题源于人们对这个话题一无所知,只是在所有时间摆弄自己 - 最后,弄乱了东西。它真的不那么复杂。


我读了。事实上,基本上它似乎并不复杂。

Unicode只是所有可用字符的编号列表,并且

例如uft-8是一种有条理的方式,可以明智地存储''这些''数字'

到字节。


我还有一些问题(并且放弃了),但是因为我开始现在已经理解它了,我应该再次尝试/检查。

- 当创建字符串键盘时,成语

dict(foo =" bar",
baz =" pillepalle")
- why are these {{{ thingies there?
markers for folding for vim
http://www.calmar.ws/tmp/sc.png
- use string interpolation like "Foo %s %i" % ("bar", 1) instead of
concatenating strings.
I see, get''s shorter and so, and I can break lines.
(seems to me, after ( or [ or so, I can use a new line without
to worry)
- it seems that you could benefit from a class instead of a bunch of
functions & few globals. No need to go too crazy about OO, but it has
its merits
I see. Maybe I could then build some classes for that prog,
especially since I use only one file, it probably would make
some sense for getting a better structure.

- try using something like glade - creating GUIs by hand sucks
big-timer :)
I should (seriously) check out probably.
- read up about unicode and encodings, what they mean and why and when
to use what. Really. Most problems in that field stem from people being
sort of ignorant on that topic and just wiggling themselves through all
the time - in the end, messing up stuff. It really _isn''t_ that complicated.
I read up. In fact, basically it does not seem to be that complicate.
Unicode just a ''numbered'' list of all available character, and
e.g. uft-8 a organized way to ''store'' those ''numbers'' wisely
into bytes.

I still have some problems with that (and gave up), but since I begin to
now understand it somebit more, I should try/check again.
- when creating string-keyed dicts, the idiom

dict(foo="bar",
baz="pillepalle")




我明白了,我也改变了。


非常感谢,

marco


-

calmar


(o_它摇滚:LINUX +命令行界面

// \

V _ / _ http://www.calmar.ws


你好,


1585如果sys.path [0] [ - 12:] ==" \library.zip":#for py2exe


怎么样


if sys.path [0] .endswith(" \\library.zip"):

(你真的是指那里有一个反斜杠?)

499元组= os.path.split(文件名)


错误的变量名称...元组(x)将序列转换为元组。

您有多个地方可以检查len(x)== 0:

674如果len(文件)== 0:

853如果len(file_show)== 0:

950 if len(imgprocess [" files_todo" ;])== 0:


人们通常建议:


如果不是文件:

如果不是file_show :

如果不是imgprocess [" files_todo"]:

你应该通过pychecker运行你的代码(它有很多话要说......)。

你使用全局很多...应该是一个红旗。就像上面提到的海报

一样,你有些东西告诉你他们想要
是对象。

#{{{和#其他程序员非常烦恼

(好吧,对我来说......)。您可能想要研究一个Python识别的

编辑器(如SPE,它内置了pychecker)。这是来自定期使用vim的人的


Hi,

1585 if sys.path[0][-12:] == "\library.zip": #for py2exe

how about

if sys.path[0].endswith( "\\library.zip" ):

(did you really mean one back-slash there?)
499 tuple = os.path.split(filename)

bad variable name... tuple(x) converts a sequence to a tuple.
You have a number of places where you check for len(x)==0:

674 if len(files) == 0:
853 if len(file_show) == 0:
950 if len(imgprocess["files_todo"]) == 0:

people usually recommend:

if not files:
if not file_show:
if not imgprocess["files_todo"]:
you should run your code through pychecker (it had a lot to say...).
You use global alot... that should be a red flag. Like the poster
above mentioned, you have things that are telling you they want to
be objects.
The #{{{ and #}}} stuff is very annoying to other programmers
(ok, to me...). You might want to investigate a Python aware
editor (like SPE, which has pychecker built in). This is
coming from someone who uses vim regularly.


这篇关于一般编码问题 - 编码风格......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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