Re: [Tutor] wiped file

2016-07-14 Thread Steven D'Aprano
On Wed, Jul 13, 2016 at 11:06:28PM -0500, Noah Stickel wrote:
> i open a python file in IDLE (python 3.5.1) and then my computer froze
> after displaying an error 40 message (i have a DELL PC) and when i
> restarted it i discovered that the file had been completely wiped clean. So
> i still have the file but there is nothing in it. is there anyway i can
> restore the contents of this python file?

Probably not. This is not a Python issue, but a problem with your 
operating system and hard drive's file system.

If your file is called (let's say) "myfile.py", you could look for a 
file called "myfile.py~" which may contain a backup, or possibly a 
previous version. But unlikely.

By the way, what's "error 40"? Is that a Windows thing?


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


Re: [Tutor] wiped file

2016-07-14 Thread Alan Gauld via Tutor
On 14/07/16 23:19, John Wong wrote:
> ... if you use editors like VIM, a temporary file is always created.

But with vim once you close the file it deletes the temporary copy.
So unless you realize the problem before it gets deleted it won't help.
But since you are using IDLE I don;t think that's even an option.
So far as i know IDLE doesn't create a backup file.

> I made my point because version control system (VCS) is an
> on-demand software. Unless you instruct VCS to keep
> "version controlling" your code, it will only keep the last copy.

It will keep all the versions that you check in. so if you create an
editor macro (assuming you have an editor that does macros
 - IDLE doesn't...) that checks in the file each time you save it
then you can roll back to any intermediate save.

> Furthermore, you'd have to store the VCS repository somewhere
> else. For example, if you are using Git, you may use BitBucket,

That's not strictly true, it depends on the VCS (and even  server
based ones can be used locally if needed). I still use RCS for my
own projects and that's just a local file (or more usually a folder
called RCS...) CVS and SVN can both work with local files if you
want something beefier than RCS.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] wiped file

2016-07-14 Thread John Wong
Alan made really good points, standard practice, however, on Linux and
MacOSX, usually if you use editors like VIM, a temporary file is always
created. For Windows, I am not sure 100%. Check your editor, your editor
may have saved a cache file but marked as hidden file. For example,
Notepad++ has this feature:
http://superuser.com/questions/281776/does-notepad-backup-pre-edited-files-anywhere
.

I made my point because version control system (VCS) is an on-demand
software. Unless you instruct VCS to keep "version controlling" your code,
it will only keep the last copy. Furthermore, you'd have to store the VCS
repository somewhere else. For example, if you are using Git, you may use
BitBucket, GitHub, Gitlab to store a remote copy.


On Thu, Jul 14, 2016 at 11:13 AM, Alan Gauld via Tutor 
wrote:

> On 14/07/16 05:06, Noah Stickel wrote:
> > i open a python file in IDLE (python 3.5.1) and then my computer froze
> > after displaying an error 40 message (i have a DELL PC) and when i
> > restarted it i discovered that the file had been completely wiped clean.
> So
> > i still have the file but there is nothing in it. is there anyway i can
> > restore the contents of this python file?
>
> If you stored the file on the cloud (Dropbox, Google drive etc)
> you may be able to recover old versions. If you run Linux you
> may have a journalling file-system that can recover previous
> versions.
>
> Alternatively you may have committed the file to a version
> control system? In that case simply check out the old version.
>
> And of course if you regularly backup your disks then your
> backup programme can probably retrieve the last saved version.
>
> If none of the above applies then now you know why they should! :-(
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] wiped file

2016-07-14 Thread Alan Gauld via Tutor
On 14/07/16 05:06, Noah Stickel wrote:
> i open a python file in IDLE (python 3.5.1) and then my computer froze
> after displaying an error 40 message (i have a DELL PC) and when i
> restarted it i discovered that the file had been completely wiped clean. So
> i still have the file but there is nothing in it. is there anyway i can
> restore the contents of this python file?

If you stored the file on the cloud (Dropbox, Google drive etc)
you may be able to recover old versions. If you run Linux you
may have a journalling file-system that can recover previous
versions.

Alternatively you may have committed the file to a version
control system? In that case simply check out the old version.

And of course if you regularly backup your disks then your
backup programme can probably retrieve the last saved version.

If none of the above applies then now you know why they should! :-(

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


[Tutor] wiped file

2016-07-14 Thread Noah Stickel
i open a python file in IDLE (python 3.5.1) and then my computer froze
after displaying an error 40 message (i have a DELL PC) and when i
restarted it i discovered that the file had been completely wiped clean. So
i still have the file but there is nothing in it. is there anyway i can
restore the contents of this python file?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Counting and grouping dictionary values in Python 2.7

2016-07-14 Thread Michael Selik
On Fri, Jul 8, 2016 at 10:15 AM Bruce Dykes  wrote:

> I'm compiling application logs from a bunch of servers, reading the log
> entries, parsing each log entry into a dictionary, and compiling all the
> log entries into a single list of dictionaries.
>

Seems reasonable. Perhaps instead of having each log entry as a dictionary,
you might prefer to create a namedtuple.


> Now, what I need to do with this arbitrarily count and total the values in
> the dictionaries, ie the total amount and number of items for transaction
> id 387, or the total number of crackers sold in NJ stores.


Use the Counter class from the collections module. Loop over your records,
write an if-statement to determine which records are interesting, then
increment the count for the appropriate key.

If you're having trouble, share your code and the error message.

Also, is there any particular advantage to pickling the list and having two
> files, one, the pickled file to be read as a data source, and the .csv file
> for portability/readability, as opposed to just a single .csv file that
> gets reparsed by the reporting script?
>

Probably simpler to keep just a CSV.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor