Deutsch English Français Italiano |
<v5bcfo$7182$4@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Sebastian Wells <sebastian@here.com.invalid> Newsgroups: comp.os.linux.advocacy Subject: Re: Languages (was: Re: More Funny Stuff From The Joke Python) Date: Mon, 24 Jun 2024 08:58:32 -0000 (UTC) Organization: A noiseless patient Spider Lines: 38 Message-ID: <v5bcfo$7182$4@dont-email.me> References: <17d716103c089ab3$7951$675878$802601b3@news.usenetexpress.com> <ej496jd0tb59u2l0nqtghq3u9ahhmann3s@4ax.com> <lcjnnuF896hU5@mid.individual.net> <kma96j1no1tp926ctejldkdk2c19aeruft@4ax.com> <lcjvk1F9n7aU1@mid.individual.net> <2ej96j1mbvgiok4q5c57vdlo94itpfu5dt@4ax.com> <v42jjg$2nd7m$1@dont-email.me> <v42vg5$2u4lh$15@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 24 Jun 2024 10:58:33 +0200 (CEST) Injection-Info: dont-email.me; posting-host="2787d93bb44b66d3fe4dceb9b5d2d9b9"; logging-data="230658"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/VvGMZSquUxzwZ6jT76u42MjUOAypdd5o=" User-Agent: Pan/0.154 (Izium; 517acf4) Cancel-Lock: sha1:UajDxEY3Gy9d4wMwfQGybdlbVak= Bytes: 2753 On Sun, 9 Jun 2024 01:11:33 -0000 (UTC), Lawrence D'Oliveiro wrote: > On Sat, 8 Jun 2024 21:48:32 -0000 (UTC), vallor wrote: > >> My go-to language has always been perl ... > > I did Perl for some years, but always felt that there were things > potentially going on that I could never quite understand. > > When I tried Python for the first time, that feeling went away. It was > always clear to me what the code was doing, and why--no mysterious > magic, > no surprises. Then you haven't delved deeply enough into Python. I had to debug a project where code similar to the following was calling invisible methods: foo.bar = 'baz' It turned out that the statement above does not overwrite the value foo.bar with a string, because bar's value was a special object that overrode the assignment operator by virtue of being the value of an attribute on another object. "foo.bar" without an assignment was also overridden, for the same reason. The thing that made foo.bar's actual value special was that its class defined the magic methods __get__, __set__, and __delete__. I don't remember how I discovered the existence of this object. Even Python's getattr() and setattr() functions are overridden. This "feature" of Python is little known. The invisibility of these objects is so bullet-proof that the only way you'd become aware of one is if one of the three magic methods threw an exception.