Marc 'BlackJack' Rintsch wrote:
> ...
>
> I write __repr__() methods similar but I think a bit more readable:
>
> def __repr__(self):
> return "%s(%r, %r, %r, %r)" % (self.__class__.__name__,
self.name,
> self.age, self.friends,
self.comment)
>
> And it'
In <[EMAIL PROTECTED]>, Martin Miller wrote:
> I've found extending this property to your own classes often fairly easy
> to implement (and useful). For example:
>
>> class person:
>> def __init__(self, name="", age=0, friends=None, comment=""):
>> if friends is None:
>> f
On 1/26/05 at 1:48 pm, Terry Reedy wrote:
> For basic builtin objects, repr(ob) generally produces a string that when
> eval()ed will recreate the object. IE
> eval(repr(ob) == ob # sometimes
I've found extending this property to your own classes often fairly easy
to implement (and useful). For
On 1/26/05 at 1:48 pm, Terry Reedy wrote:
> For basic builtin objects, repr(ob) generally produces a string that when
> eval()ed will recreate the object. IE
> eval(repr(ob) == ob # sometimes
I've found extending this property to your own classes often fairly easy
to implement (and useful). For
For basic builtin objects, repr(ob) generally produces a string that when
eval()ed will recreate the object. IE
eval(repr(ob) == ob # sometimes
For writing and reading class instances, pickle is the way to go.
Terry J. Reedy
--
http://mail.python.org/mailman/listinfo/python-list
Thanks... works like a charm :-)
On Wed, 26 Jan 2005 12:55:38 +0100, Peter Maas <[EMAIL PROTECTED]> wrote:
Johan Kohler schrieb:
class person:
name =""
age = 0
friends=[]
comment=""
me = person()
Otherwise, what is the best "Python" way to write and read this data
structure
Johan Kohler schrieb:
class person:
name =""
age = 0
friends=[]
comment=""
me = person()
Otherwise, what is the best "Python" way to write and read this data
structure?
import pickle
class person:
name =""
age = 0
friends=[]
comment=""
me = person()
# store
Hi,
I have a class with attributes that are string, integer and list. eg.
class person:
name =""
age = 0
friends=[]
comment=""
me = person()
I want to save a whole bunch of instances to a file, a classic "records"
file I/O.
To write the file, I can do f.write