在PEP 322(ireverse) [英] On PEP 322 (ireverse)

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

问题描述

我已经丢失了我的新闻阅读器上的原始帖子,所以我打开了一个新的

一个。


首先,我喜欢名字ireverse,比反向更好(eek!)。


只是一个简单的评论/问题:


- 为什么内置函数?为什么不把它塞进itertools

模块? built built。built built built,,,,,,,,,,,,,,,,,,,,,,,,我想将复制模块记为案例

,其中基本协议(__copy__和__deepcop__)不在

内置,而是在标准模块中。 br />

如果它被放入itertools我肯定是+1。在内置组件上

-0并降低......


致以最诚挚的问候,

G. Rodrigues

解决方案

Gon?alo Rodrigues写道:

我在新闻阅读器上丢失了原帖,所以我'我正在开一个新的

首先,我喜欢ireverse的名字,然后更好地反复(eek!)。


我仍​​然更喜欢Werner Schiendl对iter.reversed的看法,如果我们找到一种内置函数的方式,那就会增加一个'staticmethod' '各种各样......!


只是一个简单的评论/问题:

- 为什么内置函数?为什么不把它塞进itertools


根据雷蒙德最近在这里发布的详细标准,这对于itertools来说是不合适的。

模块?内置物已经很胖了,让它更胖不是




是的,内置物应该严格保留为必不可少的

个案(并在3.0中修剪了很多 - 但距离这几年了)。这是

为什么,例如,list.sorted是一个类型列表的类方法,而不是内置的
。同样地,如果它是一种类型,iter.reversed将

成为一种显而易见的方式......

Alex


> Gon?alo Rodrigues写道:

首先,我喜欢ireverse这个名字,然后更好地反复(eek!)。



谢谢。


[亚历克斯]我仍然更喜欢Werner Schiendl对iter.reversed的看法,如果我们找到了一种内置函数的方法,那么它会成长''静态方法''各种......!




不,谢谢。呸。请不要将这个简单的想法扭曲成结。

这应该是你可以在前半个小时教授的东西

然后永远使用。我会更快地教导负xrange()

索引而不是立即启动到虚拟引用的静态

方法附加到看起来不应该有的东西

a方法。这是一个简化,而不是一个可爱的练习

或聪明只是为了避免内置。

Raymond Hettinger


< blockquote>

" Alex Martelli" <人*** @ aleax.it>在消息中写道

新闻:4x *********************** @ news2.tin.it ...

Gon?alo Rodrigues写道:

首先,我喜欢ireverse这个名字,然后更好,然后inreverse


(eek!)。
我还是比较喜欢Werner Schiendl对iter.reversed的想法,如果我们找到了内置函数的方法,那就会成为一种静态方法......!


正如我在别处建议的那样,使iter()成为迭代器的类型对象。

然后iter.reversed与list.sorted紧密相关。

这是什么,例如,list.sorted是一个类型列表的类方法,而不是内置的类。同样地,如果它是一种类型,iter.reversed将是一种明显的方式......




任何好的理由都没有做到这一点? int,str和float曾经是b / b
。我是+1的oner.reversed,还有list.sorted。


Terry J. Reedy


I''ve lost the original thread on my news reader so I''m opening a new
one.

First, i like the name ireverse, much better then inreverse (eek!).

Just a simple comment/question:

- Why a builtin function? Why not just stuff it in the itertools
module? The builtins is already fat as it is, making it fatter is not
the way to go, IMHO. I''d like to remeber the copy module as a case
where a fundamental protocol (__copy__ and __deepcop__) is not in the
builtins but in a standard module.

If it were to be put in itertools i''m definitely +1. On the builtins
-0 and lowering...

With my best regards,
G. Rodrigues

解决方案

Gon?alo Rodrigues wrote:

I''ve lost the original thread on my news reader so I''m opening a new
one.

First, i like the name ireverse, much better then inreverse (eek!).
I still prefer Werner Schiendl''s idea of iter.reversed, IF we find a
way to have builtin function iter grow a ''staticmethod'' of sorts...!

Just a simple comment/question:

- Why a builtin function? Why not just stuff it in the itertools
It''s inappropriate for itertools according to detailed criteria that
Raymond has recently posted here.
module? The builtins is already fat as it is, making it fatter is not



Yes, builtins should indeed be reserved strictly for the indispensable
cases (and trimmed a LOT in 3.0 -- but that''s years away). Which is
why, e.g., list.sorted was made a classmethod of type list, rather
than a built-in. Similarly, IF iter was a type, iter.reversed would
be the "one obvious way to do it"...
Alex


> Gon?alo Rodrigues wrote:

First, i like the name ireverse, much better then inreverse (eek!).


Thanks.

[Alex] I still prefer Werner Schiendl''s idea of iter.reversed, IF we find a
way to have builtin function iter grow a ''staticmethod'' of sorts...!



No thanks. Yuck. Please do not twist this simple idea into knots.
This is supposed to be something you can teach in the first half-hour
and then use forever. I would sooner teach negative xrange()
indices than immediately launch into dotted references to a static
method attached to something that doesn''t look like it should have
a method. This is a simplification, not an exercise in being cute
or clever just to avoid a builtin.
Raymond Hettinger



"Alex Martelli" <al***@aleax.it> wrote in message
news:4x***********************@news2.tin.it...

Gon?alo Rodrigues wrote:

First, i like the name ireverse, much better then inreverse

(eek!).
I still prefer Werner Schiendl''s idea of iter.reversed, IF we find a
way to have builtin function iter grow a ''staticmethod'' of sorts...!
As I suggested elsewhere, make iter() the type object for iterator.
Then iter.reversed is closely parallel to list.sorted.
Which is
why, e.g., list.sorted was made a classmethod of type list, rather
than a built-in. Similarly, IF iter was a type, iter.reversed would
be the "one obvious way to do it"...



Any good reason not to make iter so? int, str, and float were once
bifs also. I''m +1 on iter.reversed, along with list.sorted.

Terry J. Reedy


这篇关于在PEP 322(ireverse)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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