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.
Może Ci się spodobać
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 Trendy
- 1. Rob Reiner 385K posts
- 2. #IDontWantToOverreactBUT N/A
- 3. #MondayMotivation 9,796 posts
- 4. #pbdpodcast N/A
- 5. Good Monday 50.6K posts
- 6. Victory Monday 1,948 posts
- 7. DJ Lagway N/A
- 8. Josh Bell N/A
- 9. All in the Family 33.2K posts
- 10. Meathead 11.3K posts
- 11. #MondayVibes 3,604 posts
- 12. #VivaLaUniónDeLosPueblos 1,823 posts
- 13. Ella Cook 42.9K posts
- 14. Steve and Dustin 1,856 posts
- 15. The Princess Bride 26.1K posts
- 16. James Evans N/A
- 17. Bill of Rights Day N/A
- 18. Chile 883K posts
- 19. Stand By Me 32.8K posts
- 20. When Harry Met Sally 32.9K posts
Something went wrong.
Something went wrong.