Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'operator': 0.03; 'string.': 0.05; 'problem:': 0.07; 'subject:while': 0.09; 'python': 0.11; '"%"': 0.16; '"%s"': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'it;': 0.16; 'language:': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'personally,': 0.16; 'prakash': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'skip:> 20': 0.16; 'subject:program': 0.16; 'subject:send': 0.16; 'subject:writing': 0.16; 'so.': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'code,': 0.22; 'example': 0.22; 'programming': 0.22; 'header :User-Agent:1': 0.23; 'error': 0.23; 'sorry,': 0.24; 'string,': 0.24; 'text.': 0.24; 'cheers,': 0.24; 'sort': 0.25; 'define': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'programming.': 0.30; 'code': 0.31; 'getting': 0.31; 'away.': 0.31; 'file': 0.32; 'supposed': 0.32; 'text': 0.33; 'url:python': 0.33; '(most': 0.33; 'problem': 0.35; 'something': 0.35; 'but': 0.35; 'received:com.au': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'two': 0.37; 'expected': 0.38; 'generic': 0.38; 'received:211': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'how': 0.40; 'new': 0.61; 'simple': 0.61; 'first': 0.61; 'back': 0.62; 'content- disposition:inline': 0.62; 'name': 0.63; 'containing': 0.69; 'william': 0.81 Date: Tue, 2 Sep 2014 09:52:00 +1000 From: Cameron Simpson To: python-list@python.org Subject: Re: error while writing program to send mail. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <540502CD.8030209@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) References: <540502CD.8030209@gmail.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=AOuw8Gd4 c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=3Kf9FMe-JDoA:10 a=4TFnWSbgze8A:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=pGLkceISAAAA:8 a=8AHkEIZyAAAA:8 a=c2FsGQbKh6uFLJ3bNn0A:9 a=CjuIK1q_8ugA:10 a=egxqZzf5gs0A:10 a=MSl-tDqOz04A:10 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1409615523 news.xs4all.nl 2852 [2001:888:2000:d::a6]:44725 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77421 On 02Sep2014 05:05, Om Prakash wrote: >I am writing this program from >https://docs.python.org/2/library/email-examples.html > >but getting the error as > >singhom@debian:~/pythons$ python send_email.py >Traceback (most recent call last): > File "send_email.py", line 18, in > msg['Subject'] = 'The contents of $s' % message >NameError: name 'message' is not defined > >i know the error would be something simple and i am overlooking it, >any help would be highly appreciated, I am sorry, but I am very new to >python programming. This problem is generic to almost any programming language: you have not defined the variable "message" before you try to use it in the format string. In the example code, the variable is called "textfile" and is supposed to be the name of a file containing some message text. The example code does not define it; you need to do so. After you sort that, you then have a ython problem: you have said "$s" in your format string, but the python "%" operator expected "%s" in the format string. Sort these two things and see how things proceed. Cheers, Cameron Simpson Personally, I find blinking text on a page to be extraordinarily annoying and my first instinct is to back up one page, right away. - William Barr