Skip to main content

Home/ Mac Attack/ Group items tagged keyword

Rss Feed Group items tagged

Benjamin Bandt-Horn

4. More Control Flow Tools - Python v2.7.6 documentation - 0 views

  • *name must occur before **name.
  • keys = sorted(keywords.keys()) for kw in keys: print kw, ":", keywords[kw]
  • Note that the list of keyword argument names is created by sorting the result of the keywords dictionary’s keys() method before printing its contents; if this is not done, the order in which the arguments are printed is undefined
  • ...11 more annotations...
  • They are syntactically restricted to a single expression
  • Like nested function definitions, lambda functions can reference variables from the containing scope
  • Coding Style
  • CamelCase for classes
  • lower_case_with_underscores for functions and methods
  • Always use self as the name for the first method argument
  • comments
  • docstrings
  • separate
  • 79 characters
  • 4-space indentation, and no tabs
  •  
    keys = sorted(keywords.keys()) for kw in keys: print kw, ":", keywords[kw]
Benjamin Bandt-Horn

operators - What is the name of ** in python? - Programmers Stack Exchange - 0 views

  • It's not an operator as such, so it doesn't really have a name, but it is defined as a "syntactic rule". So it should be called: "the keyword argument unpacking syntax"
  • # usually a tuple, always an iterable*
  • # usually a dict, always a mapping*
  • ...4 more annotations...
  • kwargs
  • args =
  • *: Iterables are objects that implement the __iter__() method and mappings are objects that implement __iter__() and __getitem__()
  • If you are unsure what to call a particular operator or if it is unnamed, you can always resort to Waka Waka Bang Splat as a reference to help you figure out what to call it. In this case for ** I would call it double-splat, though there are some alternate names for symbols.
  •  
    It's not an operator as such, so it doesn't really have a name, but it is defined as a "syntactic rule". So it should be called: "the keyword argument unpacking syntax"
Benjamin Bandt-Horn

Function overloading in Python: Missing - Stack Overflow - 0 views

  • keyword arguments with default values can go a long way.
  • In Python, I think it's more accepted to use duck typing -- asking what an object can do, rather than what it is
  • it goes against the spirit of Python to worry a lot about what types are passed into methods
  •  
    keyword arguments with default values can go a long way.
Benjamin Bandt-Horn

Binary Search Tree library in Python | Laurent Luce's Blog - 0 views

  • This article is about a Python library I created to manage binary search trees. I will go over the following: Node class Insert method Lookup method Delete method Print method Comparing 2 trees Generator returning the tree elements one by one
  • https://laurentluce@github.com/laurentluce/python-algorithms.git
  • binary search tree
  • ...5 more annotations...
  • Delete method
  • There are 3 possibilities to handle: 1- The node to remove has no child. 2- The node to remove has 1 child. 3- The node to remove has 2 children.
  • look for its successor by going right then left until we reach a leaf
  • if node is None:
  • ‘A’ < ‘B’ is True in Python.
  •  
    This article is about a Python library I created to manage binary search trees. I will go over the following: Node class Insert method Lookup method Delete method Print method Comparing 2 trees Generator returning the tree elements one by one
1 - 4 of 4
Showing 20 items per page