diff options
author | jomo <github@jomo.tv> | 2014-07-24 01:19:55 +0200 |
---|---|---|
committer | jomo <github@jomo.tv> | 2014-07-24 01:19:55 +0200 |
commit | 60b523f0d1aff04426a9bcbfe5ed8220677a504d (patch) | |
tree | d7c60096ddf2c8b0f6155ed7fd2db132564d0498 /README.md | |
parent | aafac2fe5a12b5a0fdaa017e2d4b8c6e7a41428b (diff) |
readme stuff
- avoid long methods
- clarify errors
- better traceback example
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -195,6 +195,7 @@ Give function and variable names meaningful names. If you want to shorten long n ## Readability
Don't create long lines with lots of function calls. Split into multiple lines instead.
+Also avoid methods with lots of lines. Split into multiple methods instead.
```Python
# bad
@@ -227,26 +228,20 @@ Watch out for something like `org.python.pycode._pyx5.horribleCode$23(/path/to/b 0. `/path/to/badcode.py` is the actual file of our module
0. `:214` is the line in which the error occured.
-Please note that the line may not be accurate. You'll often get the start or end of a loop, method, or the like - when the actual error was somewhere in there.
+Please note that the line may not be accurate. You'll often get the start of a loop, or the end of a method - when the actual error was somewhere in there.
In many cases, this is enough to find your bug. If you still cannot find it,try to catch exceptions in your code, as follows:
## Catching exceptions
-If you want to catch all exceptions (e.g. for debugging), do not:
-```python
-try:
- # code
-except Exception, e:
- print(e)
-```
+If you want to catch all exceptions (e.g. for debugging), do not `catch Exception`.
Since we're using jython, this will not catch Java exceptions.
This will give you some more deatails:
```python
-import traceback
+from traceback import format_exc as trace
try:
#code
except: # everything
- print(traceback.format_exc())
+ print(trace())
```
\ No newline at end of file |