## Fix Python – Asterisk in function call [duplicate]

What does the star and doublestar operator mean in a function call?

Closed 1 year ago.

I’m using itertools.chain to “flatten” a list of lists in this fashion:
uniqueCrossTa….

## Fix Python – What does the caret (^) operator do?

I ran across the caret operator in python today and trying it out, I got the following output:
>>> 8^3
11
>>> 8^4
12
>>> 8^1
9
>>> 8^0
8
>>> 7^1
6
>>> 7^2
5
>>> 7^7
0
>>> 7^8
15
>>> 9^1
8
>>> 16^1
17
>>> 15^1
14
>>>

It seems to be based on 8, so I’m guessing some sort of byte operation? I can’t seem to find much about this searching sites other ….

## Fix Python – What is `1..__truediv__` ? Does Python have a .. (“dot dot”) notation syntax?

I recently came across a syntax I never seen before when I learned python nor in most tutorials, the .. notation, it looks something like this:
f = 1..__truediv__ # or 1..__div__ for python 2

print(f(8)) # prints 0.125

I figured it was exactly the same as (except it’s longer, of course):
f = lambda x: (1).__truediv__(x)
print(f(8)) # prints 0.1….

## Fix Python – When is “i += x” different from “i = i + x” in Python?

I was told that += can have different effects than the standard notation of i = i +. Is there a case in which i += 1 would be different from i = i + 1?
….

## Fix Python – Override Python’s ‘in’ operator?

If I am creating my own class in Python, what function should I define so as to allow the use of the in operator, e.g.
class MyClass(object):

m = MyClass()

if 54 in m:

….

## Fix Python – What is the result of % in Python?

What does the % in a calculation? I can’t seem to work out what it does.
Does it work out a percent of the calculation for example: 4 % 2 is apparently equal to 0. How?
….

## Fix Python – The tilde operator in Python

What’s the usage of the tilde operator in Python?
One thing I can think about is do something in both sides of a string or list, such as check if a string is palindromic or not:
def is_palindromic(s):
return all(s[i] == s[~i] for i in range(len(s) / 2))

Any other good usage?
….

## Fix Python – How can I obtain the element-wise logical NOT of a pandas Series?

I have a pandas Series object containing boolean values. How can I get a series containing the logical NOT of each value?
For example, consider a series containing:
True
True
True
False

The series I’d like to get would contain:
False
False
False
True

This seems like it should be reasonably simple, but apparently I’ve misplaced my mojo =(
….

## Fix Python – Python != operation vs “is not”

In a comment on this question, I saw a statement that recommended using
result is not None

vs
result != None

I was wondering what the difference is, and why one might be recommended over the other?
….

## Fix Python – Is there a “not equal” operator in Python?

How would you say does not equal?
Like
if hi == hi:
print “hi”
elif hi (does not equal) bye:
print “no hi”

Is there something equivalent to == that means “not equal”?
….