3中列出内置函数

3中列出内置函数

本文介绍了是在python 3中列出内置函数或类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>>> print(list(map(list,"abcde")))
[['a'],['b'],['c'],['d'],['e']]

以上是最可能的答案,也是正确的,但是我以不同的方式想到它.

Above is the most probable answer and correct as well however i thought of it in a bit different way.

由于map需要一个函数作为第一个参数,而list是一个类权限,那么map如何工作?

Since map needs a function as the first parameter but list is a class right, so how map is working?

但是我听说列表也是一个内置函数,它返回一个列表对象.只有一个类可以返回一个对象,该对象不过是对象的创建.但是,如果它是一个类,则应该按照python中类的命名约定将列表写在驼峰式的情况下.

However i have heard of list as an inbuilt function as well which returns a list object. Only a class can return an object which is nothing but creation of an object. But if it is a class then list should have been written in camelcase according to the naming convention of classes in python which is not the case.

以上所有这些使我陷入冲突,因为列表是python中的类或方法?

All the above points lead me to a conflict that list is a class or method in python?

推荐答案

list 是Python中的内置类.但是,类可以像函数一样被调用,并且在被调用时,类会实例化并返回对象,因此您可以将类作为参数传递给期望函数(或精确地说是可调用的).

list is a built-in class in Python. However, classes are callable just like functions, and when called, classes instantiate and return objects, so you can pass a class as an argument where a function (or a callable to be precise) is expected.

这篇关于是在python 3中列出内置函数或类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 10:43