473,386 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to get name of list

10
Hi all,

In my script , I need to get name of list Im using

eg. sat I have following list ...
mca = ["kk","jj"]

Now I want to get name of the list i.e. just 'mca'.
Do anyone know any method/attribute so that I can get name of list

NOTE: 'classobj' has in built method '__name__' which gives name of class but Im not able to find anything similar for list

Thanks in advance...

rgds,
Ab
Nov 14 '08 #1
2 27576
bvdet
2,851 Expert Mod 2GB
You could iterate through the global dictionary for a list of equivalent value to get the name of the variable.

Expand|Select|Wrap|Line Numbers
  1. >>> mca = ["kk","jj"]
  2. >>> for key,value in globals().iteritems():
  3. ...     if type(value) == list and value == ["kk","jj"]:
  4. ...         print key
  5. ...         
  6. mca
  7. >>> 
Nov 14 '08 #2
aberry
10
thanks bvdet
..u r Python guru :)

have gr8 weekend !
Nov 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: David Bear | last post by:
Let's say I have a list called, alist. If I pass alist to a function, how can I get the name of it? alist = range(10) def afunction(list): listName = list.__name__ (fails for a list object)
11
by: Andrew Thompson | last post by:
I have written a few scripts to parse the URL arguments and either list them or allow access to the value of any parameter by name. <http://www.physci.org/test/003url/index.html>...
3
by: Petterson Mikael | last post by:
Hi, I have the following package names ( in an xml) that I will transform to html. I need to sort them. <package name="se.company.product.subproduct.boam.fpx.testsignals"> <package...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
0
by: Jim Avera | last post by:
On AIX, a template class containing a nested class which needs to be a friend provokes a warning: (W) A template dependent name that is a type must be qualified with "typename". and method...
1
imrosie
by: imrosie | last post by:
Hello (from Rosie the newbie), I recently got help with a wonderful event to perform this from 'thescripts'...it recognizes that a name is not in the list an allows for (after parsing first and...
4
imrosie
by: imrosie | last post by:
Hello, I need help. I have a 'NotInlist' routine that appears to givbe me 2 entries of the same new customer. It first adds the name to the list, then when I fill in other customer data (i.e.,...
2
by: cnsabar | last post by:
Hi., I am using the following code to terminate the any process by giving the process name as input... use Win32::Process::List; use Win32::OLE; $Win32::OLE::Warn = 3; $P =...
2
by: pythonnewb | last post by:
I am fairly new to programming but have some very basic Java background. I am just learning python and tried to make a module that would allow me to create a file containing an address book. I was...
1
by: vineetbindal | last post by:
Hi All, I am new to silverlight and i am following a tutorial. In order to connect to database in silverlight application i need to add a referance to a service. which gives me an error that the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.