Giter VIP home page Giter VIP logo

python-tools's Introduction

Tools

Helpful abstract tools (functions, classes, ... ) for coding in Python. Accessible via, for example, import tools; tools.Object(). Particular highlights:

  • Object (and its siblings SortedObject, OrderedObject), which are dictionaries which can behave a bit like classes, by allowing for . attribute look up in place of [] notation.
  • Record, which can be thought of as a namedtuple with mutable entries.
  • deepgetattr and deepsetattr which allow for getting and setting attributes of (subsubsub-...)subattributes.
  • set_context_variable, which allows for easily temporarily setting variables to particular values in contexts.
  • loc_count, for counting the number of lines of code, comments and whitespace of the files in a directory. Also comes in a script form: just run python -m tools.scripts.loc_count in whatever directory you like!

Plus a few more exotic things:

  • subclass_tracker, which allows for keeping track of and subsequently locating particular subclasses of a given class.
  • DynamicSubclassingMixin which allows for dynamically changing the class of an instance on the fly.
  • WithAdder, which is a mixin that allows for +-ing contexts together.
  • classproperty, which marks a method as being both a classmethod and a property. (It's not possible to mix the two usual decorators.)
  • combomethod, which marks a method as being both a classmethod and an instance method.

And a few boring-but-useful things:

  • rangeinf, which is a range that allows for inf to be passed as the second argument.
  • nonneg_list, which is a list that doesn't allow negative indexing.
  • deldict, which is a dictionary that doesn't mind bad del attempts.
  • re_sub_recursive for recursively regex'ing a string.
  • AddBase, whose __add__ method always returns whatever the other thing added to it was.
  • Some basic geometry collisions.

...and other stuff besides!

python-tools's People

Contributors

patrick-kidger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.