Re: [Tutor] lists+sort

2016-01-04 Thread Danny Yoo
> > You may also take a look at this link: > http://stackoverflow.com/questions/7237875/linear-merging-for-lists-in-python > > It appears that the poster was going through Googles python tutorials Hi Joel, Ah. Nice catch! Yes, that looks like it. It looks like this comes from the material at h

Re: [Tutor] To FORMAT or not to

2016-01-04 Thread Mark Lawrence
Sorry no as that would often leave out data that I consider important. I have no interest in whether or not you agree with my opinion. On 05/01/2016 00:53, Steven D'Aprano wrote: On Mon, Jan 04, 2016 at 07:50:59PM +, Mark Lawrence wrote: On 03/01/2016 13:12, Alan Gauld wrote: [snip unnec

Re: [Tutor] Swapping values

2016-01-04 Thread Steven D'Aprano
On Tue, Jan 05, 2016 at 02:37:27AM +0200, yehudak . wrote: > In Python we can swap values between two variable a and b this way: > > a = 3; b = 7 > print(a, b) # => 3 7 > > a, b = b, a # swapping! > print(a, b) # => 7 3 > > How does this work? The right-hand side of the assignmen

[Tutor] Swapping values

2016-01-04 Thread yehudak .
In Python we can swap values between two variable a and b this way: a = 3; b = 7 print(a, b) # => 3 7 a, b = b, a # swapping! print(a, b) # => 7 3 How does this work? If I split the 'magic' line into: a = b; b = a without a temp variable I get: print(a, b) # => 7 7 Thank

Re: [Tutor] To FORMAT or not to

2016-01-04 Thread Steven D'Aprano
On Mon, Jan 04, 2016 at 07:50:59PM +, Mark Lawrence wrote: > On 03/01/2016 13:12, Alan Gauld wrote: [snip unnecessary quoting] > >There are several reasons although your technique is far from > >the worst way of doing things. And the format string here would probably > >be better written as:

Re: [Tutor] lists+sort

2016-01-04 Thread Joel Goldstick
On Mon, Jan 4, 2016 at 5:35 PM, Danny Yoo wrote: > On Jan 4, 2016 11:00 AM, "Pooja Bhalode" wrote: > > > > Hi, I wanted to check if this program can be used to merge the lists > > together and sort them. This seems to work, but i wanted to check if > there > > are drawbacks in writing it in this

Re: [Tutor] how to grep a word and make a dictionary from multiple lines.

2016-01-04 Thread David Rock
* Fosiul Alam [2016-01-04 22:29]: > Hi Expert, > I am learning python to do some system admin code, i am still in the > process of learning but I need a help on bellow code in urgent, i will be > really greatfull for any help > > Basically i wanted like this :- > > grep a line which has 1:0:0:12

Re: [Tutor] To FORMAT or not to

2016-01-04 Thread Alan Gauld
On 04/01/16 19:50, Mark Lawrence wrote: > Three reasons for why it's better but it doesn't actually work as given. > > >>> island = "Isle Of Wight" > >>> new = "Isle of Wong" > >>> print("You've visited {0} & {2}.".format(island, new)) > Traceback (most recent call last): >File "", line 1,

Re: [Tutor] how to grep a word and make a dictionary from multiple lines.

2016-01-04 Thread Danny Yoo
On Mon, Jan 4, 2016 at 2:29 PM, Fosiul Alam wrote: > Hi Expert, > I am learning python to do some system admin code, i am still in the > process of learning but I need a help on bellow code in urgent, i will be > really greatfull for any help Question: how would you do this task with regular Uni

[Tutor] how to grep a word and make a dictionary from multiple lines.

2016-01-04 Thread Fosiul Alam
Hi Expert, I am learning python to do some system admin code, i am still in the process of learning but I need a help on bellow code in urgent, i will be really greatfull for any help Basically i wanted like this :- grep a line which has 1:0:0:129 , and get the LUN number(i.e 36006016565656563434

Re: [Tutor] lists+sort

2016-01-04 Thread Danny Yoo
On Jan 4, 2016 11:00 AM, "Pooja Bhalode" wrote: > > Hi, I wanted to check if this program can be used to merge the lists > together and sort them. This seems to work, but i wanted to check if there > are drawbacks in writing it in this manner. You may be missing some important details or misunder

Re: [Tutor] To FORMAT or not to

2016-01-04 Thread Mark Lawrence
On 04/01/2016 21:54, Bod Soutar via Tutor wrote: On 4 January 2016 at 19:50, Mark Lawrence Three reasons for why it's better but it doesn't actually work as given. island = "Isle Of Wight" new = "Isle of Wong" print("You've visited {0} & {2}.".format(island, new)) Traceback (most recent call

Re: [Tutor] To FORMAT or not to

2016-01-04 Thread Bod Soutar via Tutor
On 4 January 2016 at 19:50, Mark Lawrence > > Three reasons for why it's better but it doesn't actually work as given. > island = "Isle Of Wight" new = "Isle of Wong" print("You've visited {0} & {2}.".format(island, new)) > Traceback (most recent call last): > File "", line 1, in

Re: [Tutor] To FORMAT or not to

2016-01-04 Thread Mark Lawrence
On 03/01/2016 13:12, Alan Gauld wrote: On 03/01/16 12:27, yehudak . wrote: Hi there, In a program I wrote the following line (Python 3.5): print("You've visited", island, '&', new + ".") A programmer told me that it's a bad habit, and I should have used instead: print("You've visited {0} {1}

Re: [Tutor] lists+sort

2016-01-04 Thread Joel Goldstick
On Mon, Jan 4, 2016 at 12:34 PM, Pooja Bhalode wrote: > Hi, I wanted to check if this program can be used to merge the lists > together and sort them. This seems to work, but i wanted to check if there > are drawbacks in writing it in this manner. > > > My solution: > > > def linear_merge(list1,

Re: [Tutor] Lists+sorting

2016-01-04 Thread Pooja Bhalode
Hi, Yes, I tried sending the mail again in plain text. But I think I understood the difference there in using built-in sort function and writing the code without using that. Thank you On Mon, Jan 4, 2016 at 12:45 PM, Joel Goldstick wrote: > On Mon, Jan 4, 2016 at 12:27 PM, Alan Gauld > wrote

[Tutor] lists+sort

2016-01-04 Thread Pooja Bhalode
Hi, I wanted to check if this program can be used to merge the lists together and sort them. This seems to work, but i wanted to check if there are drawbacks in writing it in this manner. My solution: def linear_merge(list1, list2): for num in list2: list1.append(num) list1

Re: [Tutor] Lists+sorting

2016-01-04 Thread Joel Goldstick
On Mon, Jan 4, 2016 at 12:27 PM, Alan Gauld wrote: > On 04/01/16 16:56, Pooja Bhalode wrote: > > Hi, > > I wanted to check if I can write the following program in this manner as > > well. > > > > Can you resend in plain text please? > Your post lost all its formatting so its hard to read > or com

Re: [Tutor] Tutor Digest, Vol 143, Issue 6

2016-01-04 Thread Alan Gauld
On 04/01/16 17:22, yehudak . wrote: > Dear gentlemen. > This discussion gave me the pleasure of watching two programmers clash head > to head. I'm not sure we were clashing. I actually agreed with most of what Steve said. I simply clarified the intent of one aspect of his post. To summarize: For

Re: [Tutor] Tutor Digest, Vol 143, Issue 6

2016-01-04 Thread yehudak .
Dear gentlemen. This discussion gave me the pleasure of watching two programmers clash head to head. I got here a lot of knowledge that no book covers. Thank you Alan & Steve. Yehuda On Mon, Jan 4, 2016 at 7:00 PM, wrote: > Send Tutor mailing list submissions to > tutor@python.org > >

Re: [Tutor] Lists+sorting

2016-01-04 Thread Alan Gauld
On 04/01/16 16:56, Pooja Bhalode wrote: > Hi, > I wanted to check if I can write the following program in this manner as > well. > Can you resend in plain text please? Your post lost all its formatting so its hard to read or comment on. > def linear_merge(list1, list2): > result = [] > while len

[Tutor] Lists+sorting

2016-01-04 Thread Pooja Bhalode
Hi, I wanted to check if I can write the following program in this manner as well. The problem is to merge the lists together and sort them.The solution they have given is: def linear_merge(list1, list2): result = [] while len(list1) and len(list2): if list1[0] < list2[0]: result.append(list

Re: [Tutor] To FORMAT or not to

2016-01-04 Thread Alan Gauld
On 04/01/16 03:46, Steven D'Aprano wrote: >> fmtString = "You've visited {0} & {2}." >> if foo: >> print(fmtString.format(foo,bar)) >> else: >> print(fmtString.format(baz,bad)) > > I wouldn't write it like that. I'd write: > > if foo: > args = (foo, bar) >