Norman Khine wrote:
Hello,
I am writting a little module that validates if a member has completed
all the previous exams before they can access the current exam.
The way, I thought it may work is to:
Search all previous exams from the previous topics and check to see if
the user has passed t
Hello,
I am writting a little module that validates if a member has completed
all the previous exams before they can access the current exam.
The way, I thought it may work is to:
Search all previous exams from the previous topics and check to see if
the user has passed them, if not, then the
On Tue, 28 Aug 2007, Kent Johnson wrote:
> Terry Carroll wrote:
>
> > 1A) a variation of option 1 (which is why I said "depending on how you
> > count" above): duck-typing with error recovery.
> >
> > def incr(n):
> > "returns an incremented value of n, or None if n is not incrementable"
> >
Terry Carroll wrote:
> 1A) a variation of option 1 (which is why I said "depending on how you
> count" above): duck-typing with error recovery.
>
> def incr(n):
> "returns an incremented value of n, or None if n is not incrementable"
> try:
> return n + 1
> except:
> return None
>
On Tue, 28 Aug 2007, Michael wrote:
> I now have several methods in my arsenal and they all look quite simple,
> now that I know. Just wondering, when would you use isInstance()?
Well, as this thread has shown, I'm no expert, but let me take a stab on
it. If nothing else, we'll all learn somet
Thanks Everybody
I now have several methods in my arsenal and they all look quite simple,
now that I know. Just wondering, when would you use isInstance()?
Thanks
Alan Gauld wrote:
> "Michael" <[EMAIL PROTECTED]> wrote
>
>
>> to check and make sure that an integer is entered and the program
On Mon, 27 Aug 2007, Kent Johnson wrote:
> isinstance can take a tuple of types as its second argument
>
> Note that
>isinstance(thing, (list, tuple))
>
> and
>type(thing) in [list, tuple]
>
> are not equivalent. The first will be true for objects whose type is a
> subclass of list
Terry Carroll wrote:
> I ended up writing a short isListOrTuple function that went something
> like this:
>
> def isListOrTuple(thing):
> result = False
> if isinstance(thing, list): result = True
> if isinstance(thing, tuple): result = True
> return result
isinstance can take a tuple o
On Mon, 27 Aug 2007, Kent Johnson wrote:
> For the built-in types, since Python 2.2 the familiar name (int, str,
> float, list, dict, set) *is* the type and you can compare to that
> directly, e.g.:
>
> In [13]: type(3)==int
> Out[13]: True
> In [14]: type([]) == list
> Out[14]: True
That is s
"Kent Johnson" <[EMAIL PROTECTED]> wrote
>> if type(x) == type(int()):
>>
> For the built-in types, since Python 2.2 the familiar name (int,
> str,
> float, list, dict, set) *is* the type and you can compare to that
> directly, e.g.:
>
> In [13]: type(3)==int
> Out[13]: True
I knew I should be
Alan Gauld wrote:
> "Michael" <[EMAIL PROTECTED]> wrote
>> trying to use the Type() function but I cannot work out how to check
>> the
>> return value? Caomparing it to 'int' or 'str' isn't working,
>
> The easiest way is to compare to another type:
>
> x = 42
> if type(x) == type(int()):
>
> o
"Michael" <[EMAIL PROTECTED]> wrote
> to check and make sure that an integer is entered and the program
> not
> crashing when a naughty user enters a character instead.
John F has already pointed you to the use of try/except for this,
however...
> trying to use the Type() function but I cannot
On 27/08/07, Michael <[EMAIL PROTECTED]> wrote:
> I am fairly new to Python and I wish to validate input. Such as wanting
> to check and make sure that an integer is entered and the program not
> crashing when a naughty user enters a character instead. I have been
> trying to use the Type() functio
On 27-Aug-07, at 2:20 PM, Michael wrote:
> Hi
>
> I am fairly new to Python and I wish to validate input. Such as
> wanting
> to check and make sure that an integer is entered and the program not
> crashing when a naughty user enters a character instead. I have been
> trying to use the Type() f
Hi
I am fairly new to Python and I wish to validate input. Such as wanting
to check and make sure that an integer is entered and the program not
crashing when a naughty user enters a character instead. I have been
trying to use the Type() function but I cannot work out how to check the
return
15 matches
Mail list logo