Re: python programming help
On Mon, Dec 9, 2013 at 4:10 PM, ru...@yahoo.com wrote: We all use buggy software every day. *Every* piece of non-trival software is buggy -- you already know that. So you are saying that bugs that annoy *you* are ones that *others* should change their practice to join your boycott to fix. The ones that have interoperability problems are the ones that need to be fixed. When a MUD client uses CP-1252 instead of either Latin-1 or UTF-8, that's a fault in it. (Confession: My own RosMud has that exact problem, because of what it uses under the covers for screen display. But it's being retired in favour of Gypsum, which supports full Unicode and defaults to UTF-8 transport.) You sound like some Unix hard-asses of the 1990's who, by god, weren't going pollute their software with any kind of MS Windows compatibility. No supporting a broken OS for them. They would keep the software pure and Unix-only and force Microsoft to fix their broken OS. Well, most of that software and those programmers have been eliminated by Darwinian selection, and today cross-platform (or Windows only) software is the norm. And there were Microsoft people in the same era who, by Bill, weren't going to pollute their software with any kind of standards compatibility. Let's look at just one product, Internet Explorer: IE6: Microsoft enjoys a near monopoly and uses this to encourage people to use IE-only features Myriad intranet sites get set up that won't work properly on any other browser. IE7: Other browsers now actually have some market-share, and people are agitating for IE to match them in behaviour. Oh dear. Guess we'd better add tabbed browsing, everyone else has it... the monopoly isn't enough to maintain itself on its own. IE8: Actually, it looks like standards compliance is becoming important. But so is compatibility with IE6. What a pain, what a pain. IE9 and IE10: The market shift to other browsers and thus the pressure shift to standards compliance continues. Unfortunately, it's just not possible to maintain IE6 compatibility, so lots of corporates have to keep XP and IE6 for their daily use. (I was in a Subway buying a sandwich a few weeks ago, and the system was having trouble. Guy was on the phone to the US trying to get it sorted out. Everything was in IE6. I pity them.) Windows-only is hardly the norm. There's at least as much software that's Mac-only or Linux-only as Windows-only. And far far more that's cross-platform or at least multi-platform. The most important thing is interoperability - sometimes that means stuff like Samba (specifically written to talk to a foreign system), but more often it means coding to the pre-written standards. I can write all sorts of TELNET servers and clients, and I can be confident that they'll work nicely with other people's clients and servers, and that they'll understand each other when they say IAC DO NAWS or IAC SB TERMTYPE IS Gypsum IAC SE. If one of them is buggy, it must be fixed, or it must not be used. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 09/12/2013 05:07, ru...@yahoo.com wrote: On 12/08/2013 05:27 PM, Mark Lawrence wrote: On 09/12/2013 00:08, ru...@yahoo.com wrote: On 12/08/2013 12:17 PM, Chris Angelico wrote: On Mon, Dec 9, 2013 at 6:06 AM, rafaella...@gmail.com wrote:[...] [...] To the OP, please ignore the above, it's sheer, unadulterated rubbish. Nobody has ever been bullied into doing anything. People have however been asked repeatedly to either A) use the link referenced above to avoid sending double spaced crap here from the inferior google groups product or B) use an alternative technology that doesn't send double spaced crap. Mark, I appreciate your calm and reasonable requests for people to checkout the page you gave a link to, that's why I repeated your advice. It is also why I responded to Chris and not to you. However it does not change the fact that people here have responded in rather extreme way to GG posts including calling GG users twits and claiming GG posts damage their eyesight, as well as repeatedly denying the obvious fact that GG is much easier to use for many than to subscribe to a usenet provider or to a mailing list. One frequently sees words like crap, slimy, rubbish etc to describe GG posts which is pretty intimating to people who just want some help with a python question using a tool they already know how to use and have had no complaints about in other places. Well you can ask iMath, amongst others, not to send double spaced google nonsense. They've been asked repeatedly, politely, but apparently have no consideration at all for people who have no interest in seeing this ill formed dross spread throughout web land. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 08/12/2013 18:14, rafaella...@gmail.com wrote: sorry but i'm new to python ;p 1. it has to be in a form of a function called people and 2. how this code takes in an age and returns the names? it has to be in the form of a function called people, that made me laugh. Too bad he got an answer, even worse he doesn't know what to do with it. -- - Christopher Welborn cjwelb...@live.com http://welbornprod.com -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 12/09/2013 12:57 AM, Chris Angelico wrote: On Mon, Dec 9, 2013 at 4:07 PM, ru...@yahoo.com wrote: However it does not change the fact that people here have responded in rather extreme way to GG posts including calling GG users twits and claiming GG posts damage their eyesight, as well as repeatedly denying the obvious fact that GG is much easier to use for many than to subscribe to a usenet provider or to a mailing list. One frequently sees words like crap, slimy, rubbish etc to describe GG posts which is pretty intimating to people who just want some help with a python question using a tool they already know how to use and have had no complaints about in other places. Please note though that there is a difference between describing the users as twits and describing the posts as slimy. Suppose you write a letter (the sort that goes on a slab of dead tree) and, instead of placing it in an envelope and putting a stamp on it, you hand it to the Arac News Insertion Device[1] to do the enveloping for you. He does a reasonable job of it, but he uses cobwebs instead of paper for the envelope. Sure, it's still readable... but your readers now have to rub off a whole lot of cobwebs before they can read what you said. That makes your post distasteful, without it being at all your fault - other than choosing to use Arac's service. That's how I see Google Groups posts. Someone's gone looking for help about Python and has found that. It's not their fault that they don't know about alternatives; so I point out the alternatives. Nevertheless, that kind of strong judgmental language is very likely to be taken as reflecting at least in part on the poster, especially when the person is from a different culture or unsure of their English skills. And if you truly just want the poster to be apprised of alternatives, I sure you'll grant me the right to point out the alternative you consistently leave out: the option to continue to use Google Groups. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 12/09/2013 01:15 AM, Chris Angelico wrote: On Mon, Dec 9, 2013 at 4:10 PM, ru...@yahoo.com wrote: We all use buggy software every day. *Every* piece of non-trival software is buggy -- you already know that. So you are saying that bugs that annoy *you* are ones that *others* should change their practice to join your boycott to fix. The ones that have interoperability problems are the ones that need to be fixed. [...snip stuff about mud clients...]) Huh? You declare a universal truth that interoperability bugs need to be fixed but other bugs don't? A bug that give wrong financial results is less important than mojibake sometimes displayed on a web page? A bug that cause a connection failure is more important than a bug that silently corrupts saved data? Congratulations, you just won this week's jmf prize (with apologies to jmf.) You sound like some Unix hard-asses of the 1990's who, by god, weren't going pollute their software with any kind of MS Windows compatibility. No supporting a broken OS for them. They would keep the software pure and Unix-only and force Microsoft to fix their broken OS. Well, most of that software and those programmers have been eliminated by Darwinian selection, and today cross-platform (or Windows only) software is the norm. And there were Microsoft people in the same era who, by Bill, weren't going to pollute their software with any kind of standards compatibility. I don't think that is analogous in the same way. Unlike most people here, who seem to be driven by an personal (and emotional judging from the language used) distaste for GG posts, and a similar emotional response against MS by the Unix elitists in the 1990s, Microsoft's alleged embrace, extend, extinguish policy was/is (I'm pretty sure) carefully thought out and based on rational analysis. Let's look at just one product, Internet Explorer: [...snip MSIE version history claiming decreasing market share and increasing standards compliance...] Not a convincing example at all. First its not even clear that what the factors driving such change are; open standards are only one factor. Not should you assume that all open standards are equally important and that MS' (or Google's) response will be the same to all standards across all product lines. Two, although you present MSIE as changing in response to demands to match [other browsers] in behaviour you leave out demands on those other browsers (and standards) to adopt features of MSIE. A unfortunate example might be the W3C consideration (maybe approved by now?) of DRM. It is not a one-way street and standards are not cast in stone. Finally it is an absurd stretch to take pressure applied by large corporate customers to MS to adopt more open standards as comparable to a handful of people in a non-major programming language mailing list refusing to read posts from GG. I am not saying that you shouldn't continue to promote your boycott against Google, just that you shouldn't be surprised or get angry when the response of some people is similar to my response towards some friends who want me to stop eating meat to fight factory farming. Windows-only is hardly the norm. There's at least as much software that's Mac-only or Linux-only as Windows-only. As much Mac-only software as Windows-only? Possibly, but I doubt it although I acknowledge things are moving in that direction. As much Linux-only software as Windows-only? You must be smoking crack. :-) And far far more that's cross-platform or at least multi-platform. The most important thing is interoperability - sometimes that means stuff like Samba (specifically written to talk to a foreign system), but more often it means coding to the pre-written standards. I can write all sorts of TELNET servers and clients, and I can be confident that they'll work nicely with other people's clients and servers, and that they'll understand each other when they say IAC DO NAWS or IAC SB TERMTYPE IS Gypsum IAC SE. If one of them is buggy, it must be fixed, or it must not be used. TELNET? Does any one still use that except perhaps on secure, controlled legacy intranets? We nuked that and other protocols of it's era (FTP etc) for ssh and other (more) secure protocols ages ago. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 12/08/2013 10:20 PM, rusi wrote: On Monday, December 9, 2013 10:37:38 AM UTC+5:30, ru...@yahoo.com wrote: [...] However it does not change the fact that people here have responded in rather extreme way to GG posts including calling GG users twits and claiming GG posts damage their eyesight, as well as repeatedly denying the obvious fact that GG is much easier to use for many than to subscribe to a usenet provider or to a mailing list. One frequently sees words like crap, slimy, rubbish etc to describe GG posts which is pretty intimating to people who just want some help with a python question using a tool they already know how to use and have had no complaints about in other places. About the last -- no complaints about (that) in other places -- Ive recently seen that on the html/stylesheets/javascript lists (not sure which) there are also annoyed complaints about GG. I am sure that there are other usenet groups that get Google Groups posts and find them irritating for the same reason that some here do. But usenet is nearly all the way in death's door (at least text groups; binaries groups may be still be growing.) The only usenet groups I know of with any vitality left at all are ones like the Python list that are backed by an active maillist. (Curiously, it seems to me the dramatic decline in usenet occurred around 2008-2010, about the same time as the dramatic rise of social networking sites.) As for pure mailing lists, I am not sure how many are gatewayed to GG -- I subscribe to several because they are not available through GG -- so they don't get GG posts. There are however a large number of mailing lists that are hosted solely on GG by various projects. It is participants in these lists that I was thinking of by other places. Such people are likely very surprised by the hostility they meet when they simply change to the python list (or one of the other usenet-gatewayed groups) which looks very much like any another GG group from their perspective. For all the GG hostility on the python list, many python project lists are hosted on GG (Sqlalchemy, Webpy, GvR's own Tulip project, etc) About the rest -- when people get annoyed they say and do things they would not otherwise do. Humans have big cortexes so that they don't need to act out based on their feelings of the moment -- like a dog humping the boy next door or trying to bite off the arm of the postal delivery person. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On Tue, Dec 10, 2013 at 4:10 PM, ru...@yahoo.com wrote: Windows-only is hardly the norm. There's at least as much software that's Mac-only or Linux-only as Windows-only. As much Mac-only software as Windows-only? Possibly, but I doubt it although I acknowledge things are moving in that direction. As much Linux-only software as Windows-only? You must be smoking crack. :-) Or just using Linux. Stuff that runs only on Linux is actually a bit of a problem at times - coders making assumptions about the environment that aren't guaranteed, and merely happen to be correct on all current versions of the Linux kernel. And far far more that's cross-platform or at least multi-platform. The most important thing is interoperability - sometimes that means stuff like Samba (specifically written to talk to a foreign system), but more often it means coding to the pre-written standards. I can write all sorts of TELNET servers and clients, and I can be confident that they'll work nicely with other people's clients and servers, and that they'll understand each other when they say IAC DO NAWS or IAC SB TERMTYPE IS Gypsum IAC SE. If one of them is buggy, it must be fixed, or it must not be used. TELNET? Does any one still use that except perhaps on secure, controlled legacy intranets? We nuked that and other protocols of it's era (FTP etc) for ssh and other (more) secure protocols ages ago. TELNET protocol is the fundamental basis of MUDs. Doesn't mean there's a TELNET server at the other end. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
Le 08.12.2013 18:59, rafaella...@gmail.com a écrit : i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help ageDict = { 'john':42, 'jane':36, 'paul':42 } peopleWithAge = lambda age: [ name for name in ageDict if ageDict[name]==age] -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On Sunday, December 8, 2013 6:07:47 PM UTC, YBM wrote: Le 08.12.2013 18:59, rafaella...@gmail.com a �crit : i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help ageDict = { 'john':42, 'jane':36, 'paul':42 } peopleWithAge = lambda age: [ name for name in ageDict if ageDict[name]==age] sorry but i'm new to python ;p 1. it has to be in a form of a function called people and 2. how this code takes in an age and returns the names? -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
Le 08.12.2013 19:14, rafaella...@gmail.com a écrit : On Sunday, December 8, 2013 6:07:47 PM UTC, YBM wrote: Le 08.12.2013 18:59, rafaella...@gmail.com a �crit : i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help ageDict = { 'john':42, 'jane':36, 'paul':42 } peopleWithAge = lambda age: [ name for name in ageDict if ageDict[name]==age] sorry but i'm new to python ;p 1. it has to be in a form of a function called people and 2. how this code takes in an age and returns the names? ageDict = { 'john':42, 'jane':36, 'paul':42 } people = lambda age: [ name for name in ageDict if ... ageDict[name]==age] people(42) ['paul', 'john'] -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
In article 264c1144-5d04-4ad0-aa32-f4e6770d2...@googlegroups.com, rafaella...@gmail.com wrote: i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help Homework problem? In any case, this is a classic example of a real-life problem, and thus worth exploring. The general case is you have a many-to-one mapping and you want to find the inverse one-to-many map. I'm assuming when you say, a dictionary with names and ages for each name, you mean the names are the keys and the ages are the values. That would also imply that the names are unique; that's a poor assumption for real data sets, but let's assume that's the case here. So, we're going to take your original dictionary and create a new one where the keys are the ages, and the values are lists of names. That's pretty straight forward. Here's the most brute-force way (which is a good place to start): d2 = {} for name, age in d1.items(): if age not in d2: d2[age] = [] d2[age].append(name) Work through that code in your head to convince yourself that you understand what's going on. This is such a common pattern, Python has a neat tool to make this easier. It's called a defaultdict. Bascially, this is a dictionary which has built into it the if key doesn't exist, initialize something logic. It works like this: from collections import defaultdict d2 = defaultdict(list) for name, age in d1.items(): d2[age].append(name) The defaultdict(list) creates one of these and tells it that the initialize something part should be create an empty list. It's hugely convenient and used all the time. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 12/8/2013 12:59 PM, rafaella...@gmail.com wrote: i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help Welcome to the python list. Thanks for posting a question. If you were hoping for one of us to write the program for you ... well that's not what we do on this list. Please post the code you have so far and tell us exactly where you need help. Also tell us what version of Python, what OS, and what you use to write and run Python programs. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 12/08/2013 09:59 AM, rafaella...@gmail.com wrote: i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help This looks like homework for a beginning programming class. Correct? We like helping people use Python, and we like helping people learn Python, but neither of those purposes are served by us *doing* your homework for you. Please, you try to solve the problem, and when you get stuck, show us your code, and ask a specific question. Hint: You will almost certainly need a loop (through the dictionary entries), an 'if' conditional to test for the age matching the given age, and a print, Gary Herron -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 08/12/2013 18:14, rafaella...@gmail.com wrote: On Sunday, December 8, 2013 6:07:47 PM UTC, YBM wrote: Le 08.12.2013 18:59, rafaella...@gmail.com a �crit : i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help ageDict = { 'john':42, 'jane':36, 'paul':42 } peopleWithAge = lambda age: [ name for name in ageDict if ageDict[name]==age] sorry but i'm new to python ;p 1. it has to be in a form of a function called people and 2. how this code takes in an age and returns the names? I'm awfully sorry but I'm not doing your homework for you :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On Sunday, December 8, 2013 6:27:34 PM UTC, bob gailer wrote: On 12/8/2013 12:59 PM, rafaella...@gmail.com wrote: i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help Welcome to the python list. Thanks for posting a question. If you were hoping for one of us to write the program for you ... well that's not what we do on this list. Please post the code you have so far and tell us exactly where you need help. Also tell us what version of Python, what OS, and what you use to write and run Python programs. name = ['Alice', 'Bob', 'Cathy', 'Dan', 'Ed', 'Frank', 'Gary', 'Helen', 'Irene', 'Jack', 'Kelly', 'Larry'] age = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19] dic={} def combine_lists(name,age): for i in range(len(name)): dic[name[i]]= age[i] combine_lists(name,age) print dic def people(age): people=lambda age: [name for name in dic if dic[name]==age] people(20) this is the code i have so far(with the help of the first post ;p). i understand how a function and a dictionary works and what I'm asked to find. but i don't get the lambda age part. and this code doesn't give me any result -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On Sunday, December 8, 2013 6:32:31 PM UTC, rafae...@gmail.com wrote: On Sunday, December 8, 2013 6:27:34 PM UTC, bob gailer wrote: On 12/8/2013 12:59 PM, rafaella...@gmail.com wrote: i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help Welcome to the python list. Thanks for posting a question. If you were hoping for one of us to write the program for you ... well that's not what we do on this list. Please post the code you have so far and tell us exactly where you need help. Also tell us what version of Python, what OS, and what you use to write and run Python programs. name = ['Alice', 'Bob', 'Cathy', 'Dan', 'Ed', 'Frank', 'Gary', 'Helen', 'Irene', 'Jack', 'Kelly', 'Larry'] age = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19] dic={} def combine_lists(name,age): for i in range(len(name)): dic[name[i]]= age[i] combine_lists(name,age) print dic def people(age): people=lambda age: [name for name in dic if dic[name]==age] people(20) this is the code i have so far(with the help of the first post ;p). i understand how a function and a dictionary works and what I'm asked to find. but i don't get the lambda age part. and this code doesn't give me any result and I'm sorry but this is the first time i ask for help in a forum and i just didn't know how it works. I'm not looking for someone to do my homework i just need someone to help me with my code :) -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On Sun, Dec 8, 2013 at 10:32 AM, rafaella...@gmail.com wrote: On Sunday, December 8, 2013 6:27:34 PM UTC, bob gailer wrote: On 12/8/2013 12:59 PM, rafaella...@gmail.com wrote: i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help Welcome to the python list. Thanks for posting a question. If you were hoping for one of us to write the program for you ... well that's not what we do on this list. Please post the code you have so far and tell us exactly where you need help. Also tell us what version of Python, what OS, and what you use to write and run Python programs. name = ['Alice', 'Bob', 'Cathy', 'Dan', 'Ed', 'Frank', 'Gary', 'Helen', 'Irene', 'Jack', 'Kelly', 'Larry'] age = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19] dic={} def combine_lists(name,age): for i in range(len(name)): dic[name[i]]= age[i] combine_lists(name,age) print dic def people(age): people=lambda age: [name for name in dic if dic[name]==age] people(20) this is the code i have so far(with the help of the first post ;p). i understand how a function and a dictionary works and what I'm asked to find. but i don't get the lambda age part. and this code doesn't give me any result To return a value from a function, you need to use the return statement with the value you want to pass back out. You're not doing that here. Also, you're using a lot of shorthand stuff that you should probably avoid until you're more comfortable with the language * Lambda is shorthand for a function. foo = lambda bar : bar + 2 is the same thing as the function def foo(bar) : return bar + 2 * a list comprehension is short-hand for a loop. spam = [foo for foo in bar if baz(foo)] is the same thing as spam = [] for foo in bar : if baz(foo) : spam.append(foo) You don't need a lambda here- just call the code that you need to call directly. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On Sunday, December 8, 2013 6:52:12 PM UTC, Benjamin Kaplan wrote: On Sun, Dec 8, 2013 at 10:32 AM, rafaella...@gmail.com wrote: On Sunday, December 8, 2013 6:27:34 PM UTC, bob gailer wrote: On 12/8/2013 12:59 PM, rafaella...@gmail.com wrote: i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help Welcome to the python list. Thanks for posting a question. If you were hoping for one of us to write the program for you ... well that's not what we do on this list. Please post the code you have so far and tell us exactly where you need help. Also tell us what version of Python, what OS, and what you use to write and run Python programs. name = ['Alice', 'Bob', 'Cathy', 'Dan', 'Ed', 'Frank', 'Gary', 'Helen', 'Irene', 'Jack', 'Kelly', 'Larry'] age = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19] dic={} def combine_lists(name,age): for i in range(len(name)): dic[name[i]]= age[i] combine_lists(name,age) print dic def people(age): people=lambda age: [name for name in dic if dic[name]==age] people(20) this is the code i have so far(with the help of the first post ;p). i understand how a function and a dictionary works and what I'm asked to find. but i don't get the lambda age part. and this code doesn't give me any result To return a value from a function, you need to use the return statement with the value you want to pass back out. You're not doing that here. Also, you're using a lot of shorthand stuff that you should probably avoid until you're more comfortable with the language * Lambda is shorthand for a function. foo = lambda bar : bar + 2 is the same thing as the function def foo(bar) : return bar + 2 * a list comprehension is short-hand for a loop. spam = [foo for foo in bar if baz(foo)] is the same thing as spam = [] for foo in bar : if baz(foo) : spam.append(foo) You don't need a lambda here- just call the code that you need to call directly. i get it, thanks a lot i wrote a different one and it works def people(age): people=[name for name in dic if dic[name]==age] print(people) people(20) i have one last question it asks me to test my program function by running these lines: print ’Dan’ in people(18) and ’Cathy’ in people(18) print ’Ed’ in people(19) and ’Helen’ in people(19) and\ ’Irene’ in people(19) and ’Jack’ in people(19) and ’Larry’in people(19) print ’Alice’ in people(20) and ’Frank’ in people(20) and ’Gary’ in people(20) print people(21) == [’Bob’] print people(22) == [’Kelly’] print people(23) == [] but when i wrote these lines it returns me an error Traceback (most recent call last): File /Users/rafaellasavva/Desktop/people.py, line 19, in module print 'Dan' in people(18) and 'Cathy' in people(18) TypeError: argument of type 'NoneType' is not utterable do you know what it might be wrong? -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On Mon, Dec 9, 2013 at 6:06 AM, rafaella...@gmail.com wrote: but when i wrote these lines it returns me an error Traceback (most recent call last): File /Users/rafaellasavva/Desktop/people.py, line 19, in module print 'Dan' in people(18) and 'Cathy' in people(18) TypeError: argument of type 'NoneType' is not utterable do you know what it might be wrong? Hehe. The first thing that's wrong is that you're retyping the error instead of copying and pasting it. The problem is actually that it's not *iterable* here. And the reason for that is that you're printing the result instead of returning it, as has been mentioned by a few people. Also, your posts are acquiring the slimy stain of Google Groups, which makes them rather distasteful. All your replies are getting double-spaced, among other problems. Please consider switching to an alternative newsgroup reader, or subscribing to the mailing list: https://mail.python.org/mailman/listinfo/python-list The content is the same, but it comes by email instead of netnews. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 08/12/2013 19:06, rafaella...@gmail.com wrote: i get it, thanks a lot i wrote a different one and it works def people(age): people=[name for name in dic if dic[name]==age] print(people) people(20) i have one last question it asks me to test my program function by running these lines: print ’Dan’ in people(18) and ’Cathy’ in people(18) print ’Ed’ in people(19) and ’Helen’ in people(19) and\ ’Irene’ in people(19) and ’Jack’ in people(19) and ’Larry’in people(19) print ’Alice’ in people(20) and ’Frank’ in people(20) and ’Gary’ in people(20) print people(21) == [’Bob’] print people(22) == [’Kelly’] print people(23) == [] but when i wrote these lines it returns me an error Traceback (most recent call last): File /Users/rafaellasavva/Desktop/people.py, line 19, in module print 'Dan' in people(18) and 'Cathy' in people(18) TypeError: argument of type 'NoneType' is not utterable do you know what it might be wrong? You've typed up the error message instead of using cut and paste, which is why it says utterable instead of iterable? :) Seriously, it's already been pointed out that your people function needs a return statement. Without it, the default returned is always None. Would you also please read and action this https://wiki.python.org/moin/GoogleGroupsPython as it prevents us seeing huge numbers of unwanted newlines which some find extremely irritating. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On Sunday, December 8, 2013 10:32:31 AM UTC-8, rafae...@gmail.com wrote: [snip] def people(age): people=lambda age: [name for name in dic if dic[name]==age] people(20) [snip] this is the code i have so far(with the help of the first post ;p). i understand how a function and a dictionary works and what I'm asked to find. but i don't get the lambda age part. Well then, don't use it! It's clear that you are new, and at least you have posted some code now, so let me try to help. and this code doesn't give me any result Right, for TWO reasons. First problem: if your function does not end with a statement like return people, the function returns a special Python object called None. Now, if it were me, I would not wrap the calculation of your people list inside a people function for such a short program. But this is apparently a requirement of your assignment. My guess is, in the future, you will write a program that calls the people function multiple times. The lambda word has to do with creating something called an anonymous one-line function. You don't need that here. It's more advanced Python. What you want to do is compute and, importantly, return a list calculated from your dictionary. That is accomplished by this expression: [name for name in dic if dic[name]==age] This is called a list comprehension. Do you understand what this does? It's fairly advanced. I don't teach list comprehensions to my Python students for the first several lessons. So, now that you have created the list, let's make sure that Python doesn't lose it. Let's assign a NAME to it. By the way, it's probably not good form to use the same name for a function and any of its internal variables. Pick a different name for your list: for example, p. Then, return p from your function to your main program. My suggested rewrite of your function would be: def people(age): p = [name for name in dic if dic[name]==age] return p The truth is that you can cut this down by even one more line. This function doesn't need to hold on to the result after it is done returning it, but the computation of the result can be accomplished in one line. Therefore this will also work: def people(age): return [name for name in dic if dic[name]==age] OK, that takes care of Problem 1. Second problem: you call the people function with your statement people(20), but you don't do anything with the output. Once you fix the people function by providing a proper return statement, what does the main program do with the output of the function? Right now, it just throws it away. One solution to the problem is to make sure that the function's output gets a name. Try: result = people(20) Now, what do you want to do with result? I will wait to see your answer on that one before I intervene again. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 12/8/2013 2:06 PM, rafaella...@gmail.com wrote: Even when you do get what lambda means and how use it, name = lambda args: expression which is a carryover from other languages, is inferior to def name(args): return expression because the function object resulting from lambda does not have a proper name attribute. def people(age): people=[name for name in dic if dic[name]==age] An alternative is [name for name, value in dic.itervalues() if value == age] In Python 3, remove 'iter'. It this is not homework and you are not otherwise forced to start with Python 3, I (and some others here) recommend starting with Python 3. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
rafaella...@gmail.com wrote: def people(age): people=lambda age: [name for name in dic if dic[name]==age] but i don't get the lambda age part. Just to explain: YBM has tried to sabotage you by posting a solution that uses a couple of advanced Python features (lambda and list comprehensions) that a beginner would be unlikely to know about. The idea is that if you had simply handed that code in as-is, your teacher would know that you had almost certainly not written it yourself. Anyhow, you seem to be almost there. The only thing now is that your function needs to *return* the result instead of printing it out. To illustrate with a different example, you currently have a function like this: def add(a, b): print a + b This is fine as far as it goes, but the drawback is that printing out the result is all it will ever do. You're being asked to write a function like this: def add(a, b): return a + b This is much more useful, because you can do anything you like with the result, e.g. print add(2, 3) * add(4, 5) -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 12/08/2013 12:17 PM, Chris Angelico wrote: On Mon, Dec 9, 2013 at 6:06 AM, rafaella...@gmail.com wrote:[...] Also, your posts are acquiring the slimy stain of Google Groups, which makes them rather distasteful. All your replies are getting double-spaced, among other problems. Please consider switching to an alternative newsgroup reader, or subscribing to the mailing list: https://mail.python.org/mailman/listinfo/python-list To the OP: First, my apologies if my reply ends up trashing your discussion here, but you should know what is behind Mr. Angelico's response. For some time now the Google Group Wars are being fought in this group. There is a (probably very small) clique of Google haters who try present themselves as the community and who try to intimidate anyone posting from Google Groups into using some other means of posting, completely disregarding the fact that for many new people or occasional posters, Google Groups is an order of magnitude easier to use. These people are extremely noisy and obnoxious but *do not* represent the community except in their own minds. I suspect many of them are motivated by political dislike of Google as a corporation, or want to stay with the 1990's technology they invested time in learning and don't want see change. I and many other people post here from Google Groups and you should feel free to too if it is more convenient for you. (Of course you can also use the maillist or usenet if you find them a good solution for *you* but please don't feel compelled to by some loud obnoxious bullies.) As another poster pointed out, if you are able to follow some of the advice at, https://wiki.python.org/moin/GoogleGroupsPython it will help quiet down the anti-Google crowd a little but even if you don't, those without a Google chip on their shoulder will simply skip your posts if they find the Google formatting too annoying. Most of us though will deal with it as adults and try our best to answer your questions. I just thought you should have both sides of the story so to won't take the anti-Google crowd here as gospel. Addressing you last question, I presume you understood the other responses about replacing the print (people) statement in your people() function with return people. The only additional thing I wanted to add is that, people=[name for name in dic if dic[name]==age] is (I would guess) a rather advanced way of doing what you are doing, given where you seem to be in learning about python (but maybe not, in which case ignore the following). The [] thing is called as list comprehension and in described here http://docs.python.org/3/tutorial/datastructures.html#list-comprehensions However, it is just a more concise way of writing: people = [] for n, a in dic.items(): if a == age: people.append (n) return people To understand the above (if you don't already) you'll want to read about the the items() method of dicts: http://docs.python.org/3/tutorial/datastructures.html#looping-techniques http://docs.python.org/3/library/stdtypes.html#mapping-types-dict the append() method of lists, http://docs.python.org/3/tutorial/controlflow.html#for-statements http://docs.python.org/3/library/stdtypes.html#mutable-sequence-types and of course for loops; http://docs.python.org/3/tutorial/controlflow.html#for-statements Hope this helps. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 09/12/2013 00:08, ru...@yahoo.com wrote: On 12/08/2013 12:17 PM, Chris Angelico wrote: On Mon, Dec 9, 2013 at 6:06 AM, rafaella...@gmail.com wrote:[...] Also, your posts are acquiring the slimy stain of Google Groups, which makes them rather distasteful. All your replies are getting double-spaced, among other problems. Please consider switching to an alternative newsgroup reader, or subscribing to the mailing list: https://mail.python.org/mailman/listinfo/python-list To the OP: First, my apologies if my reply ends up trashing your discussion here, but you should know what is behind Mr. Angelico's response. For some time now the Google Group Wars are being fought in this group. There is a (probably very small) clique of Google haters who try present themselves as the community and who try to intimidate anyone posting from Google Groups into using some other means of posting, completely disregarding the fact that for many new people or occasional posters, Google Groups is an order of magnitude easier to use. These people are extremely noisy and obnoxious but *do not* represent the community except in their own minds. I suspect many of them are motivated by political dislike of Google as a corporation, or want to stay with the 1990's technology they invested time in learning and don't want see change. I and many other people post here from Google Groups and you should feel free to too if it is more convenient for you. (Of course you can also use the maillist or usenet if you find them a good solution for *you* but please don't feel compelled to by some loud obnoxious bullies.) As another poster pointed out, if you are able to follow some of the advice at, https://wiki.python.org/moin/GoogleGroupsPython it will help quiet down the anti-Google crowd a little but even if you don't, those without a Google chip on their shoulder will simply skip your posts if they find the Google formatting too annoying. Most of us though will deal with it as adults and try our best to answer your questions. I just thought you should have both sides of the story so to won't take the anti-Google crowd here as gospel. To the OP, please ignore the above, it's sheer, unadulterated rubbish. Nobody has ever been bullied into doing anything. People have however been asked repeatedly to either A) use the link referenced above to avoid sending double spaced crap here from the inferior google groups product or B) use an alternative technology that doesn't send double spaced crap. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
Le 09.12.2013 01:00, Gregory Ewing a écrit : rafaella...@gmail.com wrote: def people(age): people=lambda age: [name for name in dic if dic[name]==age] but i don't get the lambda age part. Just to explain: YBM has tried to sabotage you by posting a solution that uses a couple of advanced Python features (lambda and list comprehensions) that a beginner would be unlikely to know about. Oh! I've been caught! ;-) My point is not that I had a problem with the OP (btw asking for homework in a public group always irrates me), but that the teacher of the OP is incredibly stupid and illiterate (or should I say illluterate ?) So I tried to catch both. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
Le 08.12.2013 20:06, rafaella...@gmail.com a écrit : i get it, thanks a lot i wrote a different one and it works def people(age): people=[name for name in dic if dic[name]==age] print(people) No it doesn't. You are printing things not returning something. and combine_list is the most stupidest function you could write in Python, as it is built-in with the name 'zip'. name = ['Alice', 'Bob', 'Cathy', 'Dan', 'Ed', 'Frank', 'Gary', 'Helen', 'Irene', 'Jack', 'Kelly', 'Larry'] age = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19] dic = dict(zip(name,age)) def people(age): ... ''' How stupid it is to write three line for a one-line function''' ... return [name for name in dic if dic[name]==age] ... people(20) ['Gary', 'Alice', 'Frank'] Sorry for having being rude, but : 1. you shouldn't post raw homework in any kind of public group (aren't you supposed to learn something by yourself ?) 2. your teacher is a nut. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
Le 08.12.2013 19:32, rafaella...@gmail.com a écrit : On Sunday, December 8, 2013 6:27:34 PM UTC, bob gailer wrote: On 12/8/2013 12:59 PM, rafaella...@gmail.com wrote: i have a dictionary with names and ages for each name. I want to write a function that takes in an age and returns the names of all the people who are that age. please help Welcome to the python list. Thanks for posting a question. If you were hoping for one of us to write the program for you ... well that's not what we do on this list. Please post the code you have so far and tell us exactly where you need help. Also tell us what version of Python, what OS, and what you use to write and run Python programs. name = ['Alice', 'Bob', 'Cathy', 'Dan', 'Ed', 'Frank', 'Gary', 'Helen', 'Irene', 'Jack', 'Kelly', 'Larry'] age = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19] dic={} def combine_lists(name,age): for i in range(len(name)): dic[name[i]]= age[i] combine_lists(name,age) print dic def people(age): people=lambda age: [name for name in dic if dic[name]==age] people(20) this is the code i have so far(with the help of the first post ;p). i understand how a function and a dictionary works and what I'm asked to find. but i don't get the lambda age part. and this code doesn't give me any result You didn't write a function which return a result, so you have no result. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On Mon, Dec 9, 2013 at 11:08 AM, ru...@yahoo.com wrote: I suspect many of them are motivated by political dislike of Google as a corporation, or want to stay with the 1990's technology they invested time in learning and don't want see change. Neither. I don't at all hate Google (I quite like the company, and what it's done for the world), and I use plenty of other Google services - as you can see, I'm posting from gmail here. The only thing I call out against is Google Groups, because it is buggy. I'll cry out against anything else that's buggy, too. Of course, I'll first try to do things quietly (bug reports to the maintainers), but ultimately, the solution to buggy software is to NOT USE IT. If Google doesn't care enough about Groups to bring it up to the standard, then their penalty has to be reduced usage. In fact, Rurpy, you are actually encouraging the faulty system, because you're providing ad impressions and usage stats every time you read or write via GG. When less-buggy systems see more use than more-buggy systems, big companies have an incentive to fix bugs. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 12/08/2013 05:27 PM, Mark Lawrence wrote: On 09/12/2013 00:08, ru...@yahoo.com wrote: On 12/08/2013 12:17 PM, Chris Angelico wrote: On Mon, Dec 9, 2013 at 6:06 AM, rafaella...@gmail.com wrote:[...] [...] To the OP, please ignore the above, it's sheer, unadulterated rubbish. Nobody has ever been bullied into doing anything. People have however been asked repeatedly to either A) use the link referenced above to avoid sending double spaced crap here from the inferior google groups product or B) use an alternative technology that doesn't send double spaced crap. Mark, I appreciate your calm and reasonable requests for people to checkout the page you gave a link to, that's why I repeated your advice. It is also why I responded to Chris and not to you. However it does not change the fact that people here have responded in rather extreme way to GG posts including calling GG users twits and claiming GG posts damage their eyesight, as well as repeatedly denying the obvious fact that GG is much easier to use for many than to subscribe to a usenet provider or to a mailing list. One frequently sees words like crap, slimy, rubbish etc to describe GG posts which is pretty intimating to people who just want some help with a python question using a tool they already know how to use and have had no complaints about in other places. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On 12/08/2013 08:05 PM, Chris Angelico wrote: On Mon, Dec 9, 2013 at 11:08 AM, ru...@yahoo.com wrote: I suspect many of them are motivated by political dislike of Google as a corporation, or want to stay with the 1990's technology they invested time in learning and don't want see change. Neither. I don't at all hate Google (I quite like the company, and what it's done for the world), and I use plenty of other Google services - as you can see, I'm posting from gmail here. If the shoe doesn't fit, don't wear it. There have certainly been others who have publicly railed against Google. The only thing I call out against is Google Groups, because it is buggy. And yet you are publicly on record as referring to GG users as twits. I'll cry out against anything else that's buggy, too. Of course, I'll first try to do things quietly (bug reports to the maintainers), but ultimately, the solution to buggy software is to NOT USE IT. If Google doesn't care enough about Groups to bring it up to the standard, then their penalty has to be reduced usage. In fact, Rurpy, you are actually encouraging the faulty system, because you're providing ad impressions and usage stats every time you read or write via GG. When less-buggy systems see more use than more-buggy systems, big companies have an incentive to fix bugs. We all use buggy software every day. *Every* piece of non-trival software is buggy -- you already know that. So you are saying that bugs that annoy *you* are ones that *others* should change their practice to join your boycott to fix. You sound like some Unix hard-asses of the 1990's who, by god, weren't going pollute their software with any kind of MS Windows compatibility. No supporting a broken OS for them. They would keep the software pure and Unix-only and force Microsoft to fix their broken OS. Well, most of that software and those programmers have been eliminated by Darwinian selection, and today cross-platform (or Windows only) software is the norm. So good luck on your crusade to force Google to do things the way you think is right. (Especially given the large and growing number of Python project mailing lists *hosted* on Google Groups.) Until you're successful, I will try to encourage GG users to post more compatibly to avoid pissing off the old farts, do what I can to support Rusi's attempt to put together a tool to make it easier to do so, and finally, live with double-spaced crap because that is the lesser of two evils, the other being creating an excessively picky and hostile place for newcomers who just want to learn more about Python. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
why can't we all just get along? Rodney King, RIP -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On Monday, December 9, 2013 10:37:38 AM UTC+5:30, ru...@yahoo.com wrote: On 12/08/2013 05:27 PM, Mark Lawrence wrote: On 09/12/2013 00:08, wrote: On 12/08/2013 12:17 PM, Chris Angelico wrote: On Mon, Dec 9, 2013 at 6:06 AM, rafaell wrote: [...] To the OP, please ignore the above, it's sheer, unadulterated rubbish. Nobody has ever been bullied into doing anything. People have however been asked repeatedly to either A) use the link referenced above to avoid sending double spaced crap here from the inferior google groups product or B) use an alternative technology that doesn't send double spaced crap. Mark, I appreciate your calm and reasonable requests for people to checkout the page you gave a link to, that's why I repeated your advice. It is also why I responded to Chris and not to you. Yes agreed. However it does not change the fact that people here have responded in rather extreme way to GG posts including calling GG users twits and claiming GG posts damage their eyesight, as well as repeatedly denying the obvious fact that GG is much easier to use for many than to subscribe to a usenet provider or to a mailing list. One frequently sees words like crap, slimy, rubbish etc to describe GG posts which is pretty intimating to people who just want some help with a python question using a tool they already know how to use and have had no complaints about in other places. About the last -- no complaints about (that) in other places -- Ive recently seen that on the html/stylesheets/javascript lists (not sure which) there are also annoyed complaints about GG. About the rest -- when people get annoyed they say and do things they would not otherwise do. The sensible not-yet-annoyed-enough-to-lose-the-head folks should try to cure the annoyance rather than get annoyed with it -- dont you think? In short if we are programmers we should be thinking bug-fixes when we are bugged :-) And what is put up here https://wiki.python.org/moin/GoogleGroupsPython (only yesterday BTW) is a dynamically loadable GG-bugfix. -- https://mail.python.org/mailman/listinfo/python-list
Re: python programming help
On Mon, Dec 9, 2013 at 4:07 PM, ru...@yahoo.com wrote: However it does not change the fact that people here have responded in rather extreme way to GG posts including calling GG users twits and claiming GG posts damage their eyesight, as well as repeatedly denying the obvious fact that GG is much easier to use for many than to subscribe to a usenet provider or to a mailing list. One frequently sees words like crap, slimy, rubbish etc to describe GG posts which is pretty intimating to people who just want some help with a python question using a tool they already know how to use and have had no complaints about in other places. Please note though that there is a difference between describing the users as twits and describing the posts as slimy. Suppose you write a letter (the sort that goes on a slab of dead tree) and, instead of placing it in an envelope and putting a stamp on it, you hand it to the Arac News Insertion Device[1] to do the enveloping for you. He does a reasonable job of it, but he uses cobwebs instead of paper for the envelope. Sure, it's still readable... but your readers now have to rub off a whole lot of cobwebs before they can read what you said. That makes your post distasteful, without it being at all your fault - other than choosing to use Arac's service. That's how I see Google Groups posts. Someone's gone looking for help about Python and has found that. It's not their fault that they don't know about alternatives; so I point out the alternatives. ChrisA [1] http://math.boisestate.edu/gas/princess_ida/webop/pi_04.html On the whole we are Not intelligent... -- https://mail.python.org/mailman/listinfo/python-list
Re: PYTHON PROGRAMMING HELP PLSSS !!
On Aug 2, 6:24 pm, Dennis [EMAIL PROTECTED] wrote: HI All, i am a 4th year business student and i took web design online course for fun however i did not see that last 2 chapters were python programming.This has no relevance to my major nor does it have any contribution to my degree. My fun turned out to be my nightmare since i literally can not grasp the main idea like other computer science students. To sum up , i need help with the following code, please do not send me emails telling me that outside class help is not provided or etc, this is not my major related course and this might also affect my graduation date. This is the working sample program ;http://cmpt165.cs.sfu.ca/~ggbaker/examples/chequebook.html If interested please email me, i am ready to make it up for your time that you spend to get me out of this mess. thanks What exactly do you need done? Be more specific instead of just pasting a link to a page Also, you might want to state how much you are willing to 'compensate' someone. Maybe you will get more responses this way :) -- http://mail.python.org/mailman/listinfo/python-list
Re: PYTHON PROGRAMMING HELP PLSSS !!URGENT
Hi, Please do not double post. Especially with more than one email address. If someone can help you. I am sure they will. Danyelle -- http://mail.python.org/mailman/listinfo/python-list