Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Programming course
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
courses
Programming course
Commits
236b8b01
Commit
236b8b01
authored
11 years ago
by
J.F.J. Laros
Browse files
Options
Downloads
Patches
Plain Diff
Some more modifications on the classes slides.
parent
14546372
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
classes.ipynb
+298
-152
298 additions, 152 deletions
classes.ipynb
person.py
+29
-0
29 additions, 0 deletions
person.py
with
327 additions
and
152 deletions
classes.ipynb
+
298
−
152
View file @
236b8b01
...
...
@@ -27,6 +27,22 @@
"License: [Creative Commons Attribution 3.0 License (CC-by)](http://creativecommons.org/licenses/by/3.0)"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%%html\n",
"<style type=\"text/css\">\n",
"/* Remove the vertical scrollbar added by nbconvert. */\n",
".reveal {\n",
" overflow-y: hidden;\n",
"}\n",
"</style>"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
...
...
@@ -52,6 +68,7 @@
"collapsed": false,
"input": [
"from IPython.display import HTML, Image, IFrame\n",
"from person import Person\n",
"%pylab inline"
],
"language": "python",
...
...
@@ -69,7 +86,7 @@
]
}
],
"prompt_number": 1
28
"prompt_number": 1
},
{
"cell_type": "markdown",
...
...
@@ -79,9 +96,11 @@
}
},
"source": [
"Imagine we are collecting a number of attributes of some persons:\n",
"Keeping track of attributes\n",
"===\n",
"\n",
"Suppose we want to keep track of some properties in a population:\n",
"\n",
"* Eye colour.\n",
"* Hair colour.\n",
"* Weight.\n",
"* Length."
...
...
@@ -95,6 +114,9 @@
}
},
"source": [
"Non-object oriented\n",
"===\n",
"\n",
"Should we use simple lists?"
]
},
...
...
@@ -102,12 +124,11 @@
"cell_type": "code",
"collapsed": false,
"input": [
"eye_colour = ['blue', 'blue', 'grey', 'green', 'brown']\n",
"hair_colour = ['black', 'red', 'white', 'blue', 'red']\n",
"weight = [80, 75, 130, 90, 64]\n",
"length = [180, 174, 230, 161, 149]\n",
"\n",
"
eye_colour[3],
hair_colour[3], weight[3], length[3]"
"hair_colour[3], weight[3], length[3]"
],
"language": "python",
"metadata": {},
...
...
@@ -115,13 +136,20 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
129
,
"prompt_number":
2
,
"text": [
"(
'green',
'blue', 90, 161)"
"('blue', 90, 161)"
]
}
],
"prompt_number": 129
"prompt_number": 2
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Getting all attributes is a bit of a hastle."
]
},
{
"cell_type": "code",
...
...
@@ -135,22 +163,32 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
130
,
"prompt_number":
3
,
"text": [
"90"
]
}
],
"prompt_number": 130
"prompt_number": 3
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Getting one attribute is easy though."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "
sub
slide"
}
},
"source": [
"Non-object oriented\n",
"===\n",
"\n",
"Or nested lists?"
]
},
...
...
@@ -158,13 +196,13 @@
"cell_type": "code",
"collapsed": false,
"input": [
"person = [[
'blue',
'black', 80, 180],\n",
" [
'blue',
'red', 75, 174],\n",
" [
'grey',
'white', 130, 230],\n",
" [
'green',
'blue', 90, 161],\n",
" [
'brown',
'red', 64, 149]]\n",
"person
s
= [['black', 80, 180],\n",
" ['red', 75, 174],\n",
" ['white', 130, 230],\n",
" ['blue', 90, 161],\n",
" ['red', 64, 149]]\n",
"\n",
"person[3]"
"person
s
[3]"
],
"language": "python",
"metadata": {},
...
...
@@ -172,19 +210,26 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
131
,
"prompt_number":
4
,
"text": [
"[
'green',
'blue', 90, 161]"
"['blue', 90, 161]"
]
}
],
"prompt_number": 131
"prompt_number": 4
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now all attributes are nicely grouped."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"person[3][2]"
"person
s
[3][2]"
],
"language": "python",
"metadata": {},
...
...
@@ -192,22 +237,32 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
132
,
"prompt_number":
5
,
"text": [
"
90
"
"
161
"
]
}
],
"prompt_number": 132
"prompt_number": 5
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Accessing a single attribute is a bit cryptic though."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "
sub
slide"
}
},
"source": [
"Non-object oriented\n",
"===\n",
"\n",
"Or a list of dictionaries?"
]
},
...
...
@@ -215,13 +270,13 @@
"cell_type": "code",
"collapsed": false,
"input": [
"person = [{
'eye_colour': 'blue',
'hair_colour': 'black', 'weight': 80, 'length': 180},\n",
" {
'eye_colour': 'blue',
'hair_colour': 'red', 'weight': 75, 'length': 174},\n",
" {
'eye_colour': 'grey',
'hair_colour': 'white', 'weight': 130, 'length': 230},\n",
" {
'eye_colour': 'green',
'hair_colour': 'blue', 'weight': 90, 'length': 161},\n",
" {
'eye_colour': 'brown',
'hair_colour': 'red', 'weight': 64, 'length': 149}]\n",
"person
s
= [{'hair_colour': 'black', 'weight': 80, 'length': 180},\n",
" {'hair_colour': 'red', 'weight': 75, 'length': 174},\n",
" {'hair_colour': 'white', 'weight': 130, 'length': 230},\n",
" {'hair_colour': 'blue', 'weight': 90, 'length': 161},\n",
" {'hair_colour': 'red', 'weight': 64, 'length': 149}]\n",
"\n",
"person[3]"
"person
s
[3]"
],
"language": "python",
"metadata": {},
...
...
@@ -229,19 +284,19 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
133
,
"prompt_number":
6
,
"text": [
"{
'eye_colour': 'green',
'hair_colour': 'blue', 'length': 161, 'weight': 90}"
"{'hair_colour': 'blue', 'length': 161, 'weight': 90}"
]
}
],
"prompt_number":
133
"prompt_number":
6
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"person[3]['weight']"
"person
s
[3]['weight']"
],
"language": "python",
"metadata": {},
...
...
@@ -249,13 +304,13 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
134
,
"prompt_number":
7
,
"text": [
"90"
]
}
],
"prompt_number":
134
"prompt_number":
7
},
{
"cell_type": "markdown",
...
...
@@ -265,68 +320,22 @@
}
},
"source": [
"
Object Oriented Programming
\n",
"
Classes
\n",
"===\n",
"\n",
"A class as a simple container:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"class Person(object):\n",
" weight = 80\n",
" \n",
" def __init__(self, eye_colour='unknown', hair_colour='unknown', weight=0, length=0):\n",
" self.eye_colour = eye_colour\n",
" self.hair_colour = hair_colour\n",
" if weight:\n",
" self.weight = weight\n",
" self.length = length\n",
" \n",
" def __str__(self):\n",
" return \"Eye colour: {0}, Hair colour: {1}, Weight: {2}, Length: {3}\".format(\n",
" self.eye_colour, self.hair_colour, self.weight, self.length)\n",
" \n",
" def __len__(self):\n",
" return self.length\n",
"\n",
" def feed(self, amount=3):\n",
" self.weight += amount\n",
" \n",
" def bleach(self):\n",
" self.hair_colour = 'white'\n",
" \n",
" def _convert_weight(self, multiplier):\n",
" return self.weight * multiplier\n",
" \n",
" def weight_in_pounds(self):\n",
" return self._convert_weight(2.20462)\n",
" \n",
" def weight_in_grams(self):\n",
" return self._convert_weight(1000)"
],
"language": "python",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"outputs": [],
"prompt_number": 135
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "
slide
"
"slide_type": "
-
"
}
},
"source": [
" class Person(object):\n",
" def __init__(self, eye_colour='unknown', hair_colour='unknown', weight=0, length=0):\n",
" self.eye_colour = eye_colour\n",
" def __init__(self, hair_colour='unknown', weight=0, length=0):\n",
" self.hair_colour = hair_colour\n",
" self.weight = weight\n",
" self.length = length"
...
...
@@ -336,7 +345,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"someone = Person(
'green',
'blue', 90, 161)\n",
"someone = Person('blue', 90, 161)\n",
"\n",
"someone.weight"
],
...
...
@@ -346,39 +355,57 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
136
,
"prompt_number":
8
,
"text": [
"90"
]
}
],
"prompt_number": 136
"prompt_number": 8
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"Classes\n",
"===\n",
"\n",
"Makes initialisation a lot easier."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"person = [Person(),\n",
" Person(
'blue',
'red'),\n",
" Person(
'grey',
'white', 130, 230),\n",
" Person(weight=90),\n",
" Person(weight=64, length=149)]\n",
"person
s
= [Person(),\n",
"
Person('red'),\n",
"
Person('white', 130, 230),\n",
"
Person(weight=90),\n",
"
Person(weight=64, length=149)]\n",
"\n",
"person[3].weight"
"person
s
[3].weight"
],
"language": "python",
"metadata": {},
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
137
,
"prompt_number":
9
,
"text": [
"90"
]
}
],
"prompt_number":
137
"prompt_number":
9
},
{
"cell_type": "markdown",
...
...
@@ -387,11 +414,23 @@
"slide_type": "slide"
}
},
"source": [
"Methods\n",
"==="
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
" class Person(object):\n",
" ...\n",
" \n",
" def
feed
(self, amount=3):\n",
" def
eat
(self, amount=3):\n",
" self.weight += amount\n",
" \n",
" def bleach(self):\n",
...
...
@@ -402,9 +441,9 @@
"cell_type": "code",
"collapsed": false,
"input": [
"
pers
on = Person(
'green',
'blue', 90, 161)\n",
"
some
on
e
= Person('blue', 90, 161)\n",
"\n",
"
pers
on.weight,
pers
on.hair_colour"
"
some
on
e
.weight,
some
on
e
.hair_colour"
],
"language": "python",
"metadata": {},
...
...
@@ -412,21 +451,21 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 1
38
,
"prompt_number": 1
0
,
"text": [
"(90, 'blue')"
]
}
],
"prompt_number": 1
38
"prompt_number": 1
0
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"
person.feed
()\n",
"
pers
on.bleach()\n",
"
pers
on.weight,
pers
on.hair_colour"
"
someone.eat
()\n",
"
some
on
e
.bleach()\n",
"
some
on
e
.weight,
some
on
e
.hair_colour"
],
"language": "python",
"metadata": {},
...
...
@@ -434,13 +473,13 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 1
39
,
"prompt_number": 1
1
,
"text": [
"(93, 'white')"
]
}
],
"prompt_number": 1
39
"prompt_number": 1
1
},
{
"cell_type": "markdown",
...
...
@@ -449,6 +488,18 @@
"slide_type": "slide"
}
},
"source": [
"Public and private methods\n",
"==="
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
" class Person(object):\n",
" ...\n",
...
...
@@ -463,11 +514,20 @@
" return self._convert_weight(1000)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Private methods are prefixed with an underscore.\n",
"\n",
"* Note that this is a convention, it is not enforced."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"
pers
on.weight_in_pounds(),
pers
on.weight_in_grams()"
"
some
on
e
.weight_in_pounds(),
some
on
e
.weight_in_grams()"
],
"language": "python",
"metadata": {},
...
...
@@ -475,13 +535,13 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 1
40
,
"prompt_number": 1
2
,
"text": [
"(205.02965999999998, 93000)"
]
}
],
"prompt_number": 1
40
"prompt_number": 1
2
},
{
"cell_type": "markdown",
...
...
@@ -490,23 +550,43 @@
"slide_type": "slide"
}
},
"source": [
"Class variables vs. instance variables\n",
"==="
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
" class Person(object):\n",
" weight = 80\n",
"
default_
weight = 80\n",
" \n",
" def __init__(self, eye_colour='unknown', hair_colour='unknown', weight=0, length=0):\n",
" self.eye_colour = eye_colour\n",
" def __init__(self, hair_colour='unknown', weight=0, length=0):\n",
" self.hair_colour = hair_colour\n",
" if weight:\n",
" self.weight = weight\n",
" self.weight = weight or self.default_weight\n",
" self.length = length"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Class variables are defined outside the methods.\n",
"\n",
"* It is still refererenced as **self.** inside the methods."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"someone = Person()\n",
"\n",
"someone.weight"
],
"language": "python",
...
...
@@ -515,13 +595,13 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 1
42
,
"prompt_number": 1
3
,
"text": [
"80"
]
}
],
"prompt_number": 1
42
"prompt_number": 1
3
},
{
"cell_type": "code",
...
...
@@ -536,20 +616,21 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 14
3
,
"prompt_number": 14,
"text": [
"79"
]
}
],
"prompt_number": 14
3
"prompt_number": 14
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"Person.weight = 90\n",
"Person.
default_
weight = 90\n",
"someone = Person()\n",
"\n",
"someone.weight"
],
"language": "python",
...
...
@@ -558,13 +639,13 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 1
44
,
"prompt_number": 1
5
,
"text": [
"90"
]
}
],
"prompt_number": 1
44
"prompt_number": 1
5
},
{
"cell_type": "markdown",
...
...
@@ -573,24 +654,55 @@
"slide_type": "slide"
}
},
"source": [
"Special methods\n",
"==="
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" print someone\n",
" <__main__.Person instance at 0x321ebd8>"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"source": [
" class Person(object):\n",
" ...\n",
" \n",
" def __str__(self):\n",
" return \"
Eye colour: {0}, H
air colour: {
1
},
W
eight: {
2}, L
ength: {
3
}\".format(\n",
"
self.eye_colour,
self.hair_colour, self.weight, self.length)\n",
" return \"
Person with h
air colour: {
0
},
w
eight: {
1} and l
ength: {
2
}\".format(\n",
" self.hair_colour, self.weight, self.length)\n",
" \n",
" def __len__(self):\n",
" return self.length"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Special methods are prefixed and suffixed with double underscores.\n",
"\n",
"* There are methods for adding (**\\_\\_add\\_\\_**), subtracting (**\\_\\_sub\\_\\_**), etc."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print person\n",
"len(person)"
"someone = Person('blue', 90, 161)\n",
"\n",
"print someone\n",
"len(someone)"
],
"language": "python",
"metadata": {},
...
...
@@ -599,19 +711,31 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"
Eye colour: green, H
air colour:
whit
e,
W
eight: 9
3, L
ength: 161\n"
"
Person with h
air colour:
blu
e,
w
eight: 9
0 and l
ength: 161\n"
]
},
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 1
2
6,
"prompt_number": 16,
"text": [
"161"
]
}
],
"prompt_number": 126
"prompt_number": 16
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Class inheritance\n",
"==="
]
},
{
"cell_type": "code",
...
...
@@ -619,23 +743,30 @@
"input": [
"class DutchPerson(Person):\n",
" def __str__(self):\n",
" return \"
Oogkleur: {0}, H
aarkleur: {
1
},
G
ewicht: {
2}, L
engte: {
3
}\".format(\n",
"
self.eye_colour,
self.hair_colour, self.weight, self.length)"
" return \"
Persoon met h
aarkleur: {
0
},
g
ewicht: {
1} en l
engte: {
2
}\".format(\n",
" self.hair_colour, self.weight, self.length)"
],
"language": "python",
"metadata": {
"slideshow": {
"slide_type": "
slide
"
"slide_type": "
-
"
}
},
"outputs": [],
"prompt_number": 127
"prompt_number": 17
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A subclass can have added functionality, or it can override some functionality."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"sinterklaas = DutchPerson(
'blue',
'white', 85, 191)\n",
"sinterklaas = DutchPerson('white', 85, 191)\n",
"\n",
"print sinterklaas"
],
...
...
@@ -646,11 +777,23 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"
Oogkleur: blue, H
aarkleur: white,
G
ewicht: 85
, L
engte: 191\n"
"
Persoon met h
aarkleur: white,
g
ewicht: 85
en l
engte: 191\n"
]
}
],
"prompt_number": 86
"prompt_number": 18
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"An object oriented solution for the Sequencer assignment.\n",
"==="
]
},
{
"cell_type": "code",
...
...
@@ -658,14 +801,14 @@
"input": [
"class Read(object):\n",
" def __init__(self):\n",
" self.read =
\"\"
\n",
" self.read =
[]
\n",
" self.qual = []\n",
" \n",
" def __str__(self):\n",
" return self.read\n",
" return
\"\".join(
self.read
)
\n",
" \n",
" def a
d
d(self, base):\n",
" self.read
+=
base[0]\n",
" def a
ppen
d(self, base):\n",
" self.read
.append(
base[0]
)
\n",
" self.qual.append(base[1])\n",
" \n",
" def quality(self):\n",
...
...
@@ -674,16 +817,18 @@
" def trim(self, score):\n",
" for position in range(len(self.read) - 1, -1, -1):\n",
" if self.qual[position] >= score:\n",
" return self.read[:position]"
" self.read = self.read[:position]\n",
" self.qual = self.qual[:position]\n",
" break"
],
"language": "python",
"metadata": {
"slideshow": {
"slide_type": "
slide
"
"slide_type": "
-
"
}
},
"outputs": [],
"prompt_number":
7
"prompt_number":
19
},
{
"cell_type": "code",
...
...
@@ -697,16 +842,17 @@
"reads = [Read() for _ in range(spots)]\n",
"for tile in run:\n",
" for read_id, base in enumerate(tile):\n",
" reads[read_id].a
d
d(base)\n",
" reads[read_id].a
ppen
d(base)\n",
"\n",
"for i in reads:\n",
" print i, i.quality()\n",
" print i.trim(39)"
" i.trim(39)\n",
" print i, i.quality()"
],
"language": "python",
"metadata": {
"slideshow": {
"slide_type": "slide"
"slide_type": "
sub
slide"
}
},
"outputs": [
...
...
@@ -714,14 +860,14 @@
"output_type": "stream",
"stream": "stdout",
"text": [
"
GGTGTGATTCCCGTTCGGTGGGCCGCCTTGGGTCATTG
CTC
GG
TT
G
AG
GAGGGAAG
ACCT
30
\n",
"
GGTGTGATTCCCGTTCGGTGGGCCGCCTTGGGTCAT
\n",
"
GGCTTTAGAATGTCTCCTGC
ATCT
GATGCTATTAAAAGCTATGT
TTTTC
A
CATA
G
TA
CGG
2
9
\n",
"
GGCTTTAGAATGTCTCCTGCATCTGATGCTATTAAAAGCTATGTTTTTCACATAGT
\n"
"
ATCATTAATTCTAAGTAGTCACACCGGATTAACGATCC
CTCTTAG
CCA
AC
G
CT
TTTAGTC 29
\n",
"
ATCATTAATTCTAAGTAGTCACACCGGATTAACGATCCCTCTTAGCCAACGCTTT 30
\n",
"
TCCACTAGTGGGA
AT
A
CT
TAGTATTACACGGACATAG
TTT
AC
TC
C
CAT
T
ATA
TGCTAGAA
2
7
\n",
"
TCCACTAGTGGGAATACT 36
\n"
]
}
],
"prompt_number":
8
"prompt_number":
20
}
],
"metadata": {}
...
...
This diff is collapsed.
Click to expand it.
person.py
0 → 100644
+
29
−
0
View file @
236b8b01
class
Person
(
object
):
default_weight
=
80
def
__init__
(
self
,
hair_colour
=
'
unknown
'
,
weight
=
0
,
length
=
0
):
self
.
hair_colour
=
hair_colour
self
.
weight
=
weight
or
self
.
default_weight
self
.
length
=
length
def
__str__
(
self
):
return
"
Person with hair colour: {0}, weight: {1} and length: {2}
"
.
format
(
self
.
hair_colour
,
self
.
weight
,
self
.
length
)
def
__len__
(
self
):
return
self
.
length
def
eat
(
self
,
amount
=
3
):
self
.
weight
+=
amount
def
bleach
(
self
):
self
.
hair_colour
=
'
white
'
def
_convert_weight
(
self
,
multiplier
):
return
self
.
weight
*
multiplier
def
weight_in_pounds
(
self
):
return
self
.
_convert_weight
(
2.20462
)
def
weight_in_grams
(
self
):
return
self
.
_convert_weight
(
1000
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment