Python Question: arguments after star-arguments

My code currently has two places in which, due to the way that the code worked out, I’m calling a method and passing in as parameters first a star-argument (that is, something like “*argList”), and then a standard argument. Something like this:

myMethod(*argList, anotherParameter)

Alas, my IDE complains about my doing so, warning me that passing arguments in such an order is not allowed in Python versions < 3.5.

A quick check indicates that I’m using Python 3.6, and in any case the code runs happily. Is there any reason to worry about this?

If called for, I do have a workaround, I believe: I can simply add the standard argument to the end of the argument list, and then pass that in. Something like this:

finalList = argList + [anotherParameter]

It’s less elegant, I feel, but at the least the IDE will likely not complain about it, I think.

Is your IDE configured to use python 3.6?

Also, if you want, there’s IDEs that has special comments to make an error be ignored the same line they are placed.

It looks like it is–but it’s very possible that I’m missing an option somewhere.

Do you know of any such for PyCharm? (That being the editor that I’m using.) Alas, while it allows me to ignore some errors, it doesn’t seem to offer the option for this one…

I take it that you don’t consider the error to be worrisome?

If the code works, and the interpreters says nothing. Nope, nothing to worry about. Unless you care if the code works with older versions.

And about this:

I found this, also, you have to place the comment line on top of the line you want the error to be ignored (I don’t have PyCharm so I can’t test, but might be useful):

Great, and thank you, on both counts. :slight_smile: