Re: why () is () and [] is [] work in other way?

2012-04-23 Thread rusi
On Apr 23, 9:34 am, Steven D'Aprano wrote: > "is" is never ill-defined. "is" always, without exception, returns True > if the two operands are the same object, and False if they are not. This > is literally the simplest operator in Python. Circular definition: In case you did not notice, 'is' an

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Devin Jeanpierre
On Tue, Apr 24, 2012 at 12:12 AM, Terry Reedy wrote: >> and you're trying to dodge around that. :/ > > In a previous post you chided Stephen for an ad hominem comment. Above you > make two. Both are false. I accused you of not answering the question or shifting goalposts. This is an attack agains

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Terry Reedy
On 4/23/2012 4:37 PM, Devin Jeanpierre wrote: However, you appear to be trying to shift the goalposts. Either "1 is 1" is always True, or always False, or sometimes one or the other. If I'm mistaken and it so happens that numeric constants are guaranteed somewhere to always be cached, then repla

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Devin Jeanpierre
On Mon, Apr 23, 2012 at 11:03 PM, Tim Delaney wrote: > My claim is that doing this automatically for all integers and/or strings > could lead to prohibitively-expensive performance characteristics, and done > wrong to prohibitively-expensive memory characteristics. OK. I agree, and I'm not in fav

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Tim Delaney
On 24 April 2012 11:08, Devin Jeanpierre wrote: > cache = {} > > def intern(x): > return cache.setdefault(x, x) > > Do we agree that A) this function works without using identity > comparisons, and B) this function performs the task of interning? Of course. I never claimed otherwise. It is

Re: This code not working, need suggetions

2012-04-23 Thread Anirudh Srinivasan
Thanks Min and Chris for your ideas and suggestion, i understood my mistake. This code is working fine now. On Mon, Apr 23, 2012 at 2:51 AM, Min Yu wrote: > try this code out. The lsdir function and cat function are both used in > main(). > > The bash commands are as following: > > yumin@yumin-t

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Devin Jeanpierre
On Mon, Apr 23, 2012 at 8:03 PM, Tim Delaney wrote: > On 24 April 2012 09:08, Devin Jeanpierre wrote: >> >> On Mon, Apr 23, 2012 at 6:26 PM, Tim Delaney >> wrote: >> > And doing that would make zero sense, because it directly contradicts >> > the >> > whole *point* of "is". The point of "is" is

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Tim Delaney
On 24 April 2012 10:18, Robert Kern wrote: > On 4/24/12 1:03 AM, Tim Delaney wrote: > >> On 24 April 2012 09:08, Devin Jeanpierre > > wrote: >> >>On Mon, Apr 23, 2012 at 6:26 PM, Tim Delaney >>> > >> wrote: >> > An

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Robert Kern
On 4/24/12 1:03 AM, Tim Delaney wrote: On 24 April 2012 09:08, Devin Jeanpierre mailto:jeanpierr...@gmail.com>> wrote: On Mon, Apr 23, 2012 at 6:26 PM, Tim Delaney mailto:timothy.c.dela...@gmail.com>> wrote: > And doing that would make zero sense, because it directly contradicts the

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Tim Delaney
On 24 April 2012 09:08, Devin Jeanpierre wrote: > On Mon, Apr 23, 2012 at 6:26 PM, Tim Delaney > wrote: > > And doing that would make zero sense, because it directly contradicts the > > whole *point* of "is". The point of "is" is to tell you whether or not > two > > references are to the same ob

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Devin Jeanpierre
On Mon, Apr 23, 2012 at 6:26 PM, Tim Delaney wrote: > And doing that would make zero sense, because it directly contradicts the > whole *point* of "is". The point of "is" is to tell you whether or not two > references are to the same object. This is a *useful* property. It's useful for mutable ob

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Tim Delaney
On 24 April 2012 06:40, Devin Jeanpierre wrote: > On Mon, Apr 23, 2012 at 4:27 PM, Devin Jeanpierre > wrote: > > Well, no. Immutable objects could always compare equal, for example. > > This is more expensive though. is as-it-stands is very quick to > > execute, which is probably attractive to s

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Bernd Nawothnig
On 2012-04-23, Paul Rubin wrote: > Kiuhnm writes: >> I can't think of a single case where 'is' is ill-defined. > > If I can't predict the output of > > print (20+30 is 30+20) # check whether addition is commutative > print (20*30 is 30*20) # check whether multiplication is commutative >

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Devin Jeanpierre
On Mon, Apr 23, 2012 at 4:06 PM, Terry Reedy wrote: >> The only way to check if two values are the same or not is to compare >> via is or compare the return values of id(). > > To quote you, 'bollocks'. The right way to compare values is with value > comparison operators. I meant "the same object

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Devin Jeanpierre
On Mon, Apr 23, 2012 at 4:27 PM, Devin Jeanpierre wrote: > Well, no. Immutable objects could always compare equal, for example. > This is more expensive though. is as-it-stands is very quick to > execute, which is probably attractive to some people (especially for > its used in detecting special c

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Devin Jeanpierre
On Mon, Apr 23, 2012 at 3:59 PM, Terry Reedy wrote: >> >> Bollocks it's well defined. We've already agreed that "1 is 1" may or >> may not return True. > > > 'We' have not so agreed. The function should tell the truth. Let me repeat: > 'is' is a function whose two inputs are not eternal mathematic

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Devin Jeanpierre
On Mon, Apr 23, 2012 at 3:58 PM, Steven D'Aprano wrote: >> Whether a and b are the same object is implementation-dependent. > > And that has absolutely nothing to do with the behaviour of "is". The > "is" operator is not responsible for whether a and b are the same object. Heh, it has everything

Re: I couldn't use the sign funcion inside of another function

2012-04-23 Thread Emile van Sebille
On 4/23/2012 11:39 AM Chris Rebert said... On Mon, Apr 23, 2012 at 11:29 AM, Julio Sergio wrote: I want to use the sign function. When I use it in in-line mode works pretty well: : sign(-20) : -1 However, I wrote the following code in a file, say, pp.py def tst(x): s = sign(x)

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Terry Reedy
On 4/23/2012 1:55 PM, Devin Jeanpierre wrote: On Mon, Apr 23, 2012 at 1:21 PM, Benjamin Kaplan wrote: On Mon, Apr 23, 2012 at 1:01 PM, Paul Rubin wrote: The "is" operator is perfectly defined. But it doesn't check to see whether two objects hold equivalent values, it checks whether they are t

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Terry Reedy
On 4/23/2012 12:38 AM, Devin Jeanpierre wrote: On Sun, Apr 22, 2012 at 9:22 PM, Terry Reedy wrote: On 4/22/2012 3:43 PM, John Nagle wrote: On 4/20/2012 9:34 PM, john.tant...@gmail.com wrote: On Friday, April 20, 2012 12:34:46 PM UTC-7, Rotwang wrote: I believe it says somewhere in the Pyt

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Steven D'Aprano
On Mon, 23 Apr 2012 10:01:24 -0700, Paul Rubin wrote: > Kiuhnm writes: >> I can't think of a single case where 'is' is ill-defined. > > If I can't predict the output of > > print (20+30 is 30+20) # check whether addition is commutative > print (20*30 is 30*20) # check whether multipli

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Robert Kern
On 4/23/12 5:04 PM, John Nagle wrote: On 4/22/2012 9:34 PM, Steven D'Aprano wrote: On Sun, 22 Apr 2012 12:43:36 -0700, John Nagle wrote: On 4/20/2012 9:34 PM, john.tant...@gmail.com wrote: On Friday, April 20, 2012 12:34:46 PM UTC-7, Rotwang wrote: I believe it says somewhere in the Python

Re: I couldn't use the sign funcion inside of another function

2012-04-23 Thread Chris Rebert
On Mon, Apr 23, 2012 at 11:29 AM, Julio Sergio wrote: > I want to use the sign function. When I use it in in-line mode works pretty > well: > >   : sign(-20) >   : -1 > > However, I wrote the following code in a file, say, pp.py > > def tst(x): >    s = sign(x) >    return(s) > > Then I tried to i

I couldn't use the sign funcion inside of another function

2012-04-23 Thread Julio Sergio
I want to use the sign function. When I use it in in-line mode works pretty well: : sign(-20) : -1 However, I wrote the following code in a file, say, pp.py def tst(x): s = sign(x) return(s) Then I tried to import into my session: : from pp import * When I try to use tst, thi

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Devin Jeanpierre
On Mon, Apr 23, 2012 at 1:21 PM, Benjamin Kaplan wrote: > On Mon, Apr 23, 2012 at 1:01 PM, Paul Rubin wrote: > The "is" operator is perfectly defined. But it doesn't check to see > whether two objects hold equivalent values, it checks whether they are > the same thing. You're not interested in wh

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Ian Kelly
On Mon, Apr 23, 2012 at 11:01 AM, Paul Rubin wrote: > Kiuhnm writes: >> I can't think of a single case where 'is' is ill-defined. > > If I can't predict the output of > >    print (20+30 is 30+20)  # check whether addition is commutative >    print (20*30 is 30*20)  # check whether multiplication

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Kiuhnm
On 4/23/2012 19:01, Paul Rubin wrote: Kiuhnm writes: I can't think of a single case where 'is' is ill-defined. If I can't predict the output of print (20+30 is 30+20) # check whether addition is commutative print (20*30 is 30*20) # check whether multiplication is commutative by

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Benjamin Kaplan
On Mon, Apr 23, 2012 at 1:01 PM, Paul Rubin wrote: > > Kiuhnm writes: > > I can't think of a single case where 'is' is ill-defined. > > If I can't predict the output of > >    print (20+30 is 30+20)  # check whether addition is commutative >    print (20*30 is 30*20)  # check whether multiplicati

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Paul Rubin
Kiuhnm writes: > I can't think of a single case where 'is' is ill-defined. If I can't predict the output of print (20+30 is 30+20) # check whether addition is commutative print (20*30 is 30*20) # check whether multiplication is commutative by just reading the language definition and

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Kiuhnm
On 4/22/2012 21:43, John Nagle wrote: On 4/20/2012 9:34 PM, john.tant...@gmail.com wrote: On Friday, April 20, 2012 12:34:46 PM UTC-7, Rotwang wrote: I believe it says somewhere in the Python docs that it's undefined and implementation-dependent whether two identical expressions have the same

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread John Nagle
On 4/22/2012 9:34 PM, Steven D'Aprano wrote: On Sun, 22 Apr 2012 12:43:36 -0700, John Nagle wrote: On 4/20/2012 9:34 PM, john.tant...@gmail.com wrote: On Friday, April 20, 2012 12:34:46 PM UTC-7, Rotwang wrote: I believe it says somewhere in the Python docs that it's undefined and implementa

PyOpenCV -- help?

2012-04-23 Thread Virgil Stokes
I have tried to install PyOpenCV without success (error occurs during the installation procedure). I reported the problem to the opencv user group (http://groups.google.com/group/ctypes-opencv) but this group has not been active since June of last year. Anyone know of how to get help with PyO

Re: why () is () and [] is [] work in other way?

2012-04-23 Thread Alexander Blinne
Am 21.04.2012 14:51, schrieb gst: > Hi, > > I played (python3.2) a bit on that and : > > case 1) Ok to me (right hand side is a tuple, whose elements are evaluated > one per one and have same effect as your explanation (first [] is destroyed > right before the second one is created) : > x

Re: Newbie, homework help, please.

2012-04-23 Thread Jean-Michel Pichavant
someone wrote: I have a professor who should be [*snip*] the best person I've ever met I hope he's (not) reading this list :o) Non python advise : be very careful on the internet. JM -- http://mail.python.org/mailman/listinfo/python-list

Re: This code not working, need suggetions

2012-04-23 Thread Min Yu
try this code out. The lsdir function and cat function are both used in main(). The bash commands are as following: yumin@yumin-think:~/src/test/python/community$ python list.py `pwd` /home/yumin/src/test/python/community list.py file1 file2 Which file would you like to browse ?file1 This is file

Re: This code not working, need suggetions

2012-04-23 Thread Chris Rebert
On Sun, Apr 22, 2012 at 11:16 PM, Anirudh Srinivasan wrote: > > My code lists the files and directory under a folder and if we want to > read the file it uses the function  cat. > > But the function cat(get_file) is not working , any suggetions? Please specifically state exactly how it's deviatin