Re: [Tutor] AttributeError,
Hi Steven, Message heard loud and clear: Question: What sorted function should I write to produce the desired output, below: Desired output: 04 3 06 1 07 1 09 2 10 3 11 6 14 1 15 2 16 4 17 2 18 1 19 1 Latest revised code: count = dict() fname = raw_input("Enter file name: ")# handle = open (fname, 'r')# for line in handle: if line.startswith("From "): address = line.split()[5] line = line.rstrip() count[address] = count.get(address, 0) + 1 lst = list() for key,val in count.items(): lst.append( (val, key) ) lst.sort(reverse=True) for val, key in lst[:12]: print key,val Output code: In [3]: %run assignment_10_2_v_01 Enter file name: mbox-short.txt 16:23:48 1 16:23:48 1 11:11:52 1 17:07:00 1 16:23:48 1 11:11:52 1 17:07:00 1 16:23:48 1 11:11:52 1 04:07:34 1 17:07:00 1 16:23:48 1 11:11:52 1 07:02:32 1 04:07:34 1 17:07:00 1 16:23:48 1 11:12:37 1 11:11:52 1 07:02:32 1 04:07:34 1 17:07:00 1 16:23:48 1 14:50:18 1 11:12:37 1 11:11:52 1 07:02:32 1 04:07:34 1 17:07:00 1 16:23:48 1 14:50:18 1 11:35:08 1 11:12:37 1 11:11:52 1 07:02:32 1 04:07:34 1 17:07:00 1 16:23:48 1 14:50:18 1 11:37:30 1 11:35:08 1 11:12:37 1 11:11:52 1 07:02:32 1 04:07:34 1 18:10:48 1 17:07:00 1 16:23:48 1 14:50:18 1 11:37:30 1 11:35:08 1 11:12:37 1 11:11:52 1 07:02:32 1 04:07:34 1 18:10:48 1 17:07:00 1 16:23:48 1 14:50:18 1 11:37:30 1 11:35:08 1 11:12:37 1 11:11:52 1 11:10:22 1 07:02:32 1 04:07:34 1 19:51:21 1 18:10:48 1 17:07:00 1 16:23:48 1 14:50:18 1 11:37:30 1 11:35:08 1 11:12:37 1 11:11:52 1 11:10:22 1 07:02:32 1 04:07:34 1 19:51:21 1 18:10:48 1 17:07:00 1 16:23:48 1 15:46:24 1 14:50:18 1 11:37:30 1 11:35:08 1 11:12:37 1 11:11:52 1 11:10:22 1 07:02:32 1 19:51:21 1 18:10:48 1 17:07:00 1 16:23:48 1 16:10:39 1 15:46:24 1 14:50:18 1 11:37:30 1 11:35:08 1 11:12:37 1 11:11:52 1 11:10:22 1 19:51:21 1 18:10:48 1 17:07:00 1 16:23:48 1 16:10:39 1 15:46:24 1 14:50:18 1 11:37:30 1 11:35:08 1 11:12:37 1 11:11:52 1 11:10:22 1 19:51:21 1 18:10:48 1 17:07:00 1 16:34:40 1 16:23:48 1 16:10:39 1 15:46:24 1 14:50:18 1 11:37:30 1 11:35:08 1 11:12:37 1 11:11:52 1 19:51:21 1 18:10:48 1 17:07:00 1 16:34:40 1 16:23:48 1 16:10:39 1 15:46:24 1 14:50:18 1 11:37:30 1 11:35:08 1 11:12:37 1 11:11:52 1 19:51:21 1 18:10:48 1 17:07:00 1 16:34:40 1 16:23:48 1 16:10:39 1 15:46:24 1 14:50:18 1 11:37:30 1 11:35:08 1 11:12:37 1 11:11:52 1 19:51:21 1 18:10:48 1 17:07:00 1 16:34:40 1 16:29:07 1 16:23:48 1 16:10:39 1 15:46:24 1 14:50:18 1 11:37:30 1 11:35:08 1 11:12:37 1 19:51:21 1 18:10:48 1 17:07:00 1 16:34:40 1 16:29:07 1 16:23:48 1 16:10:39 1 15:46:24 1 15:03:18 1 14:50:18 1 11:37:30 1 11:35:08 1 19:51:21 1 18:10:48 1 17:07:00 1 16:34:40 1 16:29:07 1 16:23:48 1 16:10:39 1 15:46:24 1 15:03:18 1 14:50:18 1 11:37:30 1 11:35:08 1 19:51:21 1 18:10:48 1 17:07:00 1 16:34:40 1 16:29:07 1 16:23:48 1 16:10:39 1 15:46:24 1 15:03:18 1 14:50:18 1 11:37:30 1 11:35:08 1 19:51:21 1 18:10:48 1 17:07:00 1 16:34:40 1 16:29:07 1 16:23:48 1 16:10:39 1 15:46:24 1 15:03:18 1 14:50:18 1 11:37:30 1 11:35:08 1 19:51:21 1 18:10:48 1 17:18:23 1 17:07:00 1 16:34:40 1 16:29:07 1 16:23:48 1 16:10:39 1 15:46:24 1 15:03:18 1 14:50:18 1 11:37:30 1 19:51:21 1 18:10:48 1 17:18:23 1 17:07:00 1 16:34:40 1 16:29:07 1 16:23:48 1 16:10:39 1 15:46:24 1 15:03:18 1 14:50:18 1 11:37:30 1 19:51:21 1 18:10:48 1 17:18:23 1 17:07:00 1 16:34:40 1 16:29:07 1 16:23:48 1 16:10:39 1 15:46:24 1 15:03:18 1 14:50:18 1 11:37:30 1 19:51:21 1 18:10:48 1 17:18:23 1 17:07:00 1 16:34:40 1 16:29:07 1 16:23:48 1 16:10:39 1 15:46:24 1 15:03:18 1 14:50:18 1 11:37:30 1 In [4]: Regards, Hal On Tue, Aug 11, 2015 at 8:32 PM, Steven D'Aprano wrote: > On Tue, Aug 11, 2015 at 07:38:21PM -0700, Ltc Hotspot wrote: >> Steven, >> >> Visit the URL links below to view the latest revised code: > > I don't think so. I don't have access to the web right now, but I do > have access to email. And even if I did, I'm lazy and wouldn't follow > links and then have to copy and paste from the website into my reply. > > Since I'm donating my time for free, the least you can do is do the > copying and pasting yourself. > >> Output: 09:14:16 >> Syntax message: val is not defined > > I'm pretty sure that is not the actual error message you get. Are you > sure it is not a NameError, rather than SyntaxError? > > The kind of error you get, together with the error message, often gives > you clues as to what is going on. Python goes to a huge amount of > trouble to provide a useful and informative error message, instead of > just saying "Error!" and leaving you to guess. So read the message: if > it tells you that "val is not defined", then you have not defined a > variable val. > > > -- > Steve > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription o
Re: [Tutor] AttributeError,
Steven, Visit the URL links below to view the latest revised code: Output: 09:14:16 Syntax message: val is not defined Raw data code, available at http://tinyurl.com/ob89r9p Embedded data code, available at http://tinyurl.com/qhm4ppq Visualization URL link, available at http://tinyurl.com/ozzmffy Thanks, Hal On Tue, Aug 11, 2015 at 7:01 PM, Steven D'Aprano wrote: > On Tue, Aug 11, 2015 at 04:24:39PM -0700, Ltc Hotspot wrote: > > Hi Everyone, > > > > Why is there an AttributeError, line 12, below : 'tuple' object has no > > attribute 'sort'? > > Haven't I see this exact same question, complete with solutions, on the > python-list mailing list? > > The answer found there is that you are trying to sort the wrong value. > You are trying to sort an immutable (that is, unchangeable) (key, value) > tuple, which includes one string and one number. And then you ignore the > sorted result! > > You have: > > ncount = (key,val) > ncount.sort(reverse=True) > print key,val > > > Sorting (key, val) cannot work, because that is an immutable tuple. > Turning it into a list [key, val] now makes it sortable, but that > doesn't do what you want: Python 2 always sorts ints ahead of strings, > regardless of their actual values. But even if you did meaningfully sort > the list [key, val], having done so you don't look at the results, but > print the key and val variables instead, which are unchanged. > > Changing the order of items in a list does not, and can not, change the > variables that were used to build that list. > > If that is not clear, study this example: > > py> a = 999 > py> b = 1 > py> alist = [a, b] # construct a list from a and b > py> print alist > [999, 1] > py> alist.sort() # change the order of items in the list > py> print alist > [1, 999] > py> print a, b # have a and b changed? > 999 1 > > > The actual solution needed is, I think, sorting the entire collection: > > items = sorted(count.items()) > for key, val in items: > print key,val > > > > -- > Steve > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] AttributeError,
Hi Everyone, Why is there an AttributeError, line 12, below : 'tuple' object has no attribute 'sort'? count = dict() fname = raw_input("Enter file name: ")# handle = open (fname, 'r')# for line in handle: if line.startswith("From "): address = line.split()[5] line = line.rstrip() count[address] = count.get(address, 0) + 1 for key,val in count.items(): ncount = (key,val) ncount.sort(reverse=True) print key,val Raw data code, available at http://tinyurl.com/ob89r9p Embedded data code, available at http://tinyurl.com/qhm4ppq Visualization URL link, available at http://tinyurl.com/ozzmffy Regards, Hal ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
Hi Mark, Why is Counter not defined on line #15: line = Counter(address),i.e., NameError: name 'Counter' is not defined? Share a chat session at http://tinyurl.com/oull2fw View line entry at http://tinyurl.com/oggzn97 Hal On Fri, Aug 7, 2015 at 12:14 AM, Mark Lawrence wrote: > On 07/08/2015 01:30, Ltc Hotspot wrote: > >> Mark, >> >> I'm following the instructor's video exercise, available at >> https://www.youtube.com/watch?v=3cwXN5_3K6Q. >> >> View attached screen shot file, image file shows a copy of the >> counter: cou[wrd] =cou.get(wrd,0) +1 >> >> Please, explain the differences in counter methods? >> >> > top posted, again, *plonk* > > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
Alan, I want to find the max val , keys and values are defined on line 10: for kee, val in count.items(): Then, maxval determines the max value on line 11: if val > maxval: right, view a copy of the revised code at http://tinyurl.com/nvzdw8k Question1: are these assumptions true, above? Question2: dict maps strings into keys and values? Hal On Thu, Aug 6, 2015 at 11:35 PM, Alan Gauld wrote: > On 07/08/15 01:15, Ltc Hotspot wrote: > >> Question1: How type of argument should I use for dict, i.e.,user argument >> or list argument. >> >> Read captured traceback: >> >> TypeError >> Traceback (most recent call last) >> C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_26.py in () >>1 fname = raw_input("Enter file name: ") >>2 handle = open (fname, 'r') >> > 3 count = dict.keys() >>4 for line in handle: >>5 if line.startswith("From: "): >> > > > You appear to be making random changes to your code > for no good reason. > > I will not make any further suggestions until you > start to explain your thinking. > > What do you think the line > > count = dict.keys() > > will do? Why do you want to do that? > How will it help you solve your problem? > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
Mark, I'm following the instructor's video exercise, available at https://www.youtube.com/watch?v=3cwXN5_3K6Q. View attached screen shot file, image file shows a copy of the counter: cou[wrd] =cou.get(wrd,0) +1 Please, explain the differences in counter methods? Hal On Thu, Aug 6, 2015 at 4:53 PM, Mark Lawrence wrote: > On 06/08/2015 20:05, Ltc Hotspot wrote: > >> On my breath and soul, I did: >> >> Counter objects have a dictionary interface except that they return a zero >> count for missing items instead of raising a KeyError >> <https://docs.python.org/3/library/exceptions.html#KeyError>: >> > > That's nice to know. What do the rest of the methods on the class do? > > Please don't top post here, it makes following long threads difficult. >>>>> >>>> > What did you not understand about the above? > > You obviously haven't bothered to read the link I gave you about the >>> Counter class so I give up. >>> >>> > If you'd read the entire write up why are you still wasting time with a > loop to find a maximum that simply doesn't work, when there is likely a > solution in the Counter class right in front of your eyes? > > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
Question1: How type of argument should I use for dict, i.e.,user argument or list argument. Read captured traceback: TypeError Traceback (most recent call last) C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_26.py in () 1 fname = raw_input("Enter file name: ") 2 handle = open (fname, 'r') > 3 count = dict.keys() 4 for line in handle: 5 if line.startswith("From: "): TypeError: descriptor 'keys' of 'dict' object needs an argument In [99]: Question2: Are all the loop failures resolved in the revised code? Revised code is available at https://gist.github.com/ltc-hotspot/00fa77ca9b40c0a77170 Regards, Hal On Thu, Aug 6, 2015 at 4:20 PM, Alan Gauld wrote: > On 07/08/15 00:11, Ltc Hotspot wrote: > >> Questions(1):Why does print line, prints blank space; and, (2) print >> address prints a single email address: >> > > See my previous emails. > You are not storing your addresses so address only holds the last address > in the file. > line is at the end of the file so is empty., > > In [72]: print count >> {'gopal.ramasammyc...@gmail.com <mailto:gopal.ramasammyc...@gmail.com>': >> 1, 'lo...@media.berkeley.edu <mailto:lo...@media.berkeley.edu>': 3, >> 'cwen@iupui. >> edu': 5, 'antra...@caret.cam.ac.uk <mailto:antra...@caret.cam.ac.uk>': >> 1, 'rjl...@iupui.edu <mailto:rjl...@iupui.edu>': 2, 'gsil...@umich.ed >> u': 3, 'david.horw...@uct.ac.za <mailto:david.horw...@uct.ac.za>': 4, ' >> wagne...@iupui.edu <mailto:wagne...@iupui.edu>': 1, 'zq...@umich.edu >> <mailto:zq...@umich.edu>': >> 4, 'stephen.marqu...@uct.ac.za <mailto:stephen.marqu...@uct.ac.za>': 2, >> 'r...@media.berkeley.edu <mailto:r...@media.berkeley.edu>': 1} >> >> Question(3): why did the elements print count('keys') and print >> count('items') fail? >> > > Because, as shown above, count is a dictionary. > So items and keys are methods not strings to be passed > to a non-existent count() function. > > So you need, for example: > > print count.keys() > > Traceback (most recent call last) >> in () >> > 1 print count('items') >> >> TypeError: 'dict' object is not callable >> >> > Which is what the error is also telling you. > You cannot call - ie use () - with a dictionary like count. > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
On Thu, Aug 6, 2015 at 3:00 PM, Alan Gauld wrote: > On 06/08/15 19:30, Ltc Hotspot wrote: > > I moved counter outside the loop and below dict, maxval = None >> maxkee = None are both positioned outside the loop. >> > > You moved counter but it is still a dict() and you > don't use it anywhere. > > URL link to the revisions are available at http://tinyurl.com/nvzdw8k >> >> Question: How do I define Counter >> > > Counter is defined for you in the collections module. > So to use it you need to import collections and access it as > collections.Counter. > > But did you read how to use it? It is a lot more than > just a dictionary, it has many extra methods, some of > which almost solve your problem for you. (Whether your > teacher will approve of using Counter is another > issue!) > > Revised code reads: >> fname = raw_input("Enter file name: ") >> handle = open (fname, 'r') >> >> counter = dict () >> c = Counter(['address']) >> > > You only need to pass a list if you are adding multiple things. > > But by the same token you can add a list of items, such > as email addresses. So if you had such a list you could > create a Counter() to hold them and count them for you. > And return the one with the highest value. > Sound familiar? > > Please (re)read the Counter documentation. > Then play with one in the >>> prompt. > Don't expect us to just provide you with code, learn > how it works for yourself. Experiment. > > The >>> prompt is your friend. You will learn more from that in 15 minutes > than in a bunch of emails showing other peoples > code. > > Alternatively forget about Counter and just go back to > your dict(). You have written all the code you need already, > you just need to assemble it in the correct order. > > maxval = None >> maxkee = None >> >> for line in handle: >> if line.startswith("From: "): >> address = line.split()[1] >> > > You are not storing the addresses anywhere. > > for maxkee, val in c.items(): >> >> maxval = val >> maxkee = kee >> > > You are still not testing if its the maximum, > you just keep overwriting the variables for > each element. > > print maxkee and maxval >> > > You still have an 'and' in there. > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > Hi Alan, Questions(1):Why does print line, prints blank space; and, (2) print address prints a single email address: View print results as follows: In [70]: %run assignment_9_4_24.py Enter file name: mbox-short.txt r...@media.berkeley.edu 1 In [71]: print handle In [72]: print count {'gopal.ramasammyc...@gmail.com': 1, 'lo...@media.berkeley.edu': 3, 'cwen@iupui. edu': 5, 'antra...@caret.cam.ac.uk': 1, 'rjl...@iupui.edu': 2, 'gsil...@umich.ed u': 3, 'david.horw...@uct.ac.za': 4, 'wagne...@iupui.edu': 1, ' zq...@umich.edu': 4, 'stephen.marqu...@uct.ac.za': 2, 'r...@media.berkeley.edu': 1} In [73]: print line In [74]: print address c...@iupui.edu Question(3): why did the elements print count('keys') and print count('items') fail? View print commands as follows: In [75]: dir (count) Out[75]: ['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values', 'viewitems', 'viewkeys', 'viewvalues'] In [76]: --- TypeError Traceback (most recent call last) in () > 1 print count('items') TypeError: 'dict' object is not callable In [77]: print count('keys') --- TypeError Traceback (most recent call last) in () > 1 print count('keys') TypeError: 'dict' object is not callable In [78]: Regards, Hal ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
On my breath and soul, I did: Counter objects have a dictionary interface except that they return a zero count for missing items instead of raising a KeyError <https://docs.python.org/3/library/exceptions.html#KeyError>: >>> >>> c = Counter(['eggs', 'ham']) On Thu, Aug 6, 2015 at 11:59 AM, Mark Lawrence wrote: > On 06/08/2015 18:17, Ltc Hotspot wrote: > >> On Thu, Aug 6, 2015 at 8:28 AM, Mark Lawrence >> wrote: >> >> On 06/08/2015 05:22, Ltc Hotspot wrote: >>> >>> Please don't top post here, it makes following long threads difficult. >>> >>> Mark, >>> >>>> >>>> Replace count[address]= count.get(address,0) +1 with c = >>>> Counter(['address'])? >>>> >>>> >>> Try it at the interactive prompt and see what happens. >>> >>> How do I define counter,view trace back: >>> >>> NameError >>> Traceback (most recent call last) >>> C:\Users\vm\Desktop\apps\docs\Python\new.txt in () >>>1 fname = raw_input("Enter file name: ") >>>2 handle = open (fname, 'r') >>> > 3 c = Counter(['address']) >>>4 >>>5 >>> >>> NameError: name 'Counter' is not defined >> >> >> View revised code here: >> >> fname = raw_input("Enter file name: ") >> handle = open (fname, 'r') >> c = Counter(['address']) >> >> count = dict () >> maxval = None >> maxkee = None >> >> for kee, val in count.items(): >> maxval = val >> maxkee = kee >> >> for line in handle: >> if line.startswith("From: "): >> address = line.split()[1] >> count[address]= count.get(address,0) +1 >> print maxkee and maxval >> >> > You obviously haven't bothered to read the link I gave you about the > Counter class so I give up. > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
Mark, Visit the following URL link to view a captured copy of the latest code revision, available at http://tinyurl.com/nvzdw8k Regards, Hal On Thu, Aug 6, 2015 at 10:17 AM, Ltc Hotspot wrote: > > > On Thu, Aug 6, 2015 at 8:28 AM, Mark Lawrence > wrote: > >> On 06/08/2015 05:22, Ltc Hotspot wrote: >> >> Please don't top post here, it makes following long threads difficult. >> >> Mark, >>> >>> Replace count[address]= count.get(address,0) +1 with c = >>> Counter(['address'])? >>> >> >> Try it at the interactive prompt and see what happens. >> >> How do I define counter,view trace back: >> >> NameError >> Traceback (most recent call last) >> C:\Users\vm\Desktop\apps\docs\Python\new.txt in () >> 1 fname = raw_input("Enter file name: ") >> 2 handle = open (fname, 'r') >> > 3 c = Counter(['address']) >> 4 >> 5 >> > NameError: name 'Counter' is not defined > > > View revised code here: > > fname = raw_input("Enter file name: ") > handle = open (fname, 'r') > c = Counter(['address']) > > count = dict () > maxval = None > maxkee = None > > for kee, val in count.items(): > maxval = val > maxkee = kee > > for line in handle: > if line.startswith("From: "): > address = line.split()[1] > count[address]= count.get(address,0) +1 > print maxkee and maxval > > > In [20]: > Hal > >> >>> >>> >>> >>>> ___ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor >> > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
Hi Alan, I moved counter outside the loop and below dict, maxval = None maxkee = None are both positioned outside the loop. URL link to the revisions are available at http://tinyurl.com/nvzdw8k Question: How do I define Counter Revised code reads: fname = raw_input("Enter file name: ") handle = open (fname, 'r') counter = dict () c = Counter(['address']) maxval = None maxkee = None for line in handle: if line.startswith("From: "): address = line.split()[1] for maxkee, val in c.items(): maxval = val maxkee = kee print maxkee and maxval Traceback message reads: NameError Traceback (most recent call last) C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_16.py in () 3 4 counter = dict () > 5 c = Counter(['address']) 6 7 maxval = None NameError: name 'Counter' is not defined Regards, Hal On Thu, Aug 6, 2015 at 2:47 AM, Alan Gauld wrote: > On 06/08/15 03:27, Ltc Hotspot wrote: > >> The output as reported by the latest code revision: c...@iupui.edu >> <mailto:c...@iupui.edu> 1← Mismatch >> >> Looks like python continues to print the wrong data set: >> > > Python will print what you ask it to. Don't blame the tool! :-) > > > for line in handle: > > if line.startswith("From: "): > > address = line.split()[1] > > count[address]= count.get(address,0) +1 > > > > maxval = None > > maxkee = None > > for kee, val in count.items(): > > > > maxval = val > > maxkee = kee > > > > print address, val > > Look at the loops. > > In the second loop you are no longer setting the values to > those of the max item but are setting them every time. > So at the end of the loop val holds the val of > the last item (and so does maxval so even if you used > that it would be the same result). > > Similarly with the code for address. You are setting that > for each 'From ' line in your file so at the end of the loop > address is the last address in the file. > > Now, dictionaries do not store data in the order that you > insert it, so there is no guarantee that the last item in > the dictionary loop is the same as the last address > you read. > > You need to reinstate the test for max val in the second > loop and then print the kee that corresponds with that > (maxkee) as the address. ie. print maxkee and maxval. > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
On Thu, Aug 6, 2015 at 8:28 AM, Mark Lawrence wrote: > On 06/08/2015 05:22, Ltc Hotspot wrote: > > Please don't top post here, it makes following long threads difficult. > > Mark, >> >> Replace count[address]= count.get(address,0) +1 with c = >> Counter(['address'])? >> > > Try it at the interactive prompt and see what happens. > > How do I define counter,view trace back: > > NameError > Traceback (most recent call last) > C:\Users\vm\Desktop\apps\docs\Python\new.txt in () > 1 fname = raw_input("Enter file name: ") > 2 handle = open (fname, 'r') > > 3 c = Counter(['address']) > 4 > 5 > NameError: name 'Counter' is not defined View revised code here: fname = raw_input("Enter file name: ") handle = open (fname, 'r') c = Counter(['address']) count = dict () maxval = None maxkee = None for kee, val in count.items(): maxval = val maxkee = kee for line in handle: if line.startswith("From: "): address = line.split()[1] count[address]= count.get(address,0) +1 print maxkee and maxval In [20]: Hal > >> >> >> >>> ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
Mark, Replace count[address]= count.get(address,0) +1 with c = Counter(['address'])? Regards, Hal On Wed, Aug 5, 2015 at 9:03 PM, Mark Lawrence wrote: > On 05/08/2015 23:58, Ltc Hotspot wrote: > >> Hi Mark, >> >> Address identifies the email address with the maximum number of sends: >> c...@iupui.edu. >> >> Secondly, we are missing a count on the number of messages sent by >> c...@iupui.edu, i.e., 5. >> >> Thirdly, maxval 'none' is not defined on line # 24 >> >> Questions: How do we define the value of none for the key maxval and >> retrieve a number count on the number of messages sent by c...@iupui.edu. >> >> >> NameError: >> >> Traceback (most recent call last) >> C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_5.py in () >> 22 ## find the greatest number of mail messages. >> 23 >> ---> 24 maxval = none >> 25 maxkee = none >> 26 for kee, val in count.items(): >> >> NameError: name 'none' is not defined >> >> In [52]: print address >> c...@iupui.edu >> >> Revised data: >> >> >> ## The program looks for 'From ' lines and takes the second >> ## word of those lines as the person who sent the mail. >> >> fname = raw_input("Enter file name: ") >> handle = open (fname, 'r') >> for line in handle: >> if line.startswith("From: "): >> address = line.split()[1] >> >> >> ## The program creates a Python dictionary that maps >> ## the sender's mail address to a count of the number >> ## of times they appear in the file. >> >> count = dict() >> for wrd in address: >> count[wrd]= count.get(wrd,0) +1 >> >> ## After the dictionary is produced, the program reads >> ## through the dictionary using a maximum loop to >> ## find the greatest number of mail messages. >> >> maxval = none >> maxkee = none >> for kee, val in count.items(): >> if maxval == none or maxval > maxval = val >> maxkee = kee >> >> > You can greatly simplify all of the above code if you use a Counter from > the collections module > https://docs.python.org/3/library/collections.html#collections.Counter > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
Hi Alan The output as reported by the latest code revision: c...@iupui.edu 1 ← Mismatch Looks like python continues to print the wrong data set: In [11]: print val 1 In [12]: print kee r...@media.berkeley.edu In [13]: print address c...@iupui.edu In order to complete the assignment, using data from the source file, python must print the email address of the maximum sender and the number of sends, i.e., c...@iupui.edu 5 I think the problem is in the placement of the counter? Question: What is the source of the dictionary keys and values: maxval = None maxkee = None Here is the latest revised code as follows: fname = raw_input("Enter file name: ") handle = open (fname, 'r') count = dict () for line in handle: if line.startswith("From: "): address = line.split()[1] count[address]= count.get(address,0) +1 maxval = None maxkee = None for kee, val in count.items(): maxval = val maxkee = kee print address, val Hal On Wed, Aug 5, 2015 at 6:21 PM, Alan Gauld wrote: > On 05/08/15 23:58, Ltc Hotspot wrote: > > fname = raw_input("Enter file name: ") >> handle = open (fname, 'r') >> for line in handle: >> if line.startswith("From: "): >> address = line.split()[1] >> >> > So far so good. > > >> ## The program creates a Python dictionary that maps >> ## the sender's mail address to a count of the number >> ## of times they appear in the file. >> >> count = dict() >> > > But here you create a brand new dictionary. > Every time you go round the loop. > And it wipes out the old one. > You need to move that out of the loop. > > for wrd in address: >> > > address is a string. So wrd will be set to every > character in the string. I don;t think that's what > you want? > > count[wrd]= count.get(wrd,0) +1 >> >> ## After the dictionary is produced, the program reads >> ## through the dictionary using a maximum loop to >> ## find the greatest number of mail messages. >> >> maxval = none >> maxkee = none >> > > See my previous email. none should be None. > Case matters in Python. > > for kee, val in count.items(): >> if maxval == none or maxval > maxval = val >> maxkee = kee >> >> >> #items are printed >> >> print address >> > > Notice that address gets reset every time the loop reads > a new line so this will only print the last address. > But maybe that's what you wanted? > > --> Did I resolve the reset in the revised code? > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
The revised output reads: In [3]: %run assignment_9_4_9.py Enter file name: mbox-short.txt c...@iupui.edu 14 The desired output: c...@iupui.edu 5 Question: How do I trace the source of the count? Revised data code reads: fname = raw_input("Enter file name: ") handle = open (fname, 'r') count = dict () for line in handle: if line.startswith("From: "): address = line.split()[1] for wrd in address: count[wrd]= count.get(wrd,0) +1 maxval = None maxkee = None for kee, val in count.items(): maxval = val maxkee = kee print address, val On Wed, Aug 5, 2015 at 4:11 PM, Alan Gauld wrote: > On 05/08/15 15:15, Ltc Hotspot wrote: > > Raw data code reads: >> > > Being picky here but data and code are very different > things (in most languages at least) and what you have > below is definitely code not data. > > Meanwhile there are lots of issues in this code... > > fname = raw_input("Enter file name: ") >> handle = open (fname, 'r') >> text = handle.read() >> >> ## The program looks for 'From ' lines and takes the second >> ## word of those lines as the person who sent the mail. >> >> addresses = set() >> for addr in [ text.split()[2]('From ') >> if fromline >> > > The above looks like its supposed to be a list > comprehension embedded in a for loop. Putting too much > code in one line is usually a bad idea especially before > you have it working. > > Try separating out the formation of your list from the > for loop. Once you get the comprehension working correctly > then you can consider embedding it. > > As for the expression > > text.split()[2]('From ') > > Can you explain how you think that works? > Try it at the >>> prompt with text set to > a sample line of data. > > --> What command did you type to get the triple chevrons ? --> My python interpreter: iPython (py.2.7) > Try > > >>> text = .. # whatever your data looks like > >>> text.split() > > >>> text.split[2] > > >>> text.split()[2]('From ') > --> address data, review the latest revised code? > > The >>> prompt is one of your most powerful tools while > writing code, you should always have one ready to try > stuff out. You can answer a lot of questions that way. > > ## The program creates a Python dictionary that maps >> ## the sender's mail address to a count of the number >> ## of times they appear in the file. >> >> count = dict() >> for wrd in word: >> > > What is word? You don't define it anywhere? > > count[wrd]= count.get(wrd,0) +1 >> >> ## After the dictionary is produced, the program reads >> ## through the dictionary using a maximum loop to >> > >> --> imported address data, review revised code? > > > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Issue
Hi Mark, Address identifies the email address with the maximum number of sends: c...@iupui.edu. Secondly, we are missing a count on the number of messages sent by c...@iupui.edu, i.e., 5. Thirdly, maxval 'none' is not defined on line # 24 Questions: How do we define the value of none for the key maxval and retrieve a number count on the number of messages sent by c...@iupui.edu. NameError: Traceback (most recent call last) C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_5.py in () 22 ## find the greatest number of mail messages. 23 ---> 24 maxval = none 25 maxkee = none 26 for kee, val in count.items(): NameError: name 'none' is not defined In [52]: print address c...@iupui.edu Revised data: ## The program looks for 'From ' lines and takes the second ## word of those lines as the person who sent the mail. fname = raw_input("Enter file name: ") handle = open (fname, 'r') for line in handle: if line.startswith("From: "): address = line.split()[1] ## The program creates a Python dictionary that maps ## the sender's mail address to a count of the number ## of times they appear in the file. count = dict() for wrd in address: count[wrd]= count.get(wrd,0) +1 ## After the dictionary is produced, the program reads ## through the dictionary using a maximum loop to ## find the greatest number of mail messages. maxval = none maxkee = none for kee, val in count.items(): if maxval == none or maxval > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Dictionary Issue
Hi everyone: I want to write a python program that reads through the data file of mbox-short.txt.Mbox-short.txt, i.e., download is available at http://www.py4inf.com/code/mbox-short.txt. Secondly, I want for python to figure out who sent the greatest number of mail messages. The output should read: c...@iupui.edu 5 However, there is a traceback message: In [40]: %run 9_4_4.py File "C:\Users\vm\Desktop\apps\docs\Python\_9_4_4.py", line 19 count = dict() ^ SyntaxError: invalid syntax Raw data code reads: fname = raw_input("Enter file name: ") handle = open (fname, 'r') text = handle.read() ## The program looks for 'From ' lines and takes the second ## word of those lines as the person who sent the mail. addresses = set() for addr in [ text.split()[2]('From ') if fromline ## The program creates a Python dictionary that maps ## the sender's mail address to a count of the number ## of times they appear in the file. count = dict() for wrd in word: count[wrd]= count.get(wrd,0) +1 ## After the dictionary is produced, the program reads ## through the dictionary using a maximum loop to ## find the greatest number of mail messages. maxval = none maxkee = none for kee, val in count.items(): if maxval == none or maxval https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] String Attribute
Hi Alan, Question1: Why did the following strip function fail: line2 = line.strip (',') View instructions for 'str.strip([*chars*])¶ <https://docs.python.org/2.7/library/stdtypes.html?highlight=strip#str.strip>' which is available at https://docs.pythonorg/2.7/library/stdtypes.html?highlight=strip#str.strip Question2: How do I code a vertical column output Revised code: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) count = 0 addresses =[] for line in fh: if line.startswith('From'): line2 = line.strip () line3 = line2.split() line4 = line3[1] addresses.append(line4) count = count + 1 print addresses print "There were", count, "lines in the file with From as the first word" Produced output: ['stephen.marqu...@uct.ac.za', 'stephen.marqu...@uct.ac.za', ' lo...@media.berkeley.edu', 'lo...@media.berkeley.edu', 'zq...@umich.edu', ' zq...@umich.edu', 'rjl...@iupui.edu', 'rjl...@iupui.edu', 'zq...@umich.edu', 'zq...@umich.edu', 'rjl...@iupui.edu', 'rjl...@iupui.edu', 'c...@iupui.edu', 'c...@iupui.edu', 'c...@iupui.edu', 'c...@iupui.edu', 'gsil...@umich.edu', ' gsil...@umich.edu', 'gsil...@umich.edu', 'gsil...@umich.edu', ' zq...@umich.edu', 'zq...@umich.edu', 'gsil...@umich.edu', 'gsil...@umich.edu', 'wagne...@iupui.edu', 'wagne...@iupui.edu', 'zq...@umich.edu', ' zq...@umich.edu', 'antra...@caret.cam.ac.uk', 'antra...@caret.cam.ac.uk', ' gopal.ramasammyc...@gmail.com', 'gopal.ramasammyc...@gmail.com', ' david.horw...@uct.ac.za', 'david.horw...@uct.ac.za', ' david.horw...@uct.ac.za', 'david.horw...@uct.ac.za', ' david.horw...@uct.ac.za', 'david.horw...@uct.ac.za', ' david.horw...@uct.ac.za', 'david.horw...@uct.ac.za', ' stephen.marqu...@uct.ac.za', 'stephen.marqu...@uct.ac.za', ' lo...@media.berkeley.edu', 'lo...@media.berkeley.edu', ' lo...@media.berkeley.edu', 'lo...@media.berkeley.edu', ' r...@media.berkeley.edu', 'r...@media.berkeley.edu', 'c...@iupui.edu', ' c...@iupui.edu', 'c...@iupui.edu', 'c...@iupui.edu', 'c...@iupui.edu', ' c...@iupui.edu'] ← Mismatch There were 54 lines in the file with From as the first word Desired output: stephen.marqu...@uct.ac.za lo...@media.berkeley.edu zq...@umich.edu rjl...@iupui.edu zq...@umich.edu rjl...@iupui.edu c...@iupui.edu c...@iupui.edu gsil...@umich.edu gsil...@umich.edu zq...@umich.edu gsil...@umich.edu wagne...@iupui.edu zq...@umich.edu antra...@caret.cam.ac.uk gopal.ramasammyc...@gmail.com david.horw...@uct.ac.za david.horw...@uct.ac.za david.horw...@uct.ac.za david.horw...@uct.ac.za stephen.marqu...@uct.ac.za lo...@media.berkeley.edu lo...@media.berkeley.edu r...@media.berkeley.edu c...@iupui.edu c...@iupui.edu c...@iupui.edu There were 27 lines in the file with From as the first word Regards, Hal On Sun, Aug 2, 2015 at 1:18 AM, Alan Gauld wrote: > On 02/08/15 02:20, Ltc Hotspot wrote: > >> Hi Alan, >> >> I made a mistake and incorrectly assumed that differences between 54 lines >> of output and 27 lines of output is the result of removing duplicate email >> addresses, >> >> Apparently, this is not the case and I was wrong :( >> The solution to the problem is in the desired line output: >> >> stephen.marqu...@uct.ac.za >> lo...@media.berkeley.edu >> zq...@umich.edu >> rjl...@iupui.edu >> zq...@umich.edu >> rjl...@iupui.edu >> > ... > > OK, Only a couple of changes should see to that. > > Latest revised code: >> fname = raw_input("Enter file name: ") >> if len(fname) < 1 : fname = "mbox-short.txt" >> fh = open(fname) >> count = 0 >> addresses = set() >> > > change this to use a list > > addresses = [] > > for line in fh: >> if line.startswith('From'): >> line2 = line.strip() >> line3 = line2.split() >> line4 = line3[1] >> addresses.add(line4) >> > > and change this to use the list append() method > > addresses.append(line4) > > count = count + 1 >> print addresses >> print "There were", count, "lines in the file with From as the first word" >> > > I'm not quite sure where the 54/27 divergence comes from except that > I noticed Emille mention that there were lines beginning 'From:' > too. If that's the case then follow his advice and change the if > test to only check for 'From ' (with the space). > > That should be all you need. > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] String Attribute
Hi Emile, I made a mistake and incorrectly assumed that differences between 54 lines of output and 27 lines of output is the result of removing duplicate email addresses, i.e., gsil...@umich.edu gsil...@umich.edu, c...@iupui.edu, c...@iupui.edu Apparently, this is not the case and I was wrong :( The solution to the problem is in the desired line output: stephen.marqu...@uct.ac.za lo...@media.berkeley.edu zq...@umich.edu rjl...@iupui.edu zq...@umich.edu rjl...@iupui.edu c...@iupui.edu c...@iupui.edu gsil...@umich.edu gsil...@umich.edu zq...@umich.edu gsil...@umich.edu wagne...@iupui.edu zq...@umich.edu antra...@caret.cam.ac.uk gopal.ramasammyc...@gmail.com david.horw...@uct.ac.za david.horw...@uct.ac.za david.horw...@uct.ac.za david.horw...@uct.ac.za stephen.marqu...@uct.ac.za lo...@media.berkeley.edu lo...@media.berkeley.edu r...@media.berkeley.edu c...@iupui.edu c...@iupui.edu c...@iupui.edu There were 27 lines in the file with From as the first word Not in the output of a subset. Latest output: set(['stephen.marqu...@uct.ac.za', 'lo...@media.berkeley.edu', ' zq...@umich.edu', 'rjl...@iupui.edu', 'c...@iupui.edu', 'gsil...@umich.edu', 'wagne...@iupui.edu', 'antra...@caret.cam.ac.uk', ' gopal.ramasammyc...@gmail.com', 'david.horw...@uct.ac.za', ' r...@media.berkeley.edu']) ← Mismatch There were 54 lines in the file with From as the first word Latest revised code: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) count = 0 addresses = set() for line in fh: if line.startswith('From'): line2 = line.strip() line3 = line2.split() line4 = line3[1] addresses.add(line4) count = count + 1 print addresses print "There were", count, "lines in the file with From as the first word" Regards, Hal On Sat, Aug 1, 2015 at 5:45 PM, Emile van Sebille wrote: > On 8/1/2015 4:07 PM, Ltc Hotspot wrote: > >> Hi Alan, >> >> Question1: The output result is an address or line? >> > > It's a set actually. Ready to be further processed I imagine. Or to > print out line by line if desired. > > Question2: Why are there 54 lines as compared to 27 line in the desired >> output? >> > > Because there are 54 lines that start with 'From'. > > As I noted in looking at your source data, for each email there's a 'From > ' and a 'From:' -- you'd get the right answer checking only for > startswith('From ') > > Emile > > > > >> Here is the latest revised code: >> fname = raw_input("Enter file name: ") >> if len(fname) < 1 : fname = "mbox-short.txt" >> fh = open(fname) >> count = 0 >> addresses = set() >> for line in fh: >> if line.startswith('From'): >> line2 = line.strip() >> line3 = line2.split() >> line4 = line3[1] >> addresses.add(line4) >> count = count + 1 >> print addresses >> print "There were", count, "lines in the file with From as the first word" >> >> The output result: >> set(['stephen.marqu...@uct.ac.za', 'lo...@media.berkeley.edu', ' >> zq...@umich.edu', 'rjl...@iupui.edu', 'c...@iupui.edu', ' >> gsil...@umich.edu', >> 'wagne...@iupui.edu', 'antra...@caret.cam.ac.uk',' >> gopal.ramasammyc...@gmail.com', 'david.horw...@uct.ac.za', ' >> r...@media.berkeley.edu']) ← Mismatch >> There were 54 lines in the file with From as the first word >> >> >> The desired output result: >> stephen.marqu...@uct.ac.za >> lo...@media.berkeley.edu >> zq...@umich.edu >> rjl...@iupui.edu >> zq...@umich.edu >> rjl...@iupui.edu >> c...@iupui.edu >> c...@iupui.edu >> gsil...@umich.edu >> gsil...@umich.edu >> zq...@umich.edu >> gsil...@umich.edu >> wagne...@iupui.edu >> zq...@umich.edu >> antra...@caret.cam.ac.uk >> gopal.ramasammyc...@gmail.com >> david.horw...@uct.ac.za >> david.horw...@uct.ac.za >> david.horw...@uct.ac.za >> david.horw...@uct.ac.za >> stephen.marqu...@uct.ac.za >> lo...@media.berkeley.edu >> lo...@media.berkeley.edu >> r...@media.berkeley.edu >> c...@iupui.edu >> c...@iupui.edu >> c...@iupui.edu >> There were 27 lines in the file with From as the first word >> >> Regards, >> Hal >> >> >> >> >> >> >> >> >> >> On Sat, Aug
Re: [Tutor] String Attribute
Hi Alan, I made a mistake and incorrectly assumed that differences between 54 lines of output and 27 lines of output is the result of removing duplicate email addresses, i.e., gsil...@umich.edu gsil...@umich.edu, c...@iupui.edu, c...@iupui.edu Apparently, this is not the case and I was wrong :( The solution to the problem is in the desired line output: stephen.marqu...@uct.ac.za lo...@media.berkeley.edu zq...@umich.edu rjl...@iupui.edu zq...@umich.edu rjl...@iupui.edu c...@iupui.edu c...@iupui.edu gsil...@umich.edu gsil...@umich.edu zq...@umich.edu gsil...@umich.edu wagne...@iupui.edu zq...@umich.edu antra...@caret.cam.ac.uk gopal.ramasammyc...@gmail.com david.horw...@uct.ac.za david.horw...@uct.ac.za david.horw...@uct.ac.za david.horw...@uct.ac.za stephen.marqu...@uct.ac.za lo...@media.berkeley.edu lo...@media.berkeley.edu r...@media.berkeley.edu c...@iupui.edu c...@iupui.edu c...@iupui.edu There were 27 lines in the file with From as the first word Not in the output of a subset. Latest output: set(['stephen.marqu...@uct.ac.za', 'lo...@media.berkeley.edu', ' zq...@umich.edu', 'rjl...@iupui.edu', 'c...@iupui.edu', 'gsil...@umich.edu', 'wagne...@iupui.edu', 'antra...@caret.cam.ac.uk', ' gopal.ramasammyc...@gmail.com', 'david.horw...@uct.ac.za', ' r...@media.berkeley.edu']) ← Mismatch There were 54 lines in the file with From as the first word Latest revised code: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) count = 0 addresses = set() for line in fh: if line.startswith('From'): line2 = line.strip() line3 = line2.split() line4 = line3[1] addresses.add(line4) count = count + 1 print addresses print "There were", count, "lines in the file with From as the first word" Regards, Hal On Sat, Aug 1, 2015 at 5:44 PM, Alan Gauld wrote: > On 02/08/15 00:07, Ltc Hotspot wrote: > >> Question1: The output result is an address or line? >> > > Its your assignment,. you tell me. > But from your previous mails I'm assuming you want addresses? > > Question2: Why are there 54 lines as compared to 27 line in the desired >> output? >> > > Because the set removes duplicates? So presumably there were 27 > duplicates? (Which is a suspicious coincidence!) > > fname = raw_input("Enter file name: ") >> if len(fname) < 1 : fname = "mbox-short.txt" >> fh = open(fname) >> count = 0 >> addresses = set() >> for line in fh: >> if line.startswith('From'): >> line2 = line.strip() >> line3 = line2.split() >> line4 = line3[1] >> addresses.add(line4) >> count = count + 1 >> print addresses >> print "There were", count, "lines in the file with From as the first word" >> > > That looks right in that it does what I think you want it to do. > > The output result: >> set(['stephen.marqu...@uct.ac.za', 'lo...@media.berkeley.edu', ' >> zq...@umich.edu', 'rjl...@iupui.edu', 'c...@iupui.edu', ' >> gsil...@umich.edu', >> 'wagne...@iupui.edu', 'antra...@caret.cam.ac.uk',' >> gopal.ramasammyc...@gmail.com', 'david.horw...@uct.ac.za', ' >> r...@media.berkeley.edu']) ← Mismatch >> > > That is the set of unique addresses, correct? > > There were 54 lines in the file with From as the first word >> > > And that seems to be the number of lines in the original file > starting with From. Can you check manually if that is correct? > > The desired output result: >> stephen.marqu...@uct.ac.za >> lo...@media.berkeley.edu >> zq...@umich.edu >> rjl...@iupui.edu >> zq...@umich.edu >> rjl...@iupui.edu >> > ... > > Now I'm confused again. This has duplicates but you said you > did not want duplicates? Which is it? > > ... > >> c...@iupui.edu >> c...@iupui.edu >> There were 27 lines in the file with From as the first word >> > > And this is reporting the number of lines in the output > rather than the file (I think). Which do you want? > > Its easy enough to change the code to govre the output > you demonstrate, but that's not what you originally asked > for. So just make up your mind exactly what it is you want > out and we can make it work for you. > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] String Attribute
Hi Alan, Question1: The output result is an address or line? Question2: Why are there 54 lines as compared to 27 line in the desired output? Here is the latest revised code: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) count = 0 addresses = set() for line in fh: if line.startswith('From'): line2 = line.strip() line3 = line2.split() line4 = line3[1] addresses.add(line4) count = count + 1 print addresses print "There were", count, "lines in the file with From as the first word" The output result: set(['stephen.marqu...@uct.ac.za', 'lo...@media.berkeley.edu', ' zq...@umich.edu', 'rjl...@iupui.edu', 'c...@iupui.edu', 'gsil...@umich.edu', 'wagne...@iupui.edu', 'antra...@caret.cam.ac.uk', ' gopal.ramasammyc...@gmail.com', 'david.horw...@uct.ac.za', ' r...@media.berkeley.edu']) ← Mismatch There were 54 lines in the file with From as the first word The desired output result: stephen.marqu...@uct.ac.za lo...@media.berkeley.edu zq...@umich.edu rjl...@iupui.edu zq...@umich.edu rjl...@iupui.edu c...@iupui.edu c...@iupui.edu gsil...@umich.edu gsil...@umich.edu zq...@umich.edu gsil...@umich.edu wagne...@iupui.edu zq...@umich.edu antra...@caret.cam.ac.uk gopal.ramasammyc...@gmail.com david.horw...@uct.ac.za david.horw...@uct.ac.za david.horw...@uct.ac.za david.horw...@uct.ac.za stephen.marqu...@uct.ac.za lo...@media.berkeley.edu lo...@media.berkeley.edu r...@media.berkeley.edu c...@iupui.edu c...@iupui.edu c...@iupui.edu There were 27 lines in the file with From as the first word Regards, Hal On Sat, Aug 1, 2015 at 1:40 PM, Alan Gauld wrote: > On 01/08/15 19:48, Ltc Hotspot wrote: > >> There is an indent message in the revised code. >> Question: Where should I indent the code line for the loop? >> > > Do you understand the role of indentation in Python? > Everything in the indented block is part of the structure, > so you need to indent everything that should be executed > as part of the logical block. > > fname = raw_input("Enter file name: ") >> if len(fname) < 1 : fname = "mbox-short.txt" >> fh = open(fname) >> count = 0 >> addresses = set() >> for line in fh: >> if line.startswith('From'): >> line2 = line.strip() >> line3 = line2.split() >> line4 = line3[1] >> addresses.add(line) >> count = count + 1 >> > > Everything after the if line should be indented an extra level > because you only want to do those things if the line > startswith From. > > And note that, as I suspected, you are adding the whole line > to the set when you should only be adding the address. > (ie line4). This would be more obvious if you had > used meaningful variable names such as: > > strippedLine = line.strip() > tokens = strippedLine.split() > addr = tokens[1] > addresses.add(addr) > > PS. > Could you please delete the extra lines from your messages. > Some people pay by the byte and don't want to receive kilobytes > of stuff they have already seen multiple times. > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] String Attribute
Hi Emile, Question: What is the source of the line 7 syntax: mbox.split? Here is a copy of the Traceback message: NameError Traceback (most recent call last) C:\Users\vm\Desktop\apps\docs\Python\8_5_v_26.py in () 5 addresses = set() 6 for addr in [ fromline.split()[0] > 7 for fromline in mbox.split('From ') 8 if fromline ]: 9 count = count + 1 NameError: name 'mbox' is not defined Revised code: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) count = 0 addresses = set() for addr in [ fromline.split()[0] for fromline in mbox.split('From ') if fromline ]: count = count + 1 print addr print "There were", count, "lines in the file with From as the first word" Regards, Hal On Sat, Aug 1, 2015 at 2:18 PM, Emile van Sebille wrote: > On 8/1/2015 12:00 PM, Ltc Hotspot wrote: > >> Hi Everyone: >> >> >> Let me repost the question: >> >> You will parse the From line using split() and print out the second word >> in >> the line (i.e. the entire address of the person who sent the message). >> Then >> print out a count at the end. >> >> *Hint:* make sure not to include the lines that start with 'From:'. >> >> You can download the sample data at >> http://www.pythonlearn.com/code/mbox-short.txt >> > > Cool - thanks. That's an mbox file. > > Can you explain the apparent dichotomy of the question directing you to > 'parse the from line' and the hint? I'm going to guess they mean that > you're not to print that line in the output? Aah, I see -- there're two > different lines that start From -- both with and without a trailing colon. > So then, we can split on 'From ' and recognizing the split eats the > split-on portion > > >>> '1234567'.split('4') > ['123', '567'] > > ... and leaves an empty entry when splitting on the first characters of > the line > > >>> '1234567'.split('1') > ['', '234567'] > > ... we get to: > > for addr in [ fromline.split()[0] > for fromline in mbox.split('From ') > if fromline ]: > print addr > > stephen.marqu...@uct.ac.za > lo...@media.berkeley.edu > zq...@umich.edu > rjl...@iupui.edu > zq...@umich.edu > rjl...@iupui.edu > c...@iupui.edu > gsil...@umich.edu > gsil...@umich.edu > zq...@umich.edu > gsil...@umich.edu > wagne...@iupui.edu > zq...@umich.edu > antra...@caret.cam.ac.uk > gopal.ramasammyc...@gmail.com > david.horw...@uct.ac.za > david.horw...@uct.ac.za > stephen.marqu...@uct.ac.za > lo...@media.berkeley.edu > lo...@media.berkeley.edu > r...@media.berkeley.edu > c...@iupui.edu > c...@iupui.edu > c...@iupui.edu > >>> > > > > Emile > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] String Attribute
Hi Everyone: Let me repost the question: You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person who sent the message). Then print out a count at the end. *Hint:* make sure not to include the lines that start with 'From:'. You can download the sample data at http://www.pythonlearn.com/code/mbox-short.txt Regards, Hal On Sat, Aug 1, 2015 at 9:18 AM, Emile van Sebille wrote: > Hi Hal, > > Seeing now that the output is only extracted from six address blocks, can > you paste in the full contents of the file mbox-short.txt? (or the first > 5-10 address sets if this is only representative) I think if we have a > better understanding of the structure of the content you're parsing it'll > help us identify what the program will need to be prepared to handle. > > Emile > > > > On 7/31/2015 5:26 PM, Ltc Hotspot wrote: > >> Hi Mark, >> >> Desired output on execution of the script: >> >> stephen.marqu...@uct.ac.za >> lo...@media.berkeley.edu >> zq...@umich.edu >> rjl...@iupui.edu >> zq...@umich.edu >> rjl...@iupui.edu >> >> >> >> [...] >> >> Regards, >> Hal >> >> On Fri, Jul 31, 2015 at 5:21 PM, Ltc Hotspot >> wrote: >> >> Mark: >>> Is this any better, message sent from GMail? >>> Regards, >>> Hal >>> >>> On Fri, Jul 31, 2015 at 5:02 PM, Mark Lawrence >>> wrote: >>> >>> On 31/07/2015 19:57, ltc.hots...@gmail.com wrote: >>>> >>>> I believe that this is the third time that you've been asked to do >>>> something about the amount of whitespace that you're sending to this >>>> list. >>>> >>>> -- >>>> My fellow Pythonistas, ask not what our language can do for you, ask >>>> what you can do for our language. >>>> >>>> Mark Lawrence >>>> >>>> ___ >>>> Tutor maillist - Tutor@python.org >>>> To unsubscribe or change subscription options: >>>> https://mail.python.org/mailman/listinfo/tutor >>>> >>>> >>> >>> ___ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor >> >> > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] String Attribute
Hi Emile, I just noticed there are duplicates Here is the complete line output as requested, below: stephen.marqu...@uct.ac.za lo...@media.berkeley.edu zq...@umich.edu rjl...@iupui.edu zq...@umich.edu rjl...@iupui.edu c...@iupui.edu c...@iupui.edu gsil...@umich.edu gsil...@umich.edu zq...@umich.edu gsil...@umich.edu wagne...@iupui.edu zq...@umich.edu antra...@caret.cam.ac.uk gopal.ramasammyc...@gmail.com david.horw...@uct.ac.za david.horw...@uct.ac.za david.horw...@uct.ac.za david.horw...@uct.ac.za stephen.marqu...@uct.ac.za lo...@media.berkeley.edu lo...@media.berkeley.edu r...@media.berkeley.edu c...@iupui.edu c...@iupui.edu c...@iupui.edu There were 27 lines in the file with From as the first word Hal On Sat, Aug 1, 2015 at 9:18 AM, Emile van Sebille wrote: > Hi Hal, > > Seeing now that the output is only extracted from six address blocks, can > you paste in the full contents of the file mbox-short.txt? (or the first > 5-10 address sets if this is only representative) I think if we have a > better understanding of the structure of the content you're parsing it'll > help us identify what the program will need to be prepared to handle. > > Emile > > > > On 7/31/2015 5:26 PM, Ltc Hotspot wrote: > >> Hi Mark, >> >> Desired output on execution of the script: >> >> stephen.marqu...@uct.ac.za >> lo...@media.berkeley.edu >> zq...@umich.edu >> rjl...@iupui.edu >> zq...@umich.edu >> rjl...@iupui.edu >> >> >> >> [...] >> >> Regards, >> Hal >> >> On Fri, Jul 31, 2015 at 5:21 PM, Ltc Hotspot >> wrote: >> >> Mark: >>> Is this any better, message sent from GMail? >>> Regards, >>> Hal >>> >>> On Fri, Jul 31, 2015 at 5:02 PM, Mark Lawrence >>> wrote: >>> >>> On 31/07/2015 19:57, ltc.hots...@gmail.com wrote: >>>> >>>> I believe that this is the third time that you've been asked to do >>>> something about the amount of whitespace that you're sending to this >>>> list. >>>> >>>> -- >>>> My fellow Pythonistas, ask not what our language can do for you, ask >>>> what you can do for our language. >>>> >>>> Mark Lawrence >>>> >>>> ___ >>>> Tutor maillist - Tutor@python.org >>>> To unsubscribe or change subscription options: >>>> https://mail.python.org/mailman/listinfo/tutor >>>> >>>> >>> >>> ___ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor >> >> > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] String Attribute
Hi Alan, There is an indent message in the revised code. Question: Where should I indent the code line for the loop? View the revised codes with loop indents, below: --->Revised Code v.2 wo/indent from lines 8-12: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) count = 0 addresses = set() for line in fh: if line.startswith('From'): line2 = line.strip() line3 = line2.split() line4 = line3[1] addresses.add(line) count = count + 1 print "There were", count, "lines in the file with From as the first word" print addresses ---> Message output reads: In [62]: %run _8_5_v_25.py File "C:\Users\vm\Desktop\apps\docs\Python\_8_5_v_25.py", line 8 line2 = line.strip() ^ IndentationError: expected an indented block --->Revised Code v.3 w/indent from lines 8-12: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) count = 0 addresses = set() for line in fh: if line.startswith('From'): line2 = line.strip() line3 = line2.split() line4 = line3[1] addresses.add(line) count = count + 1 print "There were", count, "lines in the file with From as the first word" print addresses ---> Message output reads: ...pi/component/src/java/org/sakaiproject/component/util/RecordWriter.java\n', 'Dat e: 2008-01-04 11:09:12 -0500 (Fri, 04 Jan 2008)\n', '\t 4 Jan 2008 11:12:30 -050 0\n', '\tby nakamura.uits.iupui.edu (8.12.11.20060308/8.12.11/Submit) id m03M5Ea 7005273\n', 'New Revision: 39755\n', 'X-DSPAM-Processed: Thu Jan 3 16:23:48 200 8\n', 'Details: http://source.sakaiproject.org/viewsvn/?view=rev&rev=39754\n', ' \t Fri, 04 Jan 2008 11:35:08 -0500\n', '\tfor < sou...@collab.sakaiproject.org>; Fri, 4 Jan 2008 04:05:54 -0500\n', 'Received: from carrie.mr.itd.umich.edu (carr ie.mr.itd.umich.edu [141.211.93.152])\n', 'Message-ID: <200801042044.m04Kiem3007 8...@nakamura.uits.iupui.edu>\n', '\tfor ; Fri, 4 Jan 2008 16:36:37 + (GMT)\n', '\t Fri, 04 Jan 2008 15:03:18 -0500\n', '\tF ri, 4 Jan 2008 16:11:31 + (GMT)\n', ' by paploo.uhi.ac.uk (JAMES S MTP Server 2.1.3) with SMTP ID 960\n', 'From lo...@media.berkeley.edu Fri Jan 4 18:10:48 2008\n', ' Thu, 3 Jan 2008 22:06:34 + (GMT)\n', '\tfor so u...@collab.sakaiproject.org; Fri, 4 Jan 2008 10:15:57 -0500\n', 'Received: from eyewitness.mr.itd.umich.edu (eyewitness.mr.itd.umich.edu [141.211.93.142])\n', 'Subject: [sakai] svn commit: r39743 - gradebook/branches/oncourse_2-4-2/app/ui/ src/java/org/sakaiproject/tool/gradebook/ui\n', 'Date: 2008-01-04 10:15:54 -0500 (Fri, 04 Jan 2008)\n', 'New Revision: 39761\n', '\tBY salemslot.mr.itd.umich.ed u ID 477DF74E.49493.30415 ; \n', 'X-DSPAM-Processed: Sat Jan 5 09:14:16 2008\n' , '\tfor ; Fri, 4 Jan 2008 21:10:14 + (GMT) \n', '\tby paploo.uhi.ac.uk (Postfix) with ESMTP id 88598BA5B6;\n', 'X-DSPAM-Pro cessed: Fri Jan 4 04:07:34 2008\n', 'r39558 | h...@iupui.edu | 2007-12-20 15:25: 38 -0500 (Thu, 20 Dec 2007) | 3 lines\n', 'From gsil...@umich.edu Fri Jan 4 11: 10:22 2008\n', '\tby nakamura.uits.iupui.edu (8.12.11.20060308/8.12.11) with ESM TP id m04N8vHG008127\n', '\tSat, 5 Jan 2008 14:10:05 + (GMT)\n', '\tby naka mura.uits.iupui.edu (8.12.11.20060308/8.12.11/Submit) id m049W2i5006493\n', '\tT hu, 3 Jan 2008 22:06:57 + (GMT)\n', ' Fri, 4 Jan 2008 19:46:50 +00 00 (GMT)\n', 'Message-ID: < 200801041609.m04g9eux007...@nakamura.uits.iupui.edu>\ n', 'Subject: [sakai] svn commit: r39756 - in component/branches/SAK-12166/compo nent-api/component/src/java/org/sakaiproject/component: impl impl/spring/support impl/spring/support/dynamic impl/support util\n', 'site/trunk/site-tool/tool/sr c/bundle/admin.properties\n', 'Author: gopal.ramasammyc...@gmail.com\n', 'From d avid.horw...@uct.ac.za Fri Jan 4 04:33:44 2008\n', '\tby nakamura.uits.iupui.ed u (8.12.11.20060308/8.12.11) with ESMTP id m04E3pQS006928\n', '\tfor source@coll ab.sakaiproject.org; Fri, 4 Jan 2008 16:09:02 -0500\n', 'X-DSPAM-Processed: Fri Jan 4 09:05:31 2008\n', '\t 4 Jan 2008 16:10:33 -0500\n', '\tfor source@collab. sakaiproject.org; Fri, 4 Jan 2008 11:09:14 -0500\n', 'merge fix to SAK-9996 into 2-5-x branch: svn merge -r 39687:39688 https://source.sakaiproject.org/svn/site -manage/trunk/\n', 'Subject: [sakai] svn commit: r39751 - in podcasts/branches/s akai_2-5-x/podcasts-app/src/webapp: css images podcasts\n', 'Subject: [sakai] sv n commit: r39757 - in assignment/trunk: assignment-impl/impl/src/java/org/sakaip roject/assignment/impl assignment-tool/tool/src/webapp/vm/assignment\n', 'From w agne...@iupui.edu Fri Jan 4 10:38:42 2008\n', 'Date: 2008-01-03 17:16:39 -0500 (Thu, 03 Jan 2008)\n', ' by paploo.uhi.ac.uk (JAMES SMTP Server 2.1.3) with SMTP ID 906\n', 'U podcasts/podcasts-app/src/webapp/podcasts/podOptions. jsp\n', 'svn merge -c 35014 https://source.sakaiproject.org/svn/gradebook/trunk\ n', 'Received: from galaxyquest.mr.itd.umich.edu ( gala
Re: [Tutor] String Attribute
Mark: Is this any better, message sent from GMail? Regards, Hal On Fri, Jul 31, 2015 at 5:02 PM, Mark Lawrence wrote: > On 31/07/2015 19:57, ltc.hots...@gmail.com wrote: > > I believe that this is the third time that you've been asked to do > something about the amount of whitespace that you're sending to this list. > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] String Attribute
Hi Mark, Desired output on execution of the script: stephen.marqu...@uct.ac.za lo...@media.berkeley.edu zq...@umich.edu rjl...@iupui.edu zq...@umich.edu rjl...@iupui.edu [...] Regards, Hal On Fri, Jul 31, 2015 at 5:21 PM, Ltc Hotspot wrote: > Mark: > Is this any better, message sent from GMail? > Regards, > Hal > > On Fri, Jul 31, 2015 at 5:02 PM, Mark Lawrence > wrote: > >> On 31/07/2015 19:57, ltc.hots...@gmail.com wrote: >> >> I believe that this is the third time that you've been asked to do >> something about the amount of whitespace that you're sending to this list. >> >> -- >> My fellow Pythonistas, ask not what our language can do for you, ask >> what you can do for our language. >> >> Mark Lawrence >> >> ___ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor >> > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor