spanskiblog/content/posts/python_specifics.md

46 lines
688 B
Markdown
Raw Normal View History

2022-12-24 17:42:40 +01:00
2022-12-24 17:09:22 +01:00
+++
2022-12-24 17:42:40 +01:00
date="2022-11-30"
2022-12-24 17:09:22 +01:00
author="spanskiduh"
title="python_specifics"
2022-12-24 17:42:40 +01:00
description="click to read about python_specifics"
2022-12-24 17:09:22 +01:00
+++
# PYTHON SPECIFICS
### *args and **kwargs
[reference](https://www.geeksforgeeks.org/args-kwargs-python/)
#### args
```python
def myFun(*argv):
for arg in argv:
print(arg)
myFun('Hello', 'Welcome', 'to', 'GeeksforGeeks')
```
```bash
Hello
Welcome
to
GeeksforGeeks
```
#### kwargs
They are basically named args in dict
```python
def myFun(**kwargs):
for key, value in kwargs.items():
print("%s == %s" % (key, value))
# Driver code
myFun(first='Geeks', mid='for', last='Geeks')
```
```
first == Geeks
mid == for
last == Geeks
```