Currently, we have following PEP:
PEP 8: E114 indentation is not a multiple of 4 (comment)
However, I wonder how many people are using 2 spaces as their code indentation
in projects? Should it be nesserary for us to change this PEP from “multiple of
4” to “multiple of 2”?
--
https://mail.pytho
If we have the following code:
```
parser = argparse.ArgumentParser(description="test")
parser.add_argument('path')
```
Run it without args, will get error message:
```
usage: test.py [-h] path
test.py: error: the following arguments are required: path
```
However, I hope the message can be as th
Thank you for your workarounds, Mark Bourne.
`metavar` argument should be sufficient for infrequent use scenarios, and I
will consider to use the custom help formatter if necessary.
>>> That's a bit closer to what you asked for, since the required argument
>>> shown in the error message doesn't
Currently, I use `sys.exit([arg])` for exiting program and it works fine.
As described in the document:
> If another type of object is passed, None is equivalent to passing zero, and
> any other object is printed to stderr and results in an exit code of 1.
However, if I want to exit the program w
Chris:
> It doesn't actually take a list of arguments; the square brackets
indicate that arg is optional here.
Oh, I see, it seems that I mistunderstood the document.
> but for anything more complicated, just print and then exit.
> It's worth noting, by the way, that sys.exit("error message") wil
Lars:
> I totally understand your reasoning here, but in some way it follows the unix
> philosophy: Do only one thing, but do that good.
I understand, python is not strongly typed, so `sys.exit` will be able to
accept any types parameters rather than just integer.
In order to handle such “other”
The following code won’t be allowed in Java, but in python, it works fine:
```python
class A:
A = 3
def __init__(self):
print(self.A)
def p(self):
print(self.A)
self.A += 1
class B(A):
def __init__(self):
print(2)
self.p()
super().
```python
>>> class A:
... def __init__(self):
... pass
...
>>> A.__init__
>>> a = A()
>>> a.__init__
>
```
On many books and even the official documents, it seems that many authors
prefer to call `__init__` as a "method" rather than a "function".
The book PYTHON CRASH COURSE mentioned th
Thanks for all repliers:
@Tony & @Cameron, I do know related stuffs about the dunder methods, and your
explanation just make it to be more clear, thank you!
@Roel, you just caught everyone here, we do miss it even though we know it and
use it regularly!
@Clara
> its both, depending on how you're