Python摇滚 [英] Python rocks

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

问题描述

嗯,我知道我正在向转变的人讲道 - 但是Python摇滚。


我被Scheme,Lisp和Forth的警报调用所吸引,但是最后,我发现Python更容易。我甚至尝试了一点Tcl。


给出一些上下文...我最近从Windows切换到操作系统

X和Linux。我错过了MS Money,但无法继续使用GnuCash。所以我决定写一下我自己的小型家酿资金管理程序,

包括从雅虎财经下载股价信息等内容。


我选择了OS X的鸡计划。事情开始很顺利,甚至网页
下载和正则表达式的工作相当轻松。我想使用

日期,并决定我需要SRFI-19库。鸡有

鸡蛋,您可以下载并安装。问题是它需要进一步的依赖性。好吧,没有必要因为

而恐慌;但是我发现它最终依赖于gmp,这对编译来说是痛苦的。


其他语言似乎有很好的想法;比如

Scheme中的闭包或宏,或者像Forth这样的超简单语法。但我发现的一般情况是发现其他语言似乎也需要太多的痛苦

一点回报。我似乎在Python中比在任何其他语言中更有效率。

Well, I know I''m preaching to the converted - but Python rocks.

I''ve been enchanted by the siren calls of Scheme, Lisp and Forth, but in
the end, I find Python much easier. I even tried a little bit of Tcl.

To give a bit of context ... I have recently switched from Windows to OS
X and Linux. I missed MS Money, but couldn''t get on with GnuCash. So I
decided to write my own little home-brew money management program that
includes things like downloading share price info from Yahoo Finance.

I picked Chicken Scheme for OS X. Things started well, and even the web
download and regex stuff worked fairly painlessly. I wanted to work with
dates, and decided that I needed the SRFI-19 library. Chicken has
"eggs", which you can download and install. The problem is that it
needed further dependencies. Well, no need to panic just because of
that; but I found that it ultimately depended on gmp, which turned out a
pain to compile.

Other languages seem to have neat ideas; like closures or macros in
Scheme, or ultra-simple syntax like Forth. But what I have generally
found is that other languages seem to require too much pain for too
little return. I just seem to be way more productive in Python than in
any other language.

推荐答案

6月2日,12日:31 pm,Steve Howell< showel ... @ yahoo.comwrote:
On Jun 2, 12:31 pm, Steve Howell <showel...@yahoo.comwrote:

--- Mark Carter< m ... @ privacy.netwrote:
--- Mark Carter <m...@privacy.netwrote:

嗯,我知道我正在向转换后的那些人讲道 - 但是b
Python摇滚。

[。 ..]
Well, I know I''m preaching to the converted - but
Python rocks.
[...]



合唱团提出的一些问题:


作为该语言的最新成员,你是不是/>
遇到任何陷阱或陷阱,而你是学习?b $ b学习?


A few questions from the choir:

As a recent newcomer to the language, did you
encounter any traps or pitfalls while you were
learning?



我可能偶然发现许多/大多数常见的陷阱通常会提到b
(例如 http://www.ferg.org/projects/python_gotchas.html
http://zephyrfalcon.org/labs/python_pitfalls.html ) />
在第一次或第二次之后轻松取出它们。在我的脑海中,有两个错误会在几年之后不断回归:

- 比较(语义上)无法比较的类型(http://
http://www.ibm .com / developerworks / li ... egance-1.html)

值得庆幸的是,这将在Py3k中修复。

- 字符串可迭代;不幸的是,这将保留在Py3K。

I had probably stumbled on many/most of the common pitfalls usually
mentioned (e.g. http://www.ferg.org/projects/python_gotchas.html,
http://zephyrfalcon.org/labs/python_pitfalls.html) while learning, but
picked them up easily after the first or second time. Off the top of
my head, two errors that keep coming back even years after are:
- Comparing instances of (semantically) incomparable types (http://
http://www.ibm.com/developerworks/li...egance-1.html).
Thankfully this will be fixed in Py3k.
- Strings being iterable; unfortunately this will stay in Py3K.


另外,你可以在

中挑出任何特别关于Python的东西,开始让你更多

生产效率,还是仅仅是整体设计?
Also, could you single out anything in
particular about Python that started making you more
productive, or was it just the overall design?



如果我要选择一个功能,这将是三元组

iterators-generators-itertools,不仅可以提高生产率

但是可能更多的是改变思考编程的方式,让Python值得学习[1]。但总的来说,这是

整体设计,在大多数情况下做出正确的权衡。


George

[1 ]一种不会影响你对编程的看法的语言,不值得知道。 - Alan Perlis

If I were to pick a single feature, this would be the triplet
iterators-generators-itertools, not only for the productivity gains
but perhaps even more for changing the way of thinking about
programming, making Python worth learning [1]. But in general it''s the
overall design, making the right tradeoffs in most cases.

George
[1] "A language that doesn''t affect the way you think about
programming, is not worth knowing." - Alan Perlis


文章< 11 ********************** @ p47g2000hsd.googlegroups .com>,

George Sakkis< ge *********** @ gmail.comwrote:
In article <11**********************@p47g2000hsd.googlegroups .com>,
George Sakkis <ge***********@gmail.comwrote:

>
我可能偶然发现了许多/大多数常见的陷阱(例如 http://www.ferg.org/projects/python_gotchas.html
http://zephyrfalcon.org/labs/python_pitfalls.html )在学习的同时,在第一次或第二次之后轻松地将它们捡起来。在我的脑海中,有两个错误会在几年之后不断回归:
- 比较(语义上)无法比拟的类型(http://
http://www.ibm.com/developerworks/li .. .egance-1.html)。谢天谢地,这将在Py3k中修复。
- 字符串可迭代;不幸的是,这将留在Py3K。
>
I had probably stumbled on many/most of the common pitfalls usually
mentioned (e.g. http://www.ferg.org/projects/python_gotchas.html,
http://zephyrfalcon.org/labs/python_pitfalls.html) while learning, but
picked them up easily after the first or second time. Off the top of
my head, two errors that keep coming back even years after are:
- Comparing instances of (semantically) incomparable types (http://
http://www.ibm.com/developerworks/li...egance-1.html).
Thankfully this will be fixed in Py3k.
- Strings being iterable; unfortunately this will stay in Py3K.



我会重复我在python-3000上发表的评论:


" ... string iteration isn不是将字符串视为

字符串的序列,而是将字符串视为字符序列。

这个字符也是字符串的事实是我们遇到问题的原因,

但字符是其他正当理由的字符串。


事情是,你可以,例如切片字符串就像其他

序列类型一样,会产生结果,你也可以遍历

字符串 - 而且,我们中的一些人实际上会迭代字符串(尽管

当然我们可以根据需要创建列表/元组字符)。在

这个宏伟的计划中,我很少看到人们遇到问题

迭代字符串。

-

Aahz(aa**@pythoncraft.com)< * http://www.pythoncraft .com /


只要我们喜欢相同的操作系统,事情就很酷。 --piranha

I''ll repeat the comment I made on python-3000:

"...string iteration isn''t about treating strings as sequences of
strings, it''s about treating strings as sequences of characters. The
fact that characters are also strings is the reason we have problems,
but characters are strings for other good reasons."

Thing is, the fact that you can e.g. slice strings just like other
sequence types creates the consequence that you can also iterate over
strings -- moreover, some of us actually do iterate over strings (though
of course we could if necessary create lists/tuples of characters). In
the grand scheme of things, I rarely see people running into problems
with iterating over strings.
--
Aahz (aa**@pythoncraft.com) <* http://www.pythoncraft.com/

"as long as we like the same operating system, things are cool." --piranha


Mark Carter< me@privacy.netwrote:
Mark Carter <me@privacy.netwrote:

我选择了鸡计划为OS X.事情开始很好,甚至网络
I picked Chicken Scheme for OS X. Things started well, and even the web



...

...


that;但是我发现它最终依赖于gmp,这导致了编译的痛苦。
that; but I found that it ultimately depended on gmp, which turned out a
pain to compile.



是的,GMP很难编译(特别是在Mac OS X上),但我相信

那个通用二进制库的版本我已放入gmpy

下载中(参见 http://code.google.com/p/gmpy/downloads/list )工作正常

(至少它似乎适用于gmpy,这是我的Python扩展

包装GMP,gmpy曝光和大量单元测试基本上是

所有GMP的功能。


只要提一下,如果你想给Scheme另一个机会

(它可能应该得到,虽然闭包几乎不是唯一的;我想b / b $ b不知道你是否意味着继续) 。 Python可能比Scheme更享受更好的工具和图书馆,但是当时Java还是比较好的,但是我希望我能更好地使用Python,因为我更喜欢它作为一种语言* ...

Alex

Yes, GMP is a pain to compile (especially on Mac OS X), but I believe
that the Universal Binary library version I''ve put among the gmpy
downloads (see http://code.google.com/p/gmpy/downloads/list) works fine
(at least it seems to work fine for gmpy, which is my Python extension
that wraps GMP, and gmpy exposes and copiously unit-tests essentially
all of GMP''s functionality).

Just mentioning this in case you want to give Scheme another chance
(which it may well deserve, although closures are hardly unique to it; I
wonder if you meant continuations). Python may enjoy better tools and
libraries than Scheme, but then Java enjoys better ones yet, yet I
prefer to stick with Python because I like it better *as a language*...
Alex


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

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