Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
lists as arguments
#1
Another stupidly simply question, but I have to ask anyway: why do some functions expect their arguments to be what I assume to be lists (square brackets)?
So for instance the bytes function expects the arguments to be written between brackets.
bytes([48])
Another example would be the run function of the subprocess module:
subprocess.run(['ls', '-l'])
And how can one infer this by reading only its definition, and not the examples?

This doesn't seem very helpful in this respect:
Quote: subprocess.run(args, *, stdin=None, input=None, stdout=None, stderr=None, capture_output=False, shell=False, cwd=None, timeout=None, check=False, encoding=None, errors=None, text=None, env=None, universal_newlines=None, **other_popen_kwargs)
Run the command described by args. Wait for command to complete, then return a CompletedProcess instance.
https://docs.python.org/3/library/subpro...rocess.run
Reply


Messages In This Thread
lists as arguments - by vinci - Oct-26-2020, 04:21 PM
RE: lists as arguments - by bowlofred - Oct-26-2020, 05:34 PM
RE: lists as arguments - by deanhystad - Oct-26-2020, 05:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,386 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,291 Mar-20-2019, 08:01 PM
Last Post: stillsen
  Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) Adelton 2 3,882 Mar-02-2017, 10:23 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020