[Tutor] importing modules and packages

2011-10-30 Thread neubyr
Is it possible to tell whether import statement is importing a module or package? I am going through some example code with some import statements - like 'import os, sys, time', 'import packed'. I know os, sys and time are (built-in) modules and 'packed' is a package here . But can I determine whe

Re: [Tutor] importing modules and packages

2011-10-31 Thread neubyr
On Mon, Oct 31, 2011 at 4:38 AM, Steven D'Aprano wrote: > neubyr wrote: >> >> Is it possible to tell whether import statement is importing a module >> or package?  I am going through some example code with some import >> statements - like 'import os, sys, time

[Tutor] classes : post-declaration attributes

2013-02-08 Thread neubyr
I am learning Python 2.7 classes and objects. It seems like attributes (data attributes and methods) can be added to a class/object even after it's first declaration. For example, class A(object): def __init__(self,arg): self.val1 = arg a = A(1) print a.val1 Now another data attribute v

Re: [Tutor] classes : post-declaration attributes

2013-02-09 Thread neubyr
On Sat, Feb 9, 2013 at 3:24 AM, Alan Gauld wrote: > On 09/02/13 07:01, neubyr wrote: > >> >> I am learning Python 2.7 classes and objects. It seems like attributes >> (data attributes and methods) can be added to a class/object even after >> it's first declarat

[Tutor] associating two objects without ORM and processing a text file

2013-02-10 Thread neubyr
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

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread neubyr
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, Ge

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread neubyr
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 >

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread neubyr
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 cas

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread neubyr
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 o

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-12 Thread neubyr
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 alter

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-13 Thread neubyr
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

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-14 Thread neubyr
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

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-14 Thread neubyr
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

[Tutor] object attribute validation

2013-02-22 Thread neubyr
7;,'Six') Is this a good approach? Any suggestions for improving the code or alternative approaches would be helpful. -- thanks, neubyr ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] object attribute validation

2013-02-24 Thread neubyr
On Fri, Feb 22, 2013 at 10:31 PM, Steven D'Aprano wrote: > On 23/02/13 10:50, neubyr wrote: > >> I would like to validate data attributes before the object is instantiated >> or any changes thereafter. For example, following is a simple Person class >> with name and