question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Command Line Arguments for python

See original GitHub issue

Hi-

I have been trying to get the command line arguments for some part of code inside python. Normally I can do that using sys.argv. But cocotb runs via makefile. I got confused on how to take the command line arguments for python file. Is it possible to do something like this here?

==================================================================================== Cocotb version --> 1.6.0 Python --> 3.9.0 Linux Distro --> Fedora Simulator --> Cadence Xcelium

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
marlonjamescommented, May 16, 2022

If you want to be able to override only the a=3 default inside the list of PLUSARGS, I’m not enough of a make expert for that. You could however use separate variables and then add them to PLUSARGS after they have been resolved to their final values.

So make TESTCASE=<name> A=11 B=4 along with:

A?=3
B?=4
C?=0

PLUSARGS+=$(A)
PLUSARGS+=$(B)
PLUSARGS+=$(C)
0reactions
PiyushSaini09commented, May 16, 2022

Thank you for the help. This method fulfills my requirement to some extent. But with this now the variable will always have a particular value whether I pass it from the command line or not.

Please rectify me if I’m wrong here: Is it that Makefile can see the values of the variables only at one place? If I’ve defined the values of the variables in command line then it won’t see the values inside the Makefile?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command Line Arguments in Python - GeeksforGeeks
It is a list of command line arguments. · len(sys.argv) provides the number of command line arguments. · sys.argv[0] is the name of...
Read more >
Python Command Line Arguments
Python exposes a mechanism to capture and extract your Python command line arguments. These values can be used to modify the behavior of...
Read more >
Python - Command Line Arguments - Tutorialspoint
Python provided a getopt module that helps you parse command-line options and arguments. This module provides two functions and an exception to enable...
Read more >
Python Command Line Arguments - DigitalOcean
Python Command line arguments are input parameters passed to the script when executing them. Almost all programming language provide support ...
Read more >
Command Line Arguments for Your Python Script
The optional arguments are introduced by “ - ” or “ -- “, where a single hyphen will carry a single character “short...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found