Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > how to force a list to be local?

Reply
Thread Tools

how to force a list to be local?

 
 
Mark Harrison
Guest
Posts: n/a
 
      08-05-2004
In the following code, t1 does not modify b, while t2 seems to
modify b. What do I need to do in order to make b local in t2
so that b.remove() does not modify the passed in list?

def t1(a,b):
b = []

def t2(a,b):
b.remove(4)


a=[1,2,3]
b=[4,5]

t1(a,b)
print a,b

t2(a,b)
print a,b

results:
[1, 2, 3] [4, 5]
[1, 2, 3] [5]

Many TIA!
Mark

--
Mark Harrison
Pixar Animation Studios
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Nike air force one, air force 1, air force one low cut, air force one abdul_razak@indiatimes.com Digital Photography 2 12-31-2008 04:29 PM
Nike Air Force Ones,Air Force One Air Force One-1 lky52193@gmail.com Computer Support 0 01-17-2008 04:40 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:46 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:34 PM



Advertisments