spanskiblog/content/posts/python_specifics.md

46 lines
681 B
Markdown
Raw Normal View History

2022-12-24 17:09:22 +01:00
+++
date="2022-12-24"
author="spanskiduh"
title="python_specifics"
description="click to read python_specifics"
+++
# 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
```