On 2020-01-30 7:17 p.m., Andrew Barnert via Python-ideas wrote:
On Jan 30, 2020, at 11:20, Johan Vergeer wrote:
> ## Attribute names
>
> You should be able to get the name of an attribute.
>
> ```python
> class Foo:
>bar: str = "Hello"
>
>def __init__(self):
>self.baz =
On Jan 31, 2020, at 11:01 AM, Soni L. wrote:
>
> Consider:
>
> x=nameof(foo.bar)
>
> in today's python becomes:
>
> foo.bar
> x="bar"
>
> and when running this you get an AttributeError or something.
>
> the benefit is that "bar" is only typed once, and the attribute access (and
> thus erro
On Jan 31, 2020, at 08:03, Soni L. wrote:
>
> Consider:
>
> x=nameof(foo.bar)
>
> in today's python becomes:
>
> foo.bar
> x="bar"
>
> and when running this you get an AttributeError or something.
>
> the benefit is that "bar" is only typed once, and the attribute access (and
> thus error-r
On 2020-01-31 2:36 p.m., Andrew Barnert wrote:
On Jan 31, 2020, at 08:03, Soni L. wrote:
>
> Consider:
>
> x=nameof(foo.bar)
>
> in today's python becomes:
>
> foo.bar
> x="bar"
>
> and when running this you get an AttributeError or something.
>
> the benefit is that "bar" is only typed
The types in most programming languages are only technical types. If a variable
has a type, you may know that it is of type integer or double, but you don't
know if it's a length or an area.
The types required are semantic types.
stypes: length
area
time
speed
scalar
allowed expres
On Sat, Feb 1, 2020 at 10:06 AM wrote:
>
> The types in most programming languages are only technical types. If a
> variable has a type, you may know that it is of type integer or double, but
> you don't know if it's a length or an area.
> The types required are semantic types.
>
> stypes:
> len
On 1/02/20 6:15 am, Richard Damon wrote:
One issue I am seeing is that x = nameof(foo.bar) is crossing the
line between compile time and run time behaviors. The resultant
string, “bar” needs to be generated at compile time, but the
operation still needs to do a check at run-time to determine if t
Here's a simple runtime implementation that doesn't require any
dependencies or source code access:
import dis
import inspect
from functools import lru_cache
def nameof(_):
frame = inspect.currentframe().f_back
return _nameof(frame.f_code, frame.f_lasti)
@lru_cache
def _nameof(code, of
On Sat, Feb 01, 2020 at 01:52:38AM +0200, Alex Hall wrote:
> Here's a simple runtime implementation that doesn't require any
> dependencies or source code access:
>
> import dis
So this is not likely to ever work in IronPython or Jython.
There are no stability guarantees about the byte-code gen
I am really confused by this whole thread:
(I know this has all been said in this thread, but I’m summarizing to get
us on the same page for the following comments)
Python has names, and it has values (objects, whatever) when we write
Python, we bind names to values with the = operator. (And othe
On 1/31/20 9:28 PM, Christopher Barker wrote:
I am really confused by this whole thread:
(I know this has all been said in this thread, but I’m summarizing to
get us on the same page for the following comments)
Python has names, and it has values (objects, whatever) when we write
Python, we
On Jan 31, 2020, at 14:51, Soni L. wrote:
>>> On 2020-01-31 2:36 p.m., Andrew Barnert wrote:
>> That does work, but that means foo.bar has to exist and have a value before
>> you look up the name. Consider these cases:
>>class Spam:
>>def __init__(self):
>>self.eggs = 42
>
On Jan 31, 2020, at 15:05, [email protected] wrote:
>
> The types in most programming languages are only technical types. If a
> variable has a type, you may know that it is of type integer or double, but
> you don't know if it's a length or an area.
> The types required are semantic types.
On 2020-02-01 12:00 a.m., Andrew Barnert wrote:
On Jan 31, 2020, at 14:51, Soni L. wrote:
>>> On 2020-01-31 2:36 p.m., Andrew Barnert wrote:
>> That does work, but that means foo.bar has to exist and have a value before
you look up the name. Consider these cases:
>>class Spam:
>>d
Here’s a concrete proposal.
tl;dr: `nameof x == "x"`, and `nameof x.y == "y"`.
Rationale:
Even though as far as Python is concerned `nameof x.y` is identical to `"y"`,
it can make a difference to human readers—and to at least two classes of
automated tools.
When refactoring code to rename som
Sorry, sent early… ignore that and try this version.
>
> On Jan 31, 2020, at 19:58, Andrew Barnert wrote:
>
> Here’s a concrete proposal.
>
tl;dr: `nameof x == "x"`, and `nameof x.y == "y"`.
Rationale:
Even though as far as Python is concerned `nameof x.y` is identical to `"y"`,
it can mak
On Jan 31, 2020, at 19:30, Soni L. wrote:
>
>
>> On 2020-02-01 12:00 a.m., Andrew Barnert wrote:
>> On Jan 31, 2020, at 14:51, Soni L. wrote:
>> >>> On 2020-01-31 2:36 p.m., Andrew Barnert wrote:
>> >> That does work, but that means foo.bar has to exist and have a value
>> >> before you look u
On Thu, Jan 30, 2020 at 07:17:34PM -, Johan Vergeer wrote:
> It is a couple of days later, but I managed to create a more expanded
> proposal.
>
> This proposal is about having a simple and consistent way of getting the name
> of an object.
> Whether it is a class, type, function, method or
18 matches
Mail list logo