[Tutor] help with augumented assignment y += 1

Norman Khine norman at khine.net
Wed Jul 30 20:09:49 CEST 2008


Hi,
Appologies, there was a typo, in that the first line is:

['1'] ['a1', 'a2', 'a2', 'a2'] [1, 1, 2, 4]

The way the first line relates to the survey is such that, it looks at
the response.xml file and returns what the individual user has
submitted.

So that:

['1'] ['a1', 'a2', 'a2', 'a2'] [1, 1, 2, 4]

['1'] - is the username
['a1', 'a2', 'a2', 'a2'] - is the question code
[1, 1, 2, 4] - is the key value that the user has submited

Whereas the second output, simply returns a list containing a
dictionaries with the actual question properties.

To narrow the my question to specifics, I suppose I would need to make
a dictionary such as:

{options: {'count': count}}

and then relate it back to the survey.xml file so that I can get the 'labels'

        ret = {}
        for option in options:
             if not ret.has_key(option):
                 ret[option] = {'count': 1}
             else:
                 ret[option]['count'] += 1
        return ret

This I think will return a count of all tha answered questions, but
how to generate the options dictionary and relate this to the
survey.xml file to get the related labels?

Hope this makes sense.

Cheers

Norman
On 7/30/08, Emile van Sebille <emile at fenx.com> wrote:
> Norman Khine wrote:
> > Hello,
> >
> > I am writing a poll application, which has two XML files:
> >
>
> Is this entire question consistent?  I ask because when you get to asking
> your question below, it sounds like you're trying to tie together two
> outputs:
>
> <snip and paste from below>
>
> > This returns:
> > ['1'] ['1', '2', '2', '2'] [1, 1, 2, 4]
> > ['0'] ['1', '2', '2'] [2, 2, 3]
>
> ...and
>
> > This returns:
> > [{'question': 'a1', 'options': [[u'Yes', u'No', u"Don't know"]],
> > 'title': u"Is an augumented assignment such as 'x=x + 1' the same as x
> > += 1?"}, {'question': 'a2', 'options': [[u"'x=(x * y) + 1'", u"'x=x
> > *(y + 1)", u"'x=(y + 1) * x'", u'All of the above']], 'title': u"The
> > statement 'x *= y + 1' is equivalent to:"}]
>
> The second is clearly the survey -- it's the first I question.  How do those
> two lines relate to the xml response?
>
> If you could coalesce your example into a single executable or clearly
> relate those two lines to the xlm response it (presumably) derives from
> there's a better chance you'll get a more helpful reply.
>
> Regards,
>
> Emile
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list