From 406967e8e1a45844994c63ac80cb8cbea1247f86 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 3 Sep 2016 13:54:36 -0400 Subject: [PATCH] Define subpod above pod --- wolframalpha/__init__.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/wolframalpha/__init__.py b/wolframalpha/__init__.py index df6b8e0..8a249b8 100644 --- a/wolframalpha/__init__.py +++ b/wolframalpha/__init__.py @@ -121,6 +121,22 @@ class Result(ErrorHandler, Document): return {pod.title: pod.text for pod in self.pods} +class Subpod(Document): + """ + Holds a specific answer or additional information relevant to said answer. + """ + def __init__(self, *args, **kwargs): + super(Subpod, self).__init__(*args, **kwargs) + self.title = self['@title'] + self.text = self['plaintext'] + self.img = self['img'] + # Allow images to be accessed in a consistent way, + # as a list, regardless of how many there are. + if type(self.img) != list: + self.img = [self.img] + self.img = list(map(Image, self.img)) + + class Pod(ErrorHandler, Document): """ Groups answers and information contextualizing those answers. @@ -154,22 +170,6 @@ class Pod(ErrorHandler, Document): return next(iter(self.subpods)).text -class Subpod(Document): - """ - Holds a specific answer or additional information relevant to said answer. - """ - def __init__(self, *args, **kwargs): - super(Subpod, self).__init__(*args, **kwargs) - self.title = self['@title'] - self.text = self['plaintext'] - self.img = self['img'] - # Allow images to be accessed in a consistent way, - # as a list, regardless of how many there are. - if type(self.img) != list: - self.img = [self.img] - self.img = list(map(Image, self.img)) - - class Assumption(Document): @property def text(self):