On 16/02/13 19:32, eryksun wrote:
On Sat, Feb 16, 2013 at 1:21 AM, Steven D'Aprano 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 i
On Sat, Feb 16, 2013 at 1:21 AM, Steven D'Aprano 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 way. atexit is be
On 15/02/13 16:38, eryksun wrote:
On Thu, Feb 14, 2013 at 4:33 PM, Prasad, Ramit
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 find a try...finally bloc
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. Yo
On Thu, Feb 14, 2013 at 4:33 PM, Prasad, Ramit
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 early during interpreter
fin
On Thu, Feb 14, 2013 at 4:05 PM, Dave Angel 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.
On Wed, Feb 13, 2013 at 1:55 PM, Alan Gauld wrote:
> 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
>>
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 w
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
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
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 pickl
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 usi
On Tue, Feb 12, 2013 at 4:56 PM, Steven D'Aprano wrote:
> 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
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 02/12/2013 12:32 PM, neubyr wrote:
On Mon, Feb 11, 2013 at 7:34 PM, Steven D'Aprano 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?
On Mon, Feb 11, 2013 at 7:34 PM, Steven D'Aprano wrote:
> 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 o
On Mon, Feb 11, 2013 at 8:56 PM, Alan Gauld 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 parallel with
the class.
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 in
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 operate
On Mon, Feb 11, 2013 at 6:58 PM, Steven D'Aprano wrote:
> 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
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 bo
On Mon, Feb 11, 2013 at 5:16 PM, 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
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 - i.e
On Mon, Feb 11, 2013 at 12:36 PM, Dave Angel wrote:
> On 02/11/2013 01:19 PM, Alan Gauld wrote:
>
>> On 11/02/13 05:14, neubyr wrote:
>>
>>>
>>>
>>>
>>>
>> * 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 a
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 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 would
On 02/11/2013 01:19 PM, Alan Gauld wrote:
On 11/02/13 05:14, neubyr wrote:
* 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 you
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 b
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 about
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 informa
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!)
* Ge
30 matches
Mail list logo