On 05/08/2015 02:26 AM, Alex Kleider wrote:
On 2015-05-07 20:45, Dave Angel wrote:
You also only showed it working on module globals. (For code at
top-level, locals() returns the same as globals() )
You could also try it inside functions, where locals() really makes
sense as a name. And you
On 2015-05-07 20:45, Dave Angel wrote:
You also only showed it working on module globals. (For code at
top-level, locals() returns the same as globals() )
You could also try it inside functions, where locals() really makes
sense as a name. And you could try it in a nested function where
there
On 05/07/2015 11:23 PM, Alex Kleider wrote:
On 2015-05-07 19:10, Dave Angel wrote:
def get_name(localmap, item):
"""As suggested.
Returns 'a' name, not necessarily 'the' name."""
for name in localmap:
if localmap[name] == item:
This is not likely to be what was intende
On 2015-05-07 19:10, Dave Angel wrote:
def get_name(localmap, item):
"""As suggested.
Returns 'a' name, not necessarily 'the' name."""
for name in localmap:
if localmap[name] == item:
This is not likely to be what was intended. You want
if localmap[name] is
On 05/07/2015 09:50 PM, Alex Kleider wrote:
On 2015-04-21 16:48, Cameron Simpson wrote:
But it would not be schizophrenic to write a function that returned a
name arbitrarily, by inspecting locals(). It depends whether you only
need a name, or if you need "the" name.
Write yourself a "find_nam
On 2015-04-21 16:48, Cameron Simpson wrote:
But it would not be schizophrenic to write a function that returned a
name arbitrarily, by inspecting locals(). It depends whether you only
need a name, or if you need "the" name.
Write yourself a "find_name_from_locals(local_map, value)" function
tha
On 2015-04-21 16:38, Ben Finney wrote:
That hope is understandable.
Your "understanding" is appreciated.
It is also easy to be confused
So true, but with the help of "Python Tutors" things are being
rectified!
about why such a feature doesn't exist;
So why not arbitrary objects?
On 2015-04-21 16:48, Cameron Simpson wrote:
But it would not be schizophrenic to write a function that returned a
name arbitrarily, by inspecting locals(). It depends whether you only
need a name, or if you need "the" name.
In my use case there'd probably be only one name for the given object
On 21Apr2015 09:59, Alex Kleider wrote:
On 2015-04-20 22:21, Danny Yoo wrote:
What's supposed to happen in this situation?
##
class Person(object):
def __init__(self): pass
j = Person()
john = j
jack = j
##
Wha
Alex Kleider writes:
> I was hoping that it would be possible to create a function
> that would do the following:
>
> def my_name(some_object):
> return some_object.__name__
That hope is understandable.
It is also easy to be confused about why such a feature doesn't exist;
after all, it works
> But I see what I think you and others have been trying to explain to me:
> that the expression some_object.__name__, if it existed, would indeed be
> schizophrenic since it would be an attribute of the object, not the name(s)
> to which it is bound.
The hypothetical feature might also, if desi
On 2015-04-20 22:21, Danny Yoo wrote:
What's supposed to happen in this situation?
##
class Person(object):
def __init__(self): pass
j = Person()
john = j
jack = j
##
What single name should we get back from t
On 04/21/2015 01:21 AM, Danny Yoo wrote:
What's supposed to happen in this situation?
##
class Person(object):
def __init__(self): pass
j = Person()
john = j
jack = j
##
What single name should we get back fr
What's supposed to happen in this situation?
##
class Person(object):
def __init__(self): pass
j = Person()
john = j
jack = j
##
What single name should we get back from the single Person object
here? "j", "joh
On 2015-04-20 13:24, Ben Finney wrote:
Alex Kleider writes:
Does python provide the introspective ability to retrieve the name to
which an object is bound?
Objects aren't bound to names. So, no.
The binding from a reference (a name is a reference) to objects is
one-way.
See this excellent
Alex Kleider writes:
> Does python provide the introspective ability to retrieve the name to
> which an object is bound?
Objects aren't bound to names. So, no.
The binding from a reference (a name is a reference) to objects is
one-way.
See this excellent presentation from PyCon US 2015 by Ned
Alex Kleider wrote:
> On 2015-04-20 09:15, Joel Goldstick wrote:
>> On Mon, Apr 20, 2015 at 11:24 AM, Alex Kleider
>> wrote:
>>> Does python provide the introspective ability to retrieve the name to
>>> which
>>> an object is bound?
>>>
>>> For example:
>>> $ python3
>>> Python 3.4.0 (default, A
On 20/04/15 17:55, Alex Kleider wrote:
locals()
{'a': 3, 'c': 3, 'b': 6, '__builtins__': , '__package__': None, '__name__': '__main__', '__doc__':
None}
Showing my desired use case might make my question more understandable:
def debug(var_name):
if args["--debug"]:
print("Ident
On Mon, Apr 20, 2015 at 08:24:42AM -0700, Alex Kleider wrote:
> Does python provide the introspective ability to retrieve the name to
> which an object is bound?
Short answer: no.
Slightly longer answer: it *may* be possible if you dig deep into the
debugger API that you might find something wh
On 2015-04-20 09:15, Joel Goldstick wrote:
On Mon, Apr 20, 2015 at 11:24 AM, Alex Kleider
wrote:
Does python provide the introspective ability to retrieve the name to
which
an object is bound?
For example:
$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:18)
[GCC 4.8.2] on linux
Type "help
On Mon, Apr 20, 2015 at 11:24 AM, Alex Kleider wrote:
> Does python provide the introspective ability to retrieve the name to which
> an object is bound?
>
> For example:
> $ python3
> Python 3.4.0 (default, Apr 11 2014, 13:05:18)
> [GCC 4.8.2] on linux
> Type "help", "copyright", "credits" or "li
Does python provide the introspective ability to retrieve the name to
which an object is bound?
For example:
$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:18)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
a = 69
print("Identifier <{}> is bound
Negroup - wrote:
> Hi.
>
> My application hosts a module A that contains only a (variable) number
> of functions. In another part of this application I need to know which
> functions are defined inside module A. Initially I thought to use
> __dict__, but along with the functions of module A are li
Hi!
I quick solution for a name module could be:
>>> import os
>>> for d in os.__dict__:
... a="os." + d
... if callable( eval(a) ):
... print "Callable %s" % ( eval(a))
but there should also be a recipe on activestate for that problem.
I think I've red something in the Pytho
Negroup - wrote:
>Hi.
>
>My application hosts a module A that contains only a (variable) number
>of functions. In another part of this application I need to know which
>functions are defined inside module A. Initially I thought to use
>__dict__, but along with the functions of module A are listed
Hi.
My application hosts a module A that contains only a (variable) number
of functions. In another part of this application I need to know which
functions are defined inside module A. Initially I thought to use
__dict__, but along with the functions of module A are listed all the
builtins too.
H
26 matches
Mail list logo