GithubHelp home page GithubHelp logo

aquarioos / dvik-print Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 13 KB

Funkcja ładnie wypisująca obiekty z możliwością ustawienia wielkości wcięć i limitu pokazywanych kluczy/elementów.

License: MIT License

Python 100.00%

dvik-print's Introduction

dvik-print

Funkcja ładnie wypisująca obiekty z możliwością ustawienia wielkości wcięć i limitu pokazywanych kluczy/elementów.

Instalacja

Instalacja pakietu z GitHuba:

pip install git+https://github.com/aquarioos/dvik-print/#egg=dvik-print

Aktualizacja pakietu:

pip install git+https://github.com/aquarioos/dvik-print/#egg=dvik-print -U

Użycie

import dvik_print as dvp
import datetime as dt

# mamy obiekt o
o = {
    'lista': ['el1', 'el2', 1, 2, 3, 4, None, False],
    'zbiór': {1, 2, 1, 2, 'a', 'a', 'b', 'b'},
    'krotka': ('oto', 'elementy', 'naszej', 'krotki'),
    ('krotka', 'klucz'): {
        'klucz1': ['jakaś', 'lista', 123],
        'klucz2': dt.datetime.now(),
        'klucz3': dt
    },
}

# deklarujemy obiekt dvp.PrettyPrint`
pp = dvp.PrettyPrint(tab=2, head=3, tail=2, max_str_len=50, show_line=True, filename=__file__)

# obiekt jest wywoływalny
# w ten sposób wypisze na standardowe wyjście obiekt o
pp(o, var='zmienna')

wynik:

C:\Users\Daniel\GitHub\dvik-print\run_tests.py:32
zmienna = {
  u'krotka': (
    u'oto',
    u'elementy',
    u'naszej',
    u'krotki',
  ),
  u'zbiór': {
    u'a',
    1,
    2,
    u'b',
  },
  u'lista': [
    u'el1',
    u'el2',
    1,
    ...
    None,
    False,
  ],
  (u'krotka', u'klucz'): {
    u'klucz1': [
      u'jakaś',
      u'lista',
      123,
    ],
    u'klucz3': <module 'datetime' (built-in)>,
    u'klucz2': datetime.datetime(2018, 7, 11, 17, 35, 43, 44000),
  },
}

Można także zadeklarować bez żadnych parametrów. Wtedy będą użyte wartości domyślne dla klasy PrettyPrint.

pp_domyslny = PrettyPrint()
pp_domyslny(O)

wynik:

{
    u'krotka': (
        u'oto',
        u'elementy',
        ...
        u'krotki',
    ),
    u'zbiór': {
        u'a',
        1,
        ...
        u'b',
    },
    ...
    (u'krotka', u'klucz'): {
        u'klucz1': [
            u'jakaś',
            u'lista',
            123,
        ],
        u'klucz3': <module 'datetime' (built-in)>,
        u'klucz2': datetime.datetime(2018, 7, 11, 17, 39, 22, 528000),
    },
}

dvik-print's People

Contributors

aquarioos avatar

Stargazers

Piotr R. Konopelko avatar

Watchers

 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.