Re: Dynamically modifying "__setattr__"

2023-09-29 Thread Greg Ewing via Python-list

On 28/09/23 10:44 pm, Stefan Ram wrote:

class A:
 def __init__( self ):
 self.__setattr__ = self.setattr
 def setattr( self, key, value ):
 print( 'setattr called.' )

   Any idea how to achieve something like this?


class A:

def __init__(self):
self.x = 17
self.setattr = self.custom_setattr

def __setattr__(self, key, value):
self.setattr(key, value)

def setattr(self, key, value):
object.__setattr__(self, key, value)

def custom_setattr(self, key, value):
print('custom_setattr:', key, '=', value)

a = A()
a.x = 1
print('a.x =', a.x)

--
Greg

--
https://mail.python.org/mailman/listinfo/python-list


Re: error of opening Python

2023-09-29 Thread anthony.flury via Python-list




This isn't an error.


This is just a normal Python Header message announcing that you are 
using Python 3.11.3
The rest is just information from the build system : The build Id,  the 
date/time the build was made, and the version of the compiler.


There is nothing to fix.


-- Original Message --
From: "Abdelkhelk ashref salay eabakh via Python-list" 


To: python-list@python.org
Sent: Tuesday, 26 Sep, 23 At 13:27
Subject: error of opening Python
Dear Python team,
This is my not first time using Python, I tried to launch Python and it 
showed
"Python 3.11.3 (tags/v3.11.3:f3909b8, Apr  4 2023, 23:49:59) [MSC v.1934 
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information." 
I
don't know what this meant and how to fix this. Could you please help 
me?

Thank you very much.
Kind regards
--
https://mail.python.org/mailman/listinfo/python-list 



-- Anthony Fluryanthony.fl...@btinternet.com
--
https://mail.python.org/mailman/listinfo/python-list