Re: [Tutor] general basic question

2012-02-09 Thread Andreas Perstinger
On Wed, 8 Feb 2012 23:54:58 -0800 (PST) ken brockman
 wrote:
> I'm back on the list again, and if not too late, here is the asked
> for trace. i've managed to replicate the original error msg, by
> removing the pickled file Genfacts.p, from the directory.
> Traceback (most recent call last):
> File "/home/bob/Ninja/ArtyNOW2.py", line 120, in  Ginfo =
> General_info() 
> File "/home/bob/Ninja/ArtyNOW2.py", line 69, in General_info file4 =
> open("Genfacts.p", "rb") 
> IOError: [Errno 2] No such file or directory: 'Genfacts.p'

Because you have deleted "Genfacts.p" you are trying to open an
non-existing file. So check if the file exists before opening it.

Bye, Andreas

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] general basic question

2012-02-08 Thread ken brockman
Really close to it Robert. No delete but an error msg. Something akin to file 
dosen't exist, not found , or words to that effect .

Something "akin to"?



I'm back on the list again, and if not too late, here is the asked for trace.
 i've managed to replicate the original error msg, by removing the pickled file 
Genfacts.p, from the directory.
Traceback (most recent call last):
File "/home/bob/Ninja/ArtyNOW2.py", line 120, in 
Ginfo = General_info()
File "/home/bob/Ninja/ArtyNOW2.py", line 69, in General_info
file4 = open("Genfacts.p", "rb")
IOError: [Errno 2] No such file or directory: 'Genfacts.p'

elif choice == "g":
Ginfo = General_info()
print('General Info is: ',Ginfo)
# espeak routine General info
text = 'General Info is ', Ginfo
cmd = 'espeak -v en+f3 "{0}" 2>/dev/null'.format(text)
os.system(cmd)
elif choice == "p":  # Alt. choice != "q": incase anything uexpectd inputed
Thanks again
Ken___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] general basic question

2012-02-08 Thread Steven D'Aprano

ken brockman wrote:


Really close to it Robert. No delete but an error msg. Something akin to file 
dosen't exist, not found , or words to that effect .



Something "akin to"?

How about if you copy and paste the actual error message, instead of asking us 
to guess?


That means the full traceback, starting at the line "Traceback (most recent 
call last)" all the way to the end.


It may also help if you show us the code that you are running, again instead 
of making us guess. But before you do, please read this document:


http://sscce.org/



--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] general basic question

2012-02-08 Thread Alan Gauld

On 08/02/12 21:28, ken brockman wrote:


Really close to it Robert. No delete but an error msg. Something akin to
file dosen't exist, not found , or words to that effect .


Without sight of code it's only a guess but are you creating
the file with the 'wb' mode - ie. write binary? :-

myPickleFile = open("somefilename.dat", "wb")

If you are not using the 'b' for binary pickle and shelve
tend to run into problems, this might be one of those cases.
Its not glaringly obvious from the docs that you need to use
binary mode and beginners often get caught out. Could that be it?

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] general basic question

2012-02-08 Thread Joel Goldstick
On Wed, Feb 8, 2012 at 4:28 PM, ken brockman  wrote:
> Got it. I manage to get it to save to disk, but only by using the shell to
> create an empty dictionary then pickling it and saving it to a file. Priming
> the pump as it were. I had thought i had read that when you pickle and save
> a list or dictionary to file, if it didn't already exist, it would be
> created. That hasn't been my experience. Had I misunderstood or Am i doing
> something wrong?
>
> Let me see if I understand your problem. You are pickling a dictionary and
> finding that it will not work unless there already is an existing dictionary
> for your pickled dictionary to write over. Otherwise, there is either no
> write at all or the write is followed by a delete.  Is that a reasonable
> definition of your current problem?
>
> Robert Berman
>
> Really close to it Robert. No delete but an error msg. Something akin to
> file dosen't exist, not found , or words to that effect .
>  Ken
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

Ken,

The best way to get help here is to post a small example of your code
that shows the problem, along with the complete traceback.  Although
at first they seem a little daunting, the traceback will make the
problem obvious

-- 
Joel Goldstick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] general basic question

2012-02-08 Thread ken brockman
Got it. I manage to get it to save to disk, but only by using the shell to 
create an empty dictionary then pickling it and saving it to a file. Priming 
the pump as it were. I had thought i had read that when you pickle and save a 
list or dictionary to file, if it didn't already exist, it would be created. 
That hasn't been my experience. Had I misunderstood or Am i doing something 
wrong?


Let me see if I understand your problem. You are pickling a dictionary and 
finding that it will not work unless there already is an existing dictionary 
for your pickled dictionary to write over. Otherwise, there is either no write 
at all or the write is followed by a delete.  Is that a reasonable definition 
of your current problem? 

Robert Berman

Really close to it Robert. No delete but an error msg. Something akin to file 
dosen't exist, not found , or words to that effect .
 Ken___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] general basic question

2012-02-08 Thread Robert Berman
On Wed, Feb 8, 2012 at 2:57 PM, ken brockman  wrote:

>
>
> On Wed, Feb 8, 2012 at 12:33 PM, ken brockman  wrote:
> >> Using pickling I have somehow managed to save two separate lists, but
> the
> >> dictionary is giving me much more of a struggle.
>
> Got it. I manage to get it to save to disk, but only by using the shell to
> create an empty dictionary then pickling it and saving it to a file.
> Priming the pump as it were. I had thought i had read that when you pickle
> and save a list or dictionary to file, if it didn't already exist, it would
> be created. That hasn't been my experience. Had I misunderstood or Am i
> doing something wrong? Just for future reference. I'm as happy as the
> proverbial pig in excrement just to get it to function.
> Thanks all for your help.
> Ken
>
> Ken,


Let me see if I understand your problem. You are pickling a dictionary and
finding that it will not work unless there already is an existing
dictionary for your pickled dictionary to write over. Otherwise, there is
either no write at all or the write is followed by a delete.  Is that a
reasonable definition of your current problem?

Robert Berman
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] general basic question

2012-02-08 Thread ken brockman



On Wed, Feb 8, 2012 at 12:33 PM, ken brockman  wrote:
>> Using pickling I have somehow managed to save two separate lists, but the
>> dictionary is giving me much more of a struggle.


Got it. I manage to get it to save to disk, but only by using the shell to 
create an empty dictionary then pickling it and saving it to a file. Priming 
the pump as it were. I had thought i had read that when you pickle and save a 
list or dictionary to file, if it didn't already exist, it would be created. 
That hasn't been my experience. Had I misunderstood or Am i doing something 
wrong? Just for future reference. I'm as happy as the proverbial pig in 
excrement just to get it to function.
Thanks all for your help.
Ken___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] general basic question

2012-02-08 Thread Joel Goldstick
On Wed, Feb 8, 2012 at 12:33 PM, ken brockman  wrote:
>> Using pickling I have somehow managed to save two separate lists, but the
>> dictionary is giving me much more of a struggle.
>
> Well do post back if you don't manage to solve your issues (with full
> error messages & stack traces as relevant please.)  Re dictionaries --
> I actually forgot to mention, there's a specialized type of dictionary
> class available in Python, called a "shelf", implented/available via
> the "shelve" module, which is basically a dict with pickling built in.
> See here:
> http://docs.python.org/library/shelve.html
>
> HTH,
>
> Walter
>
> Walter, you're the man.
> I've read of the shelve command. Not that i understood it, but i've read it.
> I'm going to hit the books and google some more before i waste anymore of
> your time. But if i can't sort it out, I may just take you up on your kind
> offer.
> Have a good day .
> Ken
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
You might want to find some tutorials that suit you.  On the right
column of this site there is a list of several online:

www.reddit.com/r/Python/


-- 
Joel Goldstick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] general basic question

2012-02-08 Thread ken brockman
> Using pickling I have somehow managed to save two separate lists, but the
> dictionary is giving me much more of a struggle.

Well do post back if you don't manage to solve your issues (with full
error messages & stack traces as relevant please.)  Re dictionaries --
I actually forgot to mention, there's a specialized type of dictionary
class available in Python, called a "shelf", implented/available via
the "shelve" module, which is basically a dict with pickling built in.
See here:
http://docs.python.org/library/shelve.html

HTH,

Walter


Walter, you're the man.
I've read of the shelve command. Not that i understood it, but i've read it. 
I'm going to hit the books and google some more before i waste anymore of your 
time. But if i can't sort it out, I may just take you up on your kind offer.
Have a good day .
Ken___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] general basic question

2012-02-08 Thread Walter Prins
Hi Ken,

On 8 February 2012 14:17, ken brockman  wrote:
> Thank you Walter for your help and speedy reply.
You're welcome.

> Using pickling I have somehow managed to save two separate lists, but the
> dictionary is giving me much more of a struggle.

Well do post back if you don't manage to solve your issues (with full
error messages & stack traces as relevant please.)  Re dictionaries --
I actually forgot to mention, there's a specialized type of dictionary
class available in Python, called a "shelf", implented/available via
the "shelve" module, which is basically a dict with pickling built in.
 See here:
http://docs.python.org/library/shelve.html

HTH,

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] general basic question

2012-02-08 Thread ken brockman
On 8 February 2012 13:40, ken brockman  wrote:
> Hello all:
> I have a general and very basic question if I may. I am in the process
> of attempting to write my first python app. I wanted to collect information
> and save it to lists and dictionaries. My question is, is it possible to
> save said lists and dictionaries in the program proper, or do i need to save
> the information to files on the hard drive.


Python
objects very easily with Python standard functionality, referred to in
Python terms as "pickling".  See the "pickle" module for  more
information:  http://docs.python.org/library/pickle.html


Thank you Walter for your help and speedy reply.

Using pickling I have somehow managed to save two separate lists, but the 
dictionary is giving me much more of a struggle.
I will reference the link you were gracious enough to provide me. Hopefully a 
few pots of coffee and my last few remaining brain cells will get me through it.
Thanks again...
PS the last few times i had attempted reading the docs on the python site, 
well, I might as well have been reading a book in  ancient Sanskrit.
But if at first you don't succeed,try, try, try, again.
Have a great day. 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] general basic question

2012-02-08 Thread Walter Prins
Hi Ken,

Welcome to Python and to programming in general.

On 8 February 2012 13:40, ken brockman  wrote:
> Hello all:
> I have a general and very basic question if I may. I am in the process
> of attempting to write my first python app. I wanted to collect information
> and save it to lists and dictionaries. My question is, is it possible to
> save said lists and dictionaries in the program proper, or do i need to save
> the information to files on the hard drive.

You would save the information in files external and seperate to the
source code of your program.  Note however that you can in fact
directly serialize or persist (fancy object oriented terms that
basically means "to save to permanent storage, e.g. disk") Python
objects very easily with Python standard functionality, referred to in
Python terms as "pickling".  See the "pickle" module for  more
information:  http://docs.python.org/library/pickle.html Note that it
is more common for applications to use a database for data storage,
such as SQLite, Postgres, MySQL, SQL Server etc etc, rather than
simple pickling, but for simple cases it (or even simple text files)
might suffice.  It all depends on your requirements... ;)

Regards

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] general basic question

2012-02-08 Thread ken brockman
Hello all:
I have a general and very basic question if I may. I am in the process 
of attempting to write my first python app. I wanted to collect information and 
save it to lists and dictionaries. My question is, is it possible to save said 
lists and dictionaries in the program proper, or do i need to save the 
information to files on the hard drive. I apologize for the simplistic nature 
of my query. I have been reading various python books on and off for well over 
a month and I have to admit i am having a hard time ingesting the concepts. I 
have been googling and perusing articles and books but i can't grasp more then 
the most basic of concepts of what i'v gone over. I'm not looking for any thing 
more then a yes or no, I plan on beating my head against python until it starts 
to sink in or it kills me. Any help would be greatly appreciated.
thank you___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor