Say I have a variable named choice it is equal to 2. How would I access the name of the variable? Something equivalent to  In [53]: namestr(choice) Out[53]: 'choice'   for use in making a dictionary. There's a good way to do this and I'm just missing it.  EDIT:  The reason to do this is thus. I am running some data analysis stuff where I call the program with multiple parameters that I would like to tweak, or not tweak, at runtime. I read in the parameters I used in the last run from a .config file formated as  filename no_sig_resonance.dat  mass_peak 700  choice 1,2,3   When prompted for values, the previously used is displayed and an empty string input will use the previously used value.  My question comes about because when it comes to writing the dictionary that these values have been scanned into. If a parameter is needed I run get_param which accesses the file and finds the parameter.   I think I will avoid the problem all together by reading the .config file once and producing a dictionary from that. I avoided that originally for... reasons I no longer remember. Perfect situation to update my code!
15817
I have enum and use the variables like myEnum.SomeNameA, myEnum.SomeNameB, etc.  When I return one of these variables from a function, can I print their names (such as myEnum.SomeNameA) instead of the value they returned?
4447
I have a string representing a path.  Because this application is used on Windows, OSX and Linux, we've defined environment variables to properly map volumes from the different file systems.  The result is:  "$C/test/testing"   What I want to do is evaluate the environment variables in the string so that they're replaced by their respective volume names.  Is there a specific command I'm missing, or do I have to take os.environ.keys() and manually replace the strings?
27347
I would like to parse a string such as p1=6&amp;p2=7&amp;p3=8 into a NameValueCollection.  What is the most elegant way of doing this when you don't have access to the Page.Request object?
4613
How can I create or use a global variable in a function?  If I create a global variable in one function, how can I use that global variable in another function? Do I need to store the global variable in a local variable of the function which needs its access?
102259
I need to search a string in the string array. I dont want to use any for looping in it  string [] arr = {"One","Two","Three"};  string theString = "One"   I need to check whether theString variable is present in arr.
106043
I have a C# application that scans a directory and gathers some information.  I would like to display the account name for each file.  I can do this on the local system by getting the SID for the FileInfo object, and then doing:  string GetNameFromSID( SecurityIdentifier sid ) {     NTAccount ntAccount = (NTAccount)sid.Translate( typeof( NTAccount ) );     return ntAccount.ToString(); }   However, this does not work for files on a network, presumably because the Translate() function only works with local user accounts.  I thought maybe I could do an LDAP lookup on the SID, so I tried the following:  string GetNameFromSID( SecurityIdentifier sid ) {     string str = "LDAP://&lt;SID=" + sid.Value + "&gt;";     DirectoryEntry dirEntry = new DirectoryEntry( str );     return dirEntry.Name; }   This seems like it will work, in that the access to "dirEntry.Name" hangs for a few seconds, as if it is going off and querying the network, but then it throws a System.Runtime.InteropServices.COMException  Does anyone know how I can get the account name of an arbitrary file or SID?  I don't know much about networking or LDAP or anything.  There's a class called DirectorySearcher that maybe I'm supposed to use, but it wants a domain name, and I don't know how to get that either - all I have is the path to the directory I'm scanning.  Thanks in advance.
42864
I mean other than using it when required for functions, classes, if, while, switch, try-catch.  I didn't know that it could be done like .  In the above link, Eli mentioned that "They use it to fold up their code in logical sections that don't fall into a function, class, loop, etc. that would usually be folded up."  What other uses are there besides those mentioned?   Is it a good idea to use curly braces to limit the scope of your variables and expand the scope only if required (working on a "need-to-access" basis)? Or is it actually silly?   How about using scopes just so that you can use the same variable names in different scopes but in the same bigger scope? Or is it a better practise to reuse the same variable (if you want to use the same variable name) and save on deallocating and allocating (I think some compilers can optimise on this?)? Or is it better to use different variable names altogether?
95520
I want to label a scale based on a variable value and I wrote a metapost code like this.  $ := 1; for i = -.3cm step .6cm until 3.6cm:     label.bot(str$,(i,-3.7cm));     $ := incr($); endfor;   It just labels "$" instead of its value. How to output the variables value?
69465
After having poorly handled the PATH system variable (resulting in deletion), I'm now looking to reinstate the variable with the original value. I found answers like  about Windows 8 and below, but not for Windows 10. I guess values are virtually identical, but I'd like to know the exact string so I'm not missing anything. EDIT: Also, Regedit tree have changed and I'm not able to locate the variable
80627
I have a string variable that represents the name of a custom class. Example:   string s = "Customer";   I will need to create an arraylist of customers. So, the syntax needed is:  List&lt;Customer&gt; cust = new ..    How do I convert the string s to be able to create this arraylist on runtime?
73621
Is there any way to create the query parameters for doing a GET request in JavaScript?  Just like in Python you have , which takes in a dictionary (or list of two tuples) and creates a string like 'var1=value1&amp;var2=value2'.
65234
I'm writing a script which will use the filename of running processes. However, I'm unable to determine the full executable name of some processes.  Initially, I decided to query the Name entry in /proc/PID/status (or the second field in /proc/PID/stat). However, according to the , that field is always truncated to 15 characters, but I need the full name to avoid conflict/confusion.  An answer of  suggests to use /proc/PID/cmdline, but there are problems too. Some programs (e.g. chromium, electron) do stupid/smart things to the value in /proc/PID/cmdline so I can't just split the data there by NULL and directly get the program name as suggested in the manpage - they fill in a lot of things to the original argv[0] field and separate them by space, and I don't think merely splitting by space is a good choice because the path/filename may contain spaces.  This is even more complicated when I find out that some scripts (e.g. python scripts) are in the form /usr/bin/python /path/to/script while some are in the form /path/to/script. Though this is much easier to deal with as long as I have that field (without jams as above) and manually check and split.  Any ideas how to get the full program name/filename? It doesn't matter if the name contains the full path or not because that can be easily dealt with (as far as I can see now).
62239
Coming from a C# background the naming convention for variables and method names are usually either camelCase or PascalCase:  // C# example string thisIsMyVariable = "a" public void ThisIsMyMethod()   In Python, I have seen the above but I have also seen underscores being used:  # python example this_is_my_variable = 'a' def this_is_my_function():   Is there a more preferable, definitive coding style for Python?
80444
$0 is the variable for the top level Ruby program, but is there one for the current method?
84126
I am not sure whether is it possible to change attribute's parameter during runtime? For example, inside an assembly I have the following class  public class UserInfo {     [Category("change me!")]     public int Age     {         get;         set;     }     [Category("change me!")]     public string Name     {         get;         set;     } }   This is a class that is provided by a third party vendor and I can't change the code. But now I found that the above descriptions are not accurate, and I want to change the "change me" category name to something else when i bind an instance of the above class to a property grid.  May I know how to do this?
89256
I want to assign a class attribute via a string object - but how?  Example:  class test(object):   pass  a = test() test.value = 5 a.value # -&gt; 5 test.__dict__['value'] # -&gt; 5  # BUT: attr_name = 'next_value'  test.__dict__[attr_name] = 10 # -&gt; 'dictproxy' object does not support item assignment
81295
Is there any easy way to pass (receive) named parameters to a shell script?  For example,   my_script -p_out '/some/path' -arg_1 '5'   And inside my_script.sh receive them as:  # I believe this notation does not work, but is there anything close to it? p_out=$ARGUMENTS['p_out'] arg1=$ARGUMENTS['arg_1']  printf "The Argument p_out is %s" "$p_out" printf "The Argument arg_1 is %s" "$arg1"   Is this possible in Bash or Zsh?