Python standard library: built-in function any (iterable), pythoniterable

Source: Internet
Author: User
Tags iterable

Python standard library: built-in function any (iterable), pythoniterable

If one of all elements of an object that can be iterated is True, True is returned. Otherwise, False is returned. Or if the iteratable object is null, False is returned. This function is mainly used to determine whether the list, tuples, dictionaries, and other objects have elements that are True, improving the computing speed. The equivalent code is as follows:

Def any (iterable ):

For element in iterable:

If element:

Return True

Return False

 

Example:

# Any () function a = [] B = {} c = (1, 3, 4) d = (None, 1, 3) print ('a :', any (a), 'B:', any (B), 'c: ', any (c), 'd:', any (d ))

The output result is as follows:

A: False B: False c: True d: True


Cai junsheng QQ: 9073204 Shenzhen


If python has built-in functions, is there external functions?

Python built-in function built-in function refers to the built-in function in the standard library. These functions do not belong to any class or module and can be called directly. They can be considered an integral part of the python language. Similar to keywords.
Abs ()
Dict ()
Help ()
Min ()
Setattr ()

All ()
Dir ()
Hex ()
Next ()
Slice ()

Any ()
Divmod ()
Id ()
Object ()
Sorted ()

Ascii ()
Enumerate ()
Input ()
Oct ()
Staticmethod ()

Bin ()
Eval ()
Int ()
Open ()
Str ()

Bool ()
Exec ()
Isinstance ()
Ord ()
Sum ()

Bytearray ()
Filter ()
Issubclass ()
Pow ()
Super ()

Bytes ()
Float ()
Iter ()
Print ()
Tuple ()

Callable ()
Format ()
Len ()
Property ()
Type ()

Chr ()
Frozenset ()
List ()
Range ()
Vars ()

Classmethod ()
Getattr ()
Locals ()
Repr ()
Zip ()

Compile ()
Globals ()
Map ()
Reversed ()
_ Import __()

Complex ()
Hasattr ()
Max ()
Round ()

Delattr ()
Hash ()
Memoryview ()
Set ()

Static methods in other modules in the standard library are not built-in functions.

User-Defined extended functions are not built-in.
==================
However, in other languages and environments, built-in functions have different meanings.
Built-in functions do not have a unique specificity in concept. They are compound words. It is best to understand them as "built-in functions"... the rest of the text>

Python beginners start to read the python learning manual. Is there any need to create another python standard library ??

I am also self-taught. This winter vacation started, but I am reading head first python. I think it is better to read one carefully.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.