Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26806 > unrolled thread

save dictionary to a file without brackets.

Started bygiuseppe.amatulli@gmail.com
First post2012-08-09 13:11 -0700
Last post2012-08-10 02:02 +0400
Articles 20 on this page of 55 — 18 participants

Back to article view | Back to comp.lang.python


Contents

  save dictionary to a file without brackets. giuseppe.amatulli@gmail.com - 2012-08-09 13:11 -0700
    Re: save dictionary to a file without brackets. Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 00:22 +0400
    Re: save dictionary to a file without brackets. Tim Chase <python.list@tim.thechases.com> - 2012-08-09 15:35 -0500
    Re: save dictionary to a file without brackets. Giuseppe Amatulli <giuseppe.amatulli@gmail.com> - 2012-08-09 15:35 -0500
    Re: save dictionary to a file without brackets. Gelonida N <gelonida@gmail.com> - 2012-08-09 22:35 +0200
    Re: save dictionary to a file without brackets. Giuseppe Amatulli <giuseppe.amatulli@gmail.com> - 2012-08-09 15:38 -0500
    Re: save dictionary to a file without brackets. Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 00:41 +0400
    Re: save dictionary to a file without brackets. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-09 22:17 +0100
    Re: save dictionary to a file without brackets. Tim Chase <python.list@tim.thechases.com> - 2012-08-09 16:21 -0500
    Re: save dictionary to a file without brackets. Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 01:34 +0400
      Re: save dictionary to a file without brackets. Andrew Cooper <amc96@cam.ac.uk> - 2012-08-09 23:03 +0100
        Re: save dictionary to a file without brackets. Dave Angel <d@davea.name> - 2012-08-09 18:26 -0400
          Re: save dictionary to a file without brackets. Andrew Cooper <amc96@cam.ac.uk> - 2012-08-09 23:54 +0100
            Re: save dictionary to a file without brackets. Roy Smith <roy@panix.com> - 2012-08-09 19:05 -0400
              Re: save dictionary to a file without brackets. Chris Angelico <rosuav@gmail.com> - 2012-08-10 09:14 +1000
                Re: save dictionary to a file without brackets. Roy Smith <roy@panix.com> - 2012-08-09 19:24 -0400
                  Re: save dictionary to a file without brackets. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-10 00:33 +0100
                  Re: save dictionary to a file without brackets. Tim Chase <python.list@tim.thechases.com> - 2012-08-09 19:16 -0500
                    Re: save dictionary to a file without brackets. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-10 08:54 +0000
                      Re: save dictionary to a file without brackets. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-10 10:37 +0100
                        Re: save dictionary to a file without brackets. Roy Smith <roy@panix.com> - 2012-08-10 08:29 -0400
                          Re: save dictionary to a file without brackets. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-10 15:47 +0100
                        Re: save dictionary to a file without brackets. alex23 <wuwei23@gmail.com> - 2012-08-12 17:15 -0700
                          Re: save dictionary to a file without brackets. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-13 08:05 +0000
                            Re: save dictionary to a file without brackets. alex23 <wuwei23@gmail.com> - 2012-08-13 09:16 -0700
                            Re: save dictionary to a file without brackets. rusi <rustompmody@gmail.com> - 2012-08-13 08:55 -0700
                          Re: save dictionary to a file without brackets. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-13 13:37 +0100
                            Re: save dictionary to a file without brackets. alex23 <wuwei23@gmail.com> - 2012-08-13 09:14 -0700
                              Re: save dictionary to a file without brackets. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-13 18:07 +0100
                                Re: save dictionary to a file without brackets. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-14 02:54 +0000
                                  Re: save dictionary to a file without brackets. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-14 12:33 +0100
                                    Re: save dictionary to a file without brackets. Alister <alister.ware@ntlworld.com> - 2012-08-14 15:05 +0000
                                      Re: save dictionary to a file without brackets. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-14 19:15 +0100
                          Re: save dictionary to a file without brackets. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-13 18:43 +0100
                            Re: save dictionary to a file without brackets. alex23 <wuwei23@gmail.com> - 2012-08-13 18:32 -0700
                      Re: save dictionary to a file without brackets. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-10 12:34 -0400
                  Re: save dictionary to a file without brackets. Dave Angel <d@davea.name> - 2012-08-09 20:27 -0400
                  Re: save dictionary to a file without brackets. Chris Angelico <rosuav@gmail.com> - 2012-08-10 10:31 +1000
            Re: save dictionary to a file without brackets. Dave Angel <d@davea.name> - 2012-08-09 19:38 -0400
        Re: save dictionary to a file without brackets. Tim Chase <python.list@tim.thechases.com> - 2012-08-09 17:39 -0500
        Re: save dictionary to a file without brackets. Chris Kaynor <ckaynor@zindagigames.com> - 2012-08-09 15:37 -0700
        Re: save dictionary to a file without brackets. Chris Angelico <rosuav@gmail.com> - 2012-08-10 08:53 +1000
          Re: save dictionary to a file without brackets. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-11 11:26 +0000
            Re: save dictionary to a file without brackets. 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-12 04:59 -0700
        Re: save dictionary to a file without brackets. Chris Angelico <rosuav@gmail.com> - 2012-08-10 09:01 +1000
        Re: save dictionary to a file without brackets. Dave Angel <d@davea.name> - 2012-08-09 19:42 -0400
        Re: save dictionary to a file without brackets. 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-09 22:35 -0700
    Re: save dictionary to a file without brackets. Terry Reedy <tjreedy@udel.edu> - 2012-08-09 17:46 -0400
    Re: save dictionary to a file without brackets. Dave Angel <d@davea.name> - 2012-08-09 17:47 -0400
      Re: save dictionary to a file without brackets. 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-10 10:46 -0700
      Re: save dictionary to a file without brackets. 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-10 10:46 -0700
    Re: save dictionary to a file without brackets. Chris Kaynor <ckaynor@zindagigames.com> - 2012-08-09 14:49 -0700
    Re: save dictionary to a file without brackets. Chris Kaynor <ckaynor@zindagigames.com> - 2012-08-09 14:51 -0700
    Re: save dictionary to a file without brackets. Giuseppe Amatulli <giuseppe.amatulli@gmail.com> - 2012-08-09 16:53 -0500
    Re: save dictionary to a file without brackets. Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 02:02 +0400

Page 1 of 3  [1] 2 3  Next page →


#26806 — save dictionary to a file without brackets.

Fromgiuseppe.amatulli@gmail.com
Date2012-08-09 13:11 -0700
Subjectsave dictionary to a file without brackets.
Message-ID<930ab3d8-4ab9-446d-9970-ee811eb70a44@googlegroups.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 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

[toc] | [next] | [standalone]


#26807

FromRoman Vashkevich <vashkevichrb@gmail.com>
Date2012-08-10 00:22 +0400
Message-ID<mailman.3110.1344543782.4697.python-list@python.org>
In reply to#26806
for key in dict:
    print key[0], key[1], dict[key]

10.08.2012, в 0:11, giuseppe.amatulli@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 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.org/mailman/listinfo/python-list

[toc] | [prev] | [next] | [standalone]


#26808

FromTim Chase <python.list@tim.thechases.com>
Date2012-08-09 15:35 -0500
Message-ID<mailman.3112.1344544469.4697.python-list@python.org>
In reply to#26806
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:
> 	print key[0], key[1], dict[key]

This might read more cleanly with tuple unpacking:

  for (edge1, edge2), cost in d.iteritems(): # or .items()
    print edge1, edge2, cost

(I'm making the assumption that this is a edge/cost graph...use
appropriate names according to what they actually mean)

-tkc


[toc] | [prev] | [next] | [standalone]


#26809

FromGiuseppe Amatulli <giuseppe.amatulli@gmail.com>
Date2012-08-09 15:35 -0500
Message-ID<mailman.3113.1344544557.4697.python-list@python.org>
In reply to#26806
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 <oscar.j.benjamin@gmail.com> wrote:
>
> On Aug 9, 2012 9:17 PM, <giuseppe.amatulli@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 ideas?
>> Thanks in advance
>
> How's this?
>
> from __future__ import print_function
>
> output = open("out.txt", "w")
>
> for (a, b), c in d.items():
>     print(a, b, c, file=output)
>
> output.close()
>
> Oscar.
>> --
>> http://mail.python.org/mailman/listinfo/python-list



-- 
Giuseppe Amatulli
Web: www.spatial-ecology.net

[toc] | [prev] | [next] | [standalone]


#26810

FromGelonida N <gelonida@gmail.com>
Date2012-08-09 22:35 +0200
Message-ID<mailman.3114.1344544563.4697.python-list@python.org>
In reply to#26806
On 08/09/2012 10:11 PM, giuseppe.amatulli@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 ideas?
> Thanks in advance
> Giuseppe
>
Boring explicit solution:

d = {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2}
for key, val in d.items():
     v1,v2 = key
     fout.write("%d %d %d\n" % (v1, v2, val))

[toc] | [prev] | [next] | [standalone]


#26811

FromGiuseppe Amatulli <giuseppe.amatulli@gmail.com>
Date2012-08-09 15:38 -0500
Message-ID<mailman.3115.1344544732.4697.python-list@python.org>
In reply to#26806
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 <oscar.j.benjamin@gmail.com> wrote:
>
> On Aug 9, 2012 9:17 PM, <giuseppe.amatulli@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 ideas?
>> Thanks in advance
>
> How's this?
>
> from __future__ import print_function
>
> output = open("out.txt", "w")
>
> for (a, b), c in d.items():
>     print(a, b, c, file=output)
>
> output.close()
>
> Oscar.
>> --
>> http://mail.python.org/mailman/listinfo/python-list



-- 
Giuseppe Amatulli
Web: www.spatial-ecology.net

[toc] | [prev] | [next] | [standalone]


#26812

FromRoman Vashkevich <vashkevichrb@gmail.com>
Date2012-08-10 00:41 +0400
Message-ID<mailman.3116.1344544897.4697.python-list@python.org>
In reply to#26806
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): 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:
>> 	print key[0], key[1], dict[key]
> 
> This might read more cleanly with tuple unpacking:
> 
>  for (edge1, edge2), cost in d.iteritems(): # or .items()
>    print edge1, edge2, cost
> 
> (I'm making the assumption that this is a edge/cost graph...use
> appropriate names according to what they actually mean)
> 
> -tkc
> 
> 
> 

[toc] | [prev] | [next] | [standalone]


#26813

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2012-08-09 22:17 +0100
Message-ID<mailman.3117.1344547004.4697.python-list@python.org>
In reply to#26806
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/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:
>>> 	print key[0], key[1], dict[key]
>>
>> This might read more cleanly with tuple unpacking:
>>
>>   for (edge1, edge2), cost in d.iteritems(): # or .items()
>>     print edge1, edge2, cost
>>
>> (I'm making the assumption that this is a edge/cost graph...use
>> appropriate names according to what they actually mean)
>>
>> -tkc
>>
>>
>>
>

I'm impressed, the OP gives a dict with five entries and already we're 
optimising, a cunning plan if ever there was one.  Hum, I think I'll 
start on the blast proof ferro-concrete bunker tonight just in case 
WWIII starts tomorrow.

-- 
Cheers.

Mark Lawrence.

[toc] | [prev] | [next] | [standalone]


#26814

FromTim Chase <python.list@tim.thechases.com>
Date2012-08-09 16:21 -0500
Message-ID<mailman.3118.1344547197.4697.python-list@python.org>
In reply to#26806
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 something like this?
>>>> 4 5 1
>>>> 5 4 1
>>>> 4 4 2
>>>> 2 3 1
>>>> 4 3 2
>>>
>>> for key in dict:
>>> 	print key[0], key[1], dict[key]
>>
>> This might read more cleanly with tuple unpacking:
>>
>>  for (edge1, edge2), cost in d.iteritems(): # or .items()
>>    print edge1, edge2, cost
>>
>> (I'm making the assumption that this is a edge/cost graph...use
>> appropriate names according to what they actually mean)
>
> 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

That link doesn't actually discuss dict.{iter}items()

Both are O(N) because you have to touch each item in the dict--you
can't iterate over N entries in less than O(N) time.  For small
data-sets, building the list and then iterating over it may be
faster faster; for larger data-sets, the cost of building the list
overshadows the (minor) overhead of a generator.  Either way, the
iterate-and-fetch-the-associated-value of .items() & .iteritems()
can (should?) be optimized in Python's internals to the point I
wouldn't think twice about using the more readable version.

-tkc

[toc] | [prev] | [next] | [standalone]


#26817

FromRoman Vashkevich <vashkevichrb@gmail.com>
Date2012-08-10 01:34 +0400
Message-ID<mailman.3120.1344548050.4697.python-list@python.org>
In reply to#26806
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 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 something like this?
>>>>> 4 5 1
>>>>> 5 4 1
>>>>> 4 4 2
>>>>> 2 3 1
>>>>> 4 3 2
>>>> 
>>>> for key in dict:
>>>> 	print key[0], key[1], dict[key]
>>> 
>>> This might read more cleanly with tuple unpacking:
>>> 
>>> for (edge1, edge2), cost in d.iteritems(): # or .items()
>>>   print edge1, edge2, cost
>>> 
>>> (I'm making the assumption that this is a edge/cost graph...use
>>> appropriate names according to what they actually mean)
>> 
>> 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
> 
> That link doesn't actually discuss dict.{iter}items()
> 
> Both are O(N) because you have to touch each item in the dict--you
> can't iterate over N entries in less than O(N) time.  For small
> data-sets, building the list and then iterating over it may be
> faster faster; for larger data-sets, the cost of building the list
> overshadows the (minor) overhead of a generator.  Either way, the
> iterate-and-fetch-the-associated-value of .items() & .iteritems()
> can (should?) be optimized in Python's internals to the point I
> wouldn't think twice about using the more readable version.
> 
> -tkc
> 
> 

[toc] | [prev] | [next] | [standalone]


#26824

FromAndrew Cooper <amc96@cam.ac.uk>
Date2012-08-09 23:03 +0100
Message-ID<MsWUr.1183213$%k.489563@fx20.am4>
In reply to#26817
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 topic, but looking up a value in a dictionary is actually
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 an important consideration for larger datasets.

~Andrew

[toc] | [prev] | [next] | [standalone]


#26825

FromDave Angel <d@davea.name>
Date2012-08-09 18:26 -0400
Message-ID<mailman.3129.1344551238.4697.python-list@python.org>
In reply to#26824
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 dict and this is why it's O(1).
>>
> Sligtly off topic, but looking up a value in a dictionary is actually
> 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 an important consideration for larger datasets.
>
> ~Andrew

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 becomes
too small for efficiency.


Where have you seen dictionaries so poorly implemented?

-- 

DaveA

[toc] | [prev] | [next] | [standalone]


#26829

FromAndrew Cooper <amc96@cam.ac.uk>
Date2012-08-09 23:54 +0100
Message-ID<ucXUr.1030527$2z2.380746@fx19.am4>
In reply to#26825
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.
>>> Dict uses hashing to get a value from the dict and this is why it's O(1).
>>>
>> Sligtly off topic, but looking up a value in a dictionary is actually
>> 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 an important consideration for larger datasets.
>>
>> ~Andrew
> 
> 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 becomes
> too small for efficiency.
> 
> 
> Where have you seen dictionaries so poorly implemented?
> 

Different n, which I should have made more clear.  I was using it for
consistency with O() notation.  My statement was O(n) where n is the
number of hash collisions.

The choice of hash algorithm (or several depending on the
implementation) should specifically be chosen to reduce collisions to
aid in efficient space utilisation and lookup times, but any
implementation must allow for collisions.  There are certainly runtime
methods of improving efficiency using amortized operations.

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.  It didn't remain in that state for long.

~Andrew

[toc] | [prev] | [next] | [standalone]


#26831

FromRoy Smith <roy@panix.com>
Date2012-08-09 19:05 -0400
Message-ID<roy-815F5C.19053709082012@news.panix.com>
In reply to#26829
In article <ucXUr.1030527$2z2.380746@fx19.am4>,
 Andrew Cooper <amc96@cam.ac.uk> 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 
activities which are hazardous to your health, so be it.  But then 
again, you could commit this particular stupidity just as easily in C++ 
or any other language which lets you define your own hash() function.

[toc] | [prev] | [next] | [standalone]


#26832

FromChris Angelico <rosuav@gmail.com>
Date2012-08-10 09:14 +1000
Message-ID<mailman.3135.1344554073.4697.python-list@python.org>
In reply to#26831
On Fri, Aug 10, 2012 at 9:05 AM, Roy Smith <roy@panix.com> 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

[toc] | [prev] | [next] | [standalone]


#26833

FromRoy Smith <roy@panix.com>
Date2012-08-09 19:24 -0400
Message-ID<roy-8085F7.19242109082012@news.panix.com>
In reply to#26832
In article <mailman.3135.1344554073.4697.python-list@python.org>,
 Chris Angelico <rosuav@gmail.com> wrote:

> On Fri, Aug 10, 2012 at 9:05 AM, Roy Smith <roy@panix.com> 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 order it with spam, spam, spam, spam, spam, spam, and spam.

[toc] | [prev] | [next] | [standalone]


#26834

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2012-08-10 00:33 +0100
Message-ID<mailman.3136.1344555193.4697.python-list@python.org>
In reply to#26833
On 10/08/2012 00:24, Roy Smith wrote:
> In article <mailman.3135.1344554073.4697.python-list@python.org>,
>   Chris Angelico <rosuav@gmail.com> wrote:
>
>> On Fri, Aug 10, 2012 at 9:05 AM, Roy Smith <roy@panix.com> 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 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 upset the people who insist on staying on topic.  Or would we? :)

-- 
Cheers.

Mark Lawrence.

[toc] | [prev] | [next] | [standalone]


#26837

FromTim Chase <python.list@tim.thechases.com>
Date2012-08-09 19:16 -0500
Message-ID<mailman.3140.1344557748.4697.python-list@python.org>
In reply to#26833
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 upset the people who insist on staying on topic.  Or would we? :)

We apologise for the off-topicness in the thread.  Those responsible
have been sacked...

-tkc


[toc] | [prev] | [next] | [standalone]


#26845

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2012-08-10 08:54 +0000
Message-ID<5024cc52$0$29978$c3e8da3$5496439d@news.astraweb.com>
In reply to#26837
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 we're getting slightly off topic here and wouldn't
>> want to upset the people who insist on staying on topic.  Or would we?
>> :)
> 
> We apologise for the off-topicness in the thread.  Those responsible
> have been sacked...


Sacked? They were beaten to death with a large halibut!


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#26850

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2012-08-10 10:37 +0100
Message-ID<mailman.3147.1344591354.4697.python-list@python.org>
In reply to#26845
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
>>>> spam.
>>>
>>> Now now gentlemen we're getting slightly off topic here and wouldn't
>>> want to upset the people who insist on staying on topic.  Or would we?
>>> :)
>>
>> We apologise for the off-topicness in the thread.  Those responsible
>> have been sacked...
>
>
> Sacked? They were beaten to death with a large halibut!
>
>

Well whatever you do *DON'T* mention Cython. I mentioned it just now but 
I think I've got away with it.

-- 
Cheers.

Mark Lawrence.

[toc] | [prev] | [next] | [standalone]


Page 1 of 3  [1] 2 3  Next page →

Back to top | Article view | comp.lang.python


csiph-web