How do I get this working?

Richard Chamberlain richard_chamberlain at ntlworld.com
Thu Apr 20 03:12:40 EDT 2000


You were very close...

import uerrors
import sys

    def CheckParams():
                if (len(sys.argv)>5) or (len(sys.argv<2):
                            return uerrors.ERR_WRONGPARAMS
                return uerrors.ERR_NOERROR

You had an 'and' in your version, sys.argv is never going to be above 5 and
below 2 therefore it was just returning ERR_NOERROR which was 0.

Richard

"Martijn van der Kooij" <DeleteThisDev at stabiplan.nl> wrote in message
news:8dm932$q13$1 at porthos.nl.uu.net...
> Hi,
>
> I'm very new to Python and just started to port a application to Python,
but
> i have a problem.
>
> I've declared a unit with some constants this way:
>
> ERR_NOERROR = 0
> ERR_WRONGPARAMS = 1
> ERR_NOREPORTFILE = 2
> ERR_NOOPTIONSFILE = 3
> ERR_NOMAINPLAYERFOUND = 4
> ERR_PARSINGREPORT = 5
> ERR_READINGREPORTFILE = 6
>
> this is imported into another module:
>
> import uerrors
> import Sys
>
> def CheckParams():
>     if (len(sys.argv) > 5) and (len(sys.argv) < 2):
>         return uerrors.ERR_WRONGPARAMS
>     return uerrors.ERR_NOERROR
>
> def DomainBot():
>     res = CheckParams()
>     if ret:
>         return res
>     return uerrors.ERR_NOERROR
>
> which is used in the main program.
>
> The problem is that it looks like that res = CheckParams() returns the
> function instead of one of the error codes.
>
> Probably i'm docing something terribly wrong here. But can someone help me
> getting this working?
>
> Martijn
>
>
>
>





More information about the Python-list mailing list