Movatterモバイル変換


[0]ホーム

URL:


[Python-ideas] Fwd: Define a method or function attributeoutsideof a class with the dot operator

Random832random832 at fastmail.com
Wed Feb 15 00:28:15 EST 2017


On Sun, Feb 12, 2017, at 21:55, Steven D'Aprano wrote:> But honestly, no. This is not going to happen. .Net VB and C# have> something like this, as does Lua, and people still write classes the> ordinary way 99.99% of the time.The VB/C# thing you are referring to is, I assume, extension methods.But they're really very different when you look at it. Extension methodsare only used when the namespace containing them has been imported, andare based on the static type of the object they are being called on.They also have no access to the object's private members.Python doesn't have static types and doesn't have private members, andusing this would make a real modification to the type the method isbeing added to rather than relying on namespaces being imported, sothere would be fewer barriers to "use this for everything" than "useextension methods for everything in C#".


More information about the Python-ideasmailing list

[8]ページ先頭

©2009-2026 Movatter.jp