Is that possible to check what variables or instance of any classes exist in the current python workspace/environment? can I use any functions to list them? Thanks in advance!
A friend asked me last week how to enumerate or list all variables within a program/function/etc. for the purposes of debugging (essentially getting a snapshot of everything so you can see what variables are set to, or if they are set at all). I looked around a bit and found a relatively good way for Python:   #!/usr/bin/python                                                                                                                                                                                                                            foo1 = "Hello world" foo2 = "bar" foo3 = {"1":"a",         "2":"b"} foo4 = "1+1"  for name in dir():     myvalue = eval(name)     print name, "is", type(name), "and is equal to ", myvalue   which will output something like:   __builtins__ is &lt;type 'str'&gt; and is equal to  &lt;module '__builtin__' (built-in)&gt; __doc__ is &lt;type 'str'&gt; and is equal to  None __file__ is &lt;type 'str'&gt; and is equal to  ./foo.py __name__ is &lt;type 'str'&gt; and is equal to  __main__ foo1 is &lt;type 'str'&gt; and is equal to  Hello world foo2 is &lt;type 'str'&gt; and is equal to  bar foo3 is &lt;type 'str'&gt; and is equal to  {'1': 'a', '2': 'b'} foo4 is &lt;type 'str'&gt; and is equal to  1+1   I have so far found a partial way in PHP (courtesy of ) but it only lists all variables and their types, not the contents:   &lt;?php // create a few variables $bar = 'foo'; $foo ='bar'; // create a new array object $arrayObj = new ArrayObject(get_defined_vars()); // loop over the array object and echo variables and values for($iterator = $arrayObj-&gt;getIterator(); $iterator-&gt;valid(); $iterator-&gt;next())         {         echo $iterator-&gt;key() . ' =&gt; ' . $iterator-&gt;current() . '&lt;br /&gt;';         } ?&gt;   So I put it to you: how do you list all variables and their contents in your favorite language?    Edit by : I propose this question follows the spirit of a little "". If you do not agree, just edit and remove the tag and the link.
Which one should be used?      To me, it makes no difference, but I'm not really sure why.   vs     For me, it makes no difference, but I'm not really sure why. Separable Hilbert space have a countable orthonormal basis I want to show that every an infinite-dimensional separable (contains countable dense set) Hilbert space has a countable orthonormal basis.  I know that every orthogonal set in a separable Hilbert space is countable, it is help me with the proof? English equivalent for the Persian idiom "send someone out in pursuit of black chickpeas" "To send somebody out in pursuit of some black " is a Persian idiom that implies 'to make or ask someone to run an errand so that you be able to have/ buy some time in order to deal with your private affairs in their absence', like having or continuing a (secret) conversation with someone else.   According to its etymology, since 'black garbanzos/chickpeas' were rarely available in the markets, when someone wanted to buy them, they had to search many stores for a long time, and most of time they couldn't find them at all.   Today, its meaning has changed somehow, and it doesn't necessarily mean that we ask someone to run an impossible errand, but it means we use that errand as an excuse to send them away for a while just to have time to do something in their absence.   Example scenario:   Suppose your classmate has come to your house and you are talking about some girly issues in the sitting room. Now you want to tell her a big secret about one of your classmates, but not in the presence of your younger sister who is sitting there too. So you ask her to go to the market and buy some snacks for you. In this way, you will have some time to continue your conversation until she is back. So you might say to your friend:     Well, I sent my sister out in pursuit of some black chickpeas.  I'm sure that she won't be back for another 15 minutes, so we can talk more freely now."   And your sister, before leaving the house, might sarcastically say to you:     Okay, but I know this is just an excuse, and you are just sending me in pursuit of some black chickpeas!!! so don't think that you can fool me!   Is there any idiom, expression or proverb that conveys the same meaning or connotation in English (i.e. to make or ask someone to do an errand just in order to buy time so that you can deal with some of your private affairs)?   I have found to be/go on  but I'm not sure if I can use it or not. My computer no longer boots Windows or the installed operating system. Instead, I may get this error:  PXE-E61: Media test failure, check cable -or- Check cable connection!  PXE-M0F: Exiting PXE ROM.   and/or one of the following messages or similar:  Operating System not found  No boot device available- No bootable devices--strike F1 to retry boot, F2 for setup utility  No bootable device -- insert boot disk and press any key  No Boot Device Found. Press any key to reboot the machine  Default Boot Device Missing or Boot Failed  Reboot and Select proper Boot device or Insert Boot Media in selected Boot device   What does this mean and what can I do?     This question comes up often and the answers are usually the same. This post is meant to provide a definitive, canonical answer for this problem. Feel free to edit the answer to add additional details. I recently installed Lubuntu but I have a problem with Adobe Flash Player. I always see something that looks like this when I open a video:    (source: )    The video is small, grainy, and is green and purple.  I tried to reinstall Flash and to test it in multiple browsers without success. I installed an older version of Flash but no result.  [0300]: Intel Corporation 82865G Integrated Graphics Controller [8086:2572] (rev 02)     Subsystem: Hewlett-Packard Company D530 sff(dc578av) [103c:12bc]     Kernel driver in use: i915 I'm having problems with an exercise from Apostol's Introduction to Analytic Number Theory.     Given $x$ and $y$, let $m=ax+by$, $n=cx+dy$, where $ad-bc= \pm 1$. Prove that $(m,n)=(x,y)$.   I've tried to give a proof, but I suspect it's wrong (or at least not very good). I would be very thankful for any hints/help/advice!  My proof:     We observe that since $ad-bc= \pm 1$, $ad=bc \pm 1$, and $(ad,bc)=1$.   Now, $(a,b) \mid m$ and $(c,d) \mid n$ but      $$(a,b) = ((d,1)a,(c,1)b)=(ad,a,bc,b)=(ad,bc,a,b)=((ad,bc),a,b)=(1,a,b)=1.$$      Similarly, we determine $(c,d)=1$. So, $1=(a,b) \mid m$ and $1=(c,d) &gt; \mid n$. But $(x,y)$ also divide $m$ and $n$. Since $(x,y) \geq (a,b)=(c,d)=1$, this implies that $(x,y)=m,n$. Hence   $(m,n)=((x,y),(x,y))=(x,y)$. Correct spelling of Polish surname Dziubenofska? My Polish grandmothers last name was Dziubenofska, but I know that's not how it is spelt! I'm looking for the proper spelling.   Can you help find it for me?  She came over to Ellis Island and they changed it on her to dziuk. This is only a prefix to the full name. I have 2 tables. One (domains) has domain ids, and domain names (dom_id, dom_url).  the other contains actual data, 2 of which columns require a TO and FROM domain names. So I have 2 columns rev_dom_from and rev_dom_for, both of which store the domain name id, from the domains table.  Simple.  Now I need to actually display both domain names on the webpage. I know how to display one or the other, via the LEFT JOIN domains ON reviews.rev_dom_for = domains.dom_url query, and then you echo out the dom_url, which would echo out the domain name in the rev_dom_for column.  But how would I make it echo out the 2nd domain name, in the dom_rev_from column? Gaps between arrows and labels Can Button[] generate output without using Print[]? I'm brand new to jQuery and have some experience using Prototype. In Prototype, there is a method to "flash" an element &mdash; ie. briefly highlight it in another color and have it fade back to normal so that the user's eye is drawn to it. Is there such a method in jQuery? I see fadeIn, fadeOut, and animate, but I don't see anything like "flash". Perhaps one of these three can be used with appropriate inputs? Recent fluid-mechanical experiments by the groups of Couder in Paris and Bush at MIT, mimic a surprisingly wide range of quantum effects. The essential ingredient of these fluid-mechanical systems is a background or pilot-wave that guides the droplets.  Now, surprisingly, a simple analysis of a Bell-type experiment shows that, in the presence of a background field, one of the premises of the Bell inequality, namely measurement independence (MI), is violated. See the paper  (available ). Therefore such classical droplet experiments could violate a Bell inequality. More importantly, if this analysis is correct, background-based hidden-variable theories are admissible, even if they are local (in the sense of ‘involving only (sub)luminal interactions’) and even if they are compatible with free will.   My question: to me the analysis seems fully sound, but maybe there is still an unphysical hypothesis that slipped in ? How does SO's (or other SE sites) versioning work of questions and answers? Do they use some standard piece of code or is it something homebrew?  With versioning I meant if for example a question is edited you'll see all the changes (a diff). Using C# and WPF under .NET (rather than  or console), what is the correct way to create an application that can only be run as a single instance?  I know it has something to do with some mythical thing called a mutex, rarely can I find someone that bothers to stop and explain what one of these are.  The code needs to also inform the already-running instance that the user tried to start a second one, and maybe also pass any command-line arguments if any existed. How Do I Choose Between a Hash Table and a Trie (Prefix Tree)? So if I have to choose between a hash table or a prefix tree what are the discriminating factors that would lead me to choose one over the other. From my own naive point of view it seems as though using a trie has some extra overhead since it isn't stored as an array but that in terms of run time (assuming the longest key is the longest english word) it can be essentially O(1) (in relation to the upper bound). Maybe the longest english word is 50 characters?  Hash tables are instant look up once you get the index. Hashing the key to get the index however seems like it could easily take near 50 steps.  Can someone provide me a more experienced perspective on this? Thanks! linux command to prevent dos attack by using netstat and iptables I want to DROP more than 200 requests per ip to prevent ddos attack. this is command that i used to detect requests count per ip :  netstat -alpn | grep :80 | awk '{print $5}' |awk -F: '{print $(NF-1)}' |sort | uniq -c | sort -nr   now i want add all ip addresses that made more than 200 requests into IPtables to DROP input and out put. Rep line graph: Say "only 200+ accounts displayed" at all times As discovered/discussed , the cross-site reputation graph doesn't show accounts that have less than 200 reputation. The problem is that, unless you have zero accounts over that bar, it doesn't tell you that. I think the "Accounts must have a minimum of 200 reputation to appear in this graph" notice should appear either (A) at all times or (B) if you have any accounts below 200. How do I execute a command-line program from C# and get back the STD OUT results? Specifically, I want to execute DIFF on two files that are programmatically selected and write the results to a text box. What's the simplest way to decrement a date in Javascript by 1 day? I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly.  That is, if I have a date of 'Today', I want to get the date for 'Yesterday'.  It always seems to take more code than necessary when I do this, so I'm wondering if there's any simpler way.    What's the simplest way of doing this?  [Edit: Just to avoid confusion in an answer below, this is a JavaScript question, not a Java one.] GoogleApiClient.isConnected() return always false