函数是python中的第一类对象吗?

函数是python中的第一类对象吗?,第1张

概述我正在学习 python的教程.它解释了函数是如何在 Python中的第一类对象. def foo(): passprint(foo.__class__)print(issubclass(foo.__class__,object)) 我得到的上述代码的输出是 <type 'function'>True 这个程序应该证明函数是python中的第一类对象?我的问题如下. >上面 我正在学习 python的教程.它解释了函数是如何在 Python中的第一类对象.

def foo():        passprint(foo.__class__)print(issubclass(foo.__class__,object))

我得到的上述代码的输出是

<type 'function'>True

这个程序应该证明函数是python中的第一类对象?我的问题如下.

>上面的代码如何证明函数是拳头类对象?
>第一类对象的属性是什么?
>函数.__ class__表示什么?它返回一个元组< type,function>这意味着什么?

解决方法 以下是GuIDo在博客中对头等对象所说的内容:

One of my goals for Python was to make it so that all objects were “first class.” By this,I meant that I wanted all objects that Could be named in the language (e.g.,integers,strings,functions,classes,modules,methods,etc.) to have equal status. That is,they can be assigned to variables,placed in Lists,stored in dictionarIEs,passed as arguments,and so forth.

whole blog post值得一读.

在您发布的示例中,教程可能会指出第一类对象通常是“对象”类的后代.

总结

以上是内存溢出为你收集整理的函数是python中的第一类对象吗?全部内容,希望文章能够帮你解决函数是python中的第一类对象吗?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1195846.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-03
下一篇2022-06-03

发表评论

登录后才能评论

评论列表(0条)

    保存