GithubHelp home page GithubHelp logo

hhy5277 / python-var-dump Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sha256/python-var-dump

0.0 1.0 0.0 12 KB

PHP's var_dump equivalent function for Python

License: Other

Python 100.00%

python-var-dump's Introduction

var_dump

for python


var_dump is a PHP's var_dump() equivalent function for python. It displays structured information such as type, value etc of a python object, list, tuple, dict & other types.

Installation


using pip

pip install var_dump

Or

clone the project & cd into the python-var_dump directory then run:

python setup.py install

Examples


Example #1:

from var_dump import var_dump

var_dump(123) 					# output: #0 int(123)
var_dump(123.44) 				# output: #0 float(123.44)
var_dump("this is a string") 	# output: #0 str(16) "this is a string"
var_dump(None) # output: 		# output: #0 NoneType(None)
var_dump(True) # output 		# output: #0 bool(True)

Example #2:

you can pass more than one argument:

from var_dump import var_dump

var_dump(123, 123.44, None, False)

Output:

#0 int(123) 
#1 float(123.44) 
#2 NoneType(None) 
#3 bool(False) 

Example #3:

from var_dump import var_dump

class Base(object):

    def __init__(self):
        self.baseProp = (33, 44)
		self.fl = 44.33

class Bar(object):

    def __init__(self):
        self.barProp = "I'm from Bar class"
		self.boo = True


class Foo(Base):

    def __init__(self):
        super(Foo, self).__init__()
        self.someList = ['foo', 'goo']
        self.someTuple = (33, (23, 44), 55)
        self.anOb = Bar()
		self.no = None

foo = Foo()
var_dump(foo)

Output

#0 object(Foo) (6)
    baseProp => tuple(2) 
        [0] => int(33) 
        [1] => int(44) 
    someTuple => tuple(3) 
        [0] => int(33) 
        [1] => tuple(2) 
            [0] => int(23) 
            [1] => int(44) 
        [2] => int(55) 
    no => NoneType(None) 
    someList => list(2) 
        [0] => str(3) "foo"
        [1] => str(3) "goo"
    fl => float(44.33) 
    anOb => object(Bar) (2)
        boo => bool(True) 
        barProp => str(18) "I'm from Bar class"

License: BSD License

python-var-dump's People

Contributors

a904guy avatar lexaf avatar litefeel avatar sha256 avatar todorvelichkov 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.