unsubscribe
On Fri, 14 Dec 2007 03:40:17 +0100, [EMAIL PROTECTED] said: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED] > > You can reach the person managing the list at > [EMAIL PROTECTED] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tutor digest..." > > > Today's Topics: > > 1. Re: user-given variable names for objects (Kent Johnson) > 2. Re: Python Versions (Tiger12506) > 3. Re: what is the difference (Alan Gauld) > 4. Re: ipython / readline problem (Alan Gauld) > 5. Fw: what is the difference (ALAN GAULD) > 6. Re: ipython / readline problem (Kent Johnson) > 7. Re: user-given variable names for objects (Luke Paireepinart) > 8. Re: user-given variable names for objects (Luke Paireepinart) > 9. Introspect function or class' required arguments (Luis N) > 10. using quotes in IDLE (Jim Morcombe) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 13 Dec 2007 16:24:34 -0500 > From: Kent Johnson <[EMAIL PROTECTED]> > Subject: Re: [Tutor] user-given variable names for objects > To: Tiger12506 <[EMAIL PROTECTED]> > Cc: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Tiger12506 wrote: > > I may sound like a know-it-all, but dictionaries *are* iterators. > > Mmm, to nit-pick a little, dictionaries are iterables, not iterators. > They don't have a next() method. > > > [a for a in eventData if eventData[a] < time.time()] > > > > This is more efficient. The keys method creates a list in memory first and > > then it iterates over it. > > I've never tested it but I suspect that when you need keys and values, > it is more efficient to use itervalues(): > > [ k for k, v in eventData.itervalues() if v < time.time() ] > > and of course if you care about efficiency you should hoist the call to > time.time() out of the loop! > > Kent > > > ------------------------------ > > Message: 2 > Date: Thu, 13 Dec 2007 16:31:45 -0500 > From: "Tiger12506" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Python Versions > To: <tutor@python.org> > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > reply-type=response > > > > Hey Tiger, > > your system clock is set incorrectly and your e-mail was flagged as being > > sent 12/12/2008, causing it to appear after an e-mail sent as a reply - > > confusing. > > Please remedy this situation ;P > > -Luke > > Whoops!! I have to mess with my clock occasionally to test the integrity > of > date specific scripts that I write. Sorry. It has been fixed. Thank you. > > > > ------------------------------ > > Message: 3 > Date: Thu, 13 Dec 2007 22:37:05 -0000 > From: "Alan Gauld" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] what is the difference > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > reply-type=original > > > "Tiger12506" <[EMAIL PROTECTED]> wrote > > >>> I can not see the difference but the second one acts differently > >>> in > >>> my code. > >> > >> The first has no else clause so the second assignment always > >> happens. > >> > >> Alan G. > > > > No it doesn't. The return statement does not allow the second > > assignment to > > occur in the first example. The second assignment only occurs if NOT > > (self._inFlush==True), as in the second example. > > Quite right, see my other reply to Terry... > > mea culpa, > > Alan G. > > > > > ------------------------------ > > Message: 4 > Date: Thu, 13 Dec 2007 22:40:18 -0000 > From: "Alan Gauld" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] ipython / readline problem > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > reply-type=original > > > "Tiago Saboga" <[EMAIL PROTECTED]> wrote > > But in general, in the python libraries, I thought it would be safe > > to > > assume that one can equally send a string or a unicode object, and > > that otherwise there would be a warning in the docs. Is this > > assumption plain wrong, is this info really missing in the docs, or > > it's just me that have missed it? > > In general I think you can, the readline stuff is an IPython feature I > think. > But I don't really know since I don't have IPython to compare with and > don't use unicode hardly ever. > > But I think Python itself is pretty safe with unicode v ascii in most > cases. > I'm sure Kent will be able to comment further, he seems to have made > himself an expert in this area! (and I'm sure glad somebody has! :-) > > Alan G. > > > > > ------------------------------ > > Message: 5 > Date: Thu, 13 Dec 2007 23:28:46 +0000 (GMT) > From: ALAN GAULD <[EMAIL PROTECTED]> > Subject: [Tutor] Fw: what is the difference > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=utf-8 > > > Terry Carroll wrote: > On Thu, 13 Dec 2007, Alan Gauld wrote: > >> > if self._inFlush: > >> > return > >> > self._inFlush = True > >> > .... > >> > > >> > I can not see the difference but the second one acts differently > in > > >> > my code. > >> > >> The first has no else clause so the second assignment always > happens. > > > > Alan, are you teasing the newbies? > > No just not reading closely enough. > You are quite right, I've no idea why they would behave differently! > > John, care to elaborate on what is different? > > > Or am I just misreading this somehow? > > Nope, I was. > > Alan G. > > > > > > > > > > ------------------------------ > > Message: 6 > Date: Thu, 13 Dec 2007 18:36:39 -0500 > From: Kent Johnson <[EMAIL PROTECTED]> > Subject: Re: [Tutor] ipython / readline problem > To: Alan Gauld <[EMAIL PROTECTED]> > Cc: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Alan Gauld wrote: > > But I think Python itself is pretty safe with unicode v ascii in most > > cases. > > I was actually holding my tongue on that one. My guess is it varies from > one module to the next depending on how well maintained they are, but > I don't really know. > > > I'm sure Kent will be able to comment further, he seems to have made > > himself an expert in this area! (and I'm sure glad somebody has! :-) > > I'm pretty knowledgeable about character sets and conversion issues, not > so much about how specific modules use unicode. > > Kent > > > ------------------------------ > > Message: 7 > Date: Thu, 13 Dec 2007 17:48:11 -0600 > From: "Luke Paireepinart" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] user-given variable names for objects > To: "Alan Gauld" <[EMAIL PROTECTED]> > Cc: tutor@python.org > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > > > > > > By the way, what was the purpose of the line with > > > time.sleep(1) > > > > It pauses for 1 second. But i'm not sure why he wanted a pause! :-) > > > Just because it would dump a bunch of stuff to the screen really quickly > that you couldn't read as soon as some events expired. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.python.org/pipermail/tutor/attachments/20071213/a18afd70/attachment-0001.htm > > > ------------------------------ > > Message: 8 > Date: Thu, 13 Dec 2007 17:50:17 -0600 > From: "Luke Paireepinart" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] user-given variable names for objects > To: Tiger12506 <[EMAIL PROTECTED]> > Cc: tutor@python.org > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > > On Dec 13, 2008 3:12 PM, Tiger12506 <[EMAIL PROTECTED]> wrote: > > > I may sound like a know-it-all, but dictionaries *are* iterators. > > I'm used to that from you :P > > > > > [a for a in eventData if eventData[a] < time.time()] > > > > This is more efficient. The keys method creates a list in memory first and > > then it iterates over it. > > Thanks. I was fairly certain that was the case, but since I wasn't going > to > test the code, I used the alternative. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.python.org/pipermail/tutor/attachments/20071213/95c1de19/attachment-0001.htm > > > ------------------------------ > > Message: 9 > Date: Fri, 14 Dec 2007 11:08:11 +0900 > From: "Luis N" <[EMAIL PROTECTED]> > Subject: [Tutor] Introspect function or class' required arguments > To: tutor@python.org > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1 > > Is there a way to introspect a function or class' required arguments, > particularly keyword arguments? > > I can easily use a dictionary since it is my own function that I wish > to introspect. I haven't tested the below code yet, but e.g. > > obj = getattr(self, 'obj')() > preprocessors = {'Card':[{'obj_attr':'mastery', > 'call':mastery, > 'args_dict':['front', 'back']} > ] > } > obj_preprocessors = preprocessors.get(obj.__name__, None) > if obj_preprocessors: > for preprocessor in obj_preprocessors: > function_name = preprocessor['call'].__name__ > args_dict = {} > for arg in preprocessor['args_dict']: > if self.query_dict.has_key(arg): > args_dict[preprocessor[arg]] = self.query_dict.get(arg) > else: > self.error = 'Required argument %s omitted for > function %s' % (arg, function_name) > break > if not hasattr(self, error): > try: > setattr(obj, preprocessor['obj_attr'], > preprocessor['call'](args_dict)) > except: > self.error = 'Preprocessor %s failed.' % function_name > else: > break > > > ------------------------------ > > Message: 10 > Date: Fri, 14 Dec 2007 10:43:48 +0900 > From: "Jim Morcombe" <[EMAIL PROTECTED]> > Subject: [Tutor] using quotes in IDLE > To: <tutor@python.org> > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > > A really dumb question... > > When typing things into IDLE, how are quotes meant to work? > > If I type" > > employee.name = "Susan" > > then IDLE ignores the last " and I get an error. > > Jim > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.python.org/pipermail/tutor/attachments/20071214/08cd377b/attachment.htm > > > ------------------------------ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > End of Tutor Digest, Vol 46, Issue 39 > ************************************* _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor