[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame 1.9.0 release candidate 3 for Python 2.6 on Windows



main() was used to run an application from the command line:

python -c "from pygame.examples.midi import main; main()" --list

It was replaced with:

python -m pygame.examples.midi --list

pygame.tests does have a documented run() function that takes optional arguments. But pygame.tests could have a main function as well.

Lenard


René Dudfield wrote:


On Fri, Jul 10, 2009 at 2:25 PM, Lenard Lindstrom <len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>> wrote:

    Hi,


    python -m pygame.tests.__main__
    python -m pygame.docs.__main__

    There would be no reason to run pygame.examples, right?



Yeah, maybe __main__ is good. Perhaps pygame.tests should have a __main__ function too?

>>> import pygame.tests
>>> pygame.tests.main()

Since main() is what is used in the examples, it would be nice to try and keep it the same. But then we need to add a main.py and a __main__.py... ew.



"""
You can do a self test with:
    python -m pygame.tests
Or with python2.6 do:
    python -m pygame.tests.__main__
"""

Doing it for examples could list which examples are available?


$ python -m pygame.examples
    aacircle
    aliens
    arraydemo
    blend_fill
    blit_blends
    camera
    chimp
    cursors
    eventlist
    fastevents
    fonty
    glcube
    headless_no_windows_needed
    liquid
    mask
    midi
    moveit
    movieplayer
    oldalien
    overlay
    pixelarray
    scaletest
    scrap_clipboard
    scroll
    sound
    sound_array_demos
    stars
    testsprite
    vgrade


eg.

"""
See a list of examples...
  python -m pygame.examples
Or with python2.6,
  python -m pygame.examples.__main__

Run one of the 30 examples included...
  python -m pygame.examples.aliens
"""

I'm not sure anyone would remember to add __main__ at the end(or even main). oh well.


There might be a workaround... One work around might be to make it into a module-module, not a package-module. Then have the module-module load the package-module into its namespace.



    The explanation I found was that being able to run a package in
    Python 2.5 was considered a bug, so was fixed in Python 2.6.
    Adding __main__.py as an entry point for running a package in
    Python 2.7 and 3.0 is an attempt repair the fix.

    Lenard