Re: [Tutor] Re: Fw: Please submit to tutor list: dictionary update prob

2005-01-21 Thread Jacob S.
Just one question...
Why are you off the list?
I see no point.
If you want to stop getting the mail, you can change the options of your 
list account online...
That's the only reason I see...

Let's see -- reasons
1. Cost -- No, it's free
2. Security -- If you were subscribed to it once, it's too late to worry 
about that (Though there is no reason to)
   a. There is an option (in Outlook Express at least) to make your name 
invisible to others when emailing
   b. You can make your name invisible on the subscriber's list on the 
website by using the options in your account page

Anyone want to comment --  maybe a link to get him to the subscriber's 
option page?

HTH,
Jacob Schmidt 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Re: Fw: Please submit to tutor list: dictionary update prob

2005-01-20 Thread Kent Johnson

Eri Mendz wrote:
Kent Johnson  tds.net> writes:

Jacob S. wrote:
sorry to send this to you but if you may, kindly send to tutor list as im
no longer subscribed.  my problem is in the update dict portion: it just
doesnt update regardless how many contacts i add. kindly advise where
my mistake is or code gone wrong. the rest of the options i will do on my
own so just hold off the helps for now. appreciate all your good help.

def update_dict(d, f):
  ''' update the saved dictionary file '''
  read = open(f, 'rb')
  newdic = cPickle.load(read)
  newdic.update(d)
  read.close()
You don't do anything with newdic. My guess is you want to dump it back to the
file so it is saved.
this is what i tried:
read = open(f, 'rb')
newdic = cPickle.load(read)
newdic.update(d)
read.close()
write = open(f, 'wb')
cPickle.dump(f, write)
You still aren't doing anything with newdic. The absence of 'newdic' in the code after 
'read.close()' should be a clue :-)

Check the docs on pickle.dump() (which is the same as cPickle.dump()):
dump(  	obj, file[, protocol[, bin]])
Write a pickled representation of obj to the open file object file. This is equivalent to 
Pickler(file, protocol, bin).dump(obj).

So to pickle newdic you should say
  cPickle.dump(newdic, write)
write.close()
but it 'overwrites' the saved dic. can you rw in one go, dump and load the
updated dict instantly??
I think you want to overwrite the saved dict, but with the new dict instead 
of with a filename string...
Kent
sending this in gmane mail2news gateway.
Thank you

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Re: Fw: Please submit to tutor list: dictionary update prob

2005-01-20 Thread Eri Mendz
Kent Johnson  tds.net> writes:

> 
> Jacob S. wrote:
> >> sorry to send this to you but if you may, kindly send to tutor list as im
> >> no longer subscribed.  my problem is in the update dict portion: it just
> >> doesnt update regardless how many contacts i add. kindly advise where
> >> my mistake is or code gone wrong. the rest of the options i will do on my
> >> own so just hold off the helps for now. appreciate all your good help.
> 
> >> def update_dict(d, f):
> >>''' update the saved dictionary file '''
> >>
> >>read = open(f, 'rb')
> >>newdic = cPickle.load(read)
> >>newdic.update(d)
> >>read.close()
> 
> You don't do anything with newdic. My guess is you want to dump it back to the
file so it is saved.
> 

this is what i tried:
read = open(f, 'rb')
newdic = cPickle.load(read)
newdic.update(d)
read.close()

write = open(f, 'wb')
cPickle.dump(f, write)
write.close()

but it 'overwrites' the saved dic. can you rw in one go, dump and load the
updated dict instantly??

sending this in gmane mail2news gateway.

-- 
regards,
erimendz






___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor