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


Groups > comp.lang.python > #108458

Re: TypeError: unorderable types: function() < int()

From Ben Finney <ben+python@benfinney.id.au>
Newsgroups comp.lang.python
Subject Re: TypeError: unorderable types: function() < int()
Date 2016-05-10 19:16 +1000
Message-ID <mailman.558.1462871831.32212.python-list@python.org> (permalink)
References <1fc32599-0264-460c-8178-057558d19be5@googlegroups.com> <858tziff27.fsf@benfinney.id.au>

Show all headers | View raw


George Molsom <georgieelize00@gmail.com> writes:

> I have created a program in class 'make a game that tests how good
> people are at guessing when 10 seconds has elapsed.'

Welcome! You may want to join the dedicated beginners forum
<URL:https://mail.python.org/mailman/listinfo/tutor> where we
collaboratively teach foundational Python concepts.

> Traceback (most recent call last):
>   File "E:/Computing/Python/Little book of challenges/Challenge 6 10 seconds experiment.py", line 20, in <module>
>     if totaltime < 10:
> TypeError: unorderable types: function() < int()

That's right. The ‘totaltime’ name refers to a function. To ask whether
an integer object is less than a function object is not a meaningful
comparison.

If you want to *call* the function, use the “call this function”
syntax::

    totaltime()

That will evaluate to the return value when you call it, so use the
return value::

    if totaltime() < 10:
        # …

-- 
 \          “There's a certain part of the contented majority who love |
  `\            anybody who is worth a billion dollars.” —John Kenneth |
_o__)                                            Galbraith, 1992-05-23 |
Ben Finney

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


Thread

TypeError: unorderable types: function() < int() George Molsom <georgieelize00@gmail.com> - 2016-05-10 02:01 -0700
  Re: TypeError: unorderable types: function() < int() Ben Finney <ben+python@benfinney.id.au> - 2016-05-10 19:16 +1000
  Re: TypeError: unorderable types: function() < int() Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-05-10 08:19 -0400
  Re: TypeError: unorderable types: function() < int() Chris Angelico <rosuav@gmail.com> - 2016-05-10 22:31 +1000
  Re: TypeError: unorderable types: function() < int() Steven D'Aprano <steve@pearwood.info> - 2016-05-10 23:40 +1000
    Re: TypeError: unorderable types: function() < int() Chris Angelico <rosuav@gmail.com> - 2016-05-10 23:47 +1000
      Re: TypeError: unorderable types: function() < int() Steven D'Aprano <steve@pearwood.info> - 2016-05-10 23:55 +1000
  Re: TypeError: unorderable types: function() < int() Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-05-10 19:57 -0400

csiph-web