This repository was archived by the owner on Mar 29, 2021. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork0
Javascript type objects in Python. The module helps us to create javascript objects in the python language :slight_smile:
License
NotificationsYou must be signed in to change notification settings
code-roller/python-javascript-objects
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Javascript type objects in Python
To make a newJsObject
:
importjsobja=jsobj.JsObject({"first_letter":True,# `A` is the first letter of the alphabet"vowel":True,# `A` is a vowel"alphabet_position":1,# `A` is the first letter of the alphabet"consonant":False,# `A` is not a consonant"examples_of_use": ["apple","alkali","algebra","alligator","acid"]# `A` is used in all these words"famous_example":"apple"# Out of all words, apple is the most well known that starts with `A`})
To add an attribute:
a.addAttr("in_hello",False)# adds the attribute `in_hello` and sets it to boolean `False`
To change the value of an existing attribute:
a.setAttr("examples_of_use", ["apple","alkali","algebra","alligator","acid","all"])# changes the list of examples
To delete an attribute:
a.delAttr("consonant")# deletes the consonant attribute
To get the object:
a_object=a.getObj()
To add a method to the object (can also be used to refresh the object after the dictionary is changed):
# define your method as a normal functiondefa_print():print("A is for apple")# add the attributea.addMethod(a_print)# refresh the objecta_object=a.getObj()# call the method (optional)a_object.printA()
Made by these members of the Code Roller team C=
About
Javascript type objects in Python. The module helps us to create javascript objects in the python language :slight_smile:
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Contributors2
Uh oh!
There was an error while loading.Please reload this page.