Commit 692af51a by Dan Krause

Explain Object.factory method in README

closes #95
parent 3e3d2571
...@@ -126,7 +126,22 @@ class GameScore(Object): ...@@ -126,7 +126,22 @@ class GameScore(Object):
pass pass
~~~~~ ~~~~~
And then instantiate it with your parameters: You can also create an Object subclass by string name, with the `Object.factory`
method:
~~~~~ {python}
from parse_rest.datatypes import Object
myClassName = "GameScore"
myClass = Object.factory(myClassName)
print myClass
# <class 'parse_rest.datatypes.GameScore'>
print myClass.__name__
# GameScore
~~~~~
You can then instantiate your new class with some parameters:
~~~~~ {python} ~~~~~ {python}
gameScore = GameScore(score=1337, player_name='John Doe', cheat_mode=False) gameScore = GameScore(score=1337, player_name='John Doe', cheat_mode=False)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment