Skip to content

Instantly share code, notes, and snippets.

@greggyNapalm
Created July 8, 2012 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greggyNapalm/45e87c4a202d81fd63ee to your computer and use it in GitHub Desktop.
Save greggyNapalm/45e87c4a202d81fd63ee to your computer and use it in GitHub Desktop.
>>> tp = [10, 45, 50, 100, 150, 300, 500, 1000, 1500, 2000, 3000, 10000]
>>> bound = {
... 'num': 0,
... 'percentil': 0,
... }
>>>
>>> __vals = [bound] * len(tp)
>>> boundaries = dict(zip(tp, __vals))
>>> boundaries
{10000: {'num': 0, 'percentil': 0}, 100: {'num': 0, 'percentil': 0}, 1000: {'num': 0, 'percentil': 0}, 10: {'num': 0, 'percentil': 0}, 300: {'num': 0, 'percentil': 0}, 45: {'num': 0, 'percentil': 0}, 2000: {'num': 0, 'percentil': 0}, 50: {'num': 0, 'percentil': 0}, 500: {'num': 0, 'percentil': 0}, 150: {'num': 0, 'percentil': 0}, 3000: {'num': 0, 'percentil': 0}, 1500: {'num': 0, 'percentil': 0}}
>>> boundaries[10000]['num'] += 1
>>> boundaries
{10000: {'num': 1, 'percentil': 0}, 100: {'num': 1, 'percentil': 0}, 1000: {'num': 1, 'percentil': 0}, 10: {'num': 1, 'percentil': 0}, 300: {'num': 1, 'percentil': 0}, 45: {'num': 1, 'percentil': 0}, 2000: {'num': 1, 'percentil': 0}, 50: {'num': 1, 'percentil': 0}, 500: {'num': 1, 'percentil': 0}, 150: {'num': 1, 'percentil': 0}, 3000: {'num': 1, 'percentil': 0}, 1500: {'num': 1, 'percentil': 0}}
# How to make eache boundaries value independent data structure(not a link to the same obj)?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment