[Tutor] Tutor Digest, Vol 46, Issue 39
Andre Mueninghoff
andre_mueninghoff at fastmail.fm
Fri Dec 14 04:12:58 CET 2007
unsubscribe
On Fri, 14 Dec 2007 03:40:17 +0100, tutor-request at python.org said:
> Send Tutor mailing list submissions to
> tutor at 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
> tutor-request at python.org
>
> You can reach the person managing the list at
> tutor-owner at python.org
>
> 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 <kent37 at tds.net>
> Subject: Re: [Tutor] user-given variable names for objects
> To: Tiger12506 <keridee at jayco.net>
> Cc: tutor at python.org
> Message-ID: <4761A312.9000808 at tds.net>
> 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" <keridee at jayco.net>
> Subject: Re: [Tutor] Python Versions
> To: <tutor at python.org>
> Message-ID: <00de01c83dcf$e6b5d520$a1fce004 at jslaptop>
> 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" <alan.gauld at btinternet.com>
> Subject: Re: [Tutor] what is the difference
> To: tutor at python.org
> Message-ID: <fjsc6i$n9s$1 at ger.gmane.org>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
> reply-type=original
>
>
> "Tiger12506" <keridee at jayco.net> 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" <alan.gauld at btinternet.com>
> Subject: Re: [Tutor] ipython / readline problem
> To: tutor at python.org
> Message-ID: <fjscck$nr4$1 at ger.gmane.org>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
> reply-type=original
>
>
> "Tiago Saboga" <tiagosaboga at terra.com.br> 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 <alan.gauld at btinternet.com>
> Subject: [Tutor] Fw: what is the difference
> To: tutor at python.org
> Message-ID: <109474.85199.qm at web86701.mail.ird.yahoo.com>
> 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 <kent37 at tds.net>
> Subject: Re: [Tutor] ipython / readline problem
> To: Alan Gauld <alan.gauld at btinternet.com>
> Cc: tutor at python.org
> Message-ID: <4761C207.4090804 at tds.net>
> 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" <rabidpoobear at gmail.com>
> Subject: Re: [Tutor] user-given variable names for objects
> To: "Alan Gauld" <alan.gauld at btinternet.com>
> Cc: tutor at python.org
> Message-ID:
> <dfeb4470712131548i777f10dam9102c577a0a8173a at mail.gmail.com>
> 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" <rabidpoobear at gmail.com>
> Subject: Re: [Tutor] user-given variable names for objects
> To: Tiger12506 <keridee at jayco.net>
> Cc: tutor at python.org
> Message-ID:
> <dfeb4470712131550l11adf26h21dc67cb7eb86da6 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Dec 13, 2008 3:12 PM, Tiger12506 <keridee at jayco.net> 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" <globophobe at gmail.com>
> Subject: [Tutor] Introspect function or class' required arguments
> To: tutor at python.org
> Message-ID:
> <c6e072940712131808g3ad23a1dw570da5ed842646e1 at mail.gmail.com>
> 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" <jmorcombe at westnet.com.au>
> Subject: [Tutor] using quotes in IDLE
> To: <tutor at python.org>
> Message-ID: <000e01c83df2$c7e4cde0$6a00a8c0 at ASC000E7B84CF9F>
> 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 at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
> End of Tutor Digest, Vol 46, Issue 39
> *************************************
More information about the Tutor
mailing list