Skip to content

Update functional python #8

@smangham

Description

@smangham

Decorators doesn't follow smoothly from the Lambdas -> Closures line.

We also don't really explain why decorators are useful or give any examples of them. A possible alternate format:

  • Start with lambdas (e.g. minimum of list +1)
  • What if we need to generate many similar lambdas -> function factory (minimum of list +N)
  • What if we want to generalise our function factory -> function as argument (function of list +N)
  • Function factories can be used to staple any behaviour onto a function transparently through decorators
    • Make small 'timing' decorator

This also ties into the issues with some people not realising the %% magic only works in the interpreter and asking for how you time things in scripts.

Also, in the academic class:

  • People don't get __str__ and __repr__ - explain the differences or just remove __repr__
  • Add short comments to each method explaining why they've been defined

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions