Class vs instance initialization in Python I am a bit puzzled why when initializing an instance of a class in Python, I cannot use class attributes. Here is the example:  class TestClass: ... shared_list = ['a', 'b', 'c'] ... def __init__(self): ...     self.length = len(shared_list)   Now   &gt;&gt;&gt; TestClass.shared_list ['a', 'b', 'c']   So the list exists before any instance of the class appears, but  &gt;&gt;&gt; tc = TestClass() Traceback (most recent call last):   File "&lt;stdin&gt;", line 1, in &lt;module&gt;   File "&lt;stdin&gt;", line 4, in __init__ NameError: global name 'shared_list' is not defined   Am I missing something simple?  UPD: Thanks to everyone for help and a prompt response. I've cleared up my confusion: class doesn't define a scope in Python.
Short description of the scoping rules? What exactly are the Python scoping rules?  If I have some code:  code1 class Foo:    code2    def spam.....       code3       for code4..:        code5        x()   Where is x found?  Some possible choices include the list below:   In the enclosing source file In the class namespace In the function definition In the for loop index variable Inside the for loop   Also there is the context during execution, when the function spam is passed somewhere else. And maybe  pass a bit differently?  There must be a simple reference or algorithm somewhere.  It's a confusing world for intermediate Python programmers.
What should be the intuition when working with compactness? I have a question that may be regarded by many as duplicate since there's a  one at MathOverflow. The point is that I think I'm not really getting the idea on compactness. I mean, in $\mathbb{R}^n$ the compact sets are those that are closed and bounded, however the guy who answered this question and had his answer accepted says that compactness is some analogue of finiteness. That's the first problem: In my intuitive view of finiteness, only boundedness would suffice to say that a certain subset of $\mathbb{R}^n$ is in some sense &quot;finite&quot;. On the other hand there's the other definition of compactness (in terms of covers) which is the one I really need to work with and I cannot see how that definition implies this intuition on finiteness. Also, I feel it's pretty strange the covers people use when they want to deal with compact sets. To prove a set is compact I know they must show that for every open cover there's a finite subcover; the problem is that I can't see intuitively how one could show this for every cover. Also when trying to disprove compactness the books I've read start presenting strange covers that I would have never thought about. I think my real problem is that I didn't yet get the intuition on compactness. So, what intuition should we have about compact sets in general and how should we really put this definition to use? Can someone provide some reference that shows how to understand the process of proving (and disproving) compactness? How do I fill an area with faces lined up in a grid over a not flat surface? Hello to everyone again,  I'm looking for an addon or a short cut to fill fast and simmetrically a NOT FLAT surface that needs to be closed with vertices. Doing it manually it takes a lot of time. I tried to do CTRL F and then Grid fill,but it didn't work. Neither F key works. Check the attached screenshot. thanks. Maximum weight an average bicycle can carry? A few years ago, I've bought  (see edit) bike. At that time I was around 90 kgs and I didn't have any problems.  Today I'm around 120 kgs and I was considering (among other things) starting cycling again. Is this bike "good" enough to carry me? What should I expect? Any tips?  EDIT! Apparently, Drag have renamed some of their bikes in the last few years, so the above information is a bit wrong.  seems to be my bike. At first I didn't recognize much difference, but this one has suspension on the front which mine also has. Does this change anything When I open a window to air out the room, how does the smell disperse? The main effect will be non-significant if the interaction is significant? When traveling to a country with a different currency, how should you take your money? ［I'm Done］ button is available after ［Save Edits］ even when nothing was edited in First Posts queue Equivalent Definitions of the Operator Norm How do you prove that these four definitions of the operator norm are equivalent? $$\begin{align*} \lVert A\rVert_{\mathrm{op}} &amp;= \inf\{ c\;\colon\; \lVert Av\rVert\leq c\lVert v\rVert \text{ for all }v\in V\}\\ &amp;=\sup\{ \lVert Av\rVert\;\colon\; v\in V\text{ with }\lVert v\rVert\leq 1\}\\ &amp;=\sup\{\lVert Av\rVert\;\colon\; v\in V\text{ with }\lVert v\rVert = 1 \}\\ &amp;=\sup\left\{ \frac{\lVert Av\rVert}{\lVert v\rVert}\;\colon\; v\in V\text{ with }v\neq 0\right\}. \end{align*}$$ Can a virtualized machine have the CPU and RAM resources of multiple underlying physical machines? Why is $\pi$ irrational if it is represented as $C/D$? When hyperref is loaded I receive the following error:     TeX capacity exceeded, sorry [input stack size=5000].   However, when I remove hyperref package it compiles successfully. I traced it back and found that \maketitle causes the error but don't know how to fix it. Is there any way to use hyperref in my setup.   Code:       %!TEX TS-program = xelatex     \documentclass[journal,transmag,]{IEEEtran}      \usepackage[hyphens]{url}     \usepackage{hyperref}      \usepackage{xunicode}      \usepackage{fontspec}      \usepackage{polyglossia}     \setmainlanguage{english}     \setotherlanguage{arabic}     \newfontfamily\arabicfont[Script = Arabic]{Amiri} % Replace 'Simplified Arabic' with a font from your system       \begin{document}     \title{A Very Nice Title}      \author{\IEEEauthorblockN{             John Doe\IEEEauthorrefmark{1}}%,~\IEEEmembership{Member,~IEEE}         \IEEEauthorblockA{\IEEEauthorrefmark{1}My address}         % &lt;-this % stops an unwanted space         \thanks{Manuscript received mm dd, 20xx; revised mm dd, 20xx.               }     }      % The paper headers     \markboth{headers...}%     {Shell \MakeLowercase{\textit{et al.}}: Bare Demo of IEEEtran.cls for IEEE Transactions on Magnetics Journals}      \IEEEtitleabstractindextext{%         \begin{abstract}My Abstract.\end{abstract}          % Note that keywords are not normally used for peerreview papers.         \begin{IEEEkeywords}             Key 1, Key 2     \end{IEEEkeywords}}      \maketitle       \IEEEdisplaynontitleabstractindextext     % \IEEEdisplaynontitleabstractindextext has no effect when using     \IEEEpeerreviewmaketitle       \section{Introduction}     English Text      \begin{Arabic}      السَلَامُ عَلَيكُمْ     \end{Arabic}       \end{document} Uncheck checkboxes by changing particular checkbox state I have custom fields in contacts form named checkbox1__c, checkbox11__c, checkbox12__c, checkbox13__c.  When I check checkbox1__c then I want checkbox11__c,  checkbox12__c,  checkbox13__c to be unchecked.  When I unchecked checkbox1__c then I want checkbox11__c, checkbox12__c, checkbox13__c to be checked.  Is there any way to do this by using validation-rules? If not no way to this by validation-rules, then what is the best way to do this? Prevent Windows 10 installer from using the preinstalled serial key without disabling UEFI I know someone who just got an Atrix 4G and previously had an iPhone 3GS. I was asked how he could move his contacts from the iPhone/iTunes onto the Android device. I have never owned an iPhone and have had limited interaction with them. Does anyone know the simplest method of getting iPhone contacts onto an Android device? Prior to the spell cast on Mjolnir, did Thor control lightning on his own? In the film Thor, Odin casts a spell on Mjolnir and strips Thor of his power.  He then banishes Thor to Midgard (Earth).  On Earth, Thor is seemingly just a strong and durable human.  Later in the film, he becomes worthy, and regains control of Mjolnir.  This then grants him his full power set and control over Mjolnir.  My question is, prior to this, could Thor control lightning all on his own?  Or is this purely an ability of Mjolnir? Booting a Windows 7 installation on different hardware I'm in a situation where I could do with very quickly migrating a Windows 7 (RTM x64) installation from one machine to another.  What options are open to me in terms of getting W7 to boot after the drive is picked up and moved from one box to another? I thought it was supposed to be a little less sensitive to this kind of move than XP, but it doesn't work - it is stuck in a reboot loop and never reaches a GUI.  Tried a few things so far, none of which have worked:   Changed SATA mode in the BIOS of the target machine between ATA and AHCI run Windows 7 Startup Repair tried safe mode, no change   (I will keep this list up to date as suggestions come in)  UPDATE: I can confirm this reboot loop is due to STOP error 0x0000007B, and these codes follow:  0xFFFFF880009A98E8 0xFFFFFFFFC0000034 0x0000000000000000 0x0000000000000000    UPDATE: I didn't get anywhere on this and I ended up just rebuilding the machine. I think it should be theoretically possible, so I'm going to leave the question open in case someone comes along in future with an answer. MySQL - varchar length and performance Set shortcuts to change keyboard layout in Windows 10? Is there any way to set keyboard shortcuts to quickly change to a different language/keyboard layout? The old shortcuts still seem to work (when set back in Windows 7), but I can't seem to find anything to change it in Windows 10. What is a natural response to &quot;Good to see you. How you doing?&quot;? Will a natural response include &quot;doing&quot; as in &quot;I'm doing okay&quot; or will &quot;I'm okay&quot; be more natural? How do I watch a file for changes? I have a log file being written by another process which I want to watch for changes. Each time a change occurs I'd like to read the new data in to do some processing on it.  What's the best way to do this? I was hoping there'd be some sort of hook from the PyWin32 library. I've found the win32file.FindNextChangeNotification function but have no idea how to ask it to watch a specific file.  If anyone's done anything like this I'd be really grateful to hear how...  [Edit] I should have mentioned that I was after a solution that doesn't require polling.  [Edit] Curses! It seems this doesn't work over a mapped network drive. I'm guessing windows doesn't 'hear' any updates to the file the way it does on a local disk.