the below is what confuses me:  In terminal, I tried these codes:  &gt;&gt;&gt; a = 1900 &gt;&gt;&gt; b = 1900 &gt;&gt;&gt; a is b False &gt;&gt;&gt; c = 1 &gt;&gt;&gt; d = 1 &gt;&gt;&gt; c is d True   As I think, these result comes from what I read from this post: : Python caches small integer objects for performance reasons. So 'a is b' will return false because they point to different objects (obviously they are not small integer objects).  But when I try this part of code on PyCharm venv, the result comes to different:  a = 1900 b = 1900 print(a is b) console shows 'True'   Why does this happen? they have the same python version:   Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28)  [Clang 6.0 (clang-600.0.57)] on darwin
2525
My  has failed me.  In Python, are the following two tests for equality equivalent?  n = 5 # Test one. if n == 5:     print 'Yay!'  # Test two. if n is 5:     print 'Yay!'   Does this hold true for objects where you would be comparing instances (a list say)?  Okay, so this kind of answers my question:  L = [] L.append(1) if L == [1]:     print 'Yay!' # Holds true, but...  if L is [1]:     print 'Yay!' # Doesn't.   So == tests value where is tests to see if they are the same object?
89893
The __debug__ variable is handy in part because it affects every module. If I want to create another variable that works the same way, how would I do it?  The variable (let's be original and call it 'foo') doesn't have to be truly global, in the sense that if I change foo in one module, it is updated in others. I'd be fine if I could set foo before importing other modules and then they would see the same value for it.
64558
I started learning about pointers in C++ and I figured I should educate myself a bit on how memory works and is accessed. I read that when we say a processor is 64-bit, it has a 64-bit register and can access 2^64 address locations. I also read that it can fetch 64/8, so 8 bytes of data at a time, but the data bus is not the same thing as the register right? Do they need to be the same size or does that just happen to be the case usually? And is it the size of the register or the data bus size that determines what we refer to it as, such as 32/64-bit? Also is there a difference between register size and address size?
57804
I've been struggling with this problem, actually I was doing a program in python and did   1j ** 1j(complex numbers) (In python a**b = $a^b$ )   and found out the answer to be a real number with value $0.2079$, How to calculate this value of $i^i$?
6670
I was wondering how to check whether a variable is a class (not an instance!) or not.  I've tried to use the function isinstance(object, class_or_type_or_tuple) to do this, but I don't know what type would a class will have.  For example, in the following code  class Foo: pass   isinstance(Foo, **???**) # i want to make this return True.   I tried to substitute  "class" with ???, but I realized that class is a keyword in python.
71286
In MySQL table definitions is there a different between INT(5) and SMALLINT(5)?  Or do they both represent the same size?
79557
I'm having a little argument with my friend. He says that "$a + 0i$" is, in every way, absolutely equal to "$a$" (e.g.: $2 + 0i = 2$).  I say this is practically the case, so in every calculation you just assume that "$a + 0i$" is equal to the real number "$a$" and you always get the right results (this might not even be true, but I am no expert and as far as I can see this is the case). But then again, I believe that just cutting away "$+ 0i$" makes this number is not the same kind of number anymore, it's changed its structure and is not totally equivalent anymore. This is where he says I am absolutely wrong.  So, is it mathematically (strictly speaking!) perfectly fine to say that every complex number with an imaginary part of $0$ is just a real number? Or does this change the mathematical structure so much that it cannot be mathematically-valid but just something that happens to work (which is what I believe)?  I must say that I believe a complex number is one entity, whilst he believes that it is just a conglomerate of other entitites. So, as one said here, "$(a + bi) - bi = a$", I believe is barely a good argument. But then again: is it correct to view $a + bi$ as a single entity (like "$5$" or "$2$", just consisting of multiple symbols)? I'm (as a non-mathematician) not sure there either.
40474
I have a Python function that takes a numeric argument that must be an integer in order for it behave correctly. What is the preferred way of verifying this in Python?  My first reaction is to do something like this:  def isInteger(n):     return int(n) == n   But I can't help thinking that this is 1) expensive 2) ugly and 3) subject to the tender mercies of machine epsilon.   Does Python provide any native means of type checking variables? Or is this considered to be a violation of the language's dynamically typed design?  EDIT: since a number of people have asked - the application in question works with IPv4 prefixes, sourcing data from flat text files. If any input is parsed into a float, that record should be viewed as malformed and ignored.
93814
A friend &amp; I were debating how Inf's and NaN's are stored during lunch today.  Take Fortran 90 for example.  4-byte reals can obtain the value of Inf or NaN.  How is this stored internally?  Presumably, a 4-byte real is a number represented internally by a 32 digit binary number.  Are Inf's and NaN's stored as 33 bit binary numbers?
37655
In Bash, two integers can be compared using conditional expression     arg1 OP arg2      OP is one of -eq, -ne, -lt, -le, -gt, or -ge. These   arithmetic binary operators return true if arg1 is equal to, not equal   to, less than, less than or equal to, greater than, or greater than or   equal to arg2, respectively. Arg1 and arg2 may be positive or negative   integers.   or arithmetic expression:     &lt;= &gt;= &lt; &gt; comparison      == != equality and inequality   Why do we have two different ways for comparing two integers? When to use which?  For example, [[ 3 -lt 2 ]] uses conditional expression, and (( 3 &lt; 2 )) uses arithmetic expression. Both returns 0 when the comparison is true  When comparing two integers, can these two methods always be used interchangeably? If yes, why does Bash have two methods rather than one?
31644
I'm looking for a clear, concise and accurate answer.    Ideally as the actual answer, although links to good explanations welcome.  This also applies to VB.Net, but the keywords are different - ByRef and ByVal.
12905
How do you get the  of two variables in Python?  For example, I have two variables that I expect to be strings. I want to test that only one of them contains a True value (is not None or the empty string):  str1 = raw_input("Enter string one:") str2 = raw_input("Enter string two:") if logical_xor(str1, str2):     print "ok" else:     print "bad"   The ^ operator seems to be bitwise, and not defined on all objects:  &gt;&gt;&gt; 1 ^ 1 0 &gt;&gt;&gt; 2 ^ 1 3 &gt;&gt;&gt; "abc" ^ "" Traceback (most recent call last):   File "&lt;stdin&gt;", line 1, in &lt;module&gt; TypeError: unsupported operand type(s) for ^: 'str' and 'str'
91303
The following seems strange.. Basically, the somedata attribute seems shared between all the classes that inherited from the_base_class.  class the_base_class:     somedata = {}     somedata['was_false_in_base'] = False   class subclassthing(the_base_class):     def __init__(self):             print self.somedata   first = subclassthing() {'was_false_in_base': False} first.somedata['was_false_in_base'] = True second = subclassthing() {'was_false_in_base': True} &gt;&gt;&gt; del first &gt;&gt;&gt; del second &gt;&gt;&gt; third = subclassthing() {'was_false_in_base': True}   Defining self.somedata in the __init__ function is obviously the correct way to get around this (so each class has it's own somedata dict) - but when is such behavior desirable?
118039
I've been working happily with Blender all this week and last, performing hundreds of operations, many booleans, and getting good results in a rudimentary model for a small enclosure.     Today I've renamed the file to v2, and started to make a couple of changes.  I'm just removing some material using a simple shape to create insets and a boolean difference operation.  Suddenly, though, the 'difference' is behaving like a 'union' and vice-versa.  I thought I'd forgotten something overnight, and tried it on two other simple objects in the same design, with the same result. I then opened a new design with just two cubes and tried it there, where it works without error.  Quit, back to my own design v2, and still the behavior is swapped.     I've restarted Blender a couple of times.  Moving on to trying more renaming, rebooting tests etc.  Is this a known issue, am I missing something obvious? Is there a work-around that someone can suggest.   (I'm using ver 2.70 on Mac OS 10.8.5)
72634
I have this legacy code that I am working with and there is code like this all over the place:       #If PRE611 = True Then         'Do Something     #Else         'Something Else     #End If   I am pretty sure the PRE611 has something to do with versioning, but I would like to know what specifically the # sign does.
23996
I am a newbie to Python and have come across the following example in my book that is not explained very well. Here is my print out from the interpreter:  &gt;&gt;&gt; s = 'spam' &gt;&gt;&gt; s[:-1] 'spa'   Why does slicing with no beginning bound and a '-1' return every element except the last one? Is calling s[0:-1] logically the same as calling s[:-1]? They both return the same result. But I'm not sure what python is doing exactly. Any help would be greatly appreciated.
90560
In most programming languages, integer and real (or float, rational, whatever) types are usually disjoint; 2 is not the same as 2.0 (although most languages do an automatic conversion when necessary). In addition to technical reasons, this separation makes sense -- you use them for quite different purposes.  Why did they choose to say $\mathbb{Z} \subset \mathbb{R}$ in math? In other words, why are 2 and 2.0 considered the same?  When you are working in $\mathbb{R}$, does it make any difference whether some elements, eg. 2.0, also belong to $\mathbb{Z}$ or not?