Python StdLib Tip
@pythonstdlibtip
Python built-in functions and modules tips, approximately one tip per week day. Shamelessly copied from http://docs.python.org by @dmlvianna.
قد يعجبك
filter(function, iterable) Construct a list from those elements of iterable for which function returns true.
len(s) Return the length (number of items) of an object. The argument may be a sequence (string, tuple or list) or a mapping (dictionary).
iter(o[, x]) Return an iterator object. o must support iteration or sequencing. If x given, o must be callable and iteration will stop at x.
issubclass(class, classinfo) Return true if class is a subclass of classinfo. classinfo may be a tuple of class objects to be checked.
isinstance(object, class) Return true if the object is an instance of the class, or of a (direct, indirect or virtual) subclass thereof.
int(x) Convert a number or string x to an integer, or return 0 if no args. If x is floating point, the conversion truncates towards zero.
input([prompt]) Equivalent to eval(raw_input(prompt)). If readline is loaded, it provides elaborate line editing and history features.
id(object) This is an integer which is guaranteed to be unique and constant for this object during its lifetime.
hex(x) Convert an integer number (of any size) to a lowercase hexadecimal string prefixed with “0x”.
help([object]) Invoke the built-in help system. If no argument is given, the interactive help system starts on the interpreter console.
hash(object) Return the hash value of the object (if it has one). Hash values are integers, and are used to quickly compare dictionary keys.
hasattr(object, string) The result is True if the string is the name of one of the object’s attributes, False if not.
globals() Return a dictionary representing the current global symbol table. This is always the dictionary of the current module.
getattr(object, name[, default]) Return the value of the named attribute of object. If it does not exist, default is returned if provided.
frozenset([iterable]) Return a new frozenset object. frozenset is a built-in class. frozenset are like set objects, but are immutable.
format(value[, format_spec]) Convert a value to a “formatted” representation. format_spec mini-language: tinyurl.com/mtpo4l5
float([x]) Convert a string or a number to floating point. Strings can be embedded in whitespace. Argument may also be [+|-]nan or [+|-]inf.
file() Constructor function for the file type. Arguments are the same as for open(). Use open() to open files, use file() for type testing.
execfile(filename[, globals[, locals]]) This function is similar to the exec statement, but parses a file instead of a string.
eval(expression[, globals[, locals]]) Evaluates a string or code object as a Python expression using current or supplied namespaces.
United States الاتجاهات
- 1. Bondi Beach 165K posts
- 2. Gunther 93.1K posts
- 3. Hanukkah 60.5K posts
- 4. Spurs 73K posts
- 5. John Cena 579K posts
- 6. Naveed Akram 10.6K posts
- 7. #SNME 301K posts
- 8. #ThankYouCena 462K posts
- 9. Triple H 101K posts
- 10. Wemby 51.9K posts
- 11. Good Sunday 57.6K posts
- 12. Brown University 232K posts
- 13. Chanukah 14.9K posts
- 14. Chet 17.2K posts
- 15. #JungkookxElleKorea 79.1K posts
- 16. Chrisean 7,397 posts
- 17. TOP CALL 6,445 posts
- 18. Caruso 8,088 posts
- 19. #UFCVegas112 21.9K posts
- 20. Never Give Up 40.1K posts
Something went wrong.
Something went wrong.