bpdusk / jsonschema

Automatically exported from code.google.com/p/jsonschema
0 stars 0 forks source link

Python 2.4 problems #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If these lines will be changed:

    # We need to know if the field exists or if it's just Null
    fieldexists = True
    try:
      value = x[fieldname]
    except KeyError:
      fieldexists = False
    finally:
      value = x.get(fieldname)

to 

    # We need to know if the field exists or if it's just Null
    fieldexists = fieldname in x
    value = x.get(fieldname)

Then jsonschema will work in Python 2.4

Cheers
Petr Kobalíček

Original issue reported on code.google.com by kobalicek.petr on 24 Nov 2008 at 2:37

GoogleCodeExporter commented 8 years ago
I believe this would be better as:

fieldexists = False
if x.has_key(fieldname):
    fieldexists = True
    value = x[fieldname]

Original comment by wdier...@gmail.com on 1 Mar 2011 at 5:36