Deutsch   English   Français   Italiano  
<binding-20240121183433@ram.dialup.fu-berlin.de>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.lisp
Subject: Re: Is Lexical Binding The Norm Yet?
Date: 21 Jan 2024 17:35:34 GMT
Organization: Stefan Ram
Lines: 42
Expires: 1 Dec 2024 11:59:58 GMT
Message-ID: <binding-20240121183433@ram.dialup.fu-berlin.de>
References: <uo1i8c$jbru$2@dont-email.me> <86r0ijsdyj.fsf@williamsburg.bawden.org> <871qajgr9k.fsf@nightsong.com> <uo4id7$14ifr$1@dont-email.me> <jwvedeg510z.fsf-monnier+comp.lang.lisp@gnu.org> <uo9cbb$264u2$1@dont-email.me> <20240117122629.806@kylheku.com> <uo9o4k$281t4$1@dont-email.me> <qitjqi521brjnpvebd2b1bidrhevocbt62@4ax.com> <uod249$30h1g$3@dont-email.me> <oc8lqilj3c2sromuq36mp3vuee9uven9mo@4ax.com> <uoeme2$39ohi$4@dont-email.me> <e5eoqi1116aosn2sb2oam0b8jdqv9mg0tb@4ax.com> <uohonn$3sm2o$2@dont-email.me> <86y1cjqpei.fsf@williamsburg.bawden.org> <lookup-20240121111504@ram.dialup.fu-berlin.de> <len-20240121124048@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de EEZCq/LWvobtE/N49QBU8Q44xvFqqVlSPQ3yJUEAACIPcd
Cancel-Lock: sha1:h6T6HUKrjmlU0MrXZjdgGEN6KKU= sha256:8rSihSKtYTIQOpeLu/JAD3M2RjVR/0o8rmylbFgVQwo=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
	Distribution through any means other than regular usenet
	channels is forbidden. It is forbidden to publish this
	article in the Web, to change URIs of this article into links,
        and to transfer the body without this notice, but quotations
        of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
	services to mirror the article in the web. But the article may
	be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>the Python standard library assumes class-based objects.)

  Since the thread is about "binding": Python can be very 
  explicit when it comes to binding (should you need it).

  main.py

import types

x = 2

def f():
    return x

# prints "2"
print( f() )

g = types.FunctionType( f.__code__, { 'x': 4 } )

# prints "4"
print( g() )

h = types.FunctionType( f.__code__, globals() )

# prints "2"
print( h() )

def a():
    x = 3
    
    # prints "2"
    print( f() )

    # prints "3"
    print( types.FunctionType( f.__code__, locals() )() )

    # prints "2"
    print( types.FunctionType( f.__code__, globals() )() )

a()