{"id":39205,"date":"2025-11-08T08:07:45","date_gmt":"2025-11-08T16:07:45","guid":{"rendered":"https:\/\/cloudinary.com\/blog\/?p=39205"},"modified":"2025-11-08T08:07:46","modified_gmt":"2025-11-08T16:07:46","slug":"how-to-pack-and-unpack-arguments-in-python-functions","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/","title":{"rendered":"How to pack and unpack arguments in Python functions?"},"content":{"rendered":"\n<p>If you read Python threads in dev communities, you often see snippets that use asterisks in surprising ways: passing lists into functions with a star, forwarding *args and **kwargs, or merging dictionaries on the fly. These patterns make your APIs flexible and your call sites clean, but they can be confusing until you see them side by side with examples.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Question:<\/h2>\n\n\n\n<p><em>Hi everyone,<\/em><br><em>I keep seeing <code>*args<\/code> and <code>**kwargs<\/code> in function signatures and calls, along with sequence and dict unpacking in assignments and merges. Could someone explain clearly how to pack and unpack arguments in Python functions? I want to understand the syntax, common pitfalls, and best practices for writing flexible functions and forwarding parameters.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Answer:<\/h2>\n\n\n\n<p>Python allows you to pass functions with a variable number of arguments instead of only what\u2019s hard-coded. This can be done with the unpacking operator <code>*<\/code>, letting you store arguments in a tuple, and looping over the arguments as an iterator. Let\u2019s break it down.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1) What packing and unpacking mean<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Packing:<\/strong> Collect multiple positional arguments into a tuple via <code>*args<\/code> and multiple keyword arguments into a dict via <code>**kwargs<\/code>.<\/li>\n\n\n\n<li><strong>Unpacking:<\/strong> Expand a sequence into positional arguments with <code>*<\/code> or a mapping into keyword arguments with <code>**<\/code> at the call site or assignment.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2) Define flexible function signatures<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\">def greet(greeting, *names, punctuation=<span class=\"hljs-string\">\"!\"<\/span>):\n\u00a0 \u00a0 <span class=\"hljs-comment\"># names is a tuple of any extra positional args<\/span>\n\u00a0 \u00a0 joined = <span class=\"hljs-string\">\", \"<\/span>.join(names) <span class=\"hljs-keyword\">if<\/span> names <span class=\"hljs-keyword\">else<\/span> <span class=\"hljs-string\">\"there\"<\/span>\n\u00a0 \u00a0 <span class=\"hljs-keyword\">return<\/span> f<span class=\"hljs-string\">\"{greeting}, {joined}{punctuation}\"<\/span>\n\ndef configure(a, b=<span class=\"hljs-number\">0<\/span>, *, verbose=<span class=\"hljs-keyword\">False<\/span>, **options):\n\u00a0 \u00a0 <span class=\"hljs-comment\"># verbose is keyword-only, options captures extra keywords<\/span>\n\u00a0 \u00a0 <span class=\"hljs-keyword\">return<\/span> a, b, verbose, options\n\ndef coords(x, y, \/, *, unit=<span class=\"hljs-string\">\"px\"<\/span>):\n\u00a0 \u00a0 <span class=\"hljs-comment\"># x and y are positional-only, unit is keyword-only<\/span>\n\u00a0 \u00a0 <span class=\"hljs-keyword\">return<\/span> f<span class=\"hljs-string\">\"{x},{y} {unit}\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">3) Unpack in function calls<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\">vals = &#91;<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>]\n<span class=\"hljs-keyword\">print<\/span>(sum(*&#91;vals]))\u00a0 <span class=\"hljs-comment\"># same as sum(vals)<\/span>\n\npair = (<span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">7<\/span>)\n<span class=\"hljs-keyword\">print<\/span>(coords(*pair, unit=<span class=\"hljs-string\">\"cm\"<\/span>))\u00a0 <span class=\"hljs-comment\"># expands to coords(5, 7, unit=\"cm\")<\/span>\n\npayload = {<span class=\"hljs-string\">\"greeting\"<\/span>: <span class=\"hljs-string\">\"Hello\"<\/span>, <span class=\"hljs-string\">\"punctuation\"<\/span>: <span class=\"hljs-string\">\"!!\"<\/span>}\n<span class=\"hljs-keyword\">print<\/span>(greet(**payload, *&#91;<span class=\"hljs-string\">\"Alice\"<\/span>, <span class=\"hljs-string\">\"Bob\"<\/span>]))\u00a0 <span class=\"hljs-comment\"># mix unpacking in calls<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">4) Forwarding patterns<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\">def logging_wrapper(func, *args, **kwargs):\n\u00a0 \u00a0 <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">\"Calling\"<\/span>, func.__name__, <span class=\"hljs-string\">\"with\"<\/span>, args, kwargs)\n\u00a0 \u00a0 <span class=\"hljs-keyword\">return<\/span> func(*args, **kwargs)\n\ndef base(*args, retries=<span class=\"hljs-number\">3<\/span>, **kwargs):\n\u00a0 \u00a0 <span class=\"hljs-comment\"># Forward with defaults<\/span>\n\u00a0 \u00a0 <span class=\"hljs-keyword\">return<\/span> do_work(*args, retries=retries, **kwargs)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">5) Unpacking in assignments and merges<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\"><span class=\"hljs-comment\"># Starred assignment<\/span>\nfirst, *middle, last = &#91;<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">20<\/span>, <span class=\"hljs-number\">30<\/span>, <span class=\"hljs-number\">40<\/span>]\n<span class=\"hljs-comment\"># first=10, middle=&#91;20, 30], last=40<\/span>\n\n<span class=\"hljs-comment\"># Dict merges and overrides<\/span>\ndefaults = {<span class=\"hljs-string\">\"quality\"<\/span>: <span class=\"hljs-string\">\"auto\"<\/span>, <span class=\"hljs-string\">\"format\"<\/span>: <span class=\"hljs-string\">\"jpg\"<\/span>}\noverrides = {<span class=\"hljs-string\">\"format\"<\/span>: <span class=\"hljs-string\">\"webp\"<\/span>, <span class=\"hljs-string\">\"width\"<\/span>: <span class=\"hljs-number\">800<\/span>}\nmerged = {**defaults, **overrides}\n<span class=\"hljs-comment\"># merged == {\"quality\": \"auto\", \"format\": \"webp\", \"width\": 800}<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">6) Gotchas and best practices<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Order matters in signatures. <\/strong><code>positional, *args, keyword-only, **kwargs<\/code>.<\/li>\n\n\n\n<li><strong>Order matters in dict merges. <\/strong>later keys override earlier ones.<\/li>\n\n\n\n<li><strong>Do not overuse <code>**kwargs<\/code> if a clear, explicit API is better. <\/strong>Use it when forwarding or supporting extensibility.<\/li>\n\n\n\n<li>When forwarding, document which <code>**kwargs<\/code> you honor and pass the rest through.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Example: Using packing and unpacking with the Cloudinary Python SDK<\/h3>\n\n\n\n<p>After you understand the generic patterns, you can apply them to SDKs. With Cloudinary\u2019s Python SDK, it is common to compose upload options and transformation steps dynamically, then unpack them into a single call.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\">import cloudinary.uploader <span class=\"hljs-keyword\">as<\/span> uploader\n\nDEFAULT_UPLOAD_OPTS = {\n\u00a0 \u00a0 <span class=\"hljs-string\">\"folder\"<\/span>: <span class=\"hljs-string\">\"samples\"<\/span>,\n\u00a0 \u00a0 <span class=\"hljs-string\">\"overwrite\"<\/span>: <span class=\"hljs-keyword\">True<\/span>,\n\u00a0 \u00a0 <span class=\"hljs-string\">\"tags\"<\/span>: &#91;<span class=\"hljs-string\">\"demo\"<\/span>]\n}\n\nuser_overrides = {\n\u00a0 \u00a0 <span class=\"hljs-string\">\"public_id\"<\/span>: <span class=\"hljs-string\">\"avatar_123\"<\/span>,\n\u00a0 \u00a0 <span class=\"hljs-string\">\"resource_type\"<\/span>: <span class=\"hljs-string\">\"image\"<\/span>\n}\n\n<span class=\"hljs-comment\"># Merge defaults with user overrides<\/span>\nupload_opts = {**DEFAULT_UPLOAD_OPTS, **user_overrides}\n\n<span class=\"hljs-comment\"># Build a transformation pipeline dynamically<\/span>\nbase = {<span class=\"hljs-string\">\"width\"<\/span>: <span class=\"hljs-number\">800<\/span>, <span class=\"hljs-string\">\"height\"<\/span>: <span class=\"hljs-number\">800<\/span>, <span class=\"hljs-string\">\"crop\"<\/span>: <span class=\"hljs-string\">\"fill\"<\/span>}\nwatermark = {<span class=\"hljs-string\">\"overlay\"<\/span>: <span class=\"hljs-string\">\"logo\"<\/span>, <span class=\"hljs-string\">\"gravity\"<\/span>: <span class=\"hljs-string\">\"south_east\"<\/span>, <span class=\"hljs-string\">\"x\"<\/span>: <span class=\"hljs-number\">15<\/span>, <span class=\"hljs-string\">\"y\"<\/span>: <span class=\"hljs-number\">15<\/span>, <span class=\"hljs-string\">\"opacity\"<\/span>: <span class=\"hljs-number\">70<\/span>}\nextra = {<span class=\"hljs-string\">\"fetch_format\"<\/span>: <span class=\"hljs-string\">\"auto\"<\/span>, <span class=\"hljs-string\">\"quality\"<\/span>: <span class=\"hljs-string\">\"auto\"<\/span>}\n\n<span class=\"hljs-comment\"># transformation can be a list of dicts<\/span>\ntransformations = &#91;base, watermark, extra]\n\n<span class=\"hljs-comment\"># Unpack the dict as keyword args, pass the list directly<\/span>\nresult = uploader.upload(\n\u00a0 \u00a0 <span class=\"hljs-string\">\"local\/path\/to\/image.jpg\"<\/span>,\n\u00a0 \u00a0 transformation=transformations,\n\u00a0 \u00a0 **upload_opts\n)\n<span class=\"hljs-keyword\">print<\/span>(result&#91;<span class=\"hljs-string\">\"secure_url\"<\/span>])<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Packing lets you keep clean defaults while letting callers override exactly what they need. Unpacking ensures concise, readable calls.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">TL;DR<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>*args<\/code> packs extra positional args; <code>**kwargs<\/code> packs extra keyword args.<\/li>\n\n\n\n<li>Unpack with <code>*<\/code> and <code>**<\/code> at call sites, in assignments, and for dict merges.<\/li>\n\n\n\n<li>Prefer explicit parameters for core API, but use forwarding with <code>*args<\/code> and <code>**kwargs<\/code> to keep wrappers flexible.<\/li>\n\n\n\n<li>When merging dicts, later values win. Document which <code>kwargs<\/code> you consume vs forward.<\/li>\n\n\n\n<li>These patterns map neatly onto real SDKs like Cloudinary for building dynamic, configurable calls.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Learn More<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/cloudinary.com\/tools\/png-to-webp\">PNG to WebP Converter<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/cloudinary.com\/tools\/image-upscale\">Image Upscaling<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/cloudinary.com\/tools\/compress-png\">Compress PNG<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/cloudinary.com\/tools\/image-to-jpg\">Image to JPG<\/a><\/li>\n<\/ul>\n\n\n\n<p>Ready to streamline your media workflow and try these patterns in production? <a href=\"https:\/\/cloudinary.com\/users\/register_free\">Sign up for a free Cloudinary account<\/a> and start building faster, more flexible pipelines.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you read Python threads in dev communities, you often see snippets that use asterisks in surprising ways: passing lists into functions with a star, forwarding *args and **kwargs, or merging dictionaries on the fly. These patterns make your APIs flexible and your call sites clean, but they can be confusing until you see them [&hellip;]<\/p>\n","protected":false},"author":88,"featured_media":39206,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[423],"class_list":["post-39205","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-questions"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to pack and unpack arguments in Python functions?<\/title>\n<meta name=\"description\" content=\"If you read Python threads in dev communities, you often see snippets that use asterisks in surprising ways: passing lists into functions with a star,\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to pack and unpack arguments in Python functions?\" \/>\n<meta property=\"og:description\" content=\"If you read Python threads in dev communities, you often see snippets that use asterisks in surprising ways: passing lists into functions with a star,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2025-11-08T16:07:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-08T16:07:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1762618049\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image.jpg?_i=AA\" \/>\n\t<meta property=\"og:image:width\" content=\"2000\" \/>\n\t<meta property=\"og:image:height\" content=\"1100\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"damjanantevski\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"NewsArticle\",\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/\"},\"author\":{\"name\":\"damjanantevski\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/43592e43c12520a1e867d456b1e8cf7e\"},\"headline\":\"How to pack and unpack arguments in Python functions?\",\"datePublished\":\"2025-11-08T16:07:45+00:00\",\"dateModified\":\"2025-11-08T16:07:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/\"},\"wordCount\":440,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1762618049\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image.jpg?_i=AA\",\"keywords\":[\"Questions\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/\",\"url\":\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/\",\"name\":\"How to pack and unpack arguments in Python functions?\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1762618049\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image.jpg?_i=AA\",\"datePublished\":\"2025-11-08T16:07:45+00:00\",\"dateModified\":\"2025-11-08T16:07:46+00:00\",\"description\":\"If you read Python threads in dev communities, you often see snippets that use asterisks in surprising ways: passing lists into functions with a star,\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1762618049\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image.jpg?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1762618049\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image.jpg?_i=AA\",\"width\":2000,\"height\":1100},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to pack and unpack arguments in Python functions?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudinary.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/43592e43c12520a1e867d456b1e8cf7e\",\"name\":\"damjanantevski\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3b40c995531fe4d510212a06c9d4fc666d2cb8efbfebc98a94191701accf4817?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3b40c995531fe4d510212a06c9d4fc666d2cb8efbfebc98a94191701accf4817?s=96&d=mm&r=g\",\"caption\":\"damjanantevski\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to pack and unpack arguments in Python functions?","description":"If you read Python threads in dev communities, you often see snippets that use asterisks in surprising ways: passing lists into functions with a star,","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/","og_locale":"en_US","og_type":"article","og_title":"How to pack and unpack arguments in Python functions?","og_description":"If you read Python threads in dev communities, you often see snippets that use asterisks in surprising ways: passing lists into functions with a star,","og_url":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/","og_site_name":"Cloudinary Blog","article_published_time":"2025-11-08T16:07:45+00:00","article_modified_time":"2025-11-08T16:07:46+00:00","og_image":[{"width":2000,"height":1100,"url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1762618049\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image.jpg?_i=AA","type":"image\/jpeg"}],"author":"damjanantevski","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/"},"author":{"name":"damjanantevski","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/43592e43c12520a1e867d456b1e8cf7e"},"headline":"How to pack and unpack arguments in Python functions?","datePublished":"2025-11-08T16:07:45+00:00","dateModified":"2025-11-08T16:07:46+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/"},"wordCount":440,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1762618049\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image.jpg?_i=AA","keywords":["Questions"],"inLanguage":"en-US","copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/","url":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/","name":"How to pack and unpack arguments in Python functions?","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1762618049\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image.jpg?_i=AA","datePublished":"2025-11-08T16:07:45+00:00","dateModified":"2025-11-08T16:07:46+00:00","description":"If you read Python threads in dev communities, you often see snippets that use asterisks in surprising ways: passing lists into functions with a star,","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1762618049\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image.jpg?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1762618049\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image.jpg?_i=AA","width":2000,"height":1100},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/questions\/how-to-pack-and-unpack-arguments-in-python-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to pack and unpack arguments in Python functions?"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/43592e43c12520a1e867d456b1e8cf7e","name":"damjanantevski","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3b40c995531fe4d510212a06c9d4fc666d2cb8efbfebc98a94191701accf4817?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3b40c995531fe4d510212a06c9d4fc666d2cb8efbfebc98a94191701accf4817?s=96&d=mm&r=g","caption":"damjanantevski"}}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1762618049\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image\/how_to_pack_and_unpack_arguments_in_python_functions_featured_image.jpg?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/39205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/88"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=39205"}],"version-history":[{"count":1,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/39205\/revisions"}],"predecessor-version":[{"id":39207,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/39205\/revisions\/39207"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/39206"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=39205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=39205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=39205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}