[Tutor] Call for volunteer to help revise images for One Day of IDLE Toying

2006-05-07 Thread Danny Yoo
Hi everyone,

One of the major complaints that people have made about the One Day of 
IDLE Toying tutorial I've written is that the screenshots are badly 
outdated.

 http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/

I was curious if anyone wanted to volunteer to provide fresh, updated 
Windows XP screenshots to replace the ones on the IDLE tutorial.

Basically, I'm asking for unpaid slave labor.  *grin*

Silly as this may sound, I suddenly have about a week of free time, but I 
no longer have access to anything other than my personal Powerbook, and 
Jack Jansen's already covered MacPython already.  So if someone with 
Windows XP would be willing to do this, I'd be greatly appreciative and 
will be happy to properly attribute the work.

(Side explanations: I just finished my last day at my job.  I have about a 
week of time before I fly to my graduate school studies.  I expect that 
grad school will monopolize a great deal of my time.  I hope I can get 
some loose ends tied before then!)


Thanks a lot!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Call for volunteer to help revise images for One Day ofIDLE Toying

2006-05-07 Thread Alan Gauld
Danny,

I'm happy to do that.

I assume you just want the same shots that you currently have?

Alan G.

- Original Message - 
 One of the major complaints that people have made about the One Day 
 of IDLE Toying tutorial I've written is that the screenshots are 
 badly outdated.

 http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/

 I was curious if anyone wanted to volunteer to provide fresh, 
 updated Windows XP screenshots to replace the ones on the IDLE 
 tutorial.


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Button Signals

2006-05-07 Thread John CORRY








Hi,



I am having difficulty with using signal handlers. I am using Glade 2 and Pygtk. My
editor is Pythoncard. The following code connects to button
one and calls a function which hides button one. 



self.wTree = gtk.glade.XML (phonelog.glade,
window1)

 dic={on_window1_destroy
: self.quit, }

 self.wTree.signal_autoconnect (dic)

 

 

 process = self.wTree.get_widget(button1)

 process.connect(clicked,
self.callback1, start_date, process)



def callback1(self,data,start_date,process):

 process.hide()



The above code works fine. However I want button one to remain on
my GUI. Thus, I want to just stop the
signal being emitted after it is pressed once. I have used the following code which is
trying to disconnect the button one:



self.wTree = gtk.glade.XML (phonelog.glade,
window1)

 dic={on_window1_destroy
: self.quit, }

 self.wTree.signal_autoconnect (dic)

 

 

 process = self.wTree.get_widget(button1)

 process.connect(clicked,
self.callback1, start_date, process)



def callback1(self,data,start_date,process):

 process.disconnect()



When I run this code I get the error

TyoeError: Object takes exactly one argument(0 given)



When I put an argument in, it says that the argument must be
an integer. I have tried a number
of integers at random but none work.
On the Pygtk tutorial it states the following:



3.1.More on Signal
Handlers

Lets take another look at the connect() call.


 
  
  
  object.connect(name, func,
  func_data)
  
 


The return value from a connect() call is an integer tag that identifies your callback.
As stated above, you may have as many callbacks per signal and per object as
you need, and each will be executed in turn, in the order they were attached.

This tag allows you to remove this callback
from the list by using:


 
  
  
  object.disconnect(id)
  
 


So, by passing in the tag returned by one of
the signal connect methods, you can disconnect a signal handler.

How do I find out what the integer tag
is, so that I can put this in my code?



I have tried the pygtk faq page but it
is currently unavailable.



Any help greatly appreciated.



Thanks,



John.








___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Button Signals

2006-05-07 Thread Liam Clarke
Hi John, I'll answer your questions, but first: Pythoncard is for wxPython. wxPython is vastly different to PyGTK afaik.The docs you quote answer your question:
The return value from a connect
() call is an integer tag that identifies your callback.
As stated above, you may have as many callbacks per signal and per object as
you need, and each will be executed in turn, in the order they were attached.

This tag allows you to remove this callback
from the list by using:



 
  
  
  object.disconnect(id)
  
 


So, by passing in the tag returned by one of
the signal connect methods, you can disconnect a signal handler.Your code needs the following:  self.
callback_id1 = process.connect(clicked,
self.callback1, start_date, process)



def callback1(self,data,start_date,process
):

 process.disconnect(self.callback_id1)

On 5/7/06, John CORRY 
[EMAIL PROTECTED] wrote:


















Hi,



I am having difficulty with using signal handlers. I am using Glade 2 and Pygtk. My
editor is Pythoncard. The following code connects to button
one and calls a function which hides button one. 



self.wTree = gtk.glade.XML
 (phonelog.glade,
window1)

 dic={on_window1_destroy
: self.quit, }

 self.wTree.signal_autoconnect (dic)

 

 

 process = self.wTree.get_widget(button1)

 process.connect(clicked,
self.callback1, start_date, process)



def callback1(self,data,start_date,process
):

 process.hide()



The above code works fine. However I want button one to remain on
my GUI. Thus, I want to just stop the
signal being emitted after it is pressed once. I have used the following code which is
trying to disconnect the button one:



self.wTree = gtk.glade.XML
 (phonelog.glade,
window1)

 dic={on_window1_destroy
: self.quit, }

 self.wTree.signal_autoconnect (dic)

 

 

 process = self.wTree.get_widget(button1)

 process.connect(clicked,
self.callback1, start_date, process)



def callback1(self,data,start_date,process
):

 process.disconnect()



When I run this code I get the error

TyoeError: Object takes exactly one 
argument(0 given)



When I put an argument in, it says that the argument must be
an integer. I have tried a number
of integers at random but none work.
On the Pygtk tutorial it states the following:



3.1.More on Signal
Handlers

Lets take another look at the connect() call.



 
  
  
  object.connect(name, func,
  func_data)
  
 


The return value from a 
connect() call is an integer tag that identifies your callback.
As stated above, you may have as many callbacks per signal and per object as
you need, and each will be executed in turn, in the order they were attached.

This tag allows you to remove this callback
from the list by using:



 
  
  
  object.disconnect(id)
  
 


So, by passing in the tag returned by one of
the signal connect methods, you can disconnect a signal handler.

How do I find out what the integer tag
is, so that I can put this in my code?



I have tried the pygtk faq page but it
is currently unavailable.



Any help greatly appreciated.



Thanks,



John.









___Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Button Signals

2006-05-07 Thread John CORRY








Liam,



Thanks for the prompt reply. That is working for me.



Regards,



John,



-Original
Message-
From: Liam Clarke
[mailto:[EMAIL PROTECTED] 
Sent: 07 May 2006 13:06
To: [EMAIL PROTECTED]
Cc: tutor@python.org
Subject: Re: [Tutor] Button
Signals



Hi John, 

I'll answer your questions, but first: Pythoncard is for wxPython. wxPython is
vastly different to PyGTK afaik.

The docs you quote answer your question:

The return
value from a connect () call is an integer tag that
identifies your callback. As stated above, you may have as many callbacks per
signal and per object as you need, and each will be executed in turn, in the
order they were attached.

This tag
allows you to remove this callback from the list by using:


 
  
   object.disconnect(id)
  
 


So, by
passing in the tag returned by one of the signal connect methods, you can
disconnect a signal handler.


Your code needs the following: 

 self.
callback_id1 = process.connect(clicked, self.callback1, start_date,
process)



def callback1(self,data,start_date,process ):


process.disconnect(self.callback_id1)













On 5/7/06, John CORRY  [EMAIL PROTECTED] wrote:





Hi,



I am having difficulty with using signal handlers.
I am using Glade 2 and Pygtk. My editor is Pythoncard. The
following code connects to button one and calls a function which hides button
one. 



self.wTree = gtk.glade.XML
(phonelog.glade, window1)


dic={on_window1_destroy : self.quit, }


self.wTree.signal_autoconnect (dic)

 

 

 process =
self.wTree.get_widget(button1)


process.connect(clicked, self.callback1, start_date, process)



def callback1(self,data,start_date,process ):


process.hide()



The above code works fine. However I want
button one to remain on my GUI. Thus, I want to just stop the signal
being emitted after it is pressed once. I have used the following code
which is trying to disconnect the button one:



self.wTree = gtk.glade.XML
(phonelog.glade, window1)


dic={on_window1_destroy : self.quit, }


self.wTree.signal_autoconnect (dic)

 

 

 process =
self.wTree.get_widget(button1)


process.connect(clicked, self.callback1, start_date, process)



def callback1(self,data,start_date,process ):


process.disconnect()



When I run this code I get the error

TyoeError: Object takes exactly one argument(0
given)



When I put an argument in, it says that the argument
must be an integer. I have tried a number of integers at random but none
work. On the Pygtk tutorial it states the following:



3.1.More on Signal
Handlers

Lets take
another look at the connect() call.


 
  
   object.connect(name, func,
  func_data)
  
 


The return
value from a connect() call is an integer tag that
identifies your callback. As stated above, you may have as many callbacks per
signal and per object as you need, and each will be executed in turn, in the
order they were attached.

This tag
allows you to remove this callback from the list by using:


 
  
   object.disconnect(id)
  
 


So, by
passing in the tag returned by one of the signal connect methods, you can
disconnect a signal handler.

How do I find
out what the integer tag is, so that I can put this in my code?



I have tried
the pygtk faq page but it is currently unavailable.



Any help
greatly appreciated.



Thanks,



John.








___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor












___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Nested list comprehensions

2006-05-07 Thread Roel Schroeven
Alan Gauld schreef:
 I am having trouble wrapping my mind around
 nested list comprehensions

Me too: I feel it should be better with the order reversed.
 and my initial reaction to this is that it should be expressed as:

 result = [eachSubObject for eachSubObject in eachObject.m() for 
 eachObject in C1]

That's what I initially expected too.

 My take on that is that it doesn't work from a scoping point of view.
 You have to fetch eachObject before you can send m() to it.
 Doing it the way you have it here would involve calling
 eachObject.m() before eachObject had been fetched from C1

Not exactly; to me, the above list comprehension is just an extension 
from the way non-nested comprehensions work:

[2 * i for i in range(10)]

I interpret that as:
2 * i: we state an expression
for: we're going to evaluate that expression using the values that we're 
going to define after this
i in range(10): which is, in this case, every i in range(10)

For the nested case, let's consider an admittedly contrived example:

a = range(10)
def f(n):
 return [i + n*100 for i in range(10)]

I'd expect to be able to write

[j for j in f(i) for i in a]

Interpreting it as:
j: evaluate j for every value
for: in the sequence defined by
j in f(i): this expression, where f(i) is evaluated for every value
for: in
i in a: the sequence a

But that turns out to be the wrong way around. Not that if you literally 
nest the list comprehensions (giving a list of lists instead of a flat 
list as result), the order is as I would expect:

[[j for j in f(i)] for i in a]

So I would have expected that just dropping the inner [ and ] would 
return the same thing, but flattened.

Actually I don't use nested list comprehensions all that often, and when 
I do use them or encounter them I just remember that the for's should be 
in the same order as in the non-LC solution.


-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

Roel Schroeven

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] query python mastery via programming exercises

2006-05-07 Thread Kermit Rose
Hello.

I would like to try to master python programming this summer.

All the programming classes that I have taken previously used the technique
of

assigning programming exercises with examples of relevant techniques, and
the 
task of the student is to study the examples, and apply them to solve the
programming exercise.

So.

Has someone organized a set of exercises that when solved in the order
presented teaches mastery
of Python programming.


Second,   if or when I master Python,   how may I contact folks who wish to
pay for programs written
in Python.


Kermit  [EMAIL PROTECTED]   


 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Should I use generators here?

2006-05-07 Thread Tony C
I wrote a small Python program to count some simple statistics on a Visual Basic program thatI am maintaining.The Python program counts total lines, whitespace lines, comment lines, Public  Private Subroutines, Public and Private Functions.
The Python program takes about 20-40 seconds to count all these stats since I started using Psyco, but I am wondering if I caneliminate Pysco and improve the program performance using generators (or some other technique).
The running time is quick enough, I'm just wondering if there are other simple performance tweaks to use.I've already eliminated all . (dot) references inside the loops.I haven't quite got my head around generators yet, or when to use /not use them, even though I have seen tutorials and examples.
I'll only include the higher level calling functions, for brevity..ProcessAllFiles() and ProcessFileType() are the functions I am interested in improving the performance.Here is what the output summary looks like
Total Lines= 54932 in 45 FilesTotal Comment Lines = 7408, Total Whitespace = 33679Total Private Subs = 608, Total Public Subs = 145Total Private Funcs = 86, Total Public Funcs = 165
Thanks for any advice!Tonydef ProcessFiletype(Thesefiles, Summary, Stats): Iterate over all the files in 'Thesefiles', and process each file, one at a time
  global TotalAllLines  LongestFilenameLen=0 for Onefile in Thesefiles: > FilenameLen = len(Onefile) if( FilenameLen  LongestFilenameLen):
 LongestFilenameLen = FilenameLen #print Onefile  try: fh=open(Onefile, r) except IOError:  print(\nFATAL ERROR ocurred opening %s for input % Onefile)
 else: try: Filecontents = fh.readlines() # these files are very small, less than 100k each, so reading in an entire file isn't a problem fh.close() except IOError:
 print(\nFatal error occurred reading from %s\n\n % InputFilename) else:  Summary[Onefile] = deepcopy(Stats) # associate each filename with a new stats dict with 0 counts for all alttributes
 Filestats = Summary[Onefile] Filestats[TotalLines] = len(Filecontents) Summary[Onefile] = Filestats for line in Filecontents:
 TotalAllLines = TotalAllLines + 1 #Filteredline=line.strip() Filteredline=line if( not IsCommentLine(Filteredline, Summary[Onefile] ) ):
 if( not IsWhitespaceLine(Filteredline, Summary[Onefile] )) : if( not IsPrivateSub(Filteredline, Summary[Onefile] )): if( not IsPrivateFunc(Filteredline, Summary[Onefile] ) ):
 if( not IsPublicSub(Filteredline, Summary[Onefile] )): IsPublicFunc(Filteredline, Summary[Onefile] )  return FilenameLen 
#/def ProcessAllFiles(Summary, Stats, FileTypes, FiletypeStats): Iterates over all Files in current directory that have the extensions in Filetypes
 from glob import glob LongestFilenameLen = 0 for Filetype in FileTypes: TheseFiles = glob(* + Filetype) TheseFiles.sort() FiletypeStats[Filetype]=len(TheseFiles)
 Longest = ProcessFiletype(TheseFiles, Summary, Stats)  if( Longest  LongestFilenameLen): LongestFilenameLen = Longest  return LongestFilenameLen 
#/def main(args): import psyco psyco.full() global TotalAllLines, TotalFilecount, TotalCommentLines, TotalWhitespaceLines, TotalPrivateSubs, TotalPublicSubs, TotalPrivateFuncs, TotalPublicFuncs
 TotalAllLines = 0 FileTypes=[.frm, .bas, .cls] # Visual Basic source file extensions FiletypeStats={} FileStats={ TotalLines:0, WhitespaceLines:0, CommentLines:0, PrivateSubCount:0, PublicSubCount:0, PrivateFuncCount:0, PublicFuncCount:0 }
 FileSummary={}  LongestFilenameLen = ProcessAllFiles(FileSummary, FileStats, FileTypes, FiletypeStats) for Type, Count in FiletypeStats.iteritems(): print(\nThere are %3lu files with the %s extension % (Count, 
Type.upper()) )   print(\n)  TotalFilecount = 0 for File, Stats in FileSummary.iteritems(): TotalFilecount = TotalFilecount + 1 print(%s - %4lu Lines, %3lu Whitespace lines, %4lu Comments, %4lu Private Subs, %4lu Public Subs, %4lu Private Functions, %4lu Public Functions\n % ( File, Stats[TotalLines], Stats[WhitespaceLines], Stats[CommentLines], Stats[PrivateSubCount], Stats[PublicSubCount], Stats[PrivateFuncCount], Stats[PublicFuncCount] ) )
  print(\nTotal Lines= %5lu in %lu Files\n % (TotalAllLines, TotalFilecount) )  print(\nTotal Comment Lines = %5lu, Total Whitespace = %lu % (TotalCommentLines, TotalWhitespaceLines) ) 
 print(Total Private Subs = %5lu, Total Public Subs = %5lu % (TotalPrivateSubs, TotalPublicSubs) )  print(Total Private Funcs = %5lu, Total Public Funcs = %5lu\n\n\n % (TotalPrivateFuncs, TotalPublicFuncs) ) 
  return None
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor