[Tutor] [Fwd: [Fwd: self-modification]]

Zsiros Levente zslevi at sch.bme.hu
Tue Aug 22 12:28:53 CEST 2006


Why does the python shell says this:

>>> print exec.__doc__
  File "<stdin>", line 1
    print exec.__doc__
             ^
SyntaxError: invalid syntax


While it works with "eval".

Anyway, I'm quite impressed with the resposiveness of this list. Thanks 
a  lot.

Zsiros Levente wrote:

>
>
> Sorry, the source was for my tkinter question. I'm a bit disorganized 
> today.
>
> The problematic part is the 11. line, where I have to convert the item 
> selected from the list to an object, or something like that. At the 
> moment it only applies to a string object, but I want to call the 
> function for the object, represented by the string. (If you run it, it 
> will become more obvious what I mean.)
>
>
> -------- Original Message --------
> Subject:     [Fwd: self-modification]
> Date:     Mon, 21 Aug 2006 16:06:52 +0200
> From:     Zsiros Levente <zslevi at sch.bme.hu>
> To:     python tutor <tutor at python.org>
>
>
>
> I forgot the most important thing: the attachment.
> -------- Original Message --------
> Subject:     self-modification
> Date:     Mon, 21 Aug 2006 16:04:19 +0200
> From:     Zsiros Levente <zslevi at sch.bme.hu>
> To:     python tutor <tutor at python.org>
>
>
>
> I'm a newbie to Python. I wanted to write a graphical interface which 
> would show the built-in documentation (I mean dir() and __doc__ ) of 
> Python. The code shows how far I got before realizing that I had to 
> use some self-modification feature (converting a string to a function 
> or to an object; i'm not sure you would call it self-modification in 
> an interpreted language).
>
> I was googling around, and searching in the maillist archives and 
> found this:
> http://mail.python.org/pipermail/tutor/2004-October/032388.html
> Unanswered for two years. Not too promising :)
>
> P.S.: I'm new to this mailing list, so I don't know whether it is 
> allowed to send code as attachment. (I didn't found anything about 
> your policy in the subscription site. )  If not, I'm sorry.
>
>
>
>
>------------------------------------------------------------------------
>
>#!/usr/bin/python
>
>from Tkinter import *
>from os import *
>from string import *
>import os
>import string
>import Tkinter
>
>def list_click(event):
>	description.config( text=listbox.get(listbox.curselection()[0]).__doc__ )
>
>list = dir(Tkinter)
>#print list
>
>root=Tk()
>root.geometry('+100+100')
>
>l_frame = Frame(root)
>r_frame = Frame(root)
>
>label = Label(l_frame)
>label.config(text='filename')
>
>description = Label(r_frame)
>
>listbox = Listbox(l_frame)
>listbox.bind('<Double-Button-1>',list_click)
>
>for item in list :
>	listbox.insert(0,item)
>
>
>l_frame.pack(side=LEFT,fill=BOTH)
>label.pack()
>listbox.pack(expand=1,fill=BOTH)
>
>r_frame.pack(side=RIGHT)
>description.pack()
>
>root.mainloop()
>
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>  
>



More information about the Tutor mailing list