FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-language-tester/python.py at master · hasanzaidi/python-language-tester · GitHub
hasanzaidi
/
python-language-tester
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
python-language-tester
/
python.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (32 loc) · 816 Bytes
Breadcrumbs
python-language-tester
/
python.py
Copy path
File metadata and controls
41 lines (32 loc) · 816 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Code snippets which can't really be expressed in unit test
# Throwing an exception
items
=
[
1
,
2
]
if
len
(
items
)
==
0
:
raise
ValueError
(
"Empty list"
)
# Pass is a null operation (i.e. nothing happens). Useful to use temporarily as body for methods until they are fleshed
# out.
f
=
False
if
f
is
True
:
pass
else
:
print
(
"hello"
)
print
(
"print line never gets called"
)
# _ can be used when you don't care about its value, e.g.
print
()
for
_
in
range
(
5
):
print
(
"hello world"
)
# To create a custom exception class
class
CustomError
(
Exception
):
pass
# Creating a normal class
class
A
(
object
):
def
__init__
(
self
):
self
.
x
=
'Hello'
self
.
y
=
1
def
add
(
self
,
arg
:
int
):
self
.
y
=
self
.
y
+
arg
foo
=
A
()
print
(
foo
.
x
)
# Shows as error in IDE
foo
.
add
(
"a"
)
print
(
foo
.
y
)
Back
|
FazBrowse Home
|
New Git URL