Re: [Tutor] Python Variables Changing in Other Functions

2011-05-24 Thread Andre Engels
On Wed, May 25, 2011 at 6:14 AM, Rachel-Mikel ArceJaeger wrote: > I am having trouble with determining when python is passing by reference and > by value and how to fix it to do what I want: > > I am writing a program that will take in a list of book titles and will allow > many people to rank

[Tutor] Python Variables Changing in Other Functions

2011-05-24 Thread Rachel-Mikel ArceJaeger
Hello, I am having trouble with determining when python is passing by reference and by value and how to fix it to do what I want: I am writing a program that will take in a list of book titles and will allow many people to rank them in terms of popularity and will export the results to Excel.

Re: [Tutor] Need help wrapping my head around duck typing

2011-05-24 Thread Cory Teshera-Sterne
Hmm ... I thought I was going to try to keep this as general as possible, but it may be more helpful if I gave a more concrete example. The code below is the existing function; I'd be ok with throwing it out & starting over, but originally thought I could modify it fairly easily. The directory str

Re: [Tutor] Need help wrapping my head around duck typing

2011-05-24 Thread Wayne Werner
On Tue, May 24, 2011 at 9:17 PM, Cory Teshera-Sterne wrote: > Hello, > > Thanks for the input. I guess you're right, this is more of a case of > argument assertion - but then I'm not sure how to do error handling here, > because, for example, multiple issues that should be dealt with in very > dif

Re: [Tutor] Need help wrapping my head around duck typing

2011-05-24 Thread Cory Teshera-Sterne
Hello, Thanks for the input. I guess you're right, this is more of a case of argument assertion - but then I'm not sure how to do error handling here, because, for example, multiple issues that should be dealt with in very different ways could raise the same error (as in the original example). I'

Re: [Tutor] Need help wrapping my head around duck typing

2011-05-24 Thread Izz ad-Din Ruhulessin
I forgot to mention strptime 2011/5/25 Izz ad-Din Ruhulessin > Hi Cory, > > From your description it seems to me that your case is more one of > asserting that your function received valid arguments, than a matter of > stat

Re: [Tutor] Need help wrapping my head around duck typing

2011-05-24 Thread Izz ad-Din Ruhulessin
Hi Cory, >From your description it seems to me that your case is more one of asserting that your function received valid arguments, than a matter of static-vs-ducktyping. Even with type checking, they can still generate errors (out of bounds, incorrect formatting). Now i've seen some discussions

Re: [Tutor] Python Interview Questions..

2011-05-24 Thread ian douglas
To expand on Martin's questions, when I've interviewed in the past, I've asked (or been asked as an interviewee) questions that investigate critical thinking, like those silly-sounding questions of "how many golf balls would fit in a bus" or "how many windows are there in Seattle". Those kinds

Re: [Tutor] Python Interview Questions..

2011-05-24 Thread Martin A. Brown
Hi there, : Hey I'll be appearing for Job Interviews and wondering if anybody : of you appeared for a Python Interview Or if on the other end as : an interviewer.   Can you please share the questions asked?   : That will be of great help :) I would point out that there are many types of i

Re: [Tutor] Python Interview Questions..

2011-05-24 Thread Alan Gauld
"Neha P" wrote Hey I'll be appearing for Job Interviews and wondering if anybody of you appeared for a Python Interview Or if on the other end as an interviewer. Can you please share the questions asked? I've been an interviewer many times, but the approach we use is a tehnique called, among

[Tutor] Python Interview Questions..

2011-05-24 Thread Neha P
Hey I'll be appearing for Job Interviews and wondering if anybody of you appeared for a Python Interview Or if on the other end as an interviewer.   Can you please share the questions asked?   That will be of great help :) Regards, Neha___ Tutor maillis

[Tutor] Need help wrapping my head around duck typing

2011-05-24 Thread Cory Teshera-Sterne
Hi folks, Coming from a language background that has a different approach to variables (*cough* Java *cough*), I'm trying to understand Python's typing conventions and how to deal with unknown variable types in my code. And as a newbie, I'm really concerned with not writing code that will make the

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Walter Prins
Hi Hank, On 24 May 2011 15:15, Hank Wilkinson wrote: > Yes, I would love to know why it doesn't work, or what I'm doing wrong. > > John-Wilkinsons-iMac:p31summerfield wilkinson$ cat hello.py > #!/usr/bin/env python > > print("Hello world") > John-Wilkinsons-iMac:p31summerfield wilkinson$ chmod +

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Hank Wilkinson
Yes, I would love to know why it doesn't work, or what I'm doing wrong. John-Wilkinsons-iMac:p31summerfield wilkinson$ cat hello.py #!/usr/bin/env python print("Hello world") John-Wilkinsons-iMac:p31summerfield wilkinson$ chmod +X hello.py John-Wilkinsons-iMac:p31summerfield wilkinson$ ./hello.py

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Walter Prins
On 24 May 2011 14:51, Hank Wilkinson wrote: > Thank you, I changed the first line to: > #!/usr/bin/env/python3 > then I tried again: > John-Wilkinsons-iMac:p31summerfield wilkinson$ ./hello.py > -bash: ./hello.py: /usr/bin/env/python3^M: bad interpreter: Not a directory > John-Wilkinsons-iMac:p31

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Walter Prins
On 24 May 2011 14:53, Hank Wilkinson wrote: > Thank you. > John-Wilkinsons-iMac:p31summerfield wilkinson$ which python > /opt/local/bin/python > > OK excellent.So you can either use '#!/opt/local/bin/python' in your script, or alternatively '/usr/bin/env python' (presuming that you have 'env'

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Hank Wilkinson
Thank you. John-Wilkinsons-iMac:p31summerfield wilkinson$ which python /opt/local/bin/python On May 24, 2011, at 9:27 AM, Walter Prins wrote: > The problem likely is as intimated by the error message that your python > interpreter not called "/usr/local/bin/python3.1" but I'd offhand guess, >

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Hank Wilkinson
Thank you, I changed the first line to: #!/usr/bin/env/python3 then I tried again: John-Wilkinsons-iMac:p31summerfield wilkinson$ ./hello.py -bash: ./hello.py: /usr/bin/env/python3^M: bad interpreter: Not a directory John-Wilkinsons-iMac:p31summerfield wilkinson$ So I am getting different message

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Peter Otten
Hank Wilkinson wrote: > I am trying to do script in python using "./" > Here is a session showing "bad interpreter: No such file or directory" > Is this a python question/problem? It's a bash problem. The shell cannot cope with Windows line endings: ^M in the error message stands for chr(13) or

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Christian Witts
On 2011/05/24 03:10 PM, Hank Wilkinson wrote: I am trying to do script in python using "./" Here is a session showing "bad interpreter: No such file or directory" Is this a python question/problem? Last login: Sat May 21 14:22:49 on ttys000 John-Wilkinsons-iMac:~ wilkinson$ cd /Users/wilkinson/

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Flynn, Stephen (L & P - IT)
You missed a "*" from the end of the ls command but it matters not. Your python executable is named "/usr/local/bin/python3" so if you change the first line of your script to... #!/usr/local/bin/python3 ...you should get along much better! :) S. -Original Message- From: Hank Wilkinson

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Joel Goldstick
On Tue, May 24, 2011 at 9:10 AM, Hank Wilkinson wrote: > I am trying to do script in python using "./" > Here is a session showing "bad interpreter: No such file or directory" > Is this a python question/problem? > > Last login: Sat May 21 14:22:49 on ttys000 > John-Wilkinsons-iMac:~ wilkinson$ cd

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Hank Wilkinson
John-Wilkinsons-iMac:p31summerfield wilkinson$ ls -al /usr/local/bin/python ls: /usr/local/bin/python: No such file or directory John-Wilkinsons-iMac:p31summerfield wilkinson$ ls -al /usr/local/bin/python3 lrwxr-xr-x 1 root wheel 69 Mar 21 13:45 /usr/local/bin/python3 -> ../../../Library/Framew

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Hank Wilkinson
Here is what you asked me: John-Wilkinsons-iMac:p31summerfield wilkinson$ ls -al /usr/local/bin/pytho* lrwxr-xr-x 1 root wheel 69 Mar 21 13:45 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.1/bin/python3 lrwxr-xr-x 1 root wheel 76 Mar 21 13:45 /usr/local/bi

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Walter Prins
The problem likely is as intimated by the error message that your python interpreter not called "/usr/local/bin/python3.1" but I'd offhand guess, probably "/usr/local/bin/python". (Indeed, you run the interpreter yourself as "python" not "python3.1" so you should not be using "python3.1" in your s

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Flynn, Stephen (L & P - IT)
What is your Python executable called? You refer to it as "python" on the command line but your "#!" line in your script refers to the executable as "python3.1". tried it with just "python" in the #! Line? Check the output of 'ls -al /usr/local/bin/pytho*'... S. -Original Message- From:

[Tutor] python scripting using "./"

2011-05-24 Thread Hank Wilkinson
I am trying to do script in python using "./" Here is a session showing "bad interpreter: No such file or directory" Is this a python question/problem? Last login: Sat May 21 14:22:49 on ttys000 John-Wilkinsons-iMac:~ wilkinson$ cd /Users/wilkinson/Documents/py32/p31summerfield John-Wilkinsons-iM

Re: [Tutor] Parsing an XML document using ElementTree

2011-05-24 Thread Stefan Behnel
Sithembewena Lloyd Dube, 24.05.2011 11:59: I am trying to parse an XML feed and display the text of each child node without any success. My code in the python shell is as follows: >>> import urllib >>> from xml.etree import ElementTree as ET >>> content = urllib.urlopen(' http://xml.matchbook.c

Re: [Tutor] Parsing an XML document using ElementTree

2011-05-24 Thread Alan Gauld
"Sithembewena Lloyd Dube" wrote And now, to iterate through its child nodes and print out the text of each node: for node in xml_content.getiterator('contest'): ...name = node.attrib.get('text') ...print name ... Nothing is printed, i = 0 for node in xml_content.geti

[Tutor] Parsing an XML document using ElementTree

2011-05-24 Thread Sithembewena Lloyd Dube
Hi Everyone, I am trying to parse an XML feed and display the text of each child node without any success. My code in the python shell is as follows: >>>import urllib >>>from xml.etree import ElementTree as ET >>>content = urllib.urlopen(' http://xml.matchbook.com/xmlfeed/feed?sport-id=&vendor=T