how to clear up a List in python?

S

Steve Holden

vbgunz said:
I much rather stand corrected than to silently remain ignorant. I take
revision of my solution for all it's worth but to be belittled without
correction is arrogant and unnecessary. I've been working with Python
for several months now and I feel I know plenty *but* I am still
learning.

I personally never had to clear a list. I never thought of Roberts
answer and my reasoning is in Roberts message. In the end I stood
correct because Robert was nice enough to answer two birds with one
stone. Fredrik on the other hand had nothing positive to add and his
message seemed gestapo.

Where I come from and how I grew up is quite simple. A wrong answer is
better than no answer and a worthless remark is worth garbage. Why?
Because no right answer is gospel and no answer no matter how dumb is
cause for discourtesy. I tried and thats the bottom line.
Frankly I can't agree that a wrong answer is better than no answer,
despite my frequent strategy of opining that something is impossible
just so the cleverer denizens of c.l.py will prove me wrong. A wrong
answer requires correction by people who know the "right" answer, so you
end up consuming group bandwidth and mindshare unnecessarily.

I am assuming the part of Fredrik's post that "seemed gestapo" to you
is """if you don't know how to do things, you don't need to post."""

Please read this carefully, as Fredrik's use of language is precise: he
doesn't say you *shouldn't* post, he says you don't *need to*. This is
good advice, because posting a lame solution too quickly, while
reflecting an earnest and praiseworthy desire to help, can often lead to
trouble with some of the less patient members of our community.

You did indeed try, and I give you points for that. I'd have given you
more points for a further response along the lines of """[Smacks head!]
of course, my solution wasn't very clever, was it?"

Later in this thread (the time machine tells me) you go on to say:
I bet you enjoy stealing candy from babies and dunging on the little
guy every chance you get. You're suppose to be a role model in this
community? Your temper tantrum and unrelenting 'look at me look at me
i'm bigger and better' machismo attitude is nothing more than a decoyed
ploy set out by a deluded megalomaniac. You're promoting Python or the
fact that you're the son of Zeus and Hera? You're the worse sore losing
cry baby I've ever witnessed on the net in my ten years here...
pathetic for sure...

Now that's the kind of behaviour I work hard to discourage on this
newsgroup (and everywhere else I can, come to that: you may have noticed
an improvement in President Bush's response to press questions about
Iraq yesterday).

As it happens, although Fredrik and I have corresponded for almost ten
years we have only just met this week at the Need for Speed sprint. I
can tell you the man is a pussy cat, and any offense you might feel is
due to your wounded pride, not his desire to hurt. So go Google for
"egoless programming", take your knocks, and learn to simply apologise
when you are wrong and get on with your life.

The ability to do this has stood me in good stead for many years. I am
hoping against hope that you won't, like Oscar Wilde, feel that "The
only thing you can possibly do with good advice is pass it on". Time
alone will tell. A hint:

http://www.codinghorror.com/blog/archives/000584.html

regards
Steve
 
V

vbgunz

Steve, I have no qualm with Fredrik over this '''if you don't know how
to do things, you don't need to post.''' but this ''' if you know why
this is about the dumbest way to do what you're doing, and you're
posted this on purpose, you really need to grow up.'''.

The problem was I did post it on purpose, but not with the intent to
mess anyone up over it. To top it off, this thread was done and over
with (the end) with Roberts reply that came in immediately after mines.
I acknowledged his was best and that I *learned* from it.

It just seemed Fredriks response was an attack on me and I did take it
personally because I tried my best. Sometimes I try to give back but to
try and make me regret it is poor communication if the best intent is
to advise me on how things are done and not done around here...

Its all good. I live and I learn...
 
S

Steve Holden

vbgunz said:
George, if Frederik's first reply was replaced with yours chances are
this little waste of time would have never had taken place. I am not an
animal and I am capable of understanding my mistakes but trying to
embarass me and belittle me in front of all of my peers here when all I
tried to do was help is absolutely pathetic the first time around.
That's "Georg", by the way ...
I don't try to come off as a know it all here and I don't feel I should
post a gospel warning label on my help signature but Fredrik could have
delivered his message in a much better tone. I too am learning Python
and if maybe my answer was not evident enough of that then how smart is
Fredrik to persecute me for it?
Man, if you think *that* was persecution don't *ever* take up Lisp or
Perl, where they will eat you alive just for not knowing something.
I don't wish to question Fredriks knowledge or his position in the
whole scheme of Python but to disrespect me in the name of arrogance
and call it just is a mislabel. I don't wish to carry on with this, I
don't... I just have no love for a bully and Fredrik is proving himself
to be just that.
No he isn't. Like Python itself this group is for consenting adults, and
you are letting your emotions get in the way of an adult response.
Good day George!
regards
Steve
 
L

Luis Armendariz

vbgunz said:
Steve, I have no qualm with Fredrik over this '''if you don't know how
to do things, you don't need to post.''' but this ''' if you know why
this is about the dumbest way to do what you're doing, and you're
posted this on purpose, you really need to grow up.'''.

Well, given that you did post it on purpose and had no "intent to mess
anyone up over it", it is clear that the antecedent in Fredrik's
if-statement is not satisfied and therefore your mind should've skipped
the consequent statement when reading his response. Why get so upset
about something that didn't even apply to you? :)

-Luis
 
V

vbgunz

Well, given that you did post it on purpose and had no "intent to mess
anyone up over it", it is clear that the antecedent in Fredrik's
if-statement is not satisfied and therefore your mind should've skipped
the consequent statement when reading his response. Why get so upset
about something that didn't even apply to you? :)

I wish I could've intepreted it like that... I guess that is one of the
evils of being human. the uncanny ability to intepret ambiguous
understatements and then say fork it when technically you're correct...
it really did not apply to me... The evil of being human I suppose :p

I apologize to Fredrik for my outburst but would like to request that
next time a better suited address be in order even if in doubt. Not
everyone is aware of egoless programming...
 
S

Steve Holden

vbgunz said:
I read the ten commandments. I enjoyed the link. I see my mistakes.
Thank you.
A genuine pleasure. Welcome to comp.lang.python.

regards
Steve
 
L

linnorm

The original post only mentions deleting the values in the list, not
the list itself. Given that you want to keep the list and just ditch
the values it contains I'd go with:

list1 = []

-Linnorm
 
M

Mel Wilson

The original post only mentions deleting the values in the list, not
the list itself. Given that you want to keep the list and just ditch
the values it contains I'd go with:

list1 = []

Depends what you mean by "keep the list". Consider

class C (object):
def __init__ (self, things):
self.things = things

a = range (5)
b = C (a)
a = []
print b.things

d = range (5)
e = C (d)
d[:] = []
print e.things



These are very different.
Mel.
 
D

Duncan Smith

The original post only mentions deleting the values in the list, not
the list itself. Given that you want to keep the list and just ditch
the values it contains I'd go with:

list1 = []

-Linnorm

Which rebinds list1 to a new (empty) list. It doesn't clear the
original list (which appears to be what the OP wants).
list2 = [0,1,2,3,4,5]
list1 = list2
list1 = []
list2 [0, 1, 2, 3, 4, 5]

Duncan
 
D

Duncan Smith

chris said:
Doesnt this do what the original poster is try accomplish?

Not what the OP asked for, no. Clearing a list implies that list1
should still be bound to the same list (which might be important if
there are other names bound to the same list). If it wasn't important
that it be bound to the same list then I would probably go with
linnorm's approach (which isn't really 'clearing' the list).
list1 = [0,1,2,3]
id(list1) 10772728
del list1[:]
list1 []
id(list1) 10772728 # i.e. the same list
list1 = [0,1,2,3]
id(list1) 10675264
list1 = []
id(list1) 10603576 # i.e. a different list

Duncan
 
E

Erik Max Francis

vbgunz said:
Steve, I have no qualm with Fredrik over this '''if you don't know how
to do things, you don't need to post.''' but this ''' if you know why
this is about the dumbest way to do what you're doing, and you're
posted this on purpose, you really need to grow up.'''.

The problem was I did post it on purpose, but not with the intent to
mess anyone up over it.

His statement was a conditional. Since you're saying that the
conditional does not apply, then neither does his conclusion. So his
statement doesn't apply to you. So calm down.
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Duncan said:
Not what the OP asked for, no. Clearing a list implies that list1
should still be bound to the same list (which might be important if
there are other names bound to the same list). If it wasn't important
that it be bound to the same list then I would probably go with
linnorm's approach (which isn't really 'clearing' the list).

Sure. However, the OP still might have been happy with just discarding
the old list and creating a new one. Although he explicitly said "clear
the list", he might have meant "make it so that the variable refers to
an empty list", to which clearing the list is only one possible
solution.

Regards,
Martin
 
B

Bruno Desthuilliers

D H a écrit :
Fredrik said:
vbgunz said:
I have new a list , when it hava large number of values, I wonna to
delete all the values in it,how to do?


something like this will probably help.

x = [1,2,3,4,5,6,7,8,9]
y = x

list([x.pop() for z in xrange(len(x))])

print x, y # [] []


if you don't know how to do things, you don't need to post.

if you know why this is about the dumbest way to do what you're doing,
and you're posted this on purpose, you really need to grow up.

</F>


He already posted before your post that he made a mistake.

Not the same one. Or there are missing posts on my provider's usenet
service.
You obviously ignored that and invented some argument that he
posted with malicious intentions.

Fredrik may have been a bit harsh, but the fact is that vbgunz's
solution for clearing a list *is* the dumbest possible - and it should
be obvious for anyone past CS101. Now since a lot of Python newbies read
this newsgroup, uncorrected bad answers are far worse than no answer at all.
That better describes most of
your thousands of annoying posts.

Fredrik - aka the effbot - is a Python expert, and a major contributor
here. He's known to be usually very helpful, even for questions that are
in the Fine Manual or in the FAQs. I'm afraid you can say so. You may
not like the way he corrected vbgunz - and I'll wholefully agree on this
- but this last sentence is total bullshit.
 
A

Antoon Pardon

Op 2006-05-26 said:
Frankly I can't agree that a wrong answer is better than no answer,
despite my frequent strategy of opining that something is impossible
just so the cleverer denizens of c.l.py will prove me wrong. A wrong
answer requires correction by people who know the "right" answer, so you
end up consuming group bandwidth and mindshare unnecessarily.

I am assuming the part of Fredrik's post that "seemed gestapo" to you
is """if you don't know how to do things, you don't need to post."""

But if we all wait until we are perfectly sure that the answer we
will provide is correct, then no-one will need to answer. I
have even seen Fredrik post an answer that IMO was at least outdated.
Please read this carefully, as Fredrik's use of language is precise: he
doesn't say you *shouldn't* post, he says you don't *need to*. This is
good advice, because posting a lame solution too quickly, while
reflecting an earnest and praiseworthy desire to help, can often lead to
trouble with some of the less patient members of our community.

Maybe those less patient members should take the same advise: They
don't need to react.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top