On Sat, Feb 16, 2013 at 1:21 AM, Steven D'Aprano st...@pearwood.info wrote:
while atexit can be set anywhere and isn't obvious. It's also somewhat
risky, since you never know when some library you import will silently
replace it with their own hook.
Use try/finally if the task is clearer that
On 16/02/13 19:32, eryksun wrote:
On Sat, Feb 16, 2013 at 1:21 AM, Steven D'Apranost...@pearwood.info wrote:
while atexit can be set anywhere and isn't obvious. It's also somewhat
risky, since you never know when some library you import will silently
replace it with their own hook.
Use
On 15/02/13 03:09, neubyr wrote:
I do have a doubt regarding this - e.g. how would I implement this if my
program/application is web based. For example, loading the text file
during web server start and stop.
For a long running process like a web server this is probably the wrong
approach.
On 15/02/13 16:38, eryksun wrote:
On Thu, Feb 14, 2013 at 4:33 PM, Prasad, Ramit
ramit.pra...@jpmorgan.com wrote:
My knee jerk response is a try/finally block, but I am sure there
are better ways.
The atexit.register decorator hooks sys.exitfunc:
http://docs.python.org/2/library/atexit
I
neubyr wrote:
I am not sure how to save an object in memory to a file before exiting the
program. Any examples or
related documentation links would be really helpful. I am guessing it would
be using some kind of
before teardown method, but not sure about it. Any help?
Look at the pickle or
On 02/14/2013 12:35 PM, Prasad, Ramit wrote:
neubyr wrote:
I am not sure how to save an object in memory to a file before exiting the
program. Any examples or
related documentation links would be really helpful. I am guessing it would be
using some kind of
before teardown method, but not sure
Dave Angel wrote:
On 02/14/2013 12:35 PM, Prasad, Ramit wrote:
neubyr wrote:
I am not sure how to save an object in memory to a file before exiting the
program. Any examples or
related documentation links would be really helpful. I am guessing it
would be using some kind of
before
On 02/14/2013 04:33 PM, Prasad, Ramit wrote:
Dave Angel wrote:
On 02/14/2013 12:35 PM, Prasad, Ramit wrote:
neubyr wrote:
I am not sure how to save an object in memory to a file before exiting the
program. Any examples or
related documentation links would be really helpful. I am guessing it
On Wed, Feb 13, 2013 at 1:55 PM, Alan Gauld alan.ga...@btinternet.comwrote:
On 13/02/13 19:14, neubyr wrote:
I am not sure how to save an object in memory to a file
before exiting the program. Any examples or related documentation links
would be really helpful. I am guessing it would be
On Thu, Feb 14, 2013 at 4:05 PM, Dave Angel da...@davea.name wrote:
On 02/14/2013 04:33 PM, Prasad, Ramit wrote:
Dave Angel wrote:
On 02/14/2013 12:35 PM, Prasad, Ramit wrote:
neubyr wrote:
I am not sure how to save an object in memory to a file before exiting
the program. Any examples
On Thu, Feb 14, 2013 at 4:33 PM, Prasad, Ramit
ramit.pra...@jpmorgan.com wrote:
My knee jerk response is a try/finally block, but I am sure there
are better ways.
The atexit.register decorator hooks sys.exitfunc:
http://docs.python.org/2/library/atexit
Registered atexit functions are run
On Tue, Feb 12, 2013 at 4:56 PM, Steven D'Aprano st...@pearwood.infowrote:
On 13/02/13 04:32, neubyr wrote:
I am not following your comment on opening books file twice in
list_by_author method. I have opened it only once and then reading each
line while checking for a regex match. Am I
On 13/02/13 19:14, neubyr wrote:
I am not sure how to save an object in memory to a file
before exiting the program. Any examples or related documentation links
would be really helpful. I am guessing it would be using some kind of
before teardown method, but not sure about it. Any help?
If
On Mon, Feb 11, 2013 at 8:56 PM, Alan Gauld alan.ga...@btinternet.com wrote:
(One of the unfortunate features of Python's implementation of
class methods is that you can call them from an instance which
doesn't really make sense! IMHO)
Smalltalk derives a metaclass for the class methods, in
On Mon, Feb 11, 2013 at 7:34 PM, Steven D'Aprano st...@pearwood.infowrote:
On 12/02/13 10:16, Alan Gauld wrote:
On 11/02/13 22:49, neubyr wrote:
is right approach to implement 'list_by_author' function as a class
method is typically used as an alternative constructor.
Not at all that is
On 02/12/2013 12:32 PM, neubyr wrote:
On Mon, Feb 11, 2013 at 7:34 PM, Steven D'Aprano st...@pearwood.infowrote:
snip
I am not following your comment on opening books file twice in
list_by_author method. I have opened it only once and then reading each
line while checking for a regex match.
On 13/02/13 04:32, neubyr wrote:
I am not following your comment on opening books file twice in
list_by_author method. I have opened it only once and then reading each
line while checking for a regex match. Am I missing something?
You open the catalog file once to read the books in the first
On 11/02/13 05:14, neubyr wrote:
I have a text file with each line in following format:
Book Name, Author Name, Genre, Publication Date
I would like to perform following queries on this file:
* Get all books written by an author
* Remove all books of an author
* Get information about a
On 02/11/2013 01:19 PM, Alan Gauld wrote:
On 11/02/13 05:14, neubyr wrote:
snip
* How do I associate/relate Book and Author classes so that it will help
me in getting information like 'get list of books written by an author'?
Data attribute?
I woudn't have a separate Author class but, if
Thank you for your inputs Dave. That's really helpful. Reply in-line below:
On Sun, Feb 10, 2013 at 11:56 PM, Dave Angel da...@davea.name wrote:
On 02/11/2013 12:14 AM, neubyr wrote:
I have a text file with each line in following format:
Book Name, Author Name, Genre, Publication Date
I
On Mon, Feb 11, 2013 at 12:36 PM, Dave Angel da...@davea.name wrote:
On 02/11/2013 01:19 PM, Alan Gauld wrote:
On 11/02/13 05:14, neubyr wrote:
snip
* How do I associate/relate Book and Author classes so that it will help
me in getting information like 'get list of books written by an
On 11/02/13 22:49, neubyr wrote:
is right approach to implement 'list_by_author' function as a class
method is typically used as an alternative constructor.
Not at all that is only one use case for class methods.
A class method is *any* method that operates on the whole class of
objects -
On Mon, Feb 11, 2013 at 5:16 PM, Alan Gauld alan.ga...@btinternet.comwrote:
On 11/02/13 22:49, neubyr wrote:
is right approach to implement 'list_by_author' function as a class
method is typically used as an alternative constructor.
Not at all that is only one use case for class methods.
On 11/02/13 16:14, neubyr wrote:
I have a text file with each line in following format:
Book Name, Author Name, Genre, Publication Date
I would like to perform following queries on this file:
* Get all books written by an author
* Remove all books of an author
* Get information about a
On Mon, Feb 11, 2013 at 6:58 PM, Steven D'Aprano st...@pearwood.infowrote:
On 11/02/13 16:14, neubyr wrote:
I have a text file with each line in following format:
Book Name, Author Name, Genre, Publication Date
I would like to perform following queries on this file:
* Get all books
On 12/02/13 10:16, Alan Gauld wrote:
On 11/02/13 22:49, neubyr wrote:
is right approach to implement 'list_by_author' function as a class
method is typically used as an alternative constructor.
Not at all that is only one use case for class methods.
A class method is *any* method that
On 12/02/13 01:34, Steven D'Aprano wrote:
If the class keeps a list of all instances, then the class method
could walk the list and operate on each instance in turn. (But why
would you do that?)
Because its how classes work in some languages (like smalltalk).
The class object represents all
I have a text file with each line in following format:
Book Name, Author Name, Genre, Publication Date
I would like to perform following queries on this file:
* Get all books written by an author
* Remove all books of an author
* Get information about a book (pretty print matching line!)
*
On 02/11/2013 12:14 AM, neubyr wrote:
I have a text file with each line in following format:
Book Name, Author Name, Genre, Publication Date
I would like to perform following queries on this file:
* Get all books written by an author
* Remove all books of an author
* Get information
On 02/11/2013 12:14 AM, neubyr wrote:
I have a text file with each line in following format:
Book Name, Author Name, Genre, Publication Date
I would like to perform following queries on this file:
* Get all books written by an author
* Remove all books of an author
* Get information
30 matches
Mail list logo