Re: Data model and attribute resolution in subclasses
On Monday, March 2, 2020 at 3:12:33 PM UTC-6, Marco Sulla wrote: > Is your project published somewhere? What changes have you done to the > interpreter? I'm writing my own mess: https://github.com/rockobonaparte/cloaca It's a .NET Pythonish interpreter with the distinction of using a whole lot of async-await so I can do expressive game scripting with it in one thread. If IronPython had a handle on async-await then I'd probably not be doing this at all. Well, it was also a personal education project to learn me some Python internals for an internal company job change, but they aren't interested in me at all. :( I still hack with it because I got far enough to have a REPL I could dump into Unity and it immediately looked very useful. -- https://mail.python.org/mailman/listinfo/python-list
Re: Data model and attribute resolution in subclasses
On Monday, March 2, 2020 at 7:09:24 AM UTC-6, Lele Gaifax wrote: > Yes, you just used it, although you may have confused its meaning: > Yeah I absolutely got it backwards. That's a fun one I have to fix in my project now! -- https://mail.python.org/mailman/listinfo/python-list
Re: Help building python application from source
> I think I have the solution, but can I ask you why are you creating a > bitcoin server? > Yes. I am a crypto anarchist. I have a bitcoin node to do my part to running the bitcoin network and help remain it decentralized and resilient. The more people that run a node the better it is. When it comes to hosting servers I believe I am able to do so in a highly secure manner. So I am doing my part in secure the bitcoin network and documenting what I do to help others do the same thing. I support the bitcoin project because it is a liberty enhancing technology to counter act over reaching government and expanding tyranny. People have a right to financial privacy. And the world needs a secure financial network to replace the existing institutional one that suffers from fraud and theft.In a cyber dystopian world we live in there is a war on cash and privacy to push us into a digital monetary system where governments are able to spy on and control everything and everyone. If there is a need for digital money let it be one that supports liberty instead of weakening it. It is vital that cypher tech outpaces the police state. What we do determines the future. We can let ourselves be enslaved and passive. Or we can be active and support the solutions that create a better world and preserve what is good. Right now it is a full node and not used for any other services or purposes. If possible I would like to add electrumx so users of the electrum wallet can use my server. Electrum is a very popular wallet and is what comes pre installed with TAILS. -- lee.chif...@secmail.pro PGP 97F0C3AE985A191DA0556BCAA82529E2025BDE35 -- https://mail.python.org/mailman/listinfo/python-list
Re: Changing local vars via `locals()`
On 03/02/2020 05:31 PM, Makoto Kuwata wrote: Can anyone explain about difference between above two? Why it is possiable to change local var via `locals()` only in class definition? My Stackoverflow answer (https://stackoverflow.com/q/7969949/208880): Each of `globals()`, `locals()`, and `vars()` return a dictionary: globals() always returns the dictionary of the module namespace locals() always returns a dictionary of the current namespace vars() returns either a dictionary of the current namespace (if called with no argument) or the dictionary of the argument. locals and vars could use some more explanation. If locals() is called inside a function, it updates a dict with the values of the current local variable namespace (plus any closure variables) as of that moment and returns it. Multiple calls to locals() in the same stack frame return the same dict each time - it's attached to the stack frame object as its f_locals attribute. The dict's contents are updated on each locals() call and each f_locals attribute access, but only on such calls or attribute accesses. It does not automatically update when variables are assigned, and assigning entries in the dict will not assign the corresponding local variables: import inspect def f(): x = 1 l = locals() print(l) locals() print(l) x = 2 print(x, l['x']) l['x'] = 3 print(x, l['x']) inspect.currentframe().f_locals print(x, l['x']) f() gives us: {'x': 1} {'x': 1, 'l': {...}} 2 1 2 3 2 2 The first print(l) only shows an 'x' entry, because the assignment to l happens after the locals() call. The second print(l), after calling locals() again, shows an l entry, even though we didn't save the return value. The third and fourth prints show that assigning variables doesn't update l and vice versa, but after we access f_locals, local variables are copied into locals() again. Two notes: This behavior is CPython specific -- other Pythons may allow the updates to make it back to the local namespace automatically. In CPython 2.x it is possible to make this work by putting an exec "pass" line in the function. This switches the function to an older, slower execution mode that uses the locals() dict as the canonical representation of local variables. If locals() is called outside a function it returns the actual dictionary that is the current namespace. Further changes to the namespace are reflected in the dictionary, and changes to the dictionary are reflected in the namespace: class Test(object): a = 'one' b = 'two' huh = locals() c = 'three' huh['d'] = 'four' print huh gives us: { 'a': 'one', 'b': 'two', 'c': 'three', 'd': 'four', 'huh': {...}, '__module__': '__main__', } So far, everything I've said about locals() is also true for vars()... here's the difference: vars() accepts a single object as its argument, and if you give it an object it returns the __dict__ of that object. For a typical object, its __dict__ is where most of its attribute data is stored. This includes class variables and module globals: class Test(object): a = 'one' b = 'two' def frobber(self): print self.c t = Test() huh = vars(t) huh['c'] = 'three' t.frobber() which gives us: three Note that a function's __dict__ is its attribute namespace, not local variables. It wouldn't make sense for a function's __dict__ to store local variables, since recursion and multithreading mean there can be multiple calls to a function at the same time, each with their own locals: def f(outer): if outer: f(False) print('Outer call locals:', locals()) print('f.__dict__:', f.__dict__) else: print('Inner call locals:', locals()) print('f.__dict__:', f.__dict__) f.x = 3 f(True) which gives us: Inner call locals: {'outer': False} f.__dict__: {'x': 3} Outer call locals: {'outer': True} f.__dict__: {'x': 3} Here, f calls itself recursively, so the inner and outer calls overlap. Each one sees its own local variables when it calls locals(), but both calls see the same f.__dict__, and f.__dict__ doesn't have any local variables in it. -- https://mail.python.org/mailman/listinfo/python-list
Changing local vars via `locals()`
Hi, folks. I know that it is not possible to change local vars via `locals()` (except in module-level). ``` import sys def f1(): x = 1 d = locals() d['x'] = 2 print(x) #=> 1 (not changed) f1() ``` But I found that it is possible in class definition. ``` import sys class Foo: x = 1 d = locals() d['x'] = 2 print(x) #=> 2 (changed!!!) ``` Can anyone explain about difference between above two? Why it is possiable to change local var via `locals()` only in class definition? -- https://mail.python.org/mailman/listinfo/python-list
Why there's no __json__()?
As title. For example, `copy.copy` can use the __copy__() method of a class, if defined. Is this not possible with `json`? -- https://mail.python.org/mailman/listinfo/python-list
Re: Why this message was rejected?
Ok, I sent a message as I did before to the discussion "Re: Friday Finking: Poly more thick", with only "test" as body. On Mon, 2 Mar 2020 at 22:48, Marco Sulla wrote: > > On Mon, 2 Mar 2020 at 22:36, Ethan Furman wrote: > > Questions like this should go to python-list-owner at python dot org. If > > this message hadn't been flagged we may not have noticed it. > > Sorry, I posted to python-list-owner before reading this message. > > > When the mailing list software received your post, the python-list address > > was not in the To: nor Cc: headers > > Well, this is quite strange, since I rechecked my mails and the > python-list address is in Cc. > I think the problem was caused by the fact I added the user concerned > to To:, and the list to Cc. All the rejected messages has this in > common. Indeed, this message was not rejected because I added only the > list to the To: field. > > > Try the same steps you did before and I'll keep a copy of the message for > > further debugging. > > As you wish :-) -- https://mail.python.org/mailman/listinfo/python-list
Re: Why this message was rejected?
On Mon, 2 Mar 2020 at 22:36, Ethan Furman wrote: > Questions like this should go to python-list-owner at python dot org. If > this message hadn't been flagged we may not have noticed it. Sorry, I posted to python-list-owner before reading this message. > When the mailing list software received your post, the python-list address > was not in the To: nor Cc: headers Well, this is quite strange, since I rechecked my mails and the python-list address is in Cc. I think the problem was caused by the fact I added the user concerned to To:, and the list to Cc. All the rejected messages has this in common. Indeed, this message was not rejected because I added only the list to the To: field. > Try the same steps you did before and I'll keep a copy of the message for > further debugging. As you wish :-) -- https://mail.python.org/mailman/listinfo/python-list
Re: Why this message was rejected?
On 03/02/2020 01:01 PM, Marco Sulla via Python-list wrote: One of my post on this list was rejected. The reason is: Blind carbon copies or other implicit destinations are not allowed. Try reposting your message by explicitly including the list address in the To: or Cc: fields. I rechecked my mail and I added the user to the To: field, and the python list address to the Cc field. I don't added any Bcc. I do not understand why my message was blocked. Questions like this should go to python-list-owner at python dot org. If this message hadn't been flagged we may not have noticed it. When the mailing list software received your post, the python-list address was not in the To: nor Cc: headers. Try the same steps you did before and I'll keep a copy of the message for further debugging. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Why this message was rejected?
One of my post on this list was rejected. The reason is: > Blind carbon copies or other implicit destinations are not allowed. >Try reposting your message by explicitly including the list address in > the To: or Cc: fields. I rechecked my mail and I added the user to the To: field, and the python list address to the Cc field. I don't added any Bcc. I do not understand why my message was blocked. -- https://mail.python.org/mailman/listinfo/python-list
Re: Data model and attribute resolution in subclasses
On Fri, 28 Feb 2020 at 08:28, Adam Preble wrote: > > I have been making some progress on my custom interpreter project Is your project published somewhere? What changes have you done to the interpreter? -- https://mail.python.org/mailman/listinfo/python-list
Re: Data model and attribute resolution in subclasses
Adam Preble writes: > On Sunday, March 1, 2020 at 3:08:29 PM UTC-6, Terry Reedy wrote: > >> Because BaseClass is the superclass of SubClass. > > So there's a mechanism for parent classes to know all their children? Yes, you just used it, although you may have confused its meaning: >>> class Base: ... pass ... >>> class Derived(Base): ... pass ... >>> print(Base.__subclasses__()) [] ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- https://mail.python.org/mailman/listinfo/python-list
Re: Have you some experience / link about difference between Python builded with gcc and clang?
> > Have you compiled it optimized (--enable-optimizations --with-lto)? > Nope, just ./configure. Further investigation is left as an exercise for the reader. :-) Skip > -- https://mail.python.org/mailman/listinfo/python-list
Re: Have you some experience / link about difference between Python builded with gcc and clang?
Oooohhh uff, I have to install latest clang... or better, compile it as I did for gcc. And I have to read the install docs to see if there's some trick to optimize it... and I have to read the docs of pyperformance too (I only used pyperf until now)... Oh well, tomorrow :-D On Mon, 2 Mar 2020 at 00:58, Skip Montanaro wrote: >> >> Have you compiled it optimized (--enable-optimizations --with-lto)? > > > Nope, just ./configure. Further investigation is left as an exercise for the > reader. :-) > > Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: Multiple turtles
Thank you. Giuseppe -- https://mail.python.org/mailman/listinfo/python-list