Either I'm crazy and I'm missing the obvious here or there is something
wrong with this code. Element 5 of this list says it doesn't contain the
string 255, when that's *ALL* it contains... why would it think that???
import time
ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98',
'127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
for ip in ips:
if '255' in ip:
try:
print "Removing", ip
ips.remove(ip)
except Exception, e:
print e
print ips
time.sleep(5)
Someone tell me I'm going crazy ;) 28 1490
I think it's because you're modifying the list as you're iterating over
it. Try this:
import time
ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98',
'127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
ips_new = []
for ip in ips:
if '255' not in ip:
ips_new.append(ip)
print ips_new
Or this:
ips_new = [ip for ip in ips if '255' not in ip]
print ips_new
Hope this helps,
Alan McIntyre http://www.esrgtech.com
rbt wrote: Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL* it contains... why would it think that???
import time
ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', '127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
for ip in ips: if '255' in ip: try: print "Removing", ip ips.remove(ip) except Exception, e: print e
print ips time.sleep(5)
Someone tell me I'm going crazy ;)
rbt wrote: Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL* it contains... why would it think that???
import time
ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', '127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
for ip in ips: if '255' in ip: try: print "Removing", ip ips.remove(ip) except Exception, e: print e
print ips time.sleep(5)
Someone tell me I'm going crazy ;)
You're going crazy. ;)
py> ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98',
'127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
py> for ip in ips:
.... # debugging statement:
.... print "Looking at", ip
.... if '255' in ip:
.... try:
.... print "Removing", ip
.... ips.remove(ip)
.... except Exception, e:
.... print e
....
Looking at 255.255.255.255
Removing 255.255.255.255
Looking at 198.82.247.98
Looking at 127.0.0.1
Looking at 255.0.0.0
Removing 255.0.0.0
Looking at 128.173.255.34
Removing 128.173.255.34
Notice how elements of your list are being skipped. The problem is that
you're modifying a list while you iterate over it.
Why don't you try a list comprehension:
py> ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98',
'127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
py> [ip for ip in ips if '255' not in ip]
['128.173.120.79', '198.82.247.98', '127.0.0.1']
Steve
rbt wrote: Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL* it contains... why would it think that???
import time
ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', '127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
for ip in ips: if '255' in ip: try: print "Removing", ip ips.remove(ip) except Exception, e: print e
print ips time.sleep(5)
Someone tell me I'm going crazy ;)
You are modifying the list as you iterate over it. Instead, iterate over
a copy by using:
for ip in ips[:]:
...
regards
Steve
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005 http://www.pycon.org/
Steve Holden http://www.holdenweb.com/
On Fri, 04 Feb 2005 14:23:36 -0500, rbt <rb*@athop1.ath.vt.edu> wrote: Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL* it contains... why would it think that???
import time
ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', '127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
for ip in ips: if '255' in ip: try: print "Removing", ip ips.remove(ip) except Exception, e: print e
print ips time.sleep(5)
You're gong crazy: ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98',
.... '127.0.0.1', '255.0.0.0', '255', '128.173.255.34'] for ip in ips:
.... if '255' in ip: print ip
....
255.255.255.255
255.0.0.0
255
128.173.255.34
The problem is that you're operating in-place on an array while it's
being iterated over. Since the iterator is only created once, you're
can't change the array while you're iterating over it. Instead, try a
list comprehension:
ips = [ip for ip in ips if '255' not in ip] ips
['128.173.120.79', '198.82.247.98', '127.0.0.1']
Peace
Bill Mill
bill.mill at gmail.com
Thanks guys... list comprehension it is!
Bill Mill wrote: On Fri, 04 Feb 2005 14:23:36 -0500, rbt <rb*@athop1.ath.vt.edu> wrote:
Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL* it contains... why would it think that???
import time
ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', '127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
for ip in ips: if '255' in ip: try: print "Removing", ip ips.remove(ip) except Exception, e: print e
print ips time.sleep(5)
You're gong crazy:
ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', ... '127.0.0.1', '255.0.0.0', '255', '128.173.255.34'] for ip in ips: ... if '255' in ip: print ip ... 255.255.255.255 255.0.0.0 255 128.173.255.34
The problem is that you're operating in-place on an array while it's being iterated over. Since the iterator is only created once, you're can't change the array while you're iterating over it. Instead, try a list comprehension:
ips = [ip for ip in ips if '255' not in ip] ips
['128.173.120.79', '198.82.247.98', '127.0.0.1']
Peace Bill Mill bill.mill at gmail.com
Wow, that's cool; I'd never seen that before. :) Thanks, Steve..
Steve Holden wrote: You are modifying the list as you iterate over it. Instead, iterate over a copy by using:
for ip in ips[:]: ...
regards Steve
Steve Holden wrote: rbt wrote:
Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL* it contains... why would it think that???
import time
ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', '127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
for ip in ips: if '255' in ip: try: print "Removing", ip ips.remove(ip) except Exception, e: print e
print ips time.sleep(5)
Someone tell me I'm going crazy ;)
You are modifying the list as you iterate over it. Instead, iterate over a copy by using:
for ip in ips[:]: ...
regards Steve
Very neat. That's a trick that everyone should know about. I vote it
goes in Dr. Dobbs newsletter.
Steve Holden wrote: You are modifying the list as you iterate over it. Instead, iterate over a copy by using:
for ip in ips[:]: ...
Also worth noting, you can write this like:
for ip in list(ips):
...
if you're afraid of smiley-faces [:] in your code. ;)
Steve
Alan McIntyre wrote: I think it's because you're modifying the list as you're iterating over
In this case then, shouldn't my 'except Exception' raise an error or
warning like:
"Hey, stupid, you can't iterate and object and change it at the same time!"
Or, perhaps something similar?
"rbt" <rb*@athop1.ath.vt.edu> wrote: You are modifying the list as you iterate over it. Instead, iterate over a copy by using:
for ip in ips[:]: ...
regards Steve
Very neat. That's a trick that everyone should know about.
I suppose that's why it's included in the Python tutorial: http://docs.python.org/tut/node6.htm...00000000000000
It is not safe to modify the sequence being iterated over in the loop
(this can only happen for mutable sequence types, such as lists). If
you need to modify the list you are iterating over (for example, to
duplicate selected items) you must iterate over a copy. The slice
notation makes this particularly convenient: for x in a[:]: # make a slice copy of the entire list
... if len(x) > 6: a.insert(0, x)
(slice notation is explained in an earlier chapter)
</F>
Alan McIntyre wrote: I think it's because you're modifying the list as you're iterating over it.
One last clarification on this. It's OK to modify the elements of a
list, but not the list itself while iterating over it... is that the
correct way to think about this?
On Fri, 04 Feb 2005 14:43:30 -0500, rbt <rb*@athop1.ath.vt.edu> wrote: Steve Holden wrote: rbt wrote:
Either I'm crazy and I'm missing the obvious here or there is something wrong with this code. Element 5 of this list says it doesn't contain the string 255, when that's *ALL* it contains... why would it think that???
import time
ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', '127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
for ip in ips: if '255' in ip: try: print "Removing", ip ips.remove(ip) except Exception, e: print e
print ips time.sleep(5)
Someone tell me I'm going crazy ;)
You are modifying the list as you iterate over it. Instead, iterate over a copy by using:
for ip in ips[:]: ...
regards Steve
Very neat. That's a trick that everyone should know about. I vote it goes in Dr. Dobbs newsletter.
Once you know it, it's neat, and I use it sometimes. However, it's a
little too "magical" for my tastes; I'd rather be more explicit about
what's going on.
Peace
Bill Mill
bill.mill at gmail.com
-- http://mail.python.org/mailman/listinfo/python-list
Steve Holden <st***@holdenweb.com> writes:
[...] You are modifying the list as you iterate over it. Instead, iterate over a copy by using:
for ip in ips[:]: ...
Just to help popularise the alternative idiom, which IMO is
significantly less cryptic (sane constructors of mutable objects
almost always make a copy, and list is no exception: it's guaranteed
to do so):
for ip in list(ips):
...
Works back to at least Python 1.5.2.
John
John J. Lee wrote: Steve Holden <st***@holdenweb.com> writes: [...]
You are modifying the list as you iterate over it. Instead, iterate over a copy by using:
for ip in ips[:]: ...
Just to help popularise the alternative idiom, which IMO is significantly less cryptic (sane constructors of mutable objects almost always make a copy, and list is no exception: it's guaranteed to do so):
for ip in list(ips): ...
Works back to at least Python 1.5.2.
John
I don't know that that approach is less cryptic. ips is already a
list... it looks cryptic to make it a list again, doesn't it? IMO, the
two are equally cryptic. The epitome of clarity would be copy(ips)...
now *that* makes sense, of course, ips[:] or list(ips) work equally well
to the programmer who has learned them.
On Fri, 04 Feb 2005 14:49:43 -0500, rbt wrote: Alan McIntyre wrote: I think it's because you're modifying the list as you're iterating over
In this case then, shouldn't my 'except Exception' raise an error or warning like:
"Hey, stupid, you can't iterate and object and change it at the same time!"
But you can do that, so why should it?
Certain operations are dangerous, but, well, it's impossible to enumerate
all the dangerous things and it's better to not give people false
assurances when they find one of them that slipped by.
One idiom that does what you want, though it doesn't always work for all
situations, is to iterate over the list backwards. If you're only removing
a few items from a short list, that can be faster than building a new one.
However, removing items gets to be n^2 pretty fast, so it can be better to
build a new list, which the list comprehensions make easy:
newList = [x for x in oldList if myCondition(x)]
On Fri, 04 Feb 2005 15:25:04 -0500, rbt <rb*@athop1.ath.vt.edu> wrote: John J. Lee wrote: Steve Holden <st***@holdenweb.com> writes: [...]
You are modifying the list as you iterate over it. Instead, iterate over a copy by using:
for ip in ips[:]: ...
Just to help popularise the alternative idiom, which IMO is significantly less cryptic (sane constructors of mutable objects almost always make a copy, and list is no exception: it's guaranteed to do so):
for ip in list(ips): ...
Works back to at least Python 1.5.2.
John
I don't know that that approach is less cryptic. ips is already a list... it looks cryptic to make it a list again, doesn't it? IMO, the two are equally cryptic. The epitome of clarity would be copy(ips)... now *that* makes sense, of course, ips[:] or list(ips) work equally well to the programmer who has learned them.
Howsabout: from copy import copy ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98',
.... '127.0.0.1', '255.0.0.0', '255', '128.173.255.34'] for ip in copy(ips):
.... if '255' in ip:
.... ips.remove(ip)
.... ips
['128.173.120.79', '198.82.247.98', '127.0.0.1']
But I still think that the list comprehension is the best.
Peace
Bill Mill
bill.mill at gmail.com
-- http://mail.python.org/mailman/listinfo/python-list
Bill Mill wrote: On Fri, 04 Feb 2005 15:25:04 -0500, rbt <rb*@athop1.ath.vt.edu> wrote:
John J. Lee wrote:
Steve Holden <st***@holdenweb.com> writes: [...]
You are modifying the list as you iterate over it. Instead, iterate over a copy by using:
for ip in ips[:]: ...
Just to help popularise the alternative idiom, which IMO is significantly less cryptic (sane constructors of mutable objects almost always make a copy, and list is no exception: it's guaranteed to do so):
for ip in list(ips): ...
Works back to at least Python 1.5.2.
John
I don't know that that approach is less cryptic. ips is already a list... it looks cryptic to make it a list again, doesn't it? IMO, the two are equally cryptic. The epitome of clarity would be copy(ips)... now *that* makes sense, of course, ips[:] or list(ips) work equally well to the programmer who has learned them.
Howsabout:
from copy import copy ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', ... '127.0.0.1', '255.0.0.0', '255', '128.173.255.34'] for ip in copy(ips): ... if '255' in ip: ... ips.remove(ip) ... ips
['128.173.120.79', '198.82.247.98', '127.0.0.1']
But I still think that the list comprehension is the best.
Peace Bill Mill bill.mill at gmail.com
Wow, I did not know that a copy module existed. I made all that up about
copy being the perfect example here. Great minds think alike ;) I fell
Guidoish.
"Steve Holden" <st***@holdenweb.com> wrote in message
news:36QMd.103084$Jk5.36127@lakeread01... You are modifying the list as you iterate over it. Instead, iterate over > a copy by using: for ip in ips[:]:
Or if you are only deleting items, you can iterate backwards.
You can also build a new list with only the items you want. Do this either
with an explicit loop or even better, use filter or a list comp.
ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98',
'127.0.0.1', '255.0.0.0', '255', '128.173.255.34']
# 2.2 requires single char for 'not in string' test
ips2 = []
for ip in ips:
if ip.find('255') == -1: ips2.append(ip)
print ips2
print filter(lambda ip: ip.find('255') == -1, ips)
print [ip for ip in ips if ip.find('255') == -1]
# thrice prints
['128.173.120.79', '198.82.247.98', '127.0.0.1']
This seems much more sensible to me than building a new list with
everything (a copy), including things you don't want, and then deleting the
things you don't want (an O(n**2) operation).
Terry J. Reedy
Terry Reedy wrote: "Steve Holden" <st***@holdenweb.com> wrote in message news:36QMd.103084$Jk5.36127@lakeread01...
[ ... ] This seems much more sensible to me than building a new list with everything (a copy), including things you don't want, and then deleting the things you don't want (an O(n**2) operation).
Which is presumably why the OP decided to go with the list
comprehension. My main intention was to point out how the code in error
could be fixed while retaining the same structure. You are of course
correct in saying this is far from optimal in performance terms.
regards
Steve
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005 http://www.pycon.org/
Steve Holden http://www.holdenweb.com/
rbt wrote: John J. Lee wrote:
Steve Holden <st***@holdenweb.com> writes: [...]
You are modifying the list as you iterate over it. Instead, iterate over a copy by using:
for ip in ips[:]: ...
Just to help popularise the alternative idiom, which IMO is significantly less cryptic (sane constructors of mutable objects almost always make a copy, and list is no exception: it's guaranteed to do so):
for ip in list(ips): ...
Works back to at least Python 1.5.2.
I don't know that that approach is less cryptic. ips is already a list... it looks cryptic to make it a list again, doesn't it? IMO, the two are equally cryptic. The epitome of clarity would be copy(ips)... now *that* makes sense, of course, ips[:] or list(ips) work equally well to the programmer who has learned them.
This probably seems cryptic until you realize that almost all builtin
mutable objects work this way:
py> def copy(obj):
.... return type(obj)(obj)
....
py> lst = range(5)
py> copy(lst)
[0, 1, 2, 3, 4]
py> lst is copy(lst)
False
py> dct = dict(a=1, b=2)
py> copy(dct)
{'a': 1, 'b': 2}
py> dct is copy(dct)
False
py> st = set(range(5))
py> copy(st)
set([0, 1, 2, 3, 4])
py> st is copy(st)
False
py> from collections import deque
py> dq = deque(range(5))
py> copy(dq)
deque([0, 1, 2, 3, 4])
py> dq is copy(dq)
False
If you're uncomfortable with this form, I'd suggest spending some time
playing around with it -- Python is pretty consistent about this usage
of a builtin type.
Steve
rbt wrote: Alan McIntyre wrote:
I think it's because you're modifying the list as you're iterating over it.
One last clarification on this. It's OK to modify the elements of a list, but not the list itself while iterating over it... is that the correct way to think about this?
Correct - the iteration code bases the iteration on the *old* list structure, so
you can end up with odd behaviour.
Py> l = range(10)
Py> for i in l: del l[i]
....
Traceback (most recent call last):
File "<stdin>", line 1, in ?
IndexError: list assignment index out of range
Py> l
[1, 2, 4, 5, 7, 9]
Dictionaries have the same problem, but they include some guards that try to
detect it:
Py> d = dict.fromkeys(range(10))
Py> for i in d: del d[i]
....
Traceback (most recent call last):
File "<stdin>", line 1, in ?
RuntimeError: dictionary changed size during iteration
This feature can't be added to lists because it is possible to iterate sensibly
over a mutating list:
Py> l = range(10)
Py> for i in reversed(l): del l[i]
....
Py> l
[]
Cheers,
Nick.
--
Nick Coghlan | nc******@email.com | Brisbane, Australia
--------------------------------------------------------------- http://boredomandlaziness.skystorm.net
Yes, I also this that comprehension is the clearer way to handle this. You
might also consider the good old "filter" function :
ips = filter(lambda ip: '255' not in ip, ips)
Francis Girard
Le vendredi 4 Février 2005 20:38, rbt a écrit*: Thanks guys... list comprehension it is!
Bill Mill wrote:>ips = [ip for ip in ips if '255' not in ip] >ips
Bill Mill <bi*******@gmail.com> wrote:
... You are modifying the list as you iterate over it. Instead, iterate over a copy by using:
for ip in ips[:]:
... Once you know it, it's neat, and I use it sometimes. However, it's a little too "magical" for my tastes; I'd rather be more explicit about what's going on.
Using ips[:] to make a copy on the fly is very idiomatic, but I've never
liked it, personally. I see no reason to prefer it to the even shorter
and arguably less obscure ips*1, for example. My preference is:
for ip in list(ips):
Alex
Alex Martelli wrote: Bill Mill <bi*******@gmail.com> wrote: ... > > You are modifying the list as you iterate over it. Instead, iterate over > > a copy by using: > > > > for ip in ips[:]: ... Once you know it, it's neat, and I use it sometimes. However, it's a little too "magical" for my tastes; I'd rather be more explicit about what's going on.
Using ips[:] to make a copy on the fly is very idiomatic, but I've never liked it, personally. I see no reason to prefer it to the even shorter and arguably less obscure ips*1, for example.
"Less obscure"? Either you know the `lst[:]' idiom, or you don't. If you
do, it's fine, if you don't, you will have to look it up to understand
its meaning, and that's a good thing.
Using `lst*1', on the other hand, does not make clear that a copy is
created. If you don't already know what it does, you may assume that
`lst' is left alone.
My preference is:
for ip in list(ips):
That is the most intriguing variant, of course.
Reinhold
Reinhold Birkenfeld <re************************@wolke7.net> wrote:
... Using ips[:] to make a copy on the fly is very idiomatic, but I've never liked it, personally. I see no reason to prefer it to the even shorter and arguably less obscure ips*1, for example. "Less obscure"? Either you know the `lst[:]' idiom, or you don't. If you do, it's fine, if you don't, you will have to look it up to understand its meaning, and that's a good thing.
I disagree.
Using `lst*1', on the other hand, does not make clear that a copy is created. If you don't already know what it does, you may assume that `lst' is left alone.
And indeed it is -- whatever object is bound to the name 'lst' is not
modified in the least (neither would it be by slicing lst[:], of
course). But the RESULT of x*1 is a DISTINCT object from x whenever it
matters -- i.e., whenever x is mutable. x[:] *MIGHT* not be a distinct,
separate, independent copy if x is, e.g. a Numeric.array:
x = Numeric.arange(7)
y = x[:]
x[3]=23
now y is modified too. Change the middle statement into 'y = x*1', and
the third statement won't alter y. So, *WHAT ON EARTH* could possibly
make this weird 'x[:]' form preferable to 'x*1'?! It's MUCH more
obvious that the second one returns an independent, separate object
initially equal to x -- because it does so in many more cases than those
in which x[:] does it! I'm not arguing FOR x*1 -- I'm arguing AGAINST
x[:] as being even remotely acceptable. My preference is:
for ip in list(ips):
That is the most intriguing variant, of course.
It's very down to earth because the result is obviously a list, whatever
'ips' might turn out to be -- no mystery there, and thus, no intrigue.
Maybe we should have a simpler way to specify ``an iterator that is
INDEPENDENT from any possible changes in the iterable we're passing'',
for this specific use case -- but we don't, and I don't think that
copy.copy(ips) is a substantial improvement (it would fail when ips is a
file, or a generator-iterator, or many other kinds of iterators, for
example). list(ips) may do more work than necessary (e.g., if ips were
a tuple) but at least its semantics are quite plain and obvious.
Alex
Alex Martelli wrote: So, *WHAT ON EARTH* could possibly make this weird 'x[:]' form preferable to 'x*1'?! It's MUCH more obvious that the second one returns an independent, separate object initially equal to x
..>> x = 2
..>> y = x*1
..>> x is y
True
..>>
just-kidding-ly yours,
Reinhold
Reinhold Birkenfeld <re************************@wolke7.net> wrote: Alex Martelli wrote:
So, *WHAT ON EARTH* could possibly make this weird 'x[:]' form preferable to 'x*1'?! It's MUCH more obvious that the second one returns an independent, separate object initially equal to x .>> x = 2 .>> y = x*1 .>> x is y True .>>
just-kidding-ly yours,
You're just snipping a crucial side-observation which I had put in
exactly to avert such irrelevant diversions:
whenever it matters -- i.e., whenever x is mutable.
Immutable types are allowed to collapse any two equal but "distinct"
objects into one identity -- that's always the case, I acknowledged that
in my sentence which I just quoted and which you had failed to quote
again, and I don't see what's funny in this procedure and the time it's
wasting, for me and for every reader of this group, now and in the
future from archives.
I'm sure that by selectively quoting just some of your words and
artfully omitting others I could ``make" you say, not just slightly
imprecise things, but utter and total idiocies. So? What's the point
of this "kidding"? Next time, why don't you just omit, for example, a
"not", when you quote me, so as to make it appear that I was saying
exactly the reverse of what I was obviously saying?
I guess it must be time for me to go away from this group again, if my
time on it is to me spent repeating over and over all sorts of asides
which people "just kidding" carefully avoid quoting from my posts,
apparently in order to make believe they caught me in anything less than
perfect accuracy. Cheez -- I HAVE been guilty of less than perfect
accuracy in the past (even of outright errors), but not THIS time (if
one has the common decency to look at ALL the words I posted, rather
than a careful selection thereof), so I completely fail to see how you
thought this "kidding" could be fun.
OK, I'm off. Have a nice life.
Alex
Alex Martelli wrote: Reinhold Birkenfeld <re************************@wolke7.net> wrote:
Alex Martelli wrote:
> So, *WHAT ON EARTH* could possibly > make this weird 'x[:]' form preferable to 'x*1'?! It's MUCH more > obvious that the second one returns an independent, separate object > initially equal to x .>> x = 2 .>> y = x*1 .>> x is y True .>>
just-kidding-ly yours,
You're just snipping a crucial side-observation which I had put in exactly to avert such irrelevant diversions:
whenever it matters -- i.e., whenever x is mutable.
Immutable types are allowed to collapse any two equal but "distinct" objects into one identity -- that's always the case, I acknowledged that in my sentence which I just quoted and which you had failed to quote again, and I don't see what's funny in this procedure and the time it's wasting, for me and for every reader of this group, now and in the future from archives.
Well, I overread your side-observation (can happen if you don't have too
much time and are not accustomed to flying over English text) and,
though I sensed that it was bad, posted my little joke.
I'm sure that by selectively quoting just some of your words and artfully omitting others I could ``make" you say, not just slightly imprecise things, but utter and total idiocies. So? What's the point of this "kidding"? Next time, why don't you just omit, for example, a "not", when you quote me, so as to make it appear that I was saying exactly the reverse of what I was obviously saying?
Well, snipping single paragraphs is different from snipping words out of
them.
Sorry. Didn't mean to drive you insane -- your posts are of use, so clpy
(include me) need you in the future.
I guess it must be time for me to go away from this group again, if my time on it is to me spent repeating over and over all sorts of asides which people "just kidding" carefully avoid quoting from my posts, apparently in order to make believe they caught me in anything less than perfect accuracy. Cheez -- I HAVE been guilty of less than perfect accuracy in the past (even of outright errors), but not THIS time (if one has the common decency to look at ALL the words I posted, rather than a careful selection thereof), so I completely fail to see how you thought this "kidding" could be fun.
This is the hot Italian temper, I suppose ;) Of course you were right,
and I'm glad to see your posts of today.
OK, I'm off. Have a nice life.
Thanks, I'll do.
Reinhold This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Angus Leeming |
last post by:
Hello,
Could someone explain to me why the Standard conveners chose to typedef
std::string rather than derive it from std::basic_string<char, ...>?
The result of course is that it is...
|
by: JustSomeGuy |
last post by:
I have a structure
typedef struct
{
string a;
string b;
} atype;
string ABC = ("123");
string DEF = ("456");
|
by: Chad Myers |
last post by:
I've been perf testing an application of mine and I've noticed that there
are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String
instances being created.
I've done some...
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if...
|
by: Ottar |
last post by:
I have a few numeric fields, and when I update i get the error: "Input string
was not in a correct format". Next line:" System.Number.StringToNumber(String
str, NumberStyles options, NumberBuffer&...
|
by: sudharsan |
last post by:
could any one please give me a code to reverse a string of more than
1MB .???
Thanks in advance
|
by: smnoff |
last post by:
I have searched the internet for malloc and dynamic malloc; however, I still
don't know or readily see what is general way to allocate memory to char *
variable that I want to assign the substring...
|
by: jwf |
last post by:
This question continues on from a previous post "DATE to string" but I think
it deserves a new thread.
In my previous post I was trying to convert a DATE to string in a NON MFC
C++ application...
|
by: Shhnwz.a |
last post by:
Hi,
I am in confusion regarding jargons.
When it is technically correct to say.. String or Character Array.in c.
just give me your perspectives in this issue.
Thanx in Advance.
|
by: kru |
last post by:
Hi All,
Simple issue I cannot figure out.
I have a multiline textbox, I need to convert the string contents of
this textbox into a single line string which I currently write to a
textfile.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |