I'M reading "Beginning Game Develpment with Python and Pygame". In the following code, I'M gettin this error in sysfont.py

NameError: global name 'glob' is not defined

import pygame
from pygame.locals import *
from sys import exit

pygame.init()

SCREEN_SIZE = (800, 600)
screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32)

font = pygame.font.SysFont("arial", 16)
font_height = font.get_linesize()
event_text = []

while True:
    
    event = pygame.event.wait()
    event_text.append(str(event))
    event_text = event_text[-SCREEN_SIZE[1] / font_height:]
    
    if event.type == QUIT:
        exit()
        
    screen.fill((255, 255, 255))
    
    y = SCREEN_SIZE[1] - font_height
    
    for text in reversed(event_text):
        screen.blit( font.render(text, True, (0, 0, 0)), (0, y) )
        y -= font_height
        
    pygame.display.update()

Thanks for any and all replies.

You have to define glob. Try a google for one of the online books like:
"dive into python" glob

I don't get the NameError error when running your code.
I just get following warning, but the code in running fine.

/usr/lib64/python2.6/site-packages/pygame/sysfont.py:139: DeprecationWarning: os.popen3 is deprecated.  Use the subprocess module.
  flin, flout, flerr = os.popen3('fc-list : file family style')

What version of Python & PyGame are you using?

Works just fine with Python 2.5.4 and Pygame 1.8.0 on a Windows XP machine.

Font "arial" may only be available with the Windows OS.

Don't think it is a problem with a missing font. If the font is missing, Pygame uses a standard font. You can try with gibberish, e.g. font = pygame.font.SysFont("abcdefgh", 16)... and it will this run fine.
Besides Arial is available on Linux too.

I'm using Python 2.6.2 with PyGame 1.8.1 on Fedora 12. No problem with running the code as already earlier mentioned.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.