Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8980
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:Does': 0.04; '"""': 0.07; 'see:': 0.07; 'python': 0.08; 'called.': 0.09; 'defined.': 0.09; 'wed,': 0.12; 'stored': 0.13; 'subject:file': 0.13; 'wrote:': 0.15; 'occurs.': 0.16; 'twice.': 0.16; 'object,': 0.16; 'cc:addr:python-list': 0.16; 'pm,': 0.16; 'def': 0.16; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply- To:1': 0.22; 'expect': 0.25; 'function': 0.26; 'message- id:@mail.gmail.com': 0.28; 'object': 0.30; 'cc:addr:python.org': 0.30; 'definition': 0.30; 'objects.': 0.30; 'subject:support': 0.30; 'least': 0.31; 'subject:?': 0.31; 'does': 0.32; 'there': 0.34; 'url:python': 0.37; 'passed': 0.37; 'received:google.com': 0.38; 'received:209.85.161': 0.38; 'received:209.85': 0.38; 'url:org': 0.38; 'subject:: ': 0.38; 'two': 0.38; 'returned': 0.39; 'url:docs': 0.39; 'received:209': 0.40; 'where': 0.40; 'subject:mode': 0.84; 'url:reference': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Zf2hZK/nr4yYeeu+PnV/42YwYzXWNuaPZELZNKAgyp0=; b=ge57nwbo9K8wiOtDc4oQrsLMVno+Yzlwmeq2iWUMuC2Hj9dqNqGf4UyQ0cNaiTCPY7 i4oJ5vIJJoFYLTKG6UD33AC6KVN9EBngWNdMphijpKU43lXx7xfdK4D5DGx6vE0Amf28 8STbKmQXahd8lt96jO0WNAUo+C40TACco4K5M= |
| MIME-Version | 1.0 |
| In-Reply-To | <5a4867f1-929c-4cde-b47e-4b11de767f39@h38g2000pro.googlegroups.com> |
| References | <5a4867f1-929c-4cde-b47e-4b11de767f39@h38g2000pro.googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Wed, 6 Jul 2011 13:48:36 -0600 |
| Subject | Re: Does hashlib support a file mode? |
| To | Phlip <phlip2005@gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.720.1309981747.1164.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1309981747 news.xs4all.nl 21796 [2001:888:2000:d::a6]:54462 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:8980 |
Show key headers only | View raw
On Wed, Jul 6, 2011 at 1:07 PM, Phlip <phlip2005@gmail.com> wrote:
> If I call m = md5() twice, I expect two objects.
>
> I am now aware that Python bends the definition of "call" based on
> where the line occurs. Principle of least surprise.
There is no definition-bending. The code:
"""
def file_to_hash(path, m = hashlib.md5()):
# do stuff...
file_to_hash(path1)
file_to_hash(path2)
"""
does not call hashlib.md5 twice. It calls it *once*, at the time the
file_to_hash function is defined. The returned object is stored on
the function object, and that same object is passed into file_to_hash
as a default value each time the function is called. See:
http://docs.python.org/reference/compound_stmts.html#function
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Does hashlib support a file mode? Phlip <phlip2005@gmail.com> - 2011-07-06 12:07 -0700
Re: Does hashlib support a file mode? geremy condra <debatem1@gmail.com> - 2011-07-06 15:15 -0400
Re: Does hashlib support a file mode? Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-06 14:42 -0500
Re: Does hashlib support a file mode? Mel <mwilson@the-wire.com> - 2011-07-06 15:43 -0400
Re: Does hashlib support a file mode? Anssi Saari <as@sci.fi> - 2011-07-07 14:29 +0300
Re: Does hashlib support a file mode? Paul Rudin <paul.nospam@rudin.co.uk> - 2011-07-07 13:13 +0100
Re: Does hashlib support a file mode? Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-06 13:48 -0600
Re: Does hashlib support a file mode? Ethan Furman <ethan@stoneleaf.us> - 2011-07-06 13:24 -0700
csiph-web