You know, instead of that long or thing you've set up, you could do this.
if select in [ 'l', 'v', 'V' ]:
> [quote]
> if select == '1' or select == 'v' or select == 'V':
> if file_in_disk in os.listdir('/home/jerimed'): #
change???
> fhandle = open(file_in_disk, 'r
Hey, I made some changes to my address book, with help from Oh darn,
well whoever you are, I haven't forgotten the help you gave me in changing
my if/if/if/if/if/else things into mapping objects Anyway, if anybody
wants a look, here it is.
P.S. I made some changes to the file reading part t
It was posted recently that pickleing should use binary mode.
See changes in code.
Rick Muller wrote:
>
>from cPickle import load, dump
>
>def save(fname,addressbook):
>file = open(filename,'w')
file = open(filename,'wb')
>dump(addressbook,file)
>file.close()
> spaceMult=(highLength+minimumSpaces)-len(key)
> outString=str(index)+". "+key+(spaceMult * " ") + item
> print outString
> while len(display_name) < 25:
> display_name += '.'
> count += 1
> print count, display_name, d[item]
>> How do i pretty print output of dictionary container? Sort of tabular
>> form or something, e.g.,
>>
>> 1. name1email address1
>> 2. name2email address2
>>
>> Just for my learning experience :-). Thanks!
[Liam Clarke]
highLength=0
for element in myDict.keys():
if len(eleme
On Mon, 6 Dec 2004, Liam Clarke wrote:
hey thanks a lot Liam! didnt tried it yet but later i will. appreciate you
all good people.
Just tested the setout thing. It works. Prolly a hack, but it works.
On Mon, 6 Dec 2004 19:05:58 +1300, Liam Clarke <[EMAIL PROTECTED]> wrote:
[quote]
if select == '
Just tested the setout thing. It works. Prolly a hack, but it works.
On Mon, 6 Dec 2004 19:05:58 +1300, Liam Clarke <[EMAIL PROTECTED]> wrote:
> [quote]
>
>
> if select == '1' or select == 'v' or select == 'V':
> if file_in_disk in os.listdir('/home/jerimed'): # change???
>
[quote]
if select == '1' or select == 'v' or select == 'V':
if file_in_disk in os.listdir('/home/jerimed'): # change???
fhandle = open(file_in_disk, 'r') # read mode
cPickle.load(fhandle) # restore saved data
fh
On Sun, 5 Dec 2004, Jacob S. wrote:
I did something like this about three or four months ago...
This is what I did. Notice the use of the built-in str() and eval()
functions to write and receive data to and from Telephone.cfg...
Thanks a lot Jacob, and to all who replied. I'll go through the code
d
Oops
I've got my own wee dictionary reader, writers. Very simple -
So, you have a user Dave, who has a dictionary of {'address':'21 jump
St', 'Number: 'One, the loneliest.'}
So, you create a dictionary of dictionaries -myDict = {'Dave' :
{'address':'21 jump St', 'Number: 'One, the loneliest.'}
I did something like this about three or four months ago...
This is what I did. Notice the use of the built-in str() and eval()
functions to write and receive data to and from Telephone.cfg...
from __future__ import division
tel = {}
try:
file = open('Telephone.cfg', 'r')
except:
file = op
Rick Muller([EMAIL PROTECTED])@2004.12.04 05:28:11 +:
> The advantage of pickle is that you don't have to
> decide on a text format for your data -- it just dumps
> and then reloads the python code. You can waste a lot
> of time deciding on a text format, implementing the
> readers/writers, etc
On Sun, 5 Dec 2004 09:22:25 +0300 (Arab Standard Time), Eri Mendz
<[EMAIL PROTECTED]> wrote:
>
>
> --
> Regards,
> Eri Mendz
>
> -- Forwarded message --
> Date: Sat, 4 Dec 2004 15:53:36 +0300 (Arab Standard Time)
> Subject: Address book sort of
>
> Dear Tutor,
>
> I like to kno
> then retrieve the data when run again. Basically, I'm trying to
simulate
> a simple address book (well not really for the datas are just names
for
> now)
I use an address book as an example program in the early stages of
my tutorial. The finished(well sort of) program is in the modules
& functio
Couldn't tell if this got sent, so I'm re-sending.
Apologies for duplicates:
Well, one option is to use pickle (or cPickle,
preferrably) to dump the python objects to a file:
from cPickle import load, dump
def save(fname,addressbook):
file = open(filename,'w')
dump(addressbook,file)
15 matches
Mail list logo