Agreed. I was being lazy and didn't check precisely which exception
was raised before writing the code. "Making this code production ready
is left as an exercise for the reader" :-)
On 11 October 2017 at 01:59, Steve D'Aprano wrote:
> On Wed, 11 Oct 2017 02:15 am, Paul Moore wrote:
>
>> These are
On Wed, 11 Oct 2017 02:15 am, Paul Moore wrote:
> These are all run-time behaviours, and so there's no way you can check
> for them ahead of time. If you want to be sure setattr is allowed, you
> need to handle possible exceptions:
>
> try:
> setattr(o, name, value)
> except Excep
On 10/10/17 11:00 AM, Stefan Ram wrote:
xieyuheng writes:
1. 'setattr(o, name, value)' can be used for what kind of objects ?
It takes three objects as arguments.
The first object should have an attribute named by the value
of »name« that should allow this attribute to be set to
»
On 2017-10-10 16:37, xieyuheng wrote:
>> Some callables may not be introspectable in certain implementations of
> Python.
>> For example, in CPython, some built-in functions defined in C
>> provide no metadata about their arguments.
>
>this is depends on implementation, so I ask f
On 10/10/2017 10:37 AM, xieyuheng wrote:
2. what kind of functions does not have signature,
so that 'inspect.signature(f)' can be used for them ?
When .signature was added, it may not have been usable with *any*
C-coded function. About the same, a mechanism was added to make
signatures
On 10 October 2017 at 15:37, xieyuheng wrote:
> 1. 'setattr(o, name, value)' can be used for what kind of objects ?
>
>section '2. Built-in Functions'
>of the official documentation says :
>
>> The function assigns the value to the attribute, provided the object
> allows it.
Anything
in CPython,
instead of trying each object and function,
is there any rules can help me answer the following questions ?
or is there any third part documentations
[community driven docs ? wiki ?]
that can answer them ?
1. 'setattr(o, name, value)' can be used for what kind of objects ?
secti
in CPython,
instead of trying each object and function,
is there any rules can help me answer the following questions ?
or is there any third part documentations
[community driven docs ? wiki ?]
that can answer them ?
1. 'setattr(o, name, value)' can be used for what kind of objects ?
secti