f



Does '!=' equivelent to 'is not'

I'm a bit confusing about whether "is not" equivelent to "!="

if a != b:
  ...

if a is not b:
  ...


What's the difference between "is not" and "!=" or they are the same thing?
0
pirata1 (4)
6/17/2008 3:29:53 AM
comp.lang.python 77058 articles. 6 followers. Post Follow

22 Replies
926 Views

Similar Articles

[PageSpeed] 26

pirata wrote:
> I'm a bit confusing about whether "is not" equivelent to "!="
> 
> if a != b:
>   ...
> 
> if a is not b:
>   ...
> 
> 
> What's the difference between "is not" and "!=" or they are the same thing?

No, they are not the same thing. == and != test to see if the *value* of 
two variables are the same. Like so:

 >>> a = 'hello world'
 >>> b = 'hello world'
 >>> a == b
True

a and b both have the value of 'hello world', so they are equal

is and is not, however, do not test for value equivalence, they test for 
object identity. In other words, they test to see if the object the two 
variables reference are the same object in memory, like so:

 >>> a is b
False

a and b are assigned to two different objects that happen to have the 
same value, but nevertheless there are two separate 'hello world' 
objects in memory, and therefore you cannot say that a *is* b

Now look at this:

 >>> c = d = 'hello world'
 >>> c == d
True
 >>> c is d
True

In this case, they are again the same value, but now the is test also 
shows that they are the same *object* as well, because both c and d 
refer to the same 'hello world' object in memory. There is only one this 
time.

!= and is not work the same:

 >>> a != b
False
 >>> a is not b
True
 >>> c != d
False
 >>> c is not d
False
 >>>

Hope that helps!
0
6/17/2008 3:40:14 AM
pirata wrote:

> I'm a bit confusing about whether "is not" equivelent to "!="
> 
> if a != b:
>   ...
> 
> if a is not b:
>   ...
> 
> 
> What's the difference between "is not" and "!=" or they are the same thing?

The `==` operator tests equality.  The `is` operator tests identity.

If you don't specifically intend to test for identity, use `==`.  If you 
don't know what identity tests are for (with the exception of testing 
for None-ness), then you don't need it.

-- 
Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   Do we ask what profit the little bird hopes for in singing?
    -- Johannes Kepler, 1571-1630
0
max78 (1220)
6/17/2008 3:41:49 AM
On Jun 16, 10:29=A0pm, pirata <pir...@mars.invalid> wrote:
> I'm a bit confusing about whether "is not" equivelent to "!=3D"
>
> if a !=3D b:
> =A0 ...
>
> if a is not b:
> =A0 ...
>
> What's the difference between "is not" and "!=3D" or they are the same thi=
ng?

"is not" is the logical negation of the "is" operator, while "!=3D" is
the logical negation of the "=3D=3D" operator.  The difference is equality
versus identity.

>>> a =3D [1, 2, 3]
>>> b =3D [1, 2, 3]
>>> a =3D=3D b
True
>>> a is b
False
0
danb_83 (421)
6/17/2008 3:43:55 AM
John Salerno wrote:

> == and != test to see if the *value* of 
> two variables are the same.

Let me just clarify this. It might seem like a picky point, but I think 
it's pretty important when learning Python.

I don't really mean the value of the variables themselves, I mean the 
values that the variables refer to. The variables themselves aren't 
actually the objects, nor do they have values, exactly. Instead, they 
*refer* to objects in memory, and it is these objects that we are 
testing the values and identities of. For example, using that previous code:

a ---> 'hello world'

b ---> 'hello world'

c ---\
       ---> 'hello world'
d ---/

a and b were assigned to two separate objects (it doesn't matter that 
they happen to be the same value). As you can see above, a and b refer 
to different things.

c and d, however, were assigned simultaneously to the same object, and 
therefore refer to a single object in memory. This is why "c is d" is 
True, but "a is b" is False.
0
6/17/2008 3:51:24 AM
On Tue, Jun 17, 2008 at 11:29 AM, pirata <pirata@mars.invalid> wrote:
> I'm a bit confusing about whether "is not" equivelent to "!="
>
> if a != b:
>  ...
>
> if a is not b:
>  ...
>
>
> What's the difference between "is not" and "!=" or they are the same thing?

The 'is' is used to test do they point to the exactly same object.
The '==' is used to test are their values equal.

same objects are equal, but equal don't have to be the same object.

and be very careful to the dirty corner of python:
>>> a = 100000
>>> b = 100000
>>> a is b
False
>>> a == b
True
>>> a = 5
>>> b = 5
>>> a is b
True
>>> a == b
True
>>>

which is caused by small object cache mechanism.


-- 
Best Regards,
Leo Jay
0
6/17/2008 4:07:10 AM
On Jun 17, 11:07=A0am, "Leo Jay" <python.leo...@gmail.com> wrote:
> On Tue, Jun 17, 2008 at 11:29 AM, pirata <pir...@mars.invalid> wrote:
> > I'm a bit confusing about whether "is not" equivelent to "!=3D"
>
> > if a !=3D b:
> > =A0...
>
> > if a is not b:
> > =A0...
>
> > What's the difference between "is not" and "!=3D" or they are the same t=
hing?
>
> The 'is' is used to test do they point to the exactly same object.
> The '=3D=3D' is used to test are their values equal.
>
> same objects are equal, but equal don't have to be the same object.
>
> and be very careful to the dirty corner of python:

No you don't have to be careful, you should never rely on it in the
first place.

Basically 'a is b' and 'not(a is b)' is similar to 'id(a) =3D=3D id(b)'
and 'not(id(a) =3D=3D id(b))'

You use 'is' when you want to test whether two variable/names are
actually the same thing (whether they actually refers to the same spot
on memory). The '=3D=3D' equality comparison just test whether two
objects' values can be considered equal.
0
lie.1296 (854)
6/17/2008 5:25:42 AM
En Tue, 17 Jun 2008 02:25:42 -0300, Lie <Lie.1296@gmail.com> escribi�:
> On Jun 17, 11:07�am, "Leo Jay" <python.leo...@gmail.com> wrote:
>> On Tue, Jun 17, 2008 at 11:29 AM, pirata <pir...@mars.invalid> wrote:

>> > What's the difference between "is not" and "!=" or they are the same thing?
>>
>> The 'is' is used to test do they point to the exactly same object.
>> The '==' is used to test are their values equal.
>>
>> and be very careful to the dirty corner of python:

[example with "5 is 5" but "100000 is not 100000"]

> No you don't have to be careful, you should never rely on it in the
> first place.
>
> Basically 'a is b' and 'not(a is b)' is similar to 'id(a) == id(b)'
> and 'not(id(a) == id(b))'

No.

> You use 'is' when you want to test whether two variable/names are
> actually the same thing (whether they actually refers to the same spot
> on memory). The '==' equality comparison just test whether two
> objects' values can be considered equal.

Yes, *that* is true. The above statement is not. A counterexample:

py> [] is []
False
py> id([])==id([])
True

Even dissimilar objects may have the same id:

py> class A: pass
....
py> class B: pass
....
py> A() is B()
False
py> A() == B()
False
py> id(A())==id(B())
True

Comparing id(a) with id(b) is only meaningful when a and b are both alive at the same time. If their lifetimes don't overlap, id(a) and id(b) are not related in any way. So I think that trying to explain object identity in terms of the id function is a mistake.

-- 
Gabriel Genellina

0
gagsl-py2 (3707)
6/17/2008 7:33:03 AM
"Leo Jay" <python.leojay@gmail.com> wrote:

> same objects are equal, but equal don't have to be the same object.

same objects are often equal, but not always:

>>> inf = 2e200*2e200
>>> ind = inf/inf
>>> ind==ind
False
>>> ind is ind
True

-- 
Duncan Booth http://kupuguy.blogspot.com
0
duncan.booth (1734)
6/17/2008 8:20:42 AM
--ALfTUftag+2gvp1h
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline

On Tue, Jun 17, 2008 at 04:33:03AM -0300, Gabriel Genellina wrote:
> > Basically 'a is b' and 'not(a is b)' is similar to 'id(a) == id(b)'
> > and 'not(id(a) == id(b))'
> 
> No.

Sure it is... he said "similar"... not identical.  They are not the
same, but they are similar.  

Saying a flat "no" alone, without qualifying your statement is
generally interpreted as rude in English...  It's kind of like how you
talk to children when they're too young to understand the explanation.
Yucky.

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D


--ALfTUftag+2gvp1h
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFIV6mFdjdlQoHP510RAnuCAJ0bduRUXrOsAM1YeVkB6at7QGCMQACdFTD7
qhGWDqFcvX3JokVte+EXu8s=
=OQ51
-----END PGP SIGNATURE-----

--ALfTUftag+2gvp1h--
0
code210 (96)
6/17/2008 12:09:41 PM

pirata wrote:
> I'm a bit confusing about whether "is not" equivelent to "!="

 >>> 0 is not 0.0
True
 >>> 0 != 0.0
False

0
tjreedy (5460)
6/17/2008 5:39:26 PM
En Tue, 17 Jun 2008 09:09:41 -0300, Derek Martin <code@pizzashack.org>  
escribi�:

> On Tue, Jun 17, 2008 at 04:33:03AM -0300, Gabriel Genellina wrote:
>> > Basically 'a is b' and 'not(a is b)' is similar to 'id(a) == id(b)'
>> > and 'not(id(a) == id(b))'
>>
>> No.
>
> Sure it is... he said "similar"... not identical.  They are not the
> same, but they are similar.

'equality' and 'identity' are similar too, so the whole answer would make  
no sense in that case. You can't explain identity based on things that  
aren't identical. A fine grained question for a fine grained difference  
requires a fine grained answer.

> Saying a flat "no" alone, without qualifying your statement is
> generally interpreted as rude in English...  It's kind of like how you
> talk to children when they're too young to understand the explanation.
> Yucky.

I didn't meant to be rude at all - and I apologize to Mr. Lie. The  
explanation for such strong "No" was in the paragraph below it (the idea  
was to say: "No to this, yes to that")

-- 
Gabriel Genellina

0
gagsl-py2 (3707)
6/18/2008 12:26:00 AM
On Jun 17, 5:33 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
> En Tue, 17 Jun 2008 02:25:42 -0300, Lie <Lie.1...@gmail.com> escribi=F3:

>
> > Basically 'a is b' and 'not(a is b)' is similar to 'id(a) =3D=3D id(b)'
> > and 'not(id(a) =3D=3D id(b))'
>
> No.
=2E..
> ... The above statement is not. A counterexample:
>
> py> [] is []
> False
> py> id([])=3D=3Did([])
> True
>
But that's not what he said, he used 'a' and 'b' which are names, not
anonymous objects.
Fairer would be,
a =3D [];b =3D []
id(a) =3D=3D id(b)

Morevover, Lie wrote "id(a)=3D=3Did(b)".  Since there is no need for the
anonymous object to persist following id testing, you cannot guarantee
that you are comparing an id of two objects (as referred to by 'a' and
'b').  Haven't you, in effect, tested id(a) =3D=3D id(a)?  While this
might be an interesting effect, I doubt that it clarifies the
difference between equivalence and identity testing, in the way Lie's
statement in fact does.

Also in considering what equivalence means in python reference ought
to be made to the __eq__ method.  The original querant may care to
look it up.




0
afriere (153)
6/18/2008 2:04:16 AM
>> Saying a flat "no" alone, without qualifying your statement is
>> generally interpreted as rude in English...  It's kind of like how you
>> talk to children when they're too young to understand the explanation.
>> Yucky.
> 
> I didn't meant to be rude at all - and I apologize to Mr. Lie. The 
> explanation for such strong "No" was in the paragraph below it (the idea 
> was to say: "No to this, yes to that")

As a very much native English speaker I disagree that 'No' is 
necessarily rude.  I wish I could more often get such a clean answer to 
my questions from my child.

0
tjreedy (5460)
6/18/2008 5:32:28 AM
En Tue, 17 Jun 2008 23:04:16 -0300, Asun Friere <afriere@yahoo.co.uk> escribi�:

> On Jun 17, 5:33 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
> wrote:
>> En Tue, 17 Jun 2008 02:25:42 -0300, Lie <Lie.1...@gmail.com> escribi�:
>
>>
>> > Basically 'a is b' and 'not(a is b)' is similar to 'id(a) == id(b)'
>> > and 'not(id(a) == id(b))'
>>
>> No.
> ...
>> ... The above statement is not. A counterexample:
>>
>> py> [] is []
>> False
>> py> id([])==id([])
>> True
>>
> But that's not what he said, he used 'a' and 'b' which are names, not
> anonymous objects.
> Fairer would be,
> a = [];b = []
> id(a) == id(b)

If you limit yourself to interpret 'a' and 'b' as actual names, yes, the statement is true. But I thought of them as placeholders or metasyntactic names - like in "abs(x) returns the absolute value of x", where x may represent *any* expression, not just a single name. Under this general interpretation the statement is not true anymore.

(This thread is getting way above 10000cp...)

-- 
Gabriel Genellina

0
gagsl-py2 (3707)
6/18/2008 7:45:54 AM
On Jun 17, 7:09=A0am, Derek Martin <c...@pizzashack.org> wrote:
> On Tue, Jun 17, 2008 at 04:33:03AM -0300, Gabriel Genellina wrote:
> > > Basically 'a is b' and 'not(a is b)' is similar to 'id(a) =3D=3D id(b=
)'
> > > and 'not(id(a) =3D=3D id(b))'
>
> > No.
>
<snip>
>
> Saying a flat "no" alone, without qualifying your statement is
> generally interpreted as rude in English... =A0It's kind of like how you
> talk to children when they're too young to understand the explanation.
> Yucky.
>
Geez, man, this is Usenet.  If you want rude or condescending, the
answer would have been "No, you flatulent moron."  Or maybe the
alarmist, "No! No! No!"

I see the unqualified "No." often on this list, as a short cut for
"Your technical explanation is flawed or has overlooked a critical
point or corner case," and is usually followed by more details further
down in the post to explain what the misconception or oversight was.

Back in my college days, I would not be surprised for a professor to
respond "No." (or worse) if I offered an erroneous explanation to
another student.  The unqualified "No." may be curt, and on a more
sensitive day, one might write "No. (see below)", but as one of the
most informed and careful posters on this list, I'm inclined to give
Gabriel a little slack.

-- Paul
0
ptmcg (802)
6/18/2008 2:01:23 PM
Gabriel Genellina wrote:
> (This thread is getting way above 10000cp...)

What is 10000cp?
--
Ethan



0
dp2994 (2)
6/18/2008 5:26:31 PM
On Jun 18, 7:26=A0am, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
> En Tue, 17 Jun 2008 09:09:41 -0300, Derek Martin <c...@pizzashack.org> =
=A0
> escribi=F3:
>
> > On Tue, Jun 17, 2008 at 04:33:03AM -0300, Gabriel Genellina wrote:
> >> > Basically 'a is b' and 'not(a is b)' is similar to 'id(a) =3D=3D id(=
b)'
> >> > and 'not(id(a) =3D=3D id(b))'
>
> >> No.
>
> > Sure it is... he said "similar"... not identical. =A0They are not the
> > same, but they are similar.
>
> 'equality' and 'identity' are similar too, so the whole answer would make=
 =A0
> no sense in that case. You can't explain identity based on things that =
=A0
> aren't identical. A fine grained question for a fine grained difference =
=A0
> requires a fine grained answer.

In my defense, I admit I have the tendency to forget (purposefully)
fine-grained differences if I thought that the difference was not
significant enough in the context of speaking. The OP asked about !=3D
and 'is not', so I explained in terms of those being equality and
identity testing respectively. To give a more concise and easy to
understand example, I said that 'is not' is like using testing the
'id()' of the objects. Since (I think) the difference between !=3D and
'is not' is much larger compared to the difference between 'is not'
and 'id() test', I thought I could consider 'is not' and 'id() test'
as "equivalent" in the context of this thread: 'Does !=3D is equivalent
to "is not"'.

Either way, I'm sorry that I failed to put explicit notice that 'is
not' and 'id() testing' isn't exactly the same either.

> > Saying a flat "no" alone, without qualifying your statement is
> > generally interpreted as rude in English... =A0It's kind of like how yo=
u
> > talk to children when they're too young to understand the explanation.
> > Yucky.
>
> I didn't meant to be rude at all - and I apologize to Mr. Lie.

I don't deserve the apology because the mistake is on me and I didn't
feel offended, in fact I'm delighted someone could point out my
mistake.

> The =A0
> explanation for such strong "No" was in the paragraph below it (the idea =
=A0
> was to say: "No to this, yes to that")
0
lie.1296 (854)
6/18/2008 7:14:02 PM
On Jun 18, 12:32=A0pm, Terry Reedy <tjre...@udel.edu> wrote:
> >> Saying a flat "no" alone, without qualifying your statement is
> >> generally interpreted as rude in English... =A0It's kind of like how y=
ou
> >> talk to children when they're too young to understand the explanation.
> >> Yucky.
>
> > I didn't meant to be rude at all - and I apologize to Mr. Lie. The
> > explanation for such strong "No" was in the paragraph below it (the ide=
a
> > was to say: "No to this, yes to that")
>
> As a very much native English speaker I disagree that 'No' is
> necessarily rude. =A0I wish I could more often get such a clean answer to
> my questions from my child.

I'm not a native English speaker, although I think my parents would
have liked me to be more straightforward when talking, cause I tend to
say things like "possibly", "maybe", "probably", and other ambiguous
expressions to the extent that it has frustrated them now and then.
0
lie.1296 (854)
6/18/2008 7:22:37 PM
On Jun 18, 2:22=A0pm, Lie <Lie.1...@gmail.com> wrote:
>
> I'm not a native English speaker, although I think my parents would
> have liked me to be more straightforward when talking, cause I tend to
> say things like "possibly", "maybe", "probably", and other ambiguous
> expressions to the extent that it has frustrated them now and then.

Well, at least you *talk* to your parents!  Mostly what I get from my
kids is, "can I borrow 10 dollars?"

-- Paul
0
ptmcg (802)
6/18/2008 7:51:16 PM
On Jun 19, 2:51=A0am, Paul McGuire <pt...@austin.rr.com> wrote:
> On Jun 18, 2:22=A0pm, Lie <Lie.1...@gmail.com> wrote:
>
>
>
> > I'm not a native English speaker, although I think my parents would
> > have liked me to be more straightforward when talking, cause I tend to
> > say things like "possibly", "maybe", "probably", and other ambiguous
> > expressions to the extent that it has frustrated them now and then.
>
> Well, at least you *talk* to your parents! =A0Mostly what I get from my
> kids is, "can I borrow 10 dollars?"

lol, I rarely initiate the talk to my parents unless I have to, they
usually starts talking first which I usually responded with the
ambiguous statements. Well, in fact, I rarely initiate a talk with
anybody, it's my nature to keep myself in the shade until I have to be
in the light.

But I never asked for money up straight like that though.
0
lie.1296 (854)
6/18/2008 8:43:14 PM
En Wed, 18 Jun 2008 14:26:31 -0300, Ethan Furman <dp@admailinc.com>  
escribi�:

> Gabriel Genellina wrote:
>> (This thread is getting way above 10000cp...)
>
> What is 10000cp?

cp = centipoise, a unit of dynamic viscosity, measuring the resistence to  
flow.
Honey viscosity is a few hundreds, corn syrup a few thousands, and  
something above 10000 cp is really viscous...

-- 
Gabriel Genellina

0
gagsl-py2 (3707)
6/18/2008 9:31:42 PM
On Jun 18, 9:43=A0pm, Lie <Lie.1...@gmail.com> wrote:
> On Jun 19, 2:51=A0am, Paul McGuire <pt...@austin.rr.com> wrote:
>
> > On Jun 18, 2:22=A0pm, Lie <Lie.1...@gmail.com> wrote:
>
> > > I'm not a native English speaker, although I think my parents would
> > > have liked me to be more straightforward when talking, cause I tend t=
o
> > > say things like "possibly", "maybe", "probably", and other ambiguous
> > > expressions to the extent that it has frustrated them now and then.
>
> > Well, at least you *talk* to your parents! =A0Mostly what I get from my
> > kids is, "can I borrow 10 dollars?"
>
> lol, I rarely initiate the talk to my parents unless I have to, they
> usually starts talking first which I usually responded with the
> ambiguous statements. Well, in fact, I rarely initiate a talk with
> anybody, it's my nature to keep myself in the shade until I have to be
> in the light.
>
"'Tis better to remain silent and be thought a fool, than open one's
mouth and remove all doubt." - Samuel Johnson. :-)

> But I never asked for money up straight like that though.

0
google4813 (798)
6/18/2008 11:19:54 PM
Reply:

Similar Artilces:

'is not' or '!='
A newbie question to you; what is the difference between statements like: if x is not None: and if x != None: Without any context, which one should be preferred? IMHO, the latter is more readable. On 2014-08-18 21:35, ElChino wrote: > A newbie question to you; what is the difference between statements > like: > if x is not None: > and > if x != None: > > Without any context, which one should be preferred? > IMHO, the latter is more readable. > "x == y" tells you whether x and y refer to objects that are equal. "x is y&qu...

'^=' and '~='?
Hello, What is the difference between '^=' and '~='? Thanks, Duckhye ...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal''''''''''''''
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; _____________________________________________________ SELECT "criteria" FROM "criteria" WHERE "criteria" UPDATE/APPEND "field selections" RecordSource "qryExample" = above text strings" _______________________________________________________________________ When i am running a SELECT query in this manner it works fine with no problems, and accepts the values of specified linked for...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal'''''''''''''' #2
Hi, Thanks for ur help there HJ. I know how to do the tasks you specified there. I would like for the update query to use field values from some of the fields on the form (frmInvoices) such as InvoiceNumber, DateFrom, DateTo. My problem is that an append/update query can't find the values in the open Form (frmInvoices) when I specify them as; [Forms]![frmInvoices]![InvoiceNumber] a select query has no problem finding the field values on a form. please help. Aaron Hi Aaron, Could you post the entire code that you are having trouble with? Now it is not possible to see what goes wrong. HJ "Aaron" <aaron@rapid-motion.co.uk> wrote in message news:260d7f40.0408120245.2f3d01f8@posting.google.com... > Hi, > > Thanks for ur help there HJ. > > I know how to do the tasks you specified there. > > I would like for the update query to use field values from some of the > fields on the form (frmInvoices) such as InvoiceNumber, DateFrom, > DateTo. My problem is that an append/update query can't find the > values in the open Form (frmInvoices) when I specify them as; > > [Forms]![frmInvoices]![InvoiceNumber] > > a select query has no problem finding the field values on a form. > > please help. > > Aaron First off, if you are not always using all the parameters specified in your form, then you have to add parameters to your query on the fly. Also, you can't just do something like qdf.SQL = "SE...

if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.') Any shorter ?
Hi, there. =20 I'm just curious if it ever dawned on anybody how to abbreviate this line : if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.')=20 =20 Igor Kurbeko Clinical Programmer Analyst 678 336 4328 ikurbeko@atherogenics.com =20 no brain no pain =20 how about: if not (str_mo in ('','.') or str_da in ('','.') or str_yy in ('','.')) OR if not (missing(str_mo) or missing(str_da) or missing(str_yy)) Eric On 22 Oct 03 21:13:37 GMT, ikurbeko@ATHER...

A function with 'and' , 'not' , 'null' , 'car' and 'cdr'
What's this ? (defun enigma (x) (and (not (null x)) (or (null (car x)) (enigma (cdr x))))) "I suppose I should learn Lisp, but it seems so foreign." - Paul Graham, Nov 1983 On Wed, Oct 07 2015, CAI GENGYANG wrote: > What's this ? > > > (defun enigma (x) > (and (not (null x)) > (or (null (car x)) > (enigma (cdr x))))) Bad taste? It returns T if the list X contains nil as an element. It would be clearer to write (some #'null x). Helmut CAI GENGYANG ...

which is more 'pythonic' / 'better' ?
hi, there are 2 versions of a simple code. which is preferred? === if len(line) >= (n+1): text = line[n] else: text = 'nothing' === === try: text = line[n] except IndexError: text = 'nothing' === which is the one you would use? thanks, gabor gabor wrote: > hi, > > there are 2 versions of a simple code. > which is preferred? > > > === > if len(line) >= (n+1): > text = line[n] > else: > text = 'nothing' > === > > > === > try: > text = line[n] > except IndexError: > text = '...

Re: if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.') Any shorter ?
OR you could use ARRAY data new; set old; array igor $ (*) str_mo str_da str_yr; do over igor; if igor ~in (' ','.') then do; end; run; Prasad Ravi Igor Kurbeko <ikurbeko@ATHEROGENIC To: SAS-L@LISTSERV.UGA.EDU S.COM> cc: Sent by: "SAS(r) Subject: if str_mo not in ('','.') and str_da not in ('','.') and str_yy ...

error: expected '=', ',', ';', 'asm' or '__attrib
Hi I'm trying to compile an ADC Driver & come acrosss the following error. I've no experience writing drivers before, and hence have no clue how to fix it. Hope someone out there has encountered the problem & suggesst a fix for the same. The Error is I get is : qadc.c: At top level: qadc.c:97: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'qadc_read' make: *** [qadc.o] Error 1 [root@localhost qadc]# ########################################################################### ADC Driver Code ####################...

error: expected '=', ',', ';', 'asm' or '__attrib
Hi I'm trying to compile an ADC Driver & come acrosss the following error. I've no experience writing drivers before, and hence have no clue how to fix it. Hope someone out there has encountered the problem & suggesst a fix for the same. The Error is I get is : qadc.c: At top level: qadc.c:97: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'qadc_read' make: *** [qadc.o] Error 1 [root@localhost qadc]# ########################################################################### ADC Driver Code ##...

Re: '^=' and '~='?
Duckhye, According to the doc ( http://xrl.us/befwjx ) they, and one other set of characters, and the mnemonic 'NE' all represent 'NOT EQUAL'. Art ------- On Wed, 11 Feb 2009 16:52:40 -0600, Duck-Hye Yang <dyang@CHAPINHALL.ORG> wrote: >Hello, >What is the difference between '^=' and '~='? > >Thanks, >Duckhye ...

replacing '/' with '\\'
I have a MKS ksh shell script running on a Windows box. In some scripts I have to convert a UNIX filename into a DOS filename, that is replace the '/' with '\\'. For example, replace /opt/siips/archive/text.dat with \\opt\\siips\\archive\\text.dat. I've tried using sed like $FILE='echo $FILE|sed "s/\//\\\/g"' which got me \opt\siips\archive\text.dat. It's close but I still need the second \. Does anyone have any suggestion? Or tell me where I've gone wrong? Thanks -- Steffen On 9 Dec 2004 20:14:21 -0800, sajohn52@yahoo.com <sajohn52@yahoo....

Replacing ',' with '.'
Hello, I have a huge amount of numbers in a .txt file. The numbers are in the form 2,43252e+1. I need to replace the , with . How should I do this? I'd prefer some import method that does this during the import procedure. -Janne Hi, I guess you import the data as text and convert it then to numbers. Try 'strrep' before you convert the text to numbers. Tobias Jake the Snake schrieb: > Hello, > > I have a huge amount of numbers in a .txt file. The numbers are in the form 2,43252e+1. I need to replace the , with . How should I do this? I'd prefer some import method...

difference between ',' and 'a,'
Small question. In gforth is there a difference between the words ',' and 'a,'? I'm thinking not, so perhaps another question, why have both ',' and 'a,'? Thanks Should be the same, in gforth: see , : , here cell allot ! ; ok see a, : , here cell allot ! ; ok On Friday, January 9, 2015 at 5:46:04 AM UTC-8, beeflo wrote: > Small question. In gforth is there a difference between the words ',' and 'a,'? > > I'm thinking not, so perhaps another question, why have both ',' and 'a,'...

'a'..'z'
Is it possible to achieve something like this? switch (mystring.charAt(0)) { case 'a'..'z': // do something break; } "cruster" <cruster@gmail.com> wrote in message news:1151319731.988814.326200@m73g2000cwd.googlegroups.com... > Is it possible to achieve something like this? > > switch (mystring.charAt(0)) { > case 'a'..'z': > // do something > break; > } > There are times when an if statement may be more appropriate ;) Sorry - java is not VB :) -- LTP :) cruster schreef: > Is it possible to achieve somethi...

Difference between 'is' and '=='
Hey guys, this maybe a stupid question, but I can't seem to find the result anywhere online. When is the right time to use 'is' and when should we use '=='? Thanks alot~ mwql: >Hey guys, this maybe a stupid question, but I can't seem to find the >result anywhere online. When is the right time to use 'is' and when >should we use '=='? http://docs.python.org/ref/comparisons.html -- Ren� Pijlman mwql wrote: > Hey guys, this maybe a stupid question, but I can't seem to find the > result anywhere online. When is the right time to ...

Diff between '{..}' and {'..'}
Hi, Could anyone tell me the difference between ......| awk '{.......}' AND ......| awk {'......'} And also when(in what situation) these are used? Thanks in advance, Anil. 2005-01-12, 22:37(-08), Anil: > Hi, > > Could anyone tell me the difference between > > .....| awk '{.......}' > > AND > > .....| awk {'......'} > > > And also when(in what situation) these are used? > Thanks in advance, [...] The second one should never be used. The difference is at the shell level, not at the awk level. '...' are stro...

logical to 'on' / 'off'
Hi, is there a function implemented doing this conversion? my Problem is, that I want to use the following code: set(handles.edit_curr_trq_sl,'Enable',get(hObject,'Value')) where get(hObject,'Value') gives the state of a checkbox thank you! function [str]=tf2oo(logic) switch logic case 0 str='off'; case 1 str='on'; end%switch end%function tf2oo() while i do not know a built in function, I use my own:) meisterbartsch wrote: > > > function [str]=tf2oo(logic) > switch logic > case 0 > str='off'; &g...

Meaning of ':' and '{}'
Hi, Please, can anyone tell me what is meaning of predicates ':' and '{}' ? ---------------- yours Advait Advait wrote: > Hi, > Please, can anyone tell me what is meaning of predicates ':' and '{}' > ? It depends on the context. : is used for module qualification of predicates. Like lists:member(X,L) The curly brackets are used in Definite Clauses Grammars: find the section on DCGs in the manual or google for it and you will find out easily. There are uses of {} as a functor in datastructures also. Cheers Bart Demoen Hello everyone,...

'[OFF]' as in 'offensive'???
Hi, given that 'off-topicness' is indicated as '[OT]' and taking a look at those postings that started the threads indicated as '[OFF]' (which may both be seen as being somewhat offensive) may lead to the conclusion that '[OFF]' stands for offensiveness. I don't think that this is the intended meaning so what actually *does* '[OFF]' mean? I never came across that abbreviation before (although I have been around on the USENET for quite some time) but maybe it is worth knowing? Josef 'Jupp' Schugt NOTE: mails >100 KiB ...

'!' vs. '.'
Is there an advantage to using the '!' notation to represent form/ control relationships? (eg. Me!text1 vs Me.text1) I am currently using the '.' notation exclusively (for code completion in the VB Editor), but much of the high-quality code that I've seen (in Duane Hookom's Query-by-Form db, for example) uses the other. Here's one opinion for you: http://doc.advisor.com/doc/05352 robert.waters wrote: >Is there an advantage to using the '!' notation to represent form/ >control relationships? (eg. Me!text1 vs Me.text1) > >I am currently using...

Override 'and' and 'or'
Is it possible to override 'and' and/or 'or'? I cannot find a special method for it... __and__ and __rand__ and __or__ and __ror__ are for binary manipulation... any proposals? Have marvelous sunday, Marco Dekker <m.aschwanden@gmail.com> wrote: > Is it possible to override 'and' and/or 'or'? I cannot find a special > method for it... __and__ and __rand__ and __or__ and __ror__ are for > binary manipulation... any proposals? If you want to customize the truth value testing you have to implement __nonzero__ " __nonzero__( self) Call...

replacement for '{' and '}' ?
I am still playing around with what kind of syntax I would like to mark up my documents. Are there equivalent long substitutes for { and } when they are not used to describe arguments to functions? Something like \begin{group} and \end{group}. In other words, if I could force myself to write, say, \begin{group} \it ... \end{group} instead of {\it ... }, then I believe I could identify from the markup context what is an argument that belongs to a just invoked macro and what is text. {Of course, in this context, \textit{...} would be better.} No more ambiguity whether a in \myfunction{a} i...

We Are Selling The Nextel I930 For Just $130usd'''''''''''
Dear Customer We have all brands of Mobile Phones,Ipods,Sidekicks,Nextel phone,Laptops for sell at cheap an affordable prices, they ranges from Nokia/Samsung/LG/Son Ericsson/Motorola/Alcatel/panasonic With Bluetooth, al Brands and Models of Nextel Phones, we want you to get bac to us with your quote so that we can begin a good busines relationship. Note they are all Brand New T2 Euro specs unlocked, no operator logo, come in thei original sealed box, With 1 year international warrant from the manufacturer, English & Spanish manual, Finlan made We want to assure you that you will never r...

Web resources about - Does '!=' equivelent to 'is not' - comp.lang.python

Resources last updated: 2/21/2016 10:36:22 PM