Re: save dictionary to a file without brackets.

2012-08-14 Thread Mark Lawrence
On 14/08/2012 16:05, Alister wrote: On Tue, 14 Aug 2012 12:33:20 +0100, Mark Lawrence wrote: On 14/08/2012 03:54, Steven D'Aprano wrote: On Mon, 13 Aug 2012 18:07:26 +0100, Mark Lawrence wrote: On 13/08/2012 17:14, alex23 wrote: On Aug 13, 10:37 pm, Mark Lawrence wrote: Why on your say so

Re: save dictionary to a file without brackets.

2012-08-14 Thread Alister
On Tue, 14 Aug 2012 12:33:20 +0100, Mark Lawrence wrote: > On 14/08/2012 03:54, Steven D'Aprano wrote: >> On Mon, 13 Aug 2012 18:07:26 +0100, Mark Lawrence wrote: >> >>> On 13/08/2012 17:14, alex23 wrote: On Aug 13, 10:37 pm, Mark Lawrence wrote: > Why on your say so? My mistak

Re: save dictionary to a file without brackets.

2012-08-14 Thread Mark Lawrence
On 14/08/2012 03:54, Steven D'Aprano wrote: On Mon, 13 Aug 2012 18:07:26 +0100, Mark Lawrence wrote: On 13/08/2012 17:14, alex23 wrote: On Aug 13, 10:37 pm, Mark Lawrence wrote: Why on your say so? My mistake, I didn't realise you wanted to sound so tedious. Knock yourself out. Yes m'l

Re: save dictionary to a file without brackets.

2012-08-13 Thread Steven D'Aprano
On Mon, 13 Aug 2012 18:07:26 +0100, Mark Lawrence wrote: > On 13/08/2012 17:14, alex23 wrote: >> On Aug 13, 10:37 pm, Mark Lawrence wrote: >>> Why on your say so? >> >> My mistake, I didn't realise you wanted to sound so tedious. Knock >> yourself out. >> >> >> > Yes m'lud. Do I lick your boots

Re: save dictionary to a file without brackets.

2012-08-13 Thread alex23
On Aug 14, 3:43 am, Mark Lawrence wrote: > On 13/08/2012 01:15, alex23 wrote: > > > On Aug 10, 7:37 pm, Mark Lawrence wrote: > >> Well whatever you do *DON'T* mention Cython. I mentioned it just now but > >> I think I've got away with it. > > > While I'm not against threads straying off topic, yo

Re: save dictionary to a file without brackets.

2012-08-13 Thread Mark Lawrence
On 13/08/2012 01:15, alex23 wrote: On Aug 10, 7:37 pm, Mark Lawrence wrote: Well whatever you do *DON'T* mention Cython. I mentioned it just now but I think I've got away with it. While I'm not against threads straying off topic, you're beginning to come across as a bit of an asshole now. Ju

Re: save dictionary to a file without brackets.

2012-08-13 Thread Mark Lawrence
On 13/08/2012 17:14, alex23 wrote: On Aug 13, 10:37 pm, Mark Lawrence wrote: Why on your say so? My mistake, I didn't realise you wanted to sound so tedious. Knock yourself out. Yes m'lud. Do I lick your boots or polish them? -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman

Re: save dictionary to a file without brackets.

2012-08-13 Thread rusi
On Aug 13, 1:05 pm, Steven D'Aprano wrote: > > Chill out Alex, it's all good. Mark was channelling a famous scene from > "Fawlty Towers", staring Monty Python's own John Cleese, hence it is on- > topic, for the sillier definitions of on-topic. Ha! Thanks for that connection. Watched and enjoyed F

Re: save dictionary to a file without brackets.

2012-08-13 Thread alex23
On Aug 13, 6:05 pm, Steven D'Aprano wrote: > Chill out Alex, it's all good. Mark was channelling a famous scene from > "Fawlty Towers", staring Monty Python's own John Cleese, hence it is on- > topic, for the sillier definitions of on-topic. Thank you, yes, I get that. However, Mark has repeatedl

Re: save dictionary to a file without brackets.

2012-08-13 Thread alex23
On Aug 13, 10:37 pm, Mark Lawrence wrote: > Why on your say so? My mistake, I didn't realise you wanted to sound so tedious. Knock yourself out. -- http://mail.python.org/mailman/listinfo/python-list

Re: save dictionary to a file without brackets.

2012-08-13 Thread Mark Lawrence
On 13/08/2012 01:15, alex23 wrote: On Aug 10, 7:37 pm, Mark Lawrence wrote: Well whatever you do *DON'T* mention Cython. I mentioned it just now but I think I've got away with it. While I'm not against threads straying off topic, you're beginning to come across as a bit of an asshole now. Ju

Re: save dictionary to a file without brackets.

2012-08-13 Thread Steven D'Aprano
On Sun, 12 Aug 2012 17:15:12 -0700, alex23 wrote: > On Aug 10, 7:37 pm, Mark Lawrence wrote: >> Well whatever you do *DON'T* mention Cython. I mentioned it just now >> but I think I've got away with it. > > While I'm not against threads straying off topic, you're beginning to > come across as a

Re: save dictionary to a file without brackets.

2012-08-12 Thread alex23
On Aug 10, 7:37 pm, Mark Lawrence wrote: > Well whatever you do *DON'T* mention Cython. I mentioned it just now but > I think I've got away with it. While I'm not against threads straying off topic, you're beginning to come across as a bit of an asshole now. Just let it go. -- http://mail.pytho

Re: save dictionary to a file without brackets.

2012-08-12 Thread 88888 Dihedral
Steven D'Aprano於 2012年8月11日星期六UTC+8下午7時26分37秒寫道: > On Fri, 10 Aug 2012 08:53:43 +1000, Chris Angelico wrote: > > > > > On Fri, Aug 10, 2012 at 8:26 AM, Dave Angel wrote: > > >> On 08/09/2012 06:03 PM, Andrew Cooper wrote: > > >>> O(n) for all other entries in the dict which suffer a hash coll

Re: save dictionary to a file without brackets.

2012-08-11 Thread Steven D'Aprano
On Fri, 10 Aug 2012 08:53:43 +1000, Chris Angelico wrote: > On Fri, Aug 10, 2012 at 8:26 AM, Dave Angel wrote: >> On 08/09/2012 06:03 PM, Andrew Cooper wrote: >>> O(n) for all other entries in the dict which suffer a hash collision >>> with the searched entry. >>> >>> True, a sensible choice of h

Re: save dictionary to a file without brackets.

2012-08-10 Thread 88888 Dihedral
Dave Angel於 2012年8月10日星期五UTC+8上午5時47分45秒寫道: > On 08/09/2012 05:34 PM, Roman Vashkevich wrote: > > > Actually, they are different. > > > Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred > > thousand entries, and you will feel the difference. > > > Dict uses hashing to get a

Re: save dictionary to a file without brackets.

2012-08-10 Thread Mark Lawrence
On 10/08/2012 13:29, Roy Smith wrote: In article , Mark Lawrence wrote: On 10/08/2012 09:54, Steven D'Aprano wrote: On Thu, 09 Aug 2012 19:16:58 -0500, Tim Chase wrote: On 08/09/12 18:33, Mark Lawrence wrote: On 10/08/2012 00:24, Roy Smith wrote: ... you mean, Python lets you make a has

Re: save dictionary to a file without brackets.

2012-08-10 Thread Roy Smith
In article , Mark Lawrence wrote: > On 10/08/2012 09:54, Steven D'Aprano wrote: > > On Thu, 09 Aug 2012 19:16:58 -0500, Tim Chase wrote: > > > >> On 08/09/12 18:33, Mark Lawrence wrote: > >>> On 10/08/2012 00:24, Roy Smith wrote: > > ... you mean, Python lets you make a hash of it? > >

Re: save dictionary to a file without brackets.

2012-08-10 Thread Mark Lawrence
On 10/08/2012 09:54, Steven D'Aprano wrote: On Thu, 09 Aug 2012 19:16:58 -0500, Tim Chase wrote: On 08/09/12 18:33, Mark Lawrence wrote: On 10/08/2012 00:24, Roy Smith wrote: ... you mean, Python lets you make a hash of it? Only if you order it with spam, spam, spam, spam, spam, spam, and s

Re: save dictionary to a file without brackets.

2012-08-10 Thread Steven D'Aprano
On Thu, 09 Aug 2012 19:16:58 -0500, Tim Chase wrote: > On 08/09/12 18:33, Mark Lawrence wrote: >> On 10/08/2012 00:24, Roy Smith wrote: ... you mean, Python lets you make a hash of it? >>> >>> Only if you order it with spam, spam, spam, spam, spam, spam, and >>> spam. >> >> Now now gentlemen

Re: save dictionary to a file without brackets.

2012-08-09 Thread 88888 Dihedral
Andrew Cooper於 2012年8月10日星期五UTC+8上午6時03分26秒寫道: > On 09/08/2012 22:34, Roman Vashkevich wrote: > > > Actually, they are different. > > > Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred > > thousand entries, and you will feel the difference. > > > Dict uses hashing to get a

Re: save dictionary to a file without brackets.

2012-08-09 Thread Chris Angelico
On Fri, Aug 10, 2012 at 10:16 AM, Tim Chase wrote: > We apologise for the off-topicness in the thread. Those responsible > have been sacked... So if you take every mapping variable in your program and name them "dFoo", "dBar", "dQuux", etc, for "dict"... would that be a dirty Hungarian dictionar

Re: save dictionary to a file without brackets.

2012-08-09 Thread Dave Angel
On 08/09/2012 08:16 PM, Tim Chase wrote: > On 08/09/12 18:33, Mark Lawrence wrote: >> On 10/08/2012 00:24, Roy Smith wrote: ... you mean, Python lets you make a hash of it? >>> Only if you order it with spam, spam, spam, spam, spam, spam, and spam. >> Now now gentlemen we're getting slightly o

Re: save dictionary to a file without brackets.

2012-08-09 Thread Tim Chase
On 08/09/12 18:33, Mark Lawrence wrote: > On 10/08/2012 00:24, Roy Smith wrote: >>> ... you mean, Python lets you make a hash of it? >> >> Only if you order it with spam, spam, spam, spam, spam, spam, and spam. > > Now now gentlemen we're getting slightly off topic here and wouldn't > want to ups

Re: save dictionary to a file without brackets.

2012-08-09 Thread Oscar Benjamin
On Aug 10, 2012 12:34 AM, "Giuseppe Amatulli" wrote: > > Ciao, > is 12 minutes for 5000x5000 pixel image. half of the time is for > reading the arrays. > and the other half for making the loop. > I will try again to incorporate the mask action in the loop > and > read the image line by line. > Tha

Re: save dictionary to a file without brackets.

2012-08-09 Thread Dave Angel
On 08/09/2012 06:53 PM, Chris Angelico wrote: > On Fri, Aug 10, 2012 at 8:26 AM, Dave Angel wrote: >> On 08/09/2012 06:03 PM, Andrew Cooper wrote: >>> O(n) for all other entries in the dict which suffer a hash collision >>> with the searched entry. >>> >>> True, a sensible choice of hash function

Re: save dictionary to a file without brackets.

2012-08-09 Thread Dave Angel
On 08/09/2012 06:54 PM, Andrew Cooper wrote: > On 09/08/2012 23:26, Dave Angel wrote: >> On 08/09/2012 06:03 PM, Andrew Cooper wrote: >>> On 09/08/2012 22:34, Roman Vashkevich wrote: Actually, they are different. Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred

Re: save dictionary to a file without brackets.

2012-08-09 Thread Mark Lawrence
On 10/08/2012 00:24, Roy Smith wrote: In article , Chris Angelico wrote: On Fri, Aug 10, 2012 at 9:05 AM, Roy Smith wrote: Python assumes you are a consenting adult. If you wish to engage in activities which are hazardous to your health, so be it. ... you mean, Python lets you make a ha

Re: save dictionary to a file without brackets.

2012-08-09 Thread Roy Smith
In article , Chris Angelico wrote: > On Fri, Aug 10, 2012 at 9:05 AM, Roy Smith wrote: > > Python assumes you are a consenting adult. If you wish to engage in > > activities which are hazardous to your health, so be it. > > ... you mean, Python lets you make a hash of it? > Only if you orde

Re: save dictionary to a file without brackets.

2012-08-09 Thread Chris Angelico
On Fri, Aug 10, 2012 at 9:05 AM, Roy Smith wrote: > Python assumes you are a consenting adult. If you wish to engage in > activities which are hazardous to your health, so be it. ... you mean, Python lets you make a hash of it? *ducks for cover* ChrisA -- http://mail.python.org/mailman/listin

Re: save dictionary to a file without brackets.

2012-08-09 Thread Oscar Benjamin
> What do you think? is there a way to speed up the process? > Thanks > Giuseppe Which part is slow? How slow is it? A simple test to find the slow part of your code is to print messages between the commands so that you can see how long it takes between each message. Oscar. -- http://mail.pytho

Re: save dictionary to a file without brackets.

2012-08-09 Thread Roy Smith
In article , Andrew Cooper wrote: > As for poor implementations, > > class Foo(object): > def __hash__(self): > return 0 > > I seriously found that in some older code I had the misfortune of > reading. Python assumes you are a consenting adult. If you wish to engage in activitie

Re: save dictionary to a file without brackets.

2012-08-09 Thread Chris Angelico
On Fri, Aug 10, 2012 at 8:39 AM, Tim Chase wrote: > On 08/09/12 17:26, Dave Angel wrote: >> On 08/09/2012 06:03 PM, Andrew Cooper wrote: >> I'm glad you're wrong for CPython's dictionaries. The only time the >> lookup would degenerate to O[n] would be if the hash table had only one >> slot. CPyt

Re: save dictionary to a file without brackets.

2012-08-09 Thread Andrew Cooper
On 09/08/2012 23:26, Dave Angel wrote: > On 08/09/2012 06:03 PM, Andrew Cooper wrote: >> On 09/08/2012 22:34, Roman Vashkevich wrote: >>> Actually, they are different. >>> Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred >>> thousand entries, and you will feel the difference.

Re: save dictionary to a file without brackets.

2012-08-09 Thread Chris Angelico
On Fri, Aug 10, 2012 at 8:26 AM, Dave Angel wrote: > On 08/09/2012 06:03 PM, Andrew Cooper wrote: >> O(n) for all other entries in the dict which suffer a hash collision >> with the searched entry. >> >> True, a sensible choice of hash function will reduce n to 1 in common >> cases, but it becomes

Re: save dictionary to a file without brackets.

2012-08-09 Thread Chris Kaynor
On Thu, Aug 9, 2012 at 3:26 PM, Dave Angel wrote: > On 08/09/2012 06:03 PM, Andrew Cooper wrote: >> On 09/08/2012 22:34, Roman Vashkevich wrote: >>> Actually, they are different. >>> Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred >>> thousand entries, and you will feel the

Re: save dictionary to a file without brackets.

2012-08-09 Thread Tim Chase
On 08/09/12 17:26, Dave Angel wrote: > On 08/09/2012 06:03 PM, Andrew Cooper wrote: > I'm glad you're wrong for CPython's dictionaries. The only time the > lookup would degenerate to O[n] would be if the hash table had only one > slot. CPython sensibly increases the hash table size when it become

Re: save dictionary to a file without brackets.

2012-08-09 Thread Dave Angel
On 08/09/2012 06:03 PM, Andrew Cooper wrote: > On 09/08/2012 22:34, Roman Vashkevich wrote: >> Actually, they are different. >> Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred >> thousand entries, and you will feel the difference. >> Dict uses hashing to get a value from the

Re: save dictionary to a file without brackets.

2012-08-09 Thread Andrew Cooper
On 09/08/2012 22:34, Roman Vashkevich wrote: > Actually, they are different. > Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred > thousand entries, and you will feel the difference. > Dict uses hashing to get a value from the dict and this is why it's O(1). > Sligtly off top

Re: save dictionary to a file without brackets.

2012-08-09 Thread Roman Vashkevich
10.08.2012, в 1:47, Dave Angel написал(а): > On 08/09/2012 05:34 PM, Roman Vashkevich wrote: >> Actually, they are different. >> Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred >> thousand entries, and you will feel the difference. >> Dict uses hashing to get a value from th

Re: save dictionary to a file without brackets.

2012-08-09 Thread Giuseppe Amatulli
Thanks a lot for the clarification. Actually my problem is giving to raster dataset in geo-tif format find out unique pair combination, count the number of observation unique combination in rast1, count the number of observation unique combination in rast2, count the number of observation I try di

Re: save dictionary to a file without brackets.

2012-08-09 Thread Chris Kaynor
On Thu, Aug 9, 2012 at 2:34 PM, Roman Vashkevich wrote: > > Actually, they are different. > Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred > thousand entries, and you will feel the difference. > Dict uses hashing to get a value from the dict and this is why it's O(1). > Us

Re: save dictionary to a file without brackets.

2012-08-09 Thread Chris Kaynor
I realized, I should have done 10, 100, 1000 rather than 1, 10, 100 for better results, so here are the results for 1000 items. It still maintains the same pattern: >>> timeit.timeit('for i in d: pass', 'd=dict.fromkeys(range(1000))') 10.166595947685153 >>> timeit.timeit('for i in d.iteritems(): p

Re: save dictionary to a file without brackets.

2012-08-09 Thread Dave Angel
On 08/09/2012 05:34 PM, Roman Vashkevich wrote: > Actually, they are different. > Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred > thousand entries, and you will feel the difference. > Dict uses hashing to get a value from the dict and this is why it's O(1). Sure, that's wh

Re: save dictionary to a file without brackets.

2012-08-09 Thread Terry Reedy
On 8/9/2012 5:21 PM, Tim Chase wrote: On 08/09/12 15:41, Roman Vashkevich wrote: 10.08.2012, в 0:35, Tim Chase написал(а): On 08/09/12 15:22, Roman Vashkevich wrote: {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} and i want to print to a file without the brackets comas and semicolon i

Re: save dictionary to a file without brackets.

2012-08-09 Thread Roman Vashkevich
Actually, they are different. Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred thousand entries, and you will feel the difference. Dict uses hashing to get a value from the dict and this is why it's O(1). 10.08.2012, в 1:21, Tim Chase написал(а): > On 08/09/12 15:41, Roman V

Re: save dictionary to a file without brackets.

2012-08-09 Thread Tim Chase
On 08/09/12 15:41, Roman Vashkevich wrote: > 10.08.2012, в 0:35, Tim Chase написал(а): >> On 08/09/12 15:22, Roman Vashkevich wrote: {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} and i want to print to a file without the brackets comas and semicolon in order to obtain some

Re: save dictionary to a file without brackets.

2012-08-09 Thread Mark Lawrence
On 09/08/2012 21:41, Roman Vashkevich wrote: dict.items() is a list - linear access time whereas with 'for key in dict:' access time is constant: http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#use-in-where-possible-1 10.08.2012, в 0:35, Tim Chase написал(а): On 08/09/1

Re: save dictionary to a file without brackets.

2012-08-09 Thread Roman Vashkevich
dict.items() is a list - linear access time whereas with 'for key in dict:' access time is constant: http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#use-in-where-possible-1 10.08.2012, в 0:35, Tim Chase написал(а): > On 08/09/12 15:22, Roman Vashkevich wrote: >>> {(4, 5):

Re: save dictionary to a file without brackets.

2012-08-09 Thread Gelonida N
On 08/09/2012 10:11 PM, giuseppe.amatu...@gmail.com wrote: Hi, I have a dict() unique like this {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} and i want to print to a file without the brackets comas and semicolon in order to obtain something like this? 4 5 1 5 4 1 4 4 2 2 3 1 4 3 2 Any

Re: save dictionary to a file without brackets.

2012-08-09 Thread Giuseppe Amatulli
thanks for the fast replies my testing were very closed to yours but i did not know how to print the the number after the semicolon! thanks! On 9 August 2012 15:25, Oscar Benjamin wrote: > > On Aug 9, 2012 9:17 PM, wrote: >> >> Hi, >> I have a dict() unique >> like this >> {(4, 5): 1, (5, 4): 1

Re: save dictionary to a file without brackets.

2012-08-09 Thread Giuseppe Amatulli
thanks for the fast replies my testing were very closed to yours but i did not know how On 9 August 2012 15:25, Oscar Benjamin wrote: > > On Aug 9, 2012 9:17 PM, wrote: >> >> Hi, >> I have a dict() unique >> like this >> {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} >> and i want to pr

Re: save dictionary to a file without brackets.

2012-08-09 Thread Tim Chase
On 08/09/12 15:22, Roman Vashkevich wrote: >> {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} >> and i want to print to a file without the brackets comas and semicolon in >> order to obtain something like this? >> 4 5 1 >> 5 4 1 >> 4 4 2 >> 2 3 1 >> 4 3 2 > > for key in dict: > prin

Re: save dictionary to a file without brackets.

2012-08-09 Thread Oscar Benjamin
On Aug 9, 2012 9:17 PM, wrote: > > Hi, > I have a dict() unique > like this > {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} > and i want to print to a file without the brackets comas and semicolon in order to obtain something like this? > 4 5 1 > 5 4 1 > 4 4 2 > 2 3 1 > 4 3 2 > Any ideas

Re: save dictionary to a file without brackets.

2012-08-09 Thread Roman Vashkevich
for key in dict: print key[0], key[1], dict[key] 10.08.2012, в 0:11, giuseppe.amatu...@gmail.com написал(а): > Hi, > I have a dict() unique > like this > {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} > and i want to print to a file without the brackets comas and semicolon in > ord

save dictionary to a file without brackets.

2012-08-09 Thread giuseppe . amatulli
Hi, I have a dict() unique like this {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2} and i want to print to a file without the brackets comas and semicolon in order to obtain something like this? 4 5 1 5 4 1 4 4 2 2 3 1 4 3 2 Any ideas? Thanks in advance Giuseppe -- http://mail.python.o