FAQ
"Gregory Ewing" <greg.ewing at canterbury.ac.nz> wrote in message news:95ntriFod7U1 at mid.individual.net...
Tim Roberts wrote:
Andre Majorel wrote:
Anyway, it seems the Python way to declare a function is

def f ():
pass
No, that DEFINES a function.
Actually, it's more illuminating to say that it *creates* a function.

The 'def' statement in Python is an executable statement. Executing
it has the effect of creating a function object and binding it to
the indicated name. Before that has happened, attempting to execute
any code referring to that name will fail.

Conversely, the function name doesn't need to be bound until the
code referring to it is actually executed. So...
def g():
return f()
def f():
return 3
print g()
works because by the time g is *called*, both def statements
have been executed, and both function names have therefore been
bound.

--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Hello folks - I understand all of the above (well I suppose intuitively based on the below) but had a longtime question and this is an opportunity to ask. I have a B.A. in Linguistics and there was a topic they teach 'binding theory'. This was taught in the graduate classes or some that I didn't take. I will bet that these things are related - binding theory and this tossing around of words in software development like 'bound' and 'binding them'. So I am wondering if you learned this in Computer Science or Computer Engineering?, on the job? Is there a different theory in Computer Science than I would find in linguistics?

OK - so I just grabbed one of my semantics books and found one thing in the index 'bound occurence of a reference in a formula', doesn't really help. It is in the Predicate Logic section and just used while he is trying to explain something else, used in context.

Thanks

Patty
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110613/13faf289/attachment.html>

Search Discussions

  • Ethan Furman at Jun 14, 2011 at 5:55 am

    Patty wrote:
    So I am wondering if you learned this
    in Computer Science or Computer Engineering?, on the job?
    I learned it on this list. :)

    ~Ethan~
  • Patty at Jun 14, 2011 at 1:59 pm
    ----- Original Message -----
    From: "Ethan Furman" <ethan at stoneleaf.us>
    To: <python-list at python.org>
    Sent: Monday, June 13, 2011 10:55 PM
    Subject: Re: Binding was Re: Function declarations ?

    Patty wrote:
    So I am wondering if you learned this
    in Computer Science or Computer Engineering?, on the job?
    I learned it on this list. :)

    ~Ethan~
    --
    http://mail.python.org/mailman/listinfo/python-list
    Smarty - I guess I can say the same thing - I understand it

    or was I supposed to add '+1' ? I learned that on this list ;)

    Patty

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 14, '11 at 2:54a
activeJun 14, '11 at 1:59p
posts3
users2
websitepython.org

2 users in discussion

Patty: 2 posts Ethan Furman: 1 post

People

Translate

site design / logo © 2022 Grokbase