Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

positional-argument

Why do I get “TypeError: Missing 1 required positional argument: ‘self'”?

October 2, 2023 by Tarik

To use the class, first create an instance, like so: p = Pump() p.getPumps() A full example: >>> class TestClass: … def __init__(self): … print(“init”) … def testFunc(self): … print(“Test Func”) … >>> testInstance = TestClass() init >>> testInstance.testFunc() Test Func

Categories python Tags constructor, positional-argument, python, typeerror Leave a comment

What does a bare asterisk do in a parameter list? What are “keyword-only” parameters?

October 2, 2023 by Tarik

Bare * is used to force the caller to use named arguments – so you cannot define a function with * as an argument when you have no following keyword arguments. See this answer or Python 3 documentation for more details.

Categories python Tags keyword-argument, parameter-passing, positional-argument, python, python-3.x Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa