Your #Python function takes a filename and **kwargs. But this raises an error, since "filename" is passed twice: myfunc('outfile.txt', filename='abcd', x=100) Solution: Set filename to be positional only: def myfunc(filename, /, **kwargs): Now *any* keyword argument works!
Fixing Python Function Error with Positional Only Argument
More Relevant Posts
-
Load custom #Python modules into #Excel 🤯 The *real* Python in Excel i.e., #xlwings Lite (https://lnkd.in/eMuEm773), just got better! Felix Zumstein recently announced the new feature in xlwings Lite to drag and drop data files straight into Excel (https://lnkd.in/ePVR9jUd), that was exciting! Now you can mount your own personal #Python modules into #Excel! See here (https://lnkd.in/epPcXYPw) how to do it. This is proof that you can import your own custom Python modules into Excel. Really exciting! 🤩
To view or add a comment, sign in
-
-
I haven't properly announced this feature yet, but yes, you can now import or mount local Python files that automatically register as scripts in your Run button or as custom functions across all workbooks (and you can import them into main.py). It works like the venerable "Personal.xlsb" file with VBA. It's a little smarter though, as you can filter modules to only load with certain workbooks. E.g., whenever I open a Stripe report, my cleanup_stripe script automatically appears. Since these files are on your local machine, you can track them with Git or store them on OneDrive, etc. See https://lnkd.in/e_CU9tmP #pythoninexcel #python #microsoftexcel
Load custom #Python modules into #Excel 🤯 The *real* Python in Excel i.e., #xlwings Lite (https://lnkd.in/eMuEm773), just got better! Felix Zumstein recently announced the new feature in xlwings Lite to drag and drop data files straight into Excel (https://lnkd.in/ePVR9jUd), that was exciting! Now you can mount your own personal #Python modules into #Excel! See here (https://lnkd.in/epPcXYPw) how to do it. This is proof that you can import your own custom Python modules into Excel. Really exciting! 🤩
To view or add a comment, sign in
-
-
As far as i know, xlwings from Felix Zumstein is still the Best way to use Python in Excel sheets. It's been a while Microsoft said Python will be embedded in Excel... but where is it ?
Load custom #Python modules into #Excel 🤯 The *real* Python in Excel i.e., #xlwings Lite (https://lnkd.in/eMuEm773), just got better! Felix Zumstein recently announced the new feature in xlwings Lite to drag and drop data files straight into Excel (https://lnkd.in/ePVR9jUd), that was exciting! Now you can mount your own personal #Python modules into #Excel! See here (https://lnkd.in/epPcXYPw) how to do it. This is proof that you can import your own custom Python modules into Excel. Really exciting! 🤩
To view or add a comment, sign in
-
-
How many NaNs in a #Python #Pandas series? Use isna (returns True/False) then sum/value_counts: s = pd.Series([10, 20, np.nan, 40, 50, np.nan, 70, 80]) s.isna().sum() # returns 2 s.isna().value_counts() # count True/False Hint: Pass normalize=True for the percentage
To view or add a comment, sign in
-
-
While working on the Valid Palindrome problem recently, I noticed a small detail that was easy to overlook. I initially wrote: `s.lower()` expecting the string to update. But in Python, strings are immutable — lower() returns a new string, it doesn’t modify the original one. The correct step was: `s = s.lower()` What stood out to me wasn’t the fix itself, but how easy it is to miss behaviors like this when focusing only on the overall logic. It was a good reminder that many bugs don’t come from complex algorithms, but from not fully understanding how basic operations behave. Still learning, and trying to be more deliberate about these small but important details. #LeetCode #Python #Strings
To view or add a comment, sign in
-
Most Python code I see still counts things manually. Something like this: counts = {} for item in data: counts[item] = counts.get(item, 0) + 1 It works. But Python has had a built-in solution for years: from collections import Counter counts = Counter(data) Cleaner code is nice. But the real advantage is clarity of intent. When someone reads Counter(data), they don’t have to figure out what the code is doing. They immediately know why it exists. Small differences like this scale more than people realize. #Python #DataAnalytics
To view or add a comment, sign in
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
cool, but perhaps you shouldn't be calling the variable `filename` at all? :-P