添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
沉稳的饭卡  ·  合肥招生考试网·  4 月前    · 
不开心的盒饭  ·  stata int转化为float - ...·  5 月前    · 
还单身的松球  ·  Mac猫 - iMac - macOS ...·  8 月前    · 

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We do ask, fairly regularly in social media places, and there are various pages on getting involved over on the official pygame wiki and a contributing discord channel. Yet still we have yet to finish creating pygame 2, so every little helps.

Honestly, I feel the most important part of the welcome message now is the string of version information printed. Historically the majority (vast majority?) of our users are people beginning their programming journey rather than power users who care about a clean console - and it smooths the path to diagnosing these user's problems when every one of them can swiftly tell us what version of pygame and SDL they have running on their system.

I also feel that the small minority of users who care about the console message are exactly the sort of users who are equipped to add a single line of code to their scripts to disable it.

Note that for projects that wishes to silent the message can use

from contextlib import redirect_stdout
from io import StringIO
with redirect_stdout(StringIO()): import pygame

While it's rare for a library to do this (usually only interactive programs print non-error messages), but it might be a good idea to guard imports of third party libraries from printing warning anyway.

It's intentional in order to foster support for pygame.

The fact it gets installed and used, already means its fostering support. You know, just like all other third-party modules.

import os
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = True
import pygame

In case anyone wants a cut-n-paste from googling this issue without following the other links.

Thanks @MyreMylar.

NOTE: "True" has to be a string, not boolean value. Otherwise an error is thrown. At least it did for me on Windows 10.

It would be great if this was a property that can be set, for example pygame.init(SUPPORT_PROMPT=False)

I don't like to complain about the decisions of other open-source projects, but this silly message breaks in a non-obvious way a tool I rely on intermittently.
Frankly, it's rude and unexpected to print stuff on import. Imagine if every library did that!

As was stated above if you need to disable the support message for your use case then:

import os
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = True
import pygame

Will do it for you. This is documented with the other environment variables here: https://www.pygame.org/docs/ref/pygame.html

The diagnostics in the message are so far still very useful for quickly gathering information and diagnosing problems from one of pygame's main audiences of young people learning programming. They often have trouble describing information like this usefully and having it ready to go at a glance saves lots of man hours of back and forth trying to explain and extract it from them. I suspect it's more likely that we might expand the message to add more platform information at this point than scrap it. I used this message today in fact in one of my classes to quickly figure out an issue in a student's code - every library is different. Pygame's nature as a graphics library, and its long development, also makes it prone to lots of platform and underlying library version specific issues that not all libraries share.

So far it is simply far less work for us to tell the occasional disgruntled 'power user' to use the environment variable for their use case than it is to try and extract platform & version information from thousands of fresh young programmers. If anyone feels strongly about the direction of pygame then the best way to change it is to become involved in the project as a regular contributor and engage with the community - including all those students using pygame as one of their first game programming experiences.

The solution suggested repeatedly, os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = True, doesn't work, at least not for me, it leads to the following error

TypeError: str expected, not bool

since environment variables have to be of type str which would be satisfied by the following:

os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'