Grokbase Groups Python tutor May 2005
FAQ

Here is what the code I settled on looks like:

###
working = email.message_from_file(open(emailfile))

clamav = popen2.Popen3(clamav_cmd,1)
clamav.tochild.write(working.as_string())
clamav.tochild.close()
clamav_result = clamav.fromchild.read().lstrip('stream: ')
clamav.fromchild.close
^^^^^^^^^^^^^^^^^^^^^^


Hi Jeffrey,

Careful: you may need parens there on your 'close' line. (clothesline?
*grin*)

As written, that last statement doesn't fire off the close() method.
This might be suprising because some other languages make parens optional.
But we need them in Python because Python makes it very easy to get
function references:

######
def calculatePi():
... return 22/7
...
calculatePi
<function calculatePi at 0x402dae64>
######

Without parens, we just get the function reference. We still need to
"call" that function value by using parens, which trigger the function to
fire off:

######
calculatePi()
3
######


Otherwise, your program looks good! I'm glad that it's working for you
now.


Best of wishes!

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 5 | next ›
Discussion Overview
grouptutor @
categoriespython
postedMay 12, '05 at 4:39a
activeMay 16, '05 at 12:18a
posts5
users2
websitepython.org

2 users in discussion

Jeffrey Rice: 3 posts Danny Yoo: 2 posts

People

Translate

site design / logo © 2022 Grokbase