0

If I wish to get the name of a numpy.ndarray converted to a string (but not the content of the numpy.ndarray, just the name only), how do I do that?

I tried str(npndarrayName) and npndarrayName.tostring() but both are converting the content and not the name itself only.

3
  • 3
    Does this answer your question? Getting the name of a variable as a string Commented Jun 8, 2022 at 15:20
  • In Python objects don't have names. An object may be assigned to a variable - or many variables, or none. So while is may, in some cases, be possible to look for the object in the global namespace, I question the practicality of this. Why do you want/need to do this? Commented Jun 8, 2022 at 15:33
  • @hpaulj for a project. I want to plot something from a np.ndarray with its name as the legend. Commented Jun 8, 2022 at 15:41

1 Answer 1

1

I am not sure if I fully understood what you're asking, but you can check this link because I think they had the same question as you. I hope that it will solve your problem.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.