Re: [Tutor] Python Interview Questions..
Marc Tompkins marc.tompk...@gmail.com wrote Java just isn't a hard enough language to separate great programmers from plodders (neither is Python, for that matter) because pointers and memory allocation are taken care of automagically. I fundamentally disagree with his stand on this. When you're hiring programmers, (Joel says) you want people who understand what the computer is actually doing under all the chrome, and you want people who are smart enough to have actually passed classes where they had to do that stuff. I have employed quantum physists and geoligists who had no idea of how computers worked but they were plenty smart and made good programmers. A good programmer is someone who can think logically, analyse and abstract a problem and express it clearly in an implementation language (regardless of what language it is, they will probably use several in their career!) There is a very small set of programming tasks where you need to undertand the machine - developing an OS and device drivers etc - but they are such a small part of the industry that mostly we can be thankful that modern languages hide the machine and let us focus on the really hard stuff - understanding the customers world and translating their requirements into code. Fred Brooks identified this as far back as the 80's with his famous No Silver Bullet article. I started out as an electronics engineer, we wrote micro-code, then machine code then assembler and finally Pascal. Then I found C and so on. But I am profoundly grateful that I no longer have to worry about which register to store the result of an addition or which memory mode I need to use in a subroutine call. There are equally complex challenges in higher order programming than there are in programming the machine. There is a role for both, but the macho I can do it faster in assembler attitude that sometimes arises is no more than ignorance of the challenges elsewhere. I've worked with highly technical programmers who couldn't understand how a Corporate General Ledger accounting system worked and so couldn't program solutions for it. But they could explain in detail how the multi-threaded kernel in the computer operated. So language preferences are fine if they are based on the language features. Computing and Programming are something else again. for Getting Stuff Done - but when you spend your hard-earned money for commercial software, or trust your computing life to an operating system, you want to know that it was written by people who knew what the hell they were doing, rather than people who scraped by in a Java School 'cause the classes weren't too hard. And this is another matter again. But if you are talking about share dealing systems or traffic control systems or factory automation I'd rather the programmer understood algorithms and the business functions than the difference between page switching and banked memory access. But I definitely want him/her to understand computing, and programming in depth. I want them to have studied the subject deeply and have a wealth of experience. Studying computing because its an easy option is not an option because its never easy. And anyone who starts down that road will be weeded out very quickly. We've all used software that was written by non-programmers - I'm struggling with just such a system at the moment - and life is just too damn short. Software can only be written by programmers, its the definition of the term. The issue is about whether the programmer was trained in computing/engineering or whether it was someone who just knew a programming language. Comp Sci was originally a branch of math, and many of the best programmers I've worked with came straight into the industry from math - but they had to learn about defensive programming etc. But their algorithm design often meant they had less to defend! Seems to be my week for ranting... :-) Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Could I modify codes and validate immediately withoutrestart program?
char...@sohu.com wrote Hi, guys. Here is a demo program like this: aa = 3 bb = 4 cc = 53 dd = 6 print cc I put a breakpoint at the first line, then debug the program. After 'aa' is set to '3', I modify '53' in the 3rd line to '34', then save the source file and run remain codes. As expected, the output is '53'. Correct because the interpreter and debugger are running the original unmodified source file, it gets loaded into memory when the interpreer started. To do what you want it would have to read each line from the file as it went which would be horrifically slow. It also would prevent the interpreter compiling the code in memory which would add to the slowdown. Does python has the ability to set cc to 34 after file savings without restarting whole program? No, and I don;t know of any language than can unless you explicitly reload the code. But that is usually a feature of the debugger/interpreter rather than the language. For example I worked ona C++ IDE a few years ago that allowed you to change code and reload and continue running. I've seen debuggers that let you step through code in reverse. All very clever but nothing to do with the language. And of course you could change the value of your variable in the debugger by setting a breakpoint immediately after the assignment. But that doesn't change the source code. I heard LISP has this ability and wonder how could it achieve this. Lisp a a language does not, but some Lisp interpreters or debuggers may well be able to reload a program in-flight. It's not in the language it's in the tools. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Interview Questions..
Alan Gauld alan.ga...@btinternet.com wrote of the term. The issue is about whether the programmer was trained in computing/engineering or whether it was someone who just knew a programming language. And I meant to add that this includes learning about the virtual machine - the execution environment, the differences between interpreted and compiled code etc. Also understanding OS concepts like scheduling and file systems etc are necessary. It's just the low level memory management/register access type stuff that I don't believe is necessary. And I do agree that we are seeing programmers who don't understand the basics of computing even at a user level and that is not good in an industry concept. It's fine for hobbyists but not for industrial grade programming. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Interview Questions..
May I direct the interview question to another direction? are there some tests (I mean, just like the examination test) of python for beginner? which asked some basic but important questions (I do not want to learn python all of the stuff, it might be so huge for me.) and most important those practice gave answers. I learned it on and off and hard to achieve something (I mean practice in daily working). But got a wish to learn. so any advice will be highly appreciated. Thanks, On Fri, May 27, 2011 at 5:15 PM, Alan Gauld alan.ga...@btinternet.com wrote: Alan Gauld alan.ga...@btinternet.com wrote of the term. The issue is about whether the programmer was trained in computing/engineering or whether it was someone who just knew a programming language. And I meant to add that this includes learning about the virtual machine - the execution environment, the differences between interpreted and compiled code etc. Also understanding OS concepts like scheduling and file systems etc are necessary. It's just the low level memory management/register access type stuff that I don't believe is necessary. And I do agree that we are seeing programmers who don't understand the basics of computing even at a user level and that is not good in an industry concept. It's fine for hobbyists but not for industrial grade programming. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Best Regards, lina ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Interview Questions..
On 27 May 2011 09:59, Alan Gauld alan.ga...@btinternet.com wrote: Marc Tompkins marc.tompk...@gmail.com wrote Java just isn't a hard enough language to separate great programmers from plodders (neither is Python, for that matter) because pointers and memory allocation are taken care of automagically. I fundamentally disagree with his stand on this. Not sure what you're saying here Alan -- are you saying you consider Java hard enough language to seperate great programmers from plodders or are you saying that you don't agree with the distinction drawn (that some programmers are plodders and others are not) or what? When you're hiring programmers, (Joel says) you want people who understand what the computer is actually doing under all the chrome, and you want people who are smart enough to have actually passed classes where they had to do that stuff. I have employed quantum physists and geoligists who had no idea of how computers worked but they were plenty smart and made good programmers. A good programmer is someone who can think logically, analyse and abstract a problem and express it clearly in an implementation language (regardless of what language it is, they will probably use several in their career!) Well, FWIW I would tend to side with Joel/Marc on this one (depending on interpretation of what you're both saying -- maybe I fall somewhere in the middle... whatever...) To try and clarify, I'd perhaps rephrase/paraphrase their view as, you want people who have some understanding of how the code you've written will actually ends up being executed by the computer in terms of the effective time and space complexity (as well as other potentially problematic aspects) of the code. To me that seems to be a largely isomorphic expression of what they're saying and perhaps closer to what they're actually trying to get at. Either way, the point I'm trying to make is that even if you have for example some awareness of the /apparent/ time/space complexity of *your* code, it's still very easy to fall into a Schlemiel painter's type algorithm by not really having an understanding of how (for example) some of the libraries or basic functionality of the language you're using are implemented. To belabor the point: The same pseudocode/algorithm realised in 2 different languages can have wildly different performance characteristics depending on the nature of the underlying languages and the exact form of the realisation. And you as programmer will never even know unless you have a more than superficial understanding of the language you program in and have some awareness that these types of issues exist and what the different performance characteristics of various algorithm classes are. And yet, many programmers don't apparently have even a superficial awareness of attributes of the code that they write, never mind how a such a superficial analysis (e.g. ignoring the platform/language) may differ from what really happens when executed, and why such a difference exists. Anyway, best regards and have a good weekend all, Walter ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Clunky Password maker
On Thu, 26 May 2011 05:45:30 am Alan Gauld wrote: [...] using the choice() function from the whrandom module. passwd = [whrandom.choice(series) for n in range(p)] whrandom was deleted in Python 2.5! I'm not sure when it was formally deprecated, but the recommended way of getting random numbers has been the random module all the way back to version 1.5! Since version 2.3, Python has been using the Mersenne Twister as the default random number generator, instead of Wichmann-Hill. Mersenne Twister is *much* better and stronger than WH. -- Steven D'Aprano ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Non programmer wanting to become programmer
Thank you all for the replies. They helped me a lot. Have a great weekend! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Cherrypy
On Thu, 26 May 2011 12:16:05 am Bryton wrote: Is anyone having a step by step tutorial of cherrypy(or book title).I have used the tutorial in their site as well as the book (cherrypy essentials) and I would like to have a one that is a bit more step by step...Please help... Sorry Bryton, I don't know any. Have you googled to see what is available? -- Steven D'Aprano ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Variables Changing in Other Functions
Rachel-Mikel ArceJaeger wrote: Hello, I am having trouble with determining when python is passing by reference and by value Others have already discussed this, but at the risk of blowing my own trumpet, I'd like to point you at an earlier discussion on this list: http://mail.python.org/pipermail/tutor/2010-December/080505.html -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Interview Questions..
On 27 May 2011 17:31, Walter Prins wpr...@gmail.com wrote: I find this thread very interesting. I've been learning Python on and off for the past 3 years, as a hobby. I am over 50 years old, so will never be a programmer. However: 1/ I've done a bit in Project Euler and have found many algorithms to get prime numbers. There is one that is 10 times faster than any other that I have found, it uses numpy. Unfortunately, I don't understand it at all. However, neither would I understand Python's sort method, but I still use it. 2/ I used be able to take a car to pieces and put it back together. Today, I wouldn't stand a chance. I suppose that what I'm trying to say is that there will always be a need for experts that know different OS's and how a computer works inside, and there will also be a need for coders who code a programme that is needed at a certain time. Is there really a time that knowing that list is interpreted as 1001000100010001001100010010 is important these days? Please flame me -- ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Creating a dictionary
Hi, I think I am new to here, as far as I remember. :-) http://docs.python.org/dev/library/stdtypes.html#dict says: we can create a dictionary with - dict({'one': 1, 'two': 2}) What is the adventage of this form to simply writing d = {'one': 1, 'two': 2}? Is there any difference? Thanks ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating a dictionary
The first approach does not really give you any variable (in easy form) to operate upon. The second approach returns a dict object that you can later reuse in easier form. So one advantage is certainly that ease of object reuse and also object modification. If you want to add, remove, update anything in the dict object, the second syntax is easier. You can also make it part of a class or module. You can pass it to a function as well. Regards SWP 2011/5/27 Válas Péter suli...@postafiok.hu Hi, I think I am new to here, as far as I remember. :-) http://docs.python.org/dev/library/stdtypes.html#dict says: we can create a dictionary with - dict({'one': 1, 'two': 2}) What is the adventage of this form to simply writing d = {'one': 1, 'two': 2}? Is there any difference? Thanks ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- http://spawgi.wordpress.com We can do it and do it better. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating a dictionary
Sorry, I am afraid, I was not clear enough. So what is the difference between d = dict({'one': 1, 'two': 2}) and d = {'one': 1, 'two': 2} ? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating a dictionary
I think the way - d = dict({'one': 1, 'two': 2}) can be used to created dictionary using list comprehension. e.g. d = dict((i,i**2) for i in range(10)) d {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81} I do not think the second approach can be used in this fashion. From python documentation - http://docs.python.org/tutorial/datastructures.html The dict() constructor builds dictionaries directly from lists of key-value pairs stored as tuples. When the pairs form a pattern, list comprehensions can compactly specify the key-value list. I am not an expert. So may be someone can explain it better. Regards SWP 2011/5/27 Válas Péter suli...@postafiok.hu Sorry, I am afraid, I was not clear enough. So what is the difference between d = dict({'one': 1, 'two': 2}) and d = {'one': 1, 'two': 2} ? -- http://spawgi.wordpress.com We can do it and do it better. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating a dictionary
Válas Péter wrote: Hi, I think I am new to here, as far as I remember. :-) http://docs.python.org/dev/library/stdtypes.html#dict says: we can create a dictionary with - dict({'one': 1, 'two': 2}) What is the adventage of this form to simply writing d = {'one': 1, 'two': 2}? Is there any difference? dict() is a function (technically, a type) that creates new dictionaries from whatever argument you pass to it. { ... } is syntax for creating literal dictionaries. Think of this as similar to the difference between a mathematical expression: x = 2*9-1 and a number literal: x = 17 HOWEVER, in the above example with dict(), the form shown is redundant. dict({'one': 1, 'two': 2}) does these four steps: (a) Python creates a dictionary using the dict literal syntax {'one': 1, 'two': 2} (b) That dictionary is then passed to the dict() function (c) The dict() function makes a copy of that dictionary and returns it (d) Python's garbage collector deletes the original dictionary. Never put a lone dict literal {...} inside a call to dict(), that's just a waste of time. Just use the literal on its own. dict() *can* be very useful, just not in the example shown. You can use it to make copies of other dicts: first_dict = {'one': 1, 'two': 2} second_dict = dict(first_dict) That's not very interesting, as you can easily make a copy with first_dict.copy() instead. But it gets more interesting if you want to add new items to the dictionary: third_dict = dict(first_dict, three=3, four=4) You can even leave out the original dict: fourth_dict = dict(a=1, b=2, c=3) or instead use a list of (key, value) pairs: items = [('a', 1), ('b', 2), ('c', 3)] fifth_dict = dict(items, d=4) -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating a dictionary
The first instance is more keystrokes while the second saves u that. Sent from my BlackBerry wireless device from MTN -Original Message- From: Válas Péter suli...@postafiok.hu Sender: tutor-bounces+delegbede=dudupay@python.org Date: Fri, 27 May 2011 16:19:08 To: spa...@gmail.com Cc: tutor@python.org Subject: Re: [Tutor] Creating a dictionary ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating a dictionary
2011. május 27. 16:31 írta, spa...@gmail.com: I think the way - d = dict({'one': 1, 'two': 2}) can be used to created dictionary using list comprehension. e.g. d = dict((i,i**2) for i in range(10)) I think this is not the same syntax, there are no braces in. dict({'one': 1, 'two': 2}) rather seems to me as a converting function that creates a dictionary from a dictionary. Thank you anyway! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Interview Questions..
Hi Colin, On 27 May 2011 14:41, col speed ajarnco...@gmail.com wrote: I've been learning Python on and off for the past 3 years, as a hobby. I am over 50 years old, so will never be a programmer. However: Well just because you're 50 years old doesn't mean you will never be a programmer ;) 1/ I've done a bit in Project Euler and have found many algorithms to get prime numbers. There is one that is 10 times faster than any other that I have found, it uses numpy. Unfortunately, I don't understand it at all. However, neither would I understand Python's sort method, but I still use it. It's this awareness (that you clearly already have0 that I submit is often (sadly) lacking in many programmers. So there mere fact that you're pointing this out tells me that you already have, at least, a feel/awareness that not all algorithms are equal, regardless of whether you understand why/how. I suppose that what I'm trying to say is that there will always be a need for experts that know different OS's and how a computer works inside, and there will also be a need for coders who code a programme that is needed at a certain time. Is there really a time that knowing that list is interpreted as 1001000100010001001100010010 is important these days? No, but that wasn't IMHO the point being made. It's more about how (for example) lists in general behave (e.g. having at least a feel for the cost of various operations etc) and (by contrast) also how **Python's** list implementation behaves (which is not the same as a classical linked list. Python lists (CPython at least) are IIRC actually implemented as dynamic arrays of pointers, which means that some operations don't cost as much as they would do with a true nodular linked list implementation, while other operations cost more etc. etc.) Best wishes (hoping this was not perceived as a flame as it wasn't intended as one!) Walter ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating a dictionary
Nice observation Spawgi. Sent from my BlackBerry wireless device from MTN -Original Message- From: spa...@gmail.com Sender: tutor-bounces+delegbede=dudupay@python.org Date: Fri, 27 May 2011 20:01:24 To: Válas Pétersuli...@postafiok.hu Cc: tutor@python.org Subject: Re: [Tutor] Creating a dictionary ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating a dictionary
Válas Péter wrote: I think I am new to here, as far as I remember. :-) http://docs.python.org/dev/library/stdtypes.html#dict says: we can create a dictionary with - dict({'one': 1, 'two': 2}) What is the adventage of this form to simply writing d = {'one': 1, 'two': 2}? Is there any difference? That is meant to illustrate that you can create a dictionary from another one by passing the existing dictionary to dict(). A more realistic example is friends = {Jim: 42, Jack: 18} family = {Sue: 7, Eli: 30} friends_and_family = dict(friends) friends_and_family.update(family) friends_and_family {'Eli': 30, 'Sue': 7, 'Jim': 42, 'Jack': 18} ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating a dictionary
2011/5/27 Steven D'Aprano st...@pearwood.info Never put a lone dict literal {...} inside a call to dict(), that's just a waste of time. Just use the literal on its own. That's what I thought about this, I just didn't want to believe that docs.python.org wrote a redundant example. third_dict = dict(first_dict, three=3, four=4) Thank you, these were useful examples! P. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Creating a dictionary
Thanks for the detailed explanation Steve. That was very helpful. On Fri, May 27, 2011 at 8:04 PM, Steven D'Aprano st...@pearwood.infowrote: Válas Péter wrote: Hi, I think I am new to here, as far as I remember. :-) http://docs.python.org/dev/library/stdtypes.html#dict says: we can create a dictionary with - dict({'one': 1, 'two': 2}) What is the adventage of this form to simply writing d = {'one': 1, 'two': 2}? Is there any difference? dict() is a function (technically, a type) that creates new dictionaries from whatever argument you pass to it. { ... } is syntax for creating literal dictionaries. Think of this as similar to the difference between a mathematical expression: x = 2*9-1 and a number literal: x = 17 HOWEVER, in the above example with dict(), the form shown is redundant. dict({'one': 1, 'two': 2}) does these four steps: (a) Python creates a dictionary using the dict literal syntax {'one': 1, 'two': 2} (b) That dictionary is then passed to the dict() function (c) The dict() function makes a copy of that dictionary and returns it (d) Python's garbage collector deletes the original dictionary. Never put a lone dict literal {...} inside a call to dict(), that's just a waste of time. Just use the literal on its own. dict() *can* be very useful, just not in the example shown. You can use it to make copies of other dicts: first_dict = {'one': 1, 'two': 2} second_dict = dict(first_dict) That's not very interesting, as you can easily make a copy with first_dict.copy() instead. But it gets more interesting if you want to add new items to the dictionary: third_dict = dict(first_dict, three=3, four=4) You can even leave out the original dict: fourth_dict = dict(a=1, b=2, c=3) or instead use a list of (key, value) pairs: items = [('a', 1), ('b', 2), ('c', 3)] fifth_dict = dict(items, d=4) -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- http://spawgi.wordpress.com We can do it and do it better. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Interview Questions..
On Fri, May 27, 2011 at 1:59 AM, Alan Gauld alan.ga...@btinternet.comwrote: I want them to have studied the subject deeply and have a wealth of experience. Studying computing because its an easy option is not an option because its never easy. That was the point that Joel and I were making. The CS programs that have become Java schools now make the curriculum as easy as possible because they used to flunk lots of students, or lose them to other majors - they obviously saw that as a Bad Thing, but it actually wasn't. A degree from a school that flunks a lot of students actually means something; a degree from a school where everybody passes is about as meaningful as a Participation trophy. And anyone who starts down that road will be weeded out very quickly. Not quickly enough! They should be weeded out IN SCHOOL, or before they even commit to a computer-science track. It's cruel to students, inefficient for business, and disastrous for consumers if they don't get weeded out until they're already employed as programmers. Software can only be written by programmers, its the definition of the term. You knew what I meant; don't be coy. Anybody with a wrench and some pipe is a plumber. Doesn't mean I'm letting him work on my dishwasher. The point I was trying to make, which apparently I didn't state clearly enough, was: Professional programmers - I really supported the effort, years back, to protect the term software engineer - should be familiar with the ins and outs of computers, not just with the quirks of the language they are employed to use. To use my dishwasher analogy from a moment ago, I'm sure we've all been visited by the appliance repairman (or auto mechanic, or whatever) who only knows how to replace a single component, and who therefore sees every malfunction as requiring a new control board. I don't want him either! I want the guy who's worked on lots of appliances - not just dishwashers, not just my model - because he's going to have a better idea of how it all works when it's working, and what can go wrong when it's not. At the same time - coming back to the theme of this group - I'm enthusiastic about the idea of people learning to fix their own dishwashers, and - if they love it, and get really good at it - becoming employed as appliance repair professionals. I have now officially over-worked this analogy. There were a couple of other points I wanted to answer, but I'm out of time. It does seem that we mostly agree - certainly we agree that Java stinks! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Interview Questions..
On Fri, May 27, 2011 at 12:51 PM, Marc Tompkins marc.tompk...@gmail.com wrote: That was the point that Joel and I were making. The CS programs that have become Java schools now make the curriculum as easy as possible because they The concept that knowledge/ability to use a language doesn't indicate quality is one I agree with. however: enough, was: Professional programmers - I really supported the effort, years back, to protect the term software engineer - should be familiar with the ins and outs of computers, not just with the quirks of the language they are employed to use. To use my dishwasher analogy from a moment ago, I'm sure Here I disagree. A certain level of base knowledge beyond the requirements of your language is required, true, but a) I think that can be taken too far. I suspect a ton of truly great programmers have never have to memalloc() and they are still good. b) I think this is placing the cart before the horse. To expand on that second point, I see a good programmer as someone that thinks abstractly, that can bounce between big picture and details, that considers concepts like reuse and flexibility without extra effort. They are lazy enough to want to take advantage of existing libraries and diligent enough to fix things the first time. They have curiosity and insight. A person like that will, in time, learn enough about the environment and foundations of their tools to reap all possible benefit from it. Studying those foundations will not make you one of those people, nor will testing for knowledge of those foundations necessarily find you one of those people. And, frankly, I suspect a great many of those people will never wrestle with when exactly their compiler performs tail call elimination. But that's just my suspicion. There were a couple of other points I wanted to answer, but I'm out of time. It does seem that we mostly agree - certainly we agree that Java stinks! One issue I've not seen discussed is some of the specific habits the language encourages. I've never been one to trash a language, believing it's a poor workman that blames his tools, and that almost all tools have their strengths, but having worked with Java (and Java developers) for a while now I've really come to dislike some of the practices that are becoming common: Stacked patterns without understanding the purpose, premature and excessive abstraction, elimination of verbs, and horrendous naming habits. I'm curious to see if any of these habits change if/when Java adds functions as first-class objects. -- Brett Ritter / SwiftOne swift...@swiftone.org ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Could I modify codes and validate immediately withoutrestart program?
Does python has the ability to set cc to 34 after file savings without restarting whole program? No, and I don;t know of any language than can unless you explicitly reload the code. But that is usually a feature of the debugger/interpreter rather than the language. It is not quite the same, but there are debuggers (not sure about for Python) that will let you change the *in memory* value of cc on the fly. Of course, any code change will still not work. Eclipse's Java debugger will let you do small changes on the fly while paused; it will restart from the beginning of the function, but more often than not it will say could not replace because the criteria that is allowed for on the fly changes is *very* narrow. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to European legal entities. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] nested / concatenated function docstrings?
I knew I could set the docstring (and played with it) but I did not realize that would work when the function is imported from a module! Thank you, Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -Original Message- From: tutor-bounces+ramit.prasad=jpmchase@python.org [mailto:tutor-bounces+ramit.prasad=jpmchase@python.org] On Behalf Of Alan Gauld Sent: Thursday, May 26, 2011 7:20 PM To: tutor@python.org Subject: Re: [Tutor] nested / concatenated function docstrings? Prasad, Ramit ramit.pra...@jpmchase.com wrote I would like to have the docstring for function first also contain the docstring for second because it should support/pass any argument second contains. You can explicitly set the docstring by assigning to __doc__: def f(): ... '''here is f's doc string ''' ... return 42 ... def g(): ... return f() + 10 ... g.__doc__ = Here is g's help\n + f.__doc__ help(g) help(g) Help on function g in module __main__: g() Here is g's help here is f's doc string There may be a more elegant way but that seems to work... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to European legal entities. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] nested / concatenated function docstrings?
I knew I could set the docstring (and played with it) but I did not realize that would work when the function is imported from a module! You are changing the doc string of the function in the same module, you couldn't change the docstring of a function in another module - or at least not permanently. Thank you, Ramit___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Interview Questions..
Walter Prins wpr...@gmail.com wrote Java just isn't a hard enough language to separate great programmers from plodders (neither is Python, for that matter) because pointers and memory allocation are taken care of automagically. I fundamentally disagree with his stand on this. Not sure what you're saying here Alan -- are you saying you consider Java hard enough language to seperate great programmers from plodders Yes, I'm saying the language just isn't that significant. you saying that you don't agree with the distinction drawn (that some programmers are plodders and others are not) or what? No, there are plodders and greats, but I'm disagreeing about what constitutes great. When you're hiring programmers, (Joel says) you want people who understand what the computer is actually doing under all the chrome, Thats where I disagree, you might occasionally need a few of those, but not often and not many. you want people who are smart enough to have actually passed classes where they had to do that stuff. And I do want them to have studied the subject and be qualified - either by exam or by experience. their view as, you want people who have some understanding of how the code you've written will actually ends up being executed by the computer in terms of the effective time and space complexity (as well as other potentially problematic aspects) of the code. The efficiency of an algorithm is one thing. The way a computer executes it? That's much harder to guess since much depends on the compiler/interpreter. A good algorithm is usually independant of those things. (So an algorithm that creates zillions of objects in memory is a bad algorithm and you need to be aware of the impact, but you don't usually need to be aware of how the computer is creating those in memory.) point: The same pseudocode/algorithm realised in 2 different languages can have wildly different performance characteristics depending on the nature of the underlying languages and the exact form of the realisation. I would say slight differences depending on language, the same algorithm will generally have the same *relative* performance regardless of language. The quality of the optimiser is likely to be far more important. And in most real world scenarios the quality of data structure design and database choice and network usage are far more likely to cause performance issues than the code. I'd rather have someone who can design a good code structure than someone who can write tight code any day. programmer will never even know unless you have a more than superficial understanding of the language you program in and have some awareness that these types of issues exist I'd have agreed with that 10-15 years ago. Nowadays thats rarely an issue. I haven't had to deal with those kind of issues in a project for at least 10 years. I've had lots of performamce issues to resolve, but the code is the last place I look. what the different performance characteristics of various algorithm classes are. Here we agree. Redesigning the algorithm (and the data structures) are far more likely to solve a performance issue than tightening the code to suit the CPU characteristics. Tightening code can save a few seconds tightening the algorithm/data will save minutes or even hours. Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Clunky Password maker
Steven D'Aprano st...@pearwood.info wrote whrandom was deleted in Python 2.5! Well, I'm using 2.5 but I confess I didn't try it, I looked up my O'Reilly Python standard Library book because I already had it to hand. It obviously predates 2.5! :-) Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Could I modify codes and validateimmediately withoutrestart program?
Prasad, Ramit ramit.pra...@jpmchase.com wrote It is not quite the same, but there are debuggers (not sure about for Python) that will let you change the *in memory* value of cc on the fly. Yes Pythons debugger can set a variable value during a break. But the OP wanted to do it in the source file not in memory. Of course, any code change will still not work. And that was the problem. And a reload() would restart the code from the start. Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Interview Questions..
Marc Tompkins wrote: And anyone who starts down that road will be weeded out very quickly. Not quickly enough! They should be weeded out IN SCHOOL, or before they even commit to a computer-science track. It's cruel to students, inefficient for business, and disastrous for consumers if they don't get weeded out until they're already employed as programmers. I'd like to point out a blog post by Jeff Atwood asking why programmers can't program. Not program well, but program *at all*. http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html Actually, the blog post title is provocatively wrong, since Jeff isn't *actually* saying that 99.5% of working programmers can't program, but that 99.5% of applicants for programming jobs can't write a simple beginner program. Or sometimes even a single line of code. (The correct figure for working programmers is more like 80% *wink*) Hilariously, about half the people writing in to say they easily solved the FizzBuzz problem actually *got it wrong*. One commenter defended the can't-program-programmers by saying: The people who couldn't solve the fizzbuzz test you describe in your article, might be great at solving well defined problems. Presumably he meant well-defined problems *except* the fizzbuzz problem. Follow the links in Jeff's post for more controversy, hilarity and/or analysis of the problem of finding good programmers. Software can only be written by programmers, its the definition of the term. You knew what I meant; don't be coy. Anybody with a wrench and some pipe is a plumber. Doesn't mean I'm letting him work on my dishwasher. Not here in Australia you're not. You can only call yourself a plumber if you are properly licensed and certified. That usually means having gone through *at least* a five(?) year apprenticeship and that they at least know that water flows downhill. The point I was trying to make, which apparently I didn't state clearly enough, was: Professional programmers - I really supported the effort, years back, to protect the term software engineer - should be familiar with the ins and outs of computers, not just with the quirks of the language they are Well, that depends on what you mean by familiar. I like to think that any good programmer should understand that there *are* hardware issues to consider, even if they don't actually know how to consider them. They should know about Big Oh notation, and be able to explain in general terms why bubblesort is so slow and quicksort is usually fast but sometimes becomes slow. If they can actually calculate the best/worst/ average Big Oh running times for a function, that's a bonus. A good programmer should be aware that hardware caches invalidation will make your code run slow, even in a high-level language like Python. A *great* programmer will be able to tell you exactly which code will invalidate the hardware cache, and what to do to stop it. But let's not mistake ignorance with stupidity. An ignorant programmer may have merely never learned about the difference between O(1) and O(2**n) running times, by some accident of education and work experience, but still be a good programmer. A stupid programmer still writes Shlemiel the painter's algorithms even after having them pointed out again and again. http://www.joelonsoftware.com/articles/fog000319.html employed to use. To use my dishwasher analogy from a moment ago, I'm sure we've all been visited by the appliance repairman (or auto mechanic, or whatever) who only knows how to replace a single component, and who therefore sees every malfunction as requiring a new control board. I don't want him either! Not such a good analogy, since modern consumer goods are getting to the point where they are almost unrepairable except by replacing the control board. It often costs you *more* to fix a broken widget than to throw the machine away and buy a new one, e.g. monitors, TVs, DVD players... That's also often the case with computers unless you value your time very low. In my day job, if I have the choice in paying one of my junior techs more than 4 hours to diagnose a flaky piece of hardware, I'd rather just hit it with a hammer and replace the likely suspects (memory, motherboard... whatever is likely to be causing the symptoms). Obviously its a sliding scale -- I don't replace a $14,000 server because a hard drive is broken, but neither do I spend three days trying to be absolutely 100% sure that a $60 power supply is flaky before replacing it. Coming back to programming, sometimes the right answer is to throw more memory at a problem rather than to write better code. A GB of RAM costs, what, $100? That's like what, 1-3 hours of developer time? If it takes you three hours to lower your application's memory requirements by half a gig, you might be throwing money away. That's partly why we program in Python: use a relatively heavyweight
Re: [Tutor] Python Interview Questions..
Alan Gauld wrote: Walter Prins wpr...@gmail.com wrote Java just isn't a hard enough language to separate great programmers from plodders (neither is Python, for that matter) because pointers and memory allocation are taken care of automagically. I fundamentally disagree with his stand on this. Not sure what you're saying here Alan -- are you saying you consider Java hard enough language to seperate great programmers from plodders Yes, I'm saying the language just isn't that significant. Sorry Alan, you confuse me. Do you mean Java isn't that *insignificant*? When you're hiring programmers, (Joel says) you want people who understand what the computer is actually doing under all the chrome, Thats where I disagree, you might occasionally need a few of those, but not often and not many. I think that depends on what you mean by understand. If you mean, should all programmers be like Mel: http://www.catb.org/jargon/html/story-of-mel.html then Hell No!!! But I do believe that all programmers should understand the limitations of the machines they're running on (in Python's case, there's a virtual machine plus the real one), or at least understand that those limitations exist, so they can avoid making silly mistakes or at least recognise it when they do so. I'm not talking about them knowing how to write assembly code, but little things like knowing why the recursive versions of factorial function and the Fibonacci sequence are so damn slow. This is often harder than it sounds in Python, because the C built-in functions are so fast compared to those written in pure Python that for any reasonable amount of data it often is faster to use a O(n**2) function using built-ins than O(n) code in pure Python. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Interview Questions..
On Fri, May 27, 2011 at 8:38 PM, Steven D'Aprano st...@pearwood.infowrote: Not such a good analogy, since modern consumer goods are getting to the point where they are almost unrepairable except by replacing the control board. It often costs you *more* to fix a broken widget than to throw the machine away and buy a new one, e.g. monitors, TVs, DVD players... I kept going way, way too long with the dishwasher analogy, but the actual incident that was stuck in my mind was automotive: a few years ago, my brakes started pulsing whenever I tried to stop, and the brake light was constantly lit. I took it to the dealership; they took a look, and said You need a new anti-lock brake computer. That'll be $1000. That seemed a bit steep to me, so I took it to Midas Brake and Muffler. They took a look, and said You need a new right-front anti-lock brake sensor; that'll be $600. That seemed more reasonable, but when you have two clocks that don't agree you should consult a third, so I went to my regular mechanic (where I should have started in the first place!) He said A stone from the road cut the wire from the right front sensor to the computer. We spliced the wire, wrapped it in heat-shrink tubing and sealed it. That'll be $15. Now, try to re-imagine my analogy with those three mechanics in the place of programmers. Which one should I hire? That's also often the case with computers unless you value your time very low. In my day job, if I have the choice in paying one of my junior techs more than 4 hours to diagnose a flaky piece of hardware, I'd rather just hit it with a hammer and replace the likely suspects (memory, motherboard... whatever is likely to be causing the symptoms). Obviously its a sliding scale -- I don't replace a $14,000 server because a hard drive is broken, but neither do I spend three days trying to be absolutely 100% sure that a $60 power supply is flaky before replacing it. Coming back to programming, sometimes the right answer is to throw more memory at a problem rather than to write better code. A GB of RAM costs, what, $100? That's like what, 1-3 hours of developer time? If it takes you three hours to lower your application's memory requirements by half a gig, you might be throwing money away. This approach may be acceptable for in-house development, or a case where you and three other people use your program. When Microsoft and Apple adopt this philosophy, it makes me incredibly angry - multiply that $100 by all the computers running their crap software, and eventually it adds up to real money. I truly think that one of the tragedies of modern software is that the developers at places like MS, Apple, Adobe, etc. get their computers replaced on a shorter lifecycle than most of the rest of us. I mean, really - have you used Outlook or iTunes, or FSM help us Acrobat, recently? Makes me want to open a vein. And that gets to the point I was trying to make. I am ALL FOR hobbyist and part-time programming - I would not describe myself as a genius programmer, so it's a good thing that it's not my full-time job (although it's my favorite part of my job!) BUT: I damn well want geniuses, and nobody else, working on the software that I have to use to make my living. It pisses me off beyond belief to have to use some Schlemiel's efforts when I'm trying to put food on my family.* And that is why, if I were hiring developers, I would be strongly tempted to skip the resumes from Java schools (even if, FSM help me, my shop actually developed in Java) - there may very well be great programmers who went to those schools, but someone else can find them; I want the ones who've been pre-sifted for me. That's partly why we program in Python: use a relatively heavyweight language environment (at least compared to C or assembly) that allows us to be 10-30 times as productive for the cost of 10 times slower code and twice as much memory. At no time have I advocated developing in assembler. I think that programmers should Get their Stuff Done in the most efficient manner possible. BUT: if you work for me, I want you to have sprained your brain learning how the flippin' machine works. Then, when you come to work for me, I will be ever-so happy to let you work in Python - because I know it's the best way to harness your talent. But (although I love this list, and wish everybody on it well) I would never hire a programmer who had only ever used Python, even if I ran a Python shop. Full disclosure: I am currently cranky on the subject of crap software (and the crap programmers who produce it) because, in one of my non-Python gigs, I've been struggling to update some templates in an Electronic Health Record system (which shall remain nameless.) The template editor was clearly written by a loosely-affiliated team of mental defectives, and it raises my blood pressure every time I get near it. So I may be a little unreasonable on the subject of quality software... *