This question already has answers here:
What is the meaning of a forward slash "/" in a Python method signature, as shown by help(foo)? [duplicate]
(1 answer)
Bare asterisk in function parameters?
(6 answers)
What does the slash mean when help() is listing method signatures?
(3 answers)
Closed 16 days ago.
Pythonestas,
I can't find any guidance or explanation of the Python help documentation?
As an example, what does the "*" and the "/" refer to?
If the default value for key = None, where are the explanations for what can be used for the key argument?
sorted(iterable, /, *, key=None, reverse=False)ΒΆ
Thanks in advance!
Cannot find the answer in the Python.org docs.
Related
This question already has answers here:
What does -> mean in Python function definitions?
(11 answers)
What are type hints in Python 3.5?
(5 answers)
Closed 9 months ago.
The function I saw has a "->int" sign after the declaration statement.
class Solution:
def numUniqueEmails(self, emails: List[str]) -> int:
What does it mean? And how can it be used or the best practices to follow?
Thanks in advance.
This question already has answers here:
What algorithm does Python's built-in sort() method use?
(2 answers)
What is `lambda` in Python code? How does it work with `key` arguments to `sorted`, `sum` etc.?
(4 answers)
Understanding the map function
(6 answers)
Closed 1 year ago.
I found the following line of code which I'm unable to google as it has a custom function. Can someone please explain this?
list.sort(key=lambda v: map(int, v.split('.')))
I know this sorts a list but I want to understand which sort is it and how it works.
This question already has answers here:
Use Python Match object in string with backreferences
(1 answer)
Regex in python: is it possible to get the match, replacement, and final string?
(2 answers)
Closed 3 years ago.
What is an example usage of Match.expand ? It doesn't give any examples in the python docs (which is the first I've heard of the method), and only states:
Match.expand(template)
Return the string obtained by doing backslash substitution on the template string template, as done by the sub() method.
How would this actually be used and how could it be useful?
you can find more explanations and examples here:
match.expand
In general:
it allows you to expand the match you have found and modify its' prefix
This question already has answers here:
Expanding tuples into arguments
(5 answers)
Closed 8 months ago.
If I have a function:
def run(time, message, time_span_pattern):
...
And a list like:
run_args = ['1s', '1 second alarm', <_sre.SRE_Pattern object at 0x100435680>]
How can I pass the list, as separate arguments, to run? Is there a builtin way to do this, or am I forced to reference each element individually and by index?
You're looking for:
run(*run_args)
This is explained in more detail in this StackOverflow answer about the star and double star operator
It's also covered in the python docs
This question already has answers here:
Use of *args and **kwargs [duplicate]
(11 answers)
Closed 8 years ago.
In nltk. collocations I use this finder.apply_ngram_filter(lambda *w: w not in list). But I do not know what does mean the asterisk here. can someone explain me what the meaning of *w here? Because I know that the asterisk comes after the string and not before it.
It is argument unpacking :*args and **kwargs?. This means it is taking all the arguments you might pass to a function.