Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85460

Re: Varable parsing error with python

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.python
Subject Re: Varable parsing error with python
Date 2015-02-10 18:24 +0000
Organization A noiseless patient Spider
Message-ID <mbdid6$1i2$3@dont-email.me> (permalink)
References <CAFo8oMD+JZPuw3WedDOPDUo1+M+Qh-08rd57SfZneFFAG7u4mQ@mail.gmail.com> <mailman.18599.1423553990.18130.python-list@python.org>

Show all headers | View raw


On Tue, 10 Feb 2015 18:39:42 +1100, Chris Angelico wrote:

> On Tue, Feb 10, 2015 at 6:30 PM, OmPs <torque.india@gmail.com> wrote:
>>     def _getPackgeVersion(xmlfile, p):
>>         package = str(p)
>>         if isinstance(fpmdict["application"]["package"], list):
>>             for i in fpmdict["application"]["package"]:
>>                 if i["@name"] == p:
>>                     _pkgVersion = i["version"]
>>         else:
>>             _pkgversion = fpmdict["application"]["package"]["version"]
>>             return _pkgVersion
> 
> One of your branches doesn't have a return statement in it, so Python
> just returns None. You may want to unindent that return statement one
> level.

Even if he unindents the return, it will still return None if it doesn't 
find an i such that i["@name"] == p, as _pkgVersion only gets set if such 
a match is found.

Could this be cause by eg a string case match issue? Perhaps:

if i["@name"].lower() == p.lower():

would be a better comparison to use?

-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Varable parsing error with python Chris Angelico <rosuav@gmail.com> - 2015-02-10 18:39 +1100
  Re: Varable parsing error with python Denis McMahon <denismfmcmahon@gmail.com> - 2015-02-10 18:24 +0000
    Re: Varable parsing error with python Dave Angel <davea@davea.name> - 2015-02-10 15:40 -0500

csiph-web