[Tutor] elementtree, lists, and dictionaries
Luis N
tegmine at gmail.com
Fri Feb 18 00:02:09 CET 2005
Thanks that's much nicer.
On Fri, 11 Feb 2005 22:28:55 -0500, Kent Johnson <kent37 at tds.net> wrote:
> If you iterate over the author nodes you can check the user name and password of each in turn.
>
> Not tested code!
>
> def authenticateAuthor(author, password):
> authorxml = 'author.xml'
> path = os.path.join(xml, authorxml)
> if not os.path.exists(path):
> return False, False
> else:
> tree = E.ElementTree(file=path)
> for authorNode in tree.getiterator('author'):
> user = authorNode.find('user').text
> pass = authorNode.find('password').text
>
> if author == user:
> if password == pass:
> return True, True
> else:
> return False, True
>
> return False, True
More information about the Tutor
mailing list