🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #28345

Re: Prośba o wytknięcie błędów

#28345
From: William Bonawentura
Date: Mon, 04 Jun 2012 05:15
16 lines
1600 bytes
> moglisbyście mi powiedzieć co zrobiłem nie po pythonowemu, lub co można 
> zrobić lepiej/bardziej pythonowo.

def calculate_hash( filename ):
    f = open( filename, 'r' )
    mail = email.message_from_file( f )


Metoda biznesowa (liczenie hasha) nie powinna realizować dostępu do danych. 
Czyli jej parametrem powinien być mail a nie filename. Gdzieś na zewnątrz, 
komponent aplikacyjny, dokona tej integracji:


with open( filename ) as f:
    mail = email.message_from_file( f )
    hash = email_calculator.calculate_hash( mail ) 
Technical Details
Message-ID: <jqhg9k$208n$1@news2.ipartners.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!news.cyf-kr.edu.pl!news.nask.pl!news.nask.org.pl!nf1.ipartners.pl!ipartners.pl!news2.ipartners.pl!not-for-mail
References: <2h09p8-kgk.ln1@depesz.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!news.cyf-kr.edu.pl!news.nask.pl!news.nask.org.pl!nf1.ipartners.pl!ipartners.pl!news2.ipartners.pl!not-for-mail
From: "William Bonawentura" <nie@ma.mnie.pl>
Newsgroups: pl.comp.lang.python
Subject: Re: Prośba o
 wytknięcie błędów
Date: Mon, 4 Jun 2012 07:15:31 +0200
Organization: GTS Energis
Lines: 17
Message-ID: <jqhg9k$208n$1@news2.ipartners.pl>
References: <2h09p8-kgk.ln1@depesz.com>
NNTP-Posting-Host: nat-coig130.coig.katowice.pl
Mime-Version: 1.0
X-Trace: news2.ipartners.pl 1338786932 65815 195.39.217.130 (4 Jun 2012 05:15:32 GMT)
X-Complaints-To: abuse@ipartners.pl
NNTP-Posting-Date: 4 Jun 2012 05:15:32 GMT
In-Reply-To: <2h09p8-kgk.ln1@depesz.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3508.1109
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 15.4.3508.1109
X-MSMail-Priority: Normal
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit