Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0ee10f

Browse files
committed
Various fixes, add decorators
1 parent 7e281d1 commit b0ee10f

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ files, and the full tutorial for each collection of code is available below.
4242
35. [Python Data Class](https://vegibit.com/python-data-class/)
4343
36. [Python Yield Keyword](https://vegibit.com/python-yield-keyword/)
4444
37. [Python Datetime Module Tutorial](https://vegibit.com/python-datetime-module-tutorial/)
45-
38. [Python os Module Tutorial](https://vegibit.com/python-os-module-tutorial/)
45+
38. [Python os Module Tutorial](https://vegibit.com/python-os-module-tutorial/)
46+
39. [What Is A Python Decorator](https://vegibit.com/what-is-a-python-decorator/)

decorators.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def my_decorator(func):
2+
'''Decorator Function'''
3+
4+
def wrapper():
5+
'''Wrapper Function'''
6+
result = func()
7+
return result.title().replace(' ', ' !##! ')
8+
9+
return wrapper
10+
11+
12+
@my_decorator
13+
def to_be_decorated():
14+
return 'output to decorate'
15+
16+
17+
result = to_be_decorated()
18+
print(result)

namemain.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def main():
2+
print("Hello World!")
3+
4+
5+
if __name__ == "__main__":
6+
main()

xmlelementtree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def main():
1616
for elem in doc.findall('post'):
1717
print(elem.tag)
1818

19-
# Count the number of posts
19+
# CountDecorator the number of posts
2020
postCount = len(doc.findall('post'))
2121
entryCount = len(doc.findall('.//entry'))
2222

@@ -27,7 +27,7 @@ def main():
2727
newPost = etree.SubElement(doc, 'post')
2828
newPost.text = 'This is a new post'
2929

30-
# Count the number of posts
30+
# CountDecorator the number of posts
3131
postCount = len(doc.findall('post'))
3232
entryCount = len(doc.findall('.//entry'))
3333

0 commit comments

Comments
 (0)