Skip to content

Tiago-0liveira/JsObjects-for-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Js Objects in Python


Made with :

  • Literally only one class
  • Basic Python Knowledge
  • Recursion
  • Dunder/magic methods to sharp some edges

How can i use it ?

In Javascript:

let obj = {
    price: 2000,
    audi: {
        engine: 100
    }
}
console.log(obj.price)
console.log(obj.audi)
console.log(obj.audi.price)
We would get this
>>> 2000
>>> {engine: 100}
>>> 100

In Python:

dict = {
    "price": 2000,
    "audi": {
        "engine": 100
    }
}
print(dict["price"])
print(dict["audi"])
print(dict["audi"]["price"])
Obviously same output
>>> 2000
>>> {engine: 100}
>>> 100

So i made this javascript concept in python:

from JsObject import JsObject
dict = {
    "price": 2000,
    "audi": {
        "engine": 100
    }
}
#with this u just need to pass the dictionary as a parameter to the 
#(for now only works with dictionaries)
#class JsObject as it follows -->

obj = JsObject(dict)
print(obj.price)
print(obj.audi)
print(obj.audi.price)

Same output but with less effort:

>>> 2000
>>> {engine: 100}
>>> 100

I'l be reading the suggestions and issues so make sure u give me headaches :D

Anything more u can contact me via Discord -> tiagooo#9119

About

this is a python dictionary dot notation library, just pass your dictionary to the JsObject and its done

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages