[Tutor] Tutor Digest, Vol 129, Issue 22

Ben Smith Ben.Smith at arnoldkeqms.com
Tue Nov 11 12:24:48 CET 2014

Hi - I'm a teacher & sometimes when we're holding a two minute silence for an important occasion an
email comes through & makes my computer ping loudly. Is there a python script to stop these kind of things happening?


-----Original Message-----
From: Tutor [mailto:tutor-bounces+ben.smith=arnoldkeqms.com at python.org] On Behalf Of tutor-request at python.org
Sent: 11 November 2014 11:00
To: tutor at python.org
Subject: Tutor Digest, Vol 129, Issue 22

Send Tutor mailing list submissions to
        tutor at python.org

To subscribe or unsubscribe via the World Wide Web, visit
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: http  question (Clayton Kirkwood)
   2. Re: ?has a value of True? versus ?evaluates true? (was: don't
      understand iteration) (wesley chun)
   3. Re: don't understand iteration (Alan Gauld)


Message: 1
Date: Mon, 10 Nov 2014 20:52:23 -0800
From: "Clayton Kirkwood" <crk at godblessthe.us>
To: <tutor at python.org>
Subject: Re: [Tutor] http  question
Message-ID: <01c801cffd6b$492408a0$db6c19e0$@us>
Content-Type: text/plain;       charset="us-ascii"

>-----Original Message-----
>From: Tutor [mailto:tutor-bounces+crk=godblessthe.us at python.org] On
>Behalf Of Steven D'Aprano
>Sent: Sunday, November 09, 2014 3:04 AM
>To: tutor at python.org
>Subject: Re: [Tutor] http question
>On Sat, Nov 08, 2014 at 09:53:33PM -0800, Clayton Kirkwood wrote:
>> >> but I also am aware of httplib2, but it still seems to be in
>> >> eternal alpha.
>> >
>> >What leads you to that conclusion? If you're talking about this:
>> >
>> >https://github.com/jcgregorio/httplib2
>> >
>> >I don't see any sign that it is alpha version software. According to
>> >the readme file, it is at version 0.8.
>> >
>> >I don't see any signs that the author publicly releases any alpha or
>> >beta versions, they all appear to be ready for production. But if
>> >you have seen something that suggests otherwise, please point it
>> >out, because I'm happy to be corrected.
>> Well, I work from the premise that 0.anything is still a work in
>> progress
>All software is always a work in progress, until such time it is

And how do you determine the abandoned timestamp? If I remember correctly, this hasn't been updated for several years, and a job for a customer shouldn't be based on 0.*, years old hypothetical's. It sounds like a very usable product.

>> and hasn't gotten to a point where the author is comfortable with
>> general use. I am sure that you disagree.
>In the FOSS (Free and Open Source Software) community, version 0.x does
>not always carry connotations of being unready for use. It may, or it
>may not. But normally "alpha" software will have an "a" in the version
>number, e.g. 0.7a, 0.7b for beta, 0.7rc1 (release candidate 1), 0.7 is
>ready for production.
>What matters is not my opinion, or yours, but that of the author of the
>software, and I don't know what that is.
>Tutor maillist  -  Tutor at python.org
>To unsubscribe or change subscription options:


Message: 2
Date: Mon, 10 Nov 2014 23:35:07 -0800
From: wesley chun <wescpy at gmail.com>
To: crk at godblessthe.us
Cc: tutor <tutor at python.org>, Ben Finney <ben+python at benfinney.id.au>
Subject: Re: [Tutor] ?has a value of True? versus ?evaluates true?
        (was: don't understand iteration)
        <CAB6eaA7dKS1JLzWAstXXLf5=hP=JmM9ucW8_j_QUfrMO-nvQHg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

good catch, and definitely a distinction beginners should be more cognizant of.

it's also good to recognize that a call to "bool(match)" would render that statement correct, as the built-in/factory function will return what an object evaluates to (True [re.match object] or/vs.False [None]).

On Mon, Nov 10, 2014 at 5:31 PM, Clayton Kirkwood <crk at godblessthe.us>

> I reported it. I feel all grown up now. Kind of like one of the
> boys(girls...)
> Clayton:<)
> >-----Original Message-----
> >From: Tutor [mailto:tutor-bounces+crk=godblessthe.us at python.org] On
> >Behalf Of Ben Finney
> >Sent: Monday, November 10, 2014 3:24 PM
> >To: tutor at python.org
> >Subject: [Tutor] ?has a value of True? versus ?evaluates true? (was:
> >don't understand iteration)
> >
> >"Clayton Kirkwood" <crk at godblessthe.us> writes:
> >
> >> Also of confusion, the library reference says:
> >>
> >> Match objects always have a boolean value of True. Since match()
> >> and
> >> search() return None when there is no match, you can test whether
> >> there was a match with a simple if statement:
> >>
> >> match = re.search(pattern, string)
> >> if match:
> >>     process(match)
> >
> >The documentation is incorrect, as you point out: ?have a boolean
> >value of True? implies that the value is identical to the built-in ?True?
> >constant, which is never the case for these objects.
> >
> >Instead, the passage above should say ?evaluates true in a boolean
> >context?.
> >
> >Would you be so kind as to report a bug to that effect
> ><URL:http://bugs.python.org/>?
> >
> >--
> > \       ?The Vatican is not a state.? a state must have people. There |
> >  `\    are no Vaticanians.? No-one gets born in the Vatican except by |
> >_o__)        an unfortunate accident.? ?Geoffrey Robertson, 2010-09-18 |
> >Ben Finney
> >
> >_______________________________________________
> >Tutor maillist  -  Tutor at python.org
> >To unsubscribe or change subscription options:
> >https://mail.python.org/mailman/listinfo/tutor
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it."
    +wesley chun <http://google.com/+WesleyChun> : wescpy at gmail : @wescpy <http://twitter.com/wescpy>
    Python training & consulting : http://CyberwebConsulting.com
    "Core Python" books : http://CorePython.com
    Python blog: http://wescpy.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141110/297bad1d/attachment-0001.html>


Message: 3
Date: Tue, 11 Nov 2014 10:52:50 +0000
From: Alan Gauld <alan.gauld at btinternet.com>
To: tutor at python.org
Subject: Re: [Tutor] don't understand iteration
Message-ID: <m3spq2$pj$1 at ger.gmane.org>
Content-Type: text/plain; charset=utf-8; format=flowed

On 11/11/14 04:45, Clayton Kirkwood wrote:

>>> *list(range(1,6))
>    File "<input>", line 1
> SyntaxError: can use starred expression only as assignment target

list() is a function. You cannot unpack a function.

Also the * operator needs to be used inside a function parameter list.
(There may be some obscure case where you can use it outside of that but 99% of the time that's the only place you'll see it used.)

>>>> a = list(*range(5))

And again range() is a function, you can only use * on a list/tuple.

>>>> a = list(range(*5))

And here 5 is an integer. It must be a sequence.

> As far as I can tell, everything that has been suggested doesn't work:

What has been suggested is a collection inside a functions argument list. You haven't tried that in any of your examples.

Here are a couple of valid cases:

 >>> def threeArgs(a,b,c):
...    print(a,b,c)
 >>> myList = [3,5,8]
 >>> threeArgs(*myList)    # unpack a variable
3 5 8
 >>> threeArgs(*(9,3,1))   # unpack literal tuple
9 3 1

> Has to be only in assignment target,

I agree the error message is not at all clear.
Its probably technically correct from the interpreters perspective but its not that clear to the programmer.

> Perhaps the vaunted try it in the console, doesn't work.

It does work as I showed above. But you still need to type in the right syntax.

> I am sure that I am missing something

The fact that it only works inside a function's argument list.

>> And the link to Calls:
>> https://docs.python.org/3/reference/expressions.html#calls
>> which says:
>> --------------
>> ...
>> If the syntax *expression appears in the function call, expression
>> must evaluate to an iterable. Elements from this iterable are treated
>> as if they were additional positional arguments;

That's the explanation right there.
It says that if you call a function and use *name in the argument list Python will expect name to refer to an iterable and will unpack the iterables elements(values) and use them as positional arguments in the function call. Like most of the Python docs its accurate but terse.

> Yes, inside the call to a function call.
 > My question is outside to a function call.

You cannot use the * operator outside a function call.
At least I can't think of a case where it works.

Alan G
Author of the Learn to Program web site


Subject: Digest Footer

Tutor maillist  -  Tutor at python.org


End of Tutor Digest, Vol 129, Issue 22
This email and any attachments sent with it are intended only for the named recipient. If you are not that person please contact us immediately through our website and delete this message from your computer. You should not disclose the content nor take, retain or distribute any copies. No responsibility is accepted by AKS, United Learning or any associated entity for the contents of e-mails unconnected with their business. No responsibility is accepted for any loss or damage caused due to any virus attached to this email.

AKS is part of United Learning, comprising: UCST (Registered in England No: 2780748. Charity No. 1016538) and ULT (Registered in England No. 4439859. An Exempt Charity).
Companies limited by guarantee.

More information about the Tutor mailing list