New to Python

Gabriel Genellina gagsl-py2 at
Mon Mar 12 22:12:23 CET 2007

En Mon, 12 Mar 2007 10:25:15 -0300, Alberto Monteiro  
<albmont at> escribió:

> For example, yesterday I wanted to open a window, draw some
> image, and make it move. I tried it with tkinter and with pygame,
> but I didn't succeed - there was no way I could find how to
> begin the image in the center of the window (!!!).
> Such basic things are usually solved with a google search, like
> "python image position", but there was no inchantation I could utter
> that would bring me the effect I wanted (oops. Bad example. I guess
> "python image position" would give a useful answer...)

That's the problem: you have to search on how to do that using "pygame",  
or "TkInter" (or Tk actually), or wxWidgets, or GTK, or whatever framework  
you choose to make the GUI. Python itself is not bound to a single  
framework so "how to do this in Python" has no sense, or has many answers  
depending on the chosen framework.

> Another example, I found in pygame functions that would return
> something called an "EventList". But whenever I searched for
> "EventList" to see what is that, I got back to the page with
> the functions that returned the EventList :-)

You can always check yourself if in doubt. At the interpreter prompt, use  
any of these to inspect any object:

repr(xxx) # a string representation of object xxx
type(xxx) # the actual type of xxx
dir(xxx) # list of attributes, including methods
vars(xxx) # name and value for all instance attributes, if any

py> b
<webbrowser.WindowsDefault object at 0x00ADBEB0>
py> repr(b)
'<webbrowser.WindowsDefault object at 0x00ADBEB0>'
py> type(b)
<class 'webbrowser.WindowsDefault'>
py> dir(b)
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__',  
_', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',  
_', '__setattr__', '__str__', '__weakref__', 'args', 'basename', 'name',  
  'open_new', 'open_new_tab']
py> vars(b)
{'basename': '', 'name': ''}
py> help(b)
Help on WindowsDefault in module webbrowser object:

class WindowsDefault(BaseBrowser)
  |  Method resolution order:
  |      WindowsDefault
  |      BaseBrowser
  |      __builtin__.object
  |  Methods defined here:
  |  open(self, url, new=0, autoraise=1)

> Also, basic things like how does "+" operate on object "xxx"
> are impossible to google search.

Usually you find that on the documentation for "xxx", either online or using help(xxx)

Gabriel Genellina

More information about the Python-list mailing list