GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MWE

MWE

Jump to bottom Edit New page
Dan Corin edited this page Nov 28, 2023 · 4 revisions

How to write a Minimal Working Example

If you read this, you probably were asked to provide a minimal working example (MWE) in the user group or the issue tracker of the python-telegram-bot library.

So here is what that means:

Example

When trying to help you with a problem, it's often helpful to see your code instead of a vague description of the issue. Of course, a better description often also helps (see this article on asking good technical questions).

Working

In order for the example to actually be helpful, it must work. This means that it:

Is ready to run

Code that's not runnable is not very useful to see an issue - at least most times. Make sure that whoever is trying to help you only needs to plug in a bot token, run the script and send /start to the bot for the example to run.

In particular this means that

  • all necessary imports are included
  • no undefined functions are called or undefined modules imported
  • apart from PTB no additional dependencies need to be installed

Reproduces the issue

If the provided example doesn't show the described problem, it's not much of an example.

Minimal

Make sure that your example contains everything needed for the problem to show - and nothing more! Nothing delays finding a bug more than hundreds of unrelated lines of code. Your example should fit in a single short file. Reducing your problematic code to such a minimal example often times already helps to identify the actual issue.

Publishing

Be sure to remove your bot token before publishing the MWE! Always send it along with a concise description of what exactly the problem is and how it can be reproduced with your MWE.

As a final note, if you were asked for an MWE in the user group, please post your code using a pastebin, e.g. https://hastebin.com or https://pastebin.com, instead of posting it as plain text in the user group.

Wiki of python-telegram-bot © Copyright 2015-2026 – Licensed by Creative Commons

Must read

  1. Introduction to the API
  2. Tutorial: Your first bot
  3. FAQ
  4. How to ask good questions
  5. How to write an MWE

Concepts & Important Elements

  1. Architecture Overview
  2. Builder Pattern for Application
  3. Types of Handlers
  4. Working with Files and Media
  5. Exceptions, Warnings and Logging
  6. Concurrency in PTB

Notable Features

  1. Advanced Filters
  2. Storing data
  3. Making your bot persistent
  4. Adding Defaults
  5. Job Queue
  6. Arbitrary callback_data
  7. Avoiding flood limits
  8. Webhooks
  9. Bot API Forward Compatiblity

Code Resources

  1. Frequently requested design patterns
  2. Code snippets
  3. Performance Optimizations
  4. Telegram Passport
  5. Bots built with PTB
  6. Automated Bot Tests

Examples explained

  1. InlineKeyboard Example

Networking

  1. Working Behind a Proxy
  2. Handling network errors

Other resources

  1. Where to host Telegram Bots
  2. How to host your bot
  3. Local API Server
  4. Type Checking with PTB
  5. Press
  6. Notes on GAE
  7. Related Projects
  8. Emoji

Transition Guides

  • Version 4
  • Version 5
  • Version 12
  • Version 13
  • Version 20

Administration

  • Test Bots
  • How To Release
  • Bots, Groups & Channels
  • PTB tests knowledge base
  • Bot API Backward Compatibility

Clone this wiki locally

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.