GithubHelp home page GithubHelp logo

thehale / multicounter Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 3.0 183 KB

A simple, elegant counter with support for counting multiple things at once.

License: Mozilla Public License 2.0

Python 91.26% Dockerfile 8.74%
python counter statistics

multicounter's Introduction

MultiCounter

A simple, elegant counter with support for counting multiple things at once.

Joseph Hale's software engineering blog

Installation

Pip

pip install multicounter

Poetry

poetry add multicounter

Usage

from multicounter import MultiCounter
mc = MultiCounter()

# Choose a name for your counter and start counting!
mc.foo += 1

# You can choose an initial value for a counter ...
mc.bar = 42
# ... and increment or decrement it however you like.
mc.bar -= 4

print(mc.get_counters())
# {'foo': 1, 'bar': 38}

Contributing

See CONTRIBUTING.md

The Legal Stuff

`MultiCounter` by Joseph Hale is licensed under the terms of the Mozilla
Public License, v 2.0, which are available at https://mozilla.org/MPL/2.0/.

You can download the source code for `MultiCounter` for free from
https://github.com/jhale1805/multicounter.

TL;DR

You can use files from this project in both open source and proprietary applications, provided you include the above attribution. However, if you modify any code in this project, or copy blocks of it into your own code, you must publicly share the resulting files (note, not your whole program) under the MPL-2.0. The best way to do this is via a Pull Request back into this project.

If you have any other questions, you may also find Mozilla's official FAQ for the MPL-2.0 license insightful.

If you dislike this license, you can contact me about negotiating a paid contract with different terms.

Disclaimer: This TL;DR is just a summary. All legal questions regarding usage of this project must be handled according to the official terms specified in the LICENSE file.

Why the MPL-2.0 license?

I believe that an open-source software license should ensure that code can be used everywhere.

Strict copyleft licenses, like the GPL family of licenses, fail to fulfill that vision because they only permit code to be used in other GPL-licensed projects. Permissive licenses, like the MIT and Apache licenses, allow code to be used everywhere but fail to prevent proprietary or GPL-licensed projects from limiting access to any improvements they make.

In contrast, the MPL-2.0 license allows code to be used in any software project, while ensuring that any improvements remain available for everyone.

multicounter's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar thehale avatar

Stargazers

 avatar

Watchers

 avatar  avatar

multicounter's Issues

[IDEA] Add option to `reset` a multicounter

Is your feature request related to a problem? Please describe.
It would be nice to reset an existing multicounter so that all counters are zeroed out

Describe the solution you'd like

from multicounter import MultiCounter
mc = MultiCounter()

mc.foo = 2  # foo now equals 2
mc.foo += 1 # foo now equals 3

mc.reset()  # foo now equals 0
mc.reset(hard=True)  # foo no longer exists until re-created.

Describe alternatives you've considered
I could create a new multicounter (equivalent to the "hard reset" shown above), but that doesn't preserve the existing counter names I'd previously been using.

Additional context
n/a

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.