[Tutor] set key to sort

2009-01-31 Thread prasad rao
hellI got a problem sorting a list of lists. ml= [[112, 'p'], [114, 'r'], [97, 'a'], [115, 's'], [97, 'a'], [100, 'd'], [97, 'a'], [114, 'r'], [97, 'a'], [111, 'o']] sorted(ml,key=?) How can I formulate a key to sort based on the first element of each list. sorting list of lists might have been d

Re: [Tutor] set key to sort

2009-01-31 Thread Sander Sweers
On Sat, Jan 31, 2009 at 10:51, prasad rao wrote: > I got a problem sorting a list of lists. > ml= > [[112, 'p'], [114, 'r'], [97, 'a'], [115, 's'], [97, 'a'], [100, 'd'], [97, > 'a'], [114, 'r'], [97, 'a'], [111, 'o']] > sorted(ml,key=?) > How can I formulate a key to sort based on the first eleme

[Tutor] Recycle bin Windows XP - List or empty the bin

2009-01-31 Thread Dominique
Hello, I would like to access the recycle bin on windows xp and eventually empty its content. Googling around this led me to try the following (to empty the bin): from win32com.shell import shell shell.SHEmptyRecycleBin() Unfortunately, this doesn't work. The traceback gives me : TypeError: SHE

Re: [Tutor] Recycle bin Windows XP - List or empty the bin

2009-01-31 Thread Tim Golden
Dominique wrote: Googling around this led me to try the following (to empty the bin): from win32com.shell import shell shell.SHEmptyRecycleBin() Unfortunately, this doesn't work. The traceback gives me : TypeError: SHEmptyRecycleBin() takes exactly 3 arguments (0 given) So, I tried something I

[Tutor] Want to write a Perl based IP to Domain Name converter.

2009-01-31 Thread hongyi . zhao
Hi all, The script in the following can do the batch conversion from domain name to IP: -- #!/usr/bin/perl use warnings; use strict; use Socket; while ( <> ) { chomp; my ( $address, $port ) = split /:/ or next; my $number = inet_aton $address; my $ip = in

Re: [Tutor] set key to sort

2009-01-31 Thread Kent Johnson
On Sat, Jan 31, 2009 at 4:51 AM, prasad rao wrote: > hell > I got a problem sorting a list of lists. > ml= > [[112, 'p'], [114, 'r'], [97, 'a'], [115, 's'], [97, 'a'], [100, 'd'], [97, > 'a'], [114, 'r'], [97, 'a'], [111, 'o']] > sorted(ml,key=?) > How can I formulate a key to sort based on the fi

Re: [Tutor] datetime year problem, default year available?

2009-01-31 Thread Sander Sweers
On Tue, Jan 27, 2009 at 01:01, Sander Sweers wrote: > month ('11/27' for example). Now when I use datetime.strptime('11/27', > ''%m/%d) I get a datetime object but the year is 1900. This makes > sense as I did not provide one. > > Then I saw that a datetime object has a replace function so now I >

Re: [Tutor] Want to write a Perl based IP to Domain Name converter.

2009-01-31 Thread Kent Johnson
On Sat, Jan 31, 2009 at 7:11 AM, wrote: > Hi all, > > The script in the following can do the batch conversion from domain name to > IP: ?? This is a Python list, not Perl! Kent > > -- > > #!/usr/bin/perl > use warnings; > use strict; > use Socket; > > while ( <> ) { > chomp

[Tutor] Recycle bin Windows XP - List or empty the bin

2009-01-31 Thread Dominique
Tim, Thank you very much for your help. That works fine. Dominique ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Want to write a Perl based IP to Domain Name converter.

2009-01-31 Thread hongyi . zhao
On Saturday, January 31, 2009 at 21:44, ken...@tds.net wrote: > On Sat, Jan 31, 2009 at 7:11 AM, wrote: >> Hi all, >> >> The script in the following can do the batch conversion from domain name to >> IP: > This is a Python list, not Perl! OMG! It's my mistake, sorry for this. -- Hongyi Zhao

Re: [Tutor] IDLE vs PythonWin

2009-01-31 Thread Wayne Watson
Title: Signature.html Did I miss a response here? Wayne Watson wrote: vim? I'm looking at the interactive window now. Here are two choices for what you say: 1. alt-tab vim Traceback (  File "", line 1     alt-tab vim   ^ SyntaxError: invalid syntax 2. Pressing the alt-tab ke

[Tutor] methods split and join in sequence

2009-01-31 Thread David
Dear list, many thanks for all your help - much appreciated. Today I have continued reading Harrington, and produced the following code, which works flawlessly. I wonder, though, how I could join all the supplied words with underscores _without_ making use of split first? This I didn't manage.

Re: [Tutor] methods split and join in sequence

2009-01-31 Thread W W
On Sat, Jan 31, 2009 at 9:09 AM, David wrote: > Dear list, > > many thanks for all your help - much appreciated. > Today I have continued reading Harrington, and produced the following code, > which works flawlessly. > I wonder, though, how I could join all the supplied words with underscores > _

Re: [Tutor] IDLE vs PythonWin

2009-01-31 Thread Wayne Watson
Hi, sorry, but I have no idea what vim is, let alone how to use any of the features. I'd still like to know why pythonwin prints almost completely blank pages. vim=vi(m), linux?? W W wrote: On Sat, Jan 31, 2009 at 8:45 AM, Wayne Watson wrote: Did I miss

Re: [Tutor] methods split and join in sequence

2009-01-31 Thread Andre Engels
On Sat, Jan 31, 2009 at 4:09 PM, David wrote: > Dear list, > > many thanks for all your help - much appreciated. > Today I have continued reading Harrington, and produced the following code, > which works flawlessly. > I wonder, though, how I could join all the supplied words with underscores > _w

Re: [Tutor] IDLE vs PythonWin

2009-01-31 Thread W W
On Sat, Jan 31, 2009 at 9:56 AM, Wayne Watson wrote: > Hi, sorry, but I have no idea what vim is, let alone how to use any of the > features. I'd still like to know why pythonwin prints almost completely > blank pages. vim=vi(m), linux?? > VIM = Vi IMproved = vim +- vi. Basically, vim is just an

[Tutor] Thank you

2009-01-31 Thread prasad rao
Hello Thanks .Today I learned to use operator.itemgetter() to set key. Thank you prasad ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Is instance of what?

2009-01-31 Thread Tim Johnson
Using python 2.5.1 If I create a class a class a: pass initialize o as: o=a and call isinstance(o,a) the return value is True. Is there a function that takes one argument and returns the class? Example: class = whatclass(o) >> "a" Since I'm hoping the answer to this question will help me a

[Tutor] Re : Is instance of what?

2009-01-31 Thread Andre Engels
On Sat, Jan 31, 2009 at 5:57 PM, Tim Johnson wrote: > Using python 2.5.1 > > If I create a class a > > class a: > > pass > > initialize o as: > > o=a > > and call > > isinstance(o,a) > > the return value is True. Actually, it is false. To make it true, you have to do o=a() rather than o=a > Is t

[Tutor] string fomatting

2009-01-31 Thread Jay Jesus Amorin
Hi, I'm a newbie trying to learn python. Kindly help me on string formatting. test = https://www.localhost.org/testmodule/dev/trunk/admin/sql/mytest.sql what will i use to print this output? 1, https://www.localhost.org/ 2. testmodule 3. /dev/trunk/admin/sql/mytest.sql Thanks, Jay __

Re: [Tutor] string fomatting

2009-01-31 Thread bob gailer
Jay Jesus Amorin wrote: Hi, I'm a newbie trying to learn python. Kindly help me on string formatting. test = https://www.localhost.org/testmodule/dev/trunk/admin/sql/mytest.sql My browser can't establish a connection to that site! what will i use to print this output? 1, https://www.localh

Re: [Tutor] string fomatting

2009-01-31 Thread bob gailer
Jay Jesus Amorin wrote: Hi, I'm a newbie trying to learn python. Kindly help me on string formatting. test = https://www.localhost.org/testmodule/dev/trunk/admin/sql/mytest.sql what will i use to print this output? 1, https://www.localhost.org/ 2. testmodule 3. /dev/trunk/admin/sql/mytest.s

Re: [Tutor] string fomatting

2009-01-31 Thread Jay Jesus Amorin
Thanks bob. I want to search any characters in test after https://www.localhost.org/and the search will end after it finds another / and when i print it will display *testmodule*. Newbie, Jay On Sun, Feb 1, 2009 at 2:29 AM,

[Tutor] Tkinter program start with focus?`

2009-01-31 Thread W W
Hi, I'm running into a problem that's bugging me because I know a program used it, I just can't find which one it was... I want my Tkinter program to start with the focus, but I can't remember the command. TIA, Wayne -- To be considered stupid and to be told so is more painful than being called

Re: [Tutor] Re : Is instance of what?

2009-01-31 Thread Tim Johnson
On Saturday 31 January 2009, Andre Engels wrote: <...> > > o=a <> > Actually, it is false. To make it true, you have to do o=a() rather than > o=a You're correct. That was my typo. > > Is there a function that takes one > > > > argument and returns the class? > > > > Example: > > > > class =

Re: [Tutor] IDLE vs PythonWin

2009-01-31 Thread W W
On Sat, Jan 31, 2009 at 8:45 AM, Wayne Watson wrote: > Did I miss a response here? > > Wayne Watson wrote: > > vim? I'm looking at the interactive window now. Here are two choices for > what you say: > 1. > alt-tab vim > Traceback ( File "", line 1 > alt-tab vim > ^ > SyntaxErr

[Tutor] PyCon2009 Tutorial: An Introduction to Object-Oriented Programming

2009-01-31 Thread Michael H . Goldwasser
David Letscher and I will be leading a tutorial at this year's PyCon titled "An Introduction to Object-Oriented Programming." This tutorial is designed for programmers who are familiar with Python yet new to the concept of object-oriented programming. We also welcome programmers who are experien

Re: [Tutor] Re : Is instance of what?

2009-01-31 Thread spir
Le Sat, 31 Jan 2009 09:54:24 -0900, Tim Johnson a écrit : > On Saturday 31 January 2009, Andre Engels wrote: > <...> > > > o=a > <> > > Actually, it is false. To make it true, you have to do o=a() rather than > > o=a > You're correct. That was my typo. > > > Is there a function that takes

Re: [Tutor] string fomatting

2009-01-31 Thread Kent Johnson
On Sat, Jan 31, 2009 at 1:44 PM, Jay Jesus Amorin wrote: > Thanks bob. > > I want to search any characters in test after https://www.localhost.org/ and > the search will end after it finds another / > > and when i print it will display testmodule. One way to do this would be to use urlparse.urlpa

Re: [Tutor] string fomatting

2009-01-31 Thread spir
Le Sun, 1 Feb 2009 02:44:02 +0800, Jay Jesus Amorin a écrit : > Thanks bob. > > I want to search any characters in test after > https://www.localhost.org/and > the search will end after it finds another / > > and when i print

Re: [Tutor] Re : Is instance of what?

2009-01-31 Thread Kent Johnson
On Sat, Jan 31, 2009 at 2:47 PM, spir wrote: >> > o.__class__ (or rather o.__class__.__name__) will work. >> Understood. Thank you. >> tj > > type(a) has been changed (since 2.2?) to return the same value as a.__class__ I think you mean type(o) (type of the instance) rather than type(a) (type of

Re: [Tutor] Want to write a Perl based IP to Domain Name converter.

2009-01-31 Thread OkaMthembo
Lol..thats okay. Now that you are here and have seen what fun we have writing Python code - why not join the party? Don't be shy to join us :p - i bet you won't be sorry. On Sat, Jan 31, 2009 at 4:11 PM, wrote: > On Saturday, January 31, 2009 at 21:44, ken...@tds.net wrote: > > On Sat, Jan 31

[Tutor] Determining periodicity of rand.randint()

2009-01-31 Thread Tony Cappellini
Has anyone ever measured how random (or deterministic) a given sequence of numbers generated by rand.randint() are? Using these arguments for rand.randint(0, 1000 ) if a program which calls rand.randint() runs for 10 hours (or a few days), will it keep generating a repeatable set of numbers at

Re: [Tutor] string fomatting

2009-01-31 Thread bob gailer
Jay Jesus Amorin wrote: Thanks bob. I want to search any characters in test after https://www.localhost.org/ and the search will end after it finds another / and when i print it will display *testmodule*. Ah. Much clear

Re: [Tutor] Determining periodicity of rand.randint()

2009-01-31 Thread bob gailer
Tony Cappellini wrote: Has anyone ever measured how random (or deterministic) a given sequence of numbers generated by rand.randint() are? Using these arguments for rand.randint(0, 1000 ) if a program which calls rand.randint() runs for 10 hours (or a few days), will it keep generating

Re: [Tutor] Determining periodicity of rand.randint()

2009-01-31 Thread Kent Johnson
On Sat, Jan 31, 2009 at 3:39 PM, Tony Cappellini wrote: > > > Has anyone ever measured how random (or deterministic) a given sequence of > numbers generated by rand.randint() are? > > Using these arguments for rand.randint(0, 1000 ) > if a program which calls rand.randint() runs for 10 hours (

Re: [Tutor] Want to write a Perl based IP to Domain Name converter.

2009-01-31 Thread wesley chun
>> >> The script in the following can do the batch conversion from domain >> >> name to IP: >> >> > This is a Python list, not Perl! >> >> OMG! It's my mistake, sorry for this. > > Lol..thats okay. Now that you are here and have seen what fun we have > writing Python code - why not join the party

Re: [Tutor] PyCon2009 Tutorial: An Introduction to Object-Oriented Programming

2009-01-31 Thread wesley chun
> David Letscher and I will be leading a tutorial at this year's > PyCon titled "An Introduction to Object-Oriented Programming." likewise, i'll be doing one on network programming, so if you ever wanted to know all about it, we take it from the lowest layer (socket level), up thru internet proto

Re: [Tutor] string fomatting

2009-01-31 Thread wesley chun
>> I want to search any characters in test after https://www.localhost.org/ >> and >> the search will end after it finds another / here's another solution that takes advantage of the 'maxsplit' parameter of the str.split() metho

Re: [Tutor] Want to write a Perl based IP to Domain Name converter.

2009-01-31 Thread Martin Walsh
wesley chun wrote: > The script in the following can do the batch conversion from domain > name to IP: This is a Python list, not Perl! >>> OMG! It's my mistake, sorry for this. >> Lol..thats okay. Now that you are here and have seen what fun we have >> writing Python code - why not