What does ** (double star/asterisk) and * (star/asterisk) do for parameters?

In the following method definitions, what does the * and ** do for param2? def foo(param1, *param2): def bar(param1, **param2):

Django: Unpack argument list for use in aggregate query

I am attempting to create a semi-dynamic aggregate function that will return the sums of all fields within a list. The assumption is that running get_query_set() will return a filtered query that...

Reference — What does this symbol mean in PHP?

What is this? This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this...

Pass multiple parameters to concurrent.futures.Executor.map?

The concurrent.futures.Executor.map takes a variable number of iterables from which the function given is called. How should I call it if I have a generator that produces tuples that are normally...

Python: parsing binary stl file

I'm having some difficulties while parsing a binary STL file with Python (2.7.1 32-bit and Windows 7 64). The file is a about 450k in size, but my parser suddenly stops working after parsing 244...

Unpacking keyword arguments, but only the ones that match the function

Let's say I have a function: def foo(a=None, b=None, c=None): return "a:%s, b:%s, c:%s" % (a, b, c) I have a dictionary with some (or none) of the arguments above, but also with keys that are...

upgade python version using pip

So I have python 2.7.3 installed on Windows 7 64 bit and I want to do an incremental upgrade to version 2.7.5. I have pip installed and it works fine; I just installed Django using it. I ran into...

Failed to install Python Cryptography package with PIP and setup.py

When I try to install the Cryptography package for Python through either pip install cryptography or by downloading the package from their site and running python setup.py, I get the following...

How to 'unpack' table into function arguments

I'm trying to call a function in Lua that accepts multiple 'number' arguments function addShape(x1, y1, x2, y2 ... xn, yn) and I have a table of values which I'd like to pass as arguments values...

VBA: Set variable to "Empty" or "Missing"? Handling multiple optional arguments?

Is it possible, or desirable, to set objects/data to an "Empty" or "Missing" variant? I want to be able to conditionally pass optional arguments to a function. Sometimes I want to use an optional...

Type annotations for *args and **kwargs

I'm trying out Python's type annotations with abstract base classes to write some interfaces. Is there a way to annotate the possible types of *args and **kwargs? For example, how would one...

fatal: ambiguous argument 'v': unknown revision or path not in the working tree in git

i am building my binaries using gitian-build for my own blockchain(template from peershare) that is run on my localhost. when i exwcute the command git pull for the gitian-builder it gives the...

Cannot unpack array with string keys

FATAL ERROR Uncaught Error: Cannot unpack array with string keys I know I can simply run the method fetch() twice and pass the ['q'] and ['bind'] but I am trying to get to grips with using the...

OpenCV installation with Java on MAC OS Sierra

Trying to install OpenCV3.1 for Java on MAC OS 10.12.2 (Sierra). Followed the commands from this link. I would like to install this so that I can configure Eclipse with OpenCV. Couple of errors...

NoClassDefFoundError every second restart of Tomcat

Currently we are facing a strange issue. We have a big application which is deployed as ROOT.war in the webapp directory (no other applications). Tomcat (8.0.32) unpacks the war while starting. It...

Define a pytest fixture providing multiple arguments to test function

With pytest, I can define a fixture like so: @pytest.fixture def foo(): return "blah" And use it in a test like so: def test_blah(foo): assert foo == "blah" That's all very well. But...

Python pool.starmap with list of dictionaries?

Is there a function similar to pools.starmap that can be used with list of dictionaries? Instead of : pools.starmap(func, iterable_of_tuple) You would have: pools.starmapdict(func,...

How do I check if a value matches a type in python?

Let's say I have a python function whose single argument is a non-trivial type: from typing import List, Dict ArgType = List[Dict[str, int]] # this could be any non-trivial type def myfun(a:...

R equivalent of python star unpacking?

I have a routine in R that takes a variable number of arguments, and I need to call this routine passing an unpacked list. In python I would do lst = [1,2,3] my_func(*lst) What is the equivalent...

Passing NumPy arrays as arguments to numba.cfunc

I have been fighting with an issue that I am having trouble wrapping my head around, and therefore don't quite know how to start solving it. My experience in programming C is very limited and that...

I can´t install Anaconda on Linux

When I try to install Anaconda on Linux, I get to this point: Anaconda3 will now be installed into this location: /home/jorge/anaconda3 - Press ENTER to confirm the location - Press CTRL-C to...

TypeError: __init__() missing 1 required positional argument: 'msg' everytime i try to download anaconda3 on macbook

I am trying to download anaconda3 terminal version for a 64bit mac OS Catalina to use for python 3.7, and i keep running into the error: Unpacking payload...

UnPack NuGet package that gets created on build

I am trying to unpack the nuget package that gets created during the build. My Directory.Build.props file looks like this: <?xml version="1.0"...

How to make work typing annotation on mypy with unpacking params for pytest parameterized test?

I have a simple method on my_module.py with the signature: def my_method(value: float, extra: str = "something") -> str: pass Then I have a parameterized test on test_my_module.py for...

Using mypy to type check and i cant figure out why this errors are happening

So, i using mypy to learn how to code in python using type check from the beginning. I'm using this code to train: def stars(*args: int, **kwargs: float) -> None: for arg in args: ...

Docker run inside Ubuntu on Windows WSL

My error [email protected]:~/temp2607/reaction-development-platform$ sudo apt-get update Hit:1 https://download.docker.com/linux/ubuntu focal InRelease Hit:2 http://archive.ubuntu.com/ubuntu...

Problem with inputs when building a model with TFBertModel and AutoTokenizer from HuggingFace's transformers

I'm trying to build the model illustrated in this picture: I obtained a pre-trained BERT and respective tokenizer from HuggingFace's transformers in the following way: from transformers import...

"Unpacking" macro arguments

I have the following macro: #define HEX 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 #define BITS 0x01 #define ADD_FLAGS(a, b, c, d, e, f, g, h) \ a, b | BITS, c, d, e, f, g, h I use this...

Why does starred assignment produce lists and not tuples?

In python, I can write something like this: some_list = [(1, 2, 3), (3, 2, 1)] for i, *args in some_list: print(args) I will get the next output: [2, 3] [2, 1] When we use *args as function...