What Are Args and Kwargs in Python?In Python, both *args and **kwargs mean that a function can accept any number of arguments. *args refer to regular arguments (e.g. myFun(1,2,3)). **kwargs refer to keyword arguments (e.g. myFun(name="Charlie")). Today, you will learn how you can im...Jun 8, 2021 · 3 min readartturijalli.hashnode.dev
5 Useful Swift One-Liners to Code Like a Pro1. One-Liner If-Else Operator Did you know that you can replace this simple if-else statement: let money = 100 if money > 0 { print("Some money") } else { print("No money") } With this neat little one-liner expression? money > 0 ? print("Som...Jun 8, 2021 · 2 min readartturijalli.hashnode.dev
Python List Remove DuplicatesIn Python list, remove duplicates by: char_list = ["a", "a", "a", "b", "c"] char_list = list(dict.fromkeys(char_list)) print(char_list) Output: ['b', 'a', 'c'] Or if you care about the ordering, do it like this: from collections import OrderedDict...Jun 8, 2021 · 2 min readartturijalli.hashnode.dev
Convert Video to Gif with 3 Lines of Code in PythonTo create a video to gif converter, this is all the code you need: from moviepy.editor import VideoFileClip from tkinter.filedialog import * video_file = askopenfilename() clip = VideoFileClip(video_file) clip.write_gif("ouput.gif", fps=10) Detailed...Jun 8, 2021 · 2 min readartturijalli.hashnode.dev
One-Liner For Loops in Python—Code Like a ProYou can replace for-loops with one-liner expressions in Python. A one-liner for loop is made possible by utilizing comprehensions. Python supports four different comprehensions for the main sequence types: List comprehensions Dictionary comprehensio...1CJun 8, 2021 · 4 min readartturijalli.hashnode.dev