question on log as an instance method

2012-10-07 Thread Franck Ditter
Hi ! Here is Python 3.2.3, MacOSX-Lion Question : I may consider + as an hidden instance method , as 1+2 is equivalent to (1).__add__(2) ? I also consider __abs__ as an instance method : >>> (-2).__abs__() 2 Question 1 : could the parser cope with the mandatory space in 1 .__add__(2) ? Question

getting the state of an object

2012-10-07 Thread Franck Ditter
Hi ! Another question. When writing a class, I have often to destructure the state of an object as in : def foo(self) : (a,b,c,d) = (self.a,self.b,self.c,self.d) ... big code with a,b,c,d ... So I use the following method : def state(self) : return (self.a,self.b,self.c,self.d) so

Re: question on log as an instance method

2012-10-07 Thread Chris Rebert
On Sun, Oct 7, 2012 at 1:33 AM, Franck Ditter wrote: > Hi ! Here is Python 3.2.3, MacOSX-Lion > > Question 0 : I may consider + as an hidden instance method , as > 1+2 is equivalent to (1).__add__(2) ? No, it's not nearly that simple. It's technically equivalent to operator.add(1, 2) [ http://doc

Re: question on log as an instance method

2012-10-07 Thread Steven D'Aprano
On Sun, 07 Oct 2012 10:33:36 +0200, Franck Ditter wrote: > Question : I may consider + as an hidden instance method , as 1+2 is > equivalent to (1).__add__(2) ? I also consider __abs__ as an instance > method : (-2).__abs__() > 2 The short answer is, yes. The *correct* answer is, not quite

Re: getting the state of an object

2012-10-07 Thread Chris Rebert
On Sun, Oct 7, 2012 at 1:50 AM, Franck Ditter wrote: > Hi ! > > Another question. When writing a class, I have often to > destructure the state of an object as in : > > def foo(self) : > (a,b,c,d) = (self.a,self.b,self.c,self.d) > ... big code with a,b,c,d ... I would generally strongly f

Re: question on log as an instance method

2012-10-07 Thread Chris Rebert
On Sun, Oct 7, 2012 at 1:33 AM, Franck Ditter wrote: > As a matter of netiquette, please don't post from a plausible-but-invalid email address, especially at a domain that doesn't seem to belong to you. (I got a mailer-daemon bounce when replying to your posts.) If you must use an invalid address

Re: getting the state of an object

2012-10-07 Thread Oscar Benjamin
On Oct 7, 2012 9:57 AM, "Franck Ditter" wrote: > > Hi ! > > Another question. When writing a class, I have often to > destructure the state of an object as in : > > def foo(self) : > (a,b,c,d) = (self.a,self.b,self.c,self.d) > ... big code with a,b,c,d ... > What's wrong with the above? I

Re: getting the state of an object

2012-10-07 Thread Chris Angelico
On Sun, Oct 7, 2012 at 7:50 PM, Franck Ditter wrote: > def foo(self) : > (a,b,c,d) = (self.a,self.b,self.c,self.d) > ... big code with a,b,c,d ... > This strikes me as ripe for bug introduction. There's no problem if you're just reading those values, and mutating them is equally fine, but

Re: getting the state of an object

2012-10-07 Thread Miki Tebeka
> Is there a simple way to get the *ordered* list of instance Here's one way to do it (weather doing it is a good idea or not is debatable): from operator import attrgetter def __init__(self, a, b, c, d): self.a, self.b, self.c, self.d = a, b, c, d get = attrgetter('a', 'b

Re: getting the state of an object

2012-10-07 Thread Roy Smith
In article <507170e9$0$29978$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I've just looked at one of my classes, picked randomly, and the largest > method is twelve lines, the second largest is eight, and the average is > three lines. I took a look at a subtree of the project

wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-07 Thread Token Type
In order to solve the following question, http://nltk.googlecode.com/svn/trunk/doc/book/ch02.html: ★ Use one of the predefined similarity measures to score the similarity of each of the following pairs of words. Rank the pairs in order of decreasing similarity. How close is your ranking to the o

Re: Problems building Python from hg trunk on Open SUSE

2012-10-07 Thread 88888 Dihedral
Skip Montanaro於 2012年10月6日星期六UTC+8上午8時25分06秒寫道: > I haven't messed around with Python 3 recently, so decided to give it > > a whirl again. I cloned the trunk (cpython) and set about it. This > > is on an OpenSUSE 12.1 system. I configured like so: > > > > ./configure --prefix=/home/skipm/

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-07 Thread Mark Lawrence
On 07/10/2012 17:15, Token Type wrote: In order to solve the following question, http://nltk.googlecode.com/svn/trunk/doc/book/ch02.html: ★ Use one of the predefined similarity measures to score the similarity of each of the following pairs of words. Rank the pairs in order of decreasing simila

Re: Unpaking Tuple

2012-10-07 Thread woooee
On Oct 6, 3:09 am, sajuptpm wrote: > I need a way to make following code working without any ValueError . > > >>> a, b, c, d = (1,2,3,4) > >>> a, b, c, d = (1,2,3). Why is it necessary to unpack the tuple into arbitrary variables. a_tuple=(1,2,3) for v in a_tuple: print v for ctr in range(le

Question on Python Split

2012-10-07 Thread subhabangalore
Dear Group, Suppose I have a string as, "Project Gutenberg has 36000 free ebooks for Kindle Android iPad iPhone." I am terming it as, str1= "Project Gutenberg has 36000 free ebooks for Kindle Android iPad iPhone." I am working now with a split function, str_words=str1.split() so, I would ge

Convert MAC to hex howto

2012-10-07 Thread Johannes Graumann
Dear all, I'm trying to convert '00:08:9b:ce:f5:d4' to '\x00\x08\x9b\xce\xf5\xd4' for use in magic packet construction for WakeOnLan like so: wolsocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) wolsocket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-07 Thread Terry Reedy
On 10/7/2012 12:15 PM, Token Type wrote: In this case, I need to use loop to iterate each element in the above pairs. How can I refer to each element in the above pairs, i.e. pairs = [(car, automobile), (gem, jewel), (journey, voyage) ]. What's the index for 'car' and for 'automobile'? Thanks fo

Re: Convert MAC to hex howto

2012-10-07 Thread Paul Rubin
Johannes Graumann writes: > '00:08:9b:ce:f5:d4' > ... > hexcall = "\\x".join(hexcall).decode('string_escape') I think it's best not to mess with stuff like that. Convert to integers then convert back: mac = '00:08:9b:ce:f5:d4' hexcall = ''.join(chr(int(c,16)) for c in mac.split(':'))

Re: Question on Python Split

2012-10-07 Thread MRAB
On 2012-10-07 20:30, subhabangal...@gmail.com wrote: Dear Group, Suppose I have a string as, "Project Gutenberg has 36000 free ebooks for Kindle Android iPad iPhone." I am terming it as, str1= "Project Gutenberg has 36000 free ebooks for Kindle Android iPad iPhone." I am working now with a s

Re: Unpaking Tuple

2012-10-07 Thread Terry Reedy
On 10/7/2012 1:58 PM, woooee wrote: On Oct 6, 3:09 am, sajuptpm wrote: I need a way to make following code working without any ValueError . a, b, c, d = (1,2,3,4) a, b, c, d = (1,2,3) You cannot 'make' buggy code work -- except by changing it. >>> a, b, c, *d = (1,2,3) >>> d [] Why is it

Re: Convert MAC to hex howto

2012-10-07 Thread MRAB
On 2012-10-07 20:44, Johannes Graumann wrote: Dear all, I'm trying to convert '00:08:9b:ce:f5:d4' to '\x00\x08\x9b\xce\xf5\xd4' for use in magic packet construction for WakeOnLan like so: wolsocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) wolsock

Re: Question on Python Split

2012-10-07 Thread Terry Reedy
On 10/7/2012 3:30 PM, subhabangal...@gmail.com wrote: If I work again from tuple point, I get it as, tup1=('Project Gutenberg') tup2=('has 36000') tup3=('free ebooks') tup4=('for Kindle') tup5=('Android iPad') These are strings, not tuples. Numbered names like this are a bad idea. tup6=tup1

Re: Convert MAC to hex howto

2012-10-07 Thread Johannes Graumann
MRAB wrote: > On 2012-10-07 20:44, Johannes Graumann wrote: >> Dear all, >> >> I'm trying to convert >> '00:08:9b:ce:f5:d4' >> to >> '\x00\x08\x9b\xce\xf5\xd4' >> for use in magic packet construction for WakeOnLan like so: >> wolsocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) >>

Re: Convert MAC to hex howto

2012-10-07 Thread Johannes Graumann
Paul Rubin wrote: > Johannes Graumann writes: >> '00:08:9b:ce:f5:d4' >> ... >> hexcall = "\\x".join(hexcall).decode('string_escape') > > I think it's best not to mess with stuff like that. Convert to integers > then convert back: > > mac = '00:08:9b:ce:f5:d4' > hexcall = ''.join(chr(int(c,

Re: Convert MAC to hex howto

2012-10-07 Thread Peter Otten
Johannes Graumann wrote: > Dear all, > > I'm trying to convert > '00:08:9b:ce:f5:d4' > to > '\x00\x08\x9b\xce\xf5\xd4' > for use in magic packet construction for WakeOnLan like so: > wolsocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) >wolsocket.setsockopt(socket.SOL_SOCKET, sock

Re: how to run shell command like "<

2012-10-07 Thread 叶佑群
于 2012-9-29 19:53, Kushal Kumaran 写道: On Sat, Sep 29, 2012 at 6:18 AM, 叶佑群 wrote: 于 2012-9-28 16:16, Kushal Kumaran 写道: On Fri, Sep 28, 2012 at 1:15 PM, 叶佑群 wrote: Hi, all, I have the shell command like this: sfdisk -uM /dev/sdb<< EOT ,1000,83 ,,83 EOT I have tried subpro

Re: notmm is dead!

2012-10-07 Thread alex23
On Oct 6, 12:59 pm, Michael Torrie wrote: > I suppose a person can fail a turing test... You did, yes :) -- http://mail.python.org/mailman/listinfo/python-list

Re: notmm is dead!

2012-10-07 Thread Dwight Hutto
On Sun, Oct 7, 2012 at 9:19 PM, alex23 wrote: > On Oct 6, 12:59 pm, Michael Torrie wrote: >> I suppose a person can fail a turing test... > > You did, yes :) > What is failed, but a timeline in this scenario, if you found the answer in the end? Failure becomes answer not given in interval requi

Re: notmm is dead!

2012-10-07 Thread alex23
On Oct 8, 11:45 am, Dwight Hutto wrote: > What is failed, but a timeline in this scenario, if you found the > answer in the end? It was a _joke_ referring to Michael Torrie's email addressing the 8 Dihedral bot _as if it was a person_. > Failure becomes answer not given in interval required,

Re: notmm is dead!

2012-10-07 Thread Michael Torrie
On 10/07/2012 08:08 PM, alex23 wrote: > On Oct 8, 11:45 am, Dwight Hutto wrote: >> What is failed, but a timeline in this scenario, if you found the >> answer in the end? > > It was a _joke_ referring to Michael Torrie's email addressing the > 8 Dihedral bot _as if it was a person_. Well it

How to control the internet explorer?

2012-10-07 Thread yujian
I want to save all the URLs in current opened windows, and then close all the windows. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to control the internet explorer?

2012-10-07 Thread alex23
On Oct 8, 1:03 pm, yujian wrote: > I want to save all the URLs in current opened windows,  and then close > all the windows. Try mechanize or Selenium. -- http://mail.python.org/mailman/listinfo/python-list

Re: notmm is dead!

2012-10-07 Thread Jason Friedman
>> It was a _joke_ referring to Michael Torrie's email addressing the >> 8 Dihedral bot _as if it was a person_. > > Well it would be useful to probe the bot's parameters... Five eights is a busy bot: http://www.velocityreviews.com/forums/t806110-p8-ok-lets-start-real-programming-in-c-for-prob

Re: notmm is dead!

2012-10-07 Thread Michael Torrie
On 10/07/2012 09:42 PM, Jason Friedman wrote: >>> It was a _joke_ referring to Michael Torrie's email addressing the >>> 8 Dihedral bot _as if it was a person_. >> >> Well it would be useful to probe the bot's parameters... > > Five eights is a busy bot: > http://www.velocityreviews.com/forums

Re: notmm is dead!

2012-10-07 Thread Dwight Hutto
On Thu, Oct 4, 2012 at 2:10 PM, Etienne Robillard wrote: > Dear list, > > Due to lack of energy and resources i'm really sad to announce the removal of > notmm from pypi and bitbucket. I deleted > also my account from bitbucket as it was not really useful for me. Not 1 response? notmm will con