Re: [Tutor] Python Variables Changing in Other Functions

2011-05-27 Thread Steven D'Aprano
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/pi

Re: [Tutor] Python Variables Changing in Other Functions

2011-05-26 Thread Rachel-Mikel ArceJaeger
Yes it does! Thank you. Rachel On May 25, 2011, at 8:34 PM, Wayne Werner wrote: > On Wed, May 25, 2011 at 10:17 PM, Rachel-Mikel ArceJaeger > wrote: > You asked for the traceback. All I get is this: > - > > python a2.py > File "a2.py", line 20 > titles = [title in my

Re: [Tutor] Python Variables Changing in Other Functions

2011-05-25 Thread Wayne Werner
On Wed, May 25, 2011 at 10:17 PM, Rachel-Mikel ArceJaeger < arcejae...@gmail.com> wrote: > You asked for the traceback. All I get is this: > - > > python a2.py > File "a2.py", line 20 > titles = [title in myFile if title not in ["\n",""]] > > ^ > SyntaxError: invalid synt

Re: [Tutor] Python Variables Changing in Other Functions

2011-05-25 Thread Rachel-Mikel ArceJaeger
You asked for the traceback. All I get is this: - python a2.py File "a2.py", line 20 titles = [title in myFile if title not in ["\n",""]] ^ SyntaxError: invalid syntax -- (In c

Re: [Tutor] Python Variables Changing in Other Functions

2011-05-25 Thread Wayne Werner
On Wed, May 25, 2011 at 3:59 PM, Rachel-Mikel ArceJaeger < arcejae...@gmail.com> wrote: > Thank you so much for taking the time to comment this all out. It was very > very helpful and showed me improvements to some coding styles I have been > doing for years. I have a couple of questions, though:

Re: [Tutor] Python Variables Changing in Other Functions

2011-05-25 Thread Alan Gauld
"Rachel-Mikel ArceJaeger" wrote I'm not sure I like this one much... def rank( randomizedTitles, dictOfTitles ): """ Gets a user-input ranking (0-10) for each line of text. Returns those rankings """ for title in randomizedTitles: while True:

Re: [Tutor] Python Variables Changing in Other Functions

2011-05-25 Thread Prasad, Ramit
>>> I'm not quite certain I understand. When you say sections, do you mean >>> different worksheets? If so, you should finish writing on one worksheet >>> first, and then move to another. If you're talking about writing to row 5, >>> and then jumping to row 50, enumerate lets you do that by allo

Re: [Tutor] Python Variables Changing in Other Functions

2011-05-25 Thread Rachel-Mikel ArceJaeger
I'm not quite certain I understand. When you say sections, do you mean different worksheets? If so, you should finish writing on one worksheet first, and then move to another. If you're talking about writing to row 5, and then jumping to row 50, enumerate lets you do that by allowing you to dete

Re: [Tutor] Python Variables Changing in Other Functions

2011-05-25 Thread Prasad, Ramit
>> Having lots of += hanging around is a perfect example of a code smell (i.e. >> something in this code stinks, and we should change >>it). Part of being a >> good programmer is learning to recognize those bad smells and getting rid of >> them. Turns out, Python has a lot >>of nice built-in fun

Re: [Tutor] Python Variables Changing in Other Functions

2011-05-25 Thread Wayne Werner
On Tue, May 24, 2011 at 11:14 PM, Rachel-Mikel ArceJaeger < arcejae...@gmail.com> wrote: > 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: > Andre already mentioned that you shouldn't think of Python as 'pass-

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.