GoobNet

GoobNet menu

GoobNet

THIS WEBSITE IS AN INTERNATIONAL SAFE HAVEN FOR LIES – NO MALTREATMENT OF LIES SHALL BE TOLERATED

WEEKLY WHINE

We apologise for any inconvenience caused by our programming

There now follows a ranking of the top keywords in Python 3. Criteria included importance [do you use it a lot?], usefulness [does it come in handy even if you don’t use it a lot?], and intuitiveness [does it make sense that it was chosen to represent that concept?].

  1. for: Loop that iterates through a sequence. Equivalent to foreach in other programming languages, which is usually what is needed anyway. Also used for list comprehensions and generator expressions, which are two of the most awesome things that exist in Python.
  2. in: Boolean operator that tests whether an item is in a sequence, a key is in a dictionary, or a substring is within a string. Also used with for.
  3. if: Defines a conditional block.
  4. finally: Closing portion of a try block. Always executed, even if the try block raised an exception. Extraordinarily useful for making sure files, databases, and other shared resources are closed even if there is an exception.
  5. try: Defines an exception handling block. Requires either an except block or a finally block, or both.
  6. return: Exits a function with the specified return value. If no value is specified, returns None.
  7. with: Executes a context manager: an object that defines how to initialise and close itself. Automates common try-finally usage: with open('new_cooker.txt') as f:.
  8. while: Loop that repeats as long as the specified condition is true.
  9. class: Defines a class.
  10. as: Used in import, with, and except statements to assign something to an identifier.
  11. None: The null object. Capitalised because it is an object. Usually used as a default for optional function arguments. Amusingly, prior to Python 3, None was not a keyword, but still a builtin object, which meant that you could assign something else to it: None = 'blancmange'.
  12. True: Boolean true. Capitalised because it is an object. Amusingly, prior to Python 3, True was not a keyword, but still a builtin object, which meant that you could assign something else to it: True = False.
  13. False: Boolean false. Capitalised because it is an object. Amusingly, prior to Python 3, False was not a keyword, but still a builtin object, which meant that you could assign something else to it: False = True.
  14. import: Imports a module. With from, imports a module from a package, or specific identifiers from a module.
  15. else: Last alternative in a conditional block, exceptionless alternative in a try block, and closing block of a for or while loop. This last usage is helpful if you need to know whether a loop exited normally or through a break statement.
  16. not: Boolean not operator. Also used as part of comparison operators not in and is not.
  17. and: Boolean and operator.
  18. or: Boolean or operator. Disappointingly, Python has no xor operator.
  19. def: Defines a function or class method. One is inevitably left to wonder why Guido was too lazy to type out function.
  20. lambda: Defines an anonymous function. Useful when sorting, eg: silly_walks.sort(key = lambda walk: walk['name'])
  21. from: Used with import to import a module from a package, or specific identifiers from a module.
  22. yield: Returns a value from a generator. Automatically makes a function a generator, which can be suspended and resumed. Useful to define an object that returns data a bit at a time instead of all at once, which can clog memory.
  23. except: Catches an exception from a try block. Multiple except blocks may be used to test for different types of exceptions.
  24. raise: Raises an exception.
  25. elif: Alternative test in a conditional block. Programming languages must come together on this and use elseif. Not elif like Python, and definitely not elsif like Perl.
  26. break: Escapes from a for or while loop, and skips the else block.
  27. continue: Returns to the beginning of a for or while loop. If the last iteration, proceeds to the else block.
  28. pass: NOOP. Useful when declaring a stub class, like a custom exception type. Uses the “passing spins” sound from Press Your Luck.
  29. global: Declares an identifier as global.
  30. nonlocal: Declares an identifier as nonlocal, ie, from the enclosing scope. Useful when defining nested functions.
  31. del: Deletes an identifier, list item, dictionary key, or attribute.
  32. is: Boolean operator that tests whether two items are identical.
  33. assert: Debugging assertion. Still a reserved word, but more and more seems as though it should be turned into a function, like print.

PLEASE SEND ALL IRRELEVANT DETAILS TO <GOOBNET‍@‍GOOBNET.NET>

© 2018 GOOBNET ENTERPRISES, INC [WHICH DOESN’T ACTUALLY EXIST HOWEVER]

THIS FILE ACCURATE AS OF: THU 06 DEC 2018 – 06:34:50 UTC · GENERATED IN 0.008 SECONDS