是否可以在多个文件中划分一个类? [英] is it possible to dividing up a class in multiple files?

查看:79
本文介绍了是否可以在多个文件中划分一个类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


是否可以将类的方法放在不同的文件中?我只是

想要订购它们并尝试保持文件小。


问候

马丁

解决方案

Martin H ?? fling写道:


是否可以将类的方法放在不同的位置文件?我只是

想要订购它们并尝试保持文件小。



不,这是不可能的。你可以做的是创建几个类和一个继承自所有类的类。


更好的是不写大类并摆脱奇怪的

使问题看起来如此的约定或视图。解释一下:

我从来没有觉得需要在几个文件上传播一个类 - au

对比,我鄙视Java强迫我只有一个顶级等级等级
每个文件



Diez


嗨Martin,


我不认为这是可能的,因为文件是在导入

时执行的。如果您加载包含部分文件的文件class,你

会收到错误,因为缩进不正确,或者

方法将被加载到错误的命名空间中。


问候,

Michiel


Op 7-aug-2006,om 15:41 heeft Martin H?fling het volgende geschreven:
< blockquote class =post_quotes>
你好,


是否可以将类的方法放在不同的文件中?我

只是

想订购它们并尝试保持文件小。


问候

Martin

-
http://mail.python.org/mailman/listinfo/python-list




Martin H?fling写道:


你好,


是否可以将类的方法放在不同的文件中?我只是

想要订购它们并尝试保持文件小。


问候

Martin



前几天我遇到了pyp。这可能是你想要的。

http://www.freenet.org.nz/python/pyp/


Hi there,

is it possible to put the methods of a class in different files? I just
want to order them and try to keep the files small.

Regards
Martin

解决方案

Martin H??fling wrote:

is it possible to put the methods of a class in different files? I just
want to order them and try to keep the files small.

No, its not possible. What you can do is to create several classes and one
that inherits from all of them.

Better yet is to not write huge classes and getting rid of strange
conventions or views that make the problem appear as such. To explain that:
I''ve never felt the need to spread a class over several files - au
contraire, I despise Java for forcing me to only have one top level class
per file.

Diez


Hi Martin,

I don''t think that''s possible, since a file is executed when it is
imported. If you load a file which contains a "partial" class, you
will get an error because the indentation is incorrect, or the
methods will be loaded in the wrong namespace.

Regards,
Michiel

Op 7-aug-2006, om 15:41 heeft Martin H?fling het volgende geschreven:

Hi there,

is it possible to put the methods of a class in different files? I
just
want to order them and try to keep the files small.

Regards
Martin
--
http://mail.python.org/mailman/listinfo/python-list



Martin H?fling wrote:

Hi there,

is it possible to put the methods of a class in different files? I just
want to order them and try to keep the files small.

Regards
Martin

I ran across pyp the other day. It may be what you''re wanting.

http://www.freenet.org.nz/python/pyp/


这篇关于是否可以在多个文件中划分一个类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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