Posts

Showing posts with the label command-line

When I call /usr/bin/pydoc, /usr/bin/pydoc2.7 called indeed

Image
Clash Royale CLAN TAG #URR8PPP When I call /usr/bin/pydoc, /usr/bin/pydoc2.7 called indeed when I run the command /usr/bin/pydoc , it prints /usr/bin/pydoc durd@FelixDu bin$ /usr/bin/pydoc pydoc - the Python documentation tool pydoc <name> ... Show text documentation on something. <name> may be the name of a Python keyword, topic, function, module, or package, or a dotted reference to a class or function within a module or module in a package. If <name> contains a '/', it is used as the path to a Python source file to document. If name is 'keywords', 'topics', or 'modules', a listing of these things is displayed. pydoc -k <keyword> Search for a keyword in the synopsis lines of all available modules. pydoc -p <port> Start an HTTP server on the given port on the local machine. Port number 0 can be used to get an arbitrary unused port. pydoc -g Pop up a graphical interface for finding ...

How to take the string from input of argparse and use it as an object

Image
Clash Royale CLAN TAG #URR8PPP How to take the string from input of argparse and use it as an object I am trying to create a program that reads a string off an argparse input and uses that string to call a certain object and use that object for the rest of the function. #!/usr/bin/python import argparse class car: def __init__(self, color, year): self.color = color self.year = year Beatle = car("blue", 1973) parser = argparse.ArgumentParser() parser.add_argument("--vehicleType") args = parser.parse_args() print("This "+args.vehicleType+ " is nice") print("It was made:") print(2018-args.vehicleType.year) print("years ago") However, I keep getting back this error: Traceback (most recent call last): File "./test.py", line 17, in <module> print(2018-args.vehicleType.year) AttributeError: 'str' object has no attribute 'year' I think the program is reading args.vehicleTyp...