Re: [Tutor] Compute data usage from log

2009-10-27 Thread Eri Mendz
On Tue, Oct 27, 2009 at 7:24 PM, Dave Angel wrote: > (For some reason you keep top-posting.  Add your comments to the end, or > inline if appropriate) > Hi Dave, Noted the top posting thing thanks for reminding :-) > > In an earlier example, you already had a for loop on the log_file so the >

Re: [Tutor] Error

2009-10-27 Thread Emile van Sebille
On 10/27/2009 12:15 PM Vincent Jones said... I created database using the 'python manage.py sycdb' You're likely to get answers quickly on the django mailing list. Emile ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription

Re: [Tutor] How to load a dict into a dict subclass?

2009-10-27 Thread Kent Johnson
On Tue, Oct 27, 2009 at 3:02 PM, Albert-Jan Roskam wrote: > I thought reimplementing dict was a matter of defining a __dict__ attribute > in the Bar class? And isn't the normal dict inherited anyway? (through > __super__) > > Or, if one would want to disable inheritance of the normal dict, one c

Re: [Tutor] Function design

2009-10-27 Thread Eduardo Vieira
On Tue, Oct 27, 2009 at 10:14 AM, Dave Angel wrote: > > But if the file contained  0.00 as one of its items, this code would still > have the other problem I mentioned. > > DaveA > ___ > Tutor maillist  -  tu...@python.org > To unsubscribe or change sub

Re: [Tutor] How to load a dict into a dict subclass?

2009-10-27 Thread Wayne
On Tue, Oct 27, 2009 at 12:49 PM, Alan Gauld wrote: > > "Wayne" wrote > >> My favorite example (and the easiest to understand) deals with shapes: >> >> class Shape: >>def __init__(self): >> self.sides = 0 >> self.area = 0 >> >> class Triangle(Shape): >>Shape.__init__(self) >>

[Tutor] Error

2009-10-27 Thread Vincent Jones
I created database using the 'python manage.py sycdb' then proceeded to 'python manage.py sql bookmarks' and i receive this error: Error: App with label bookmarks could not be found. Are you sure your INSTALLED_APPS settings is correct? I go to Settings py and the INSTALLED_APPS is 'django_bookm

Re: [Tutor] How to load a dict into a dict subclass?

2009-10-27 Thread Albert-Jan Roskam
I thought reimplementing dict was a matter of defining a __dict__ attribute in the Bar class? And isn't the normal dict inherited anyway? (through __super__) Or, if one would want to disable inheritance of the normal dict, one could use __slots__. Right? Or did I misinterpret the New Testament

Re: [Tutor] Compute data usage from log

2009-10-27 Thread Eduardo Vieira
On Tue, Oct 27, 2009 at 5:33 AM, bibi midi wrote: > #!/usr/bin/env python > # -*- coding: utf-8 -*- > > ''' > Calculate internet data consumption > of service provider > Code as per help of python tutor mailing list > Created: 26-Oct-2009 > > ''' > > intro = raw_input('press enter to view your int

Re: [Tutor] Function design

2009-10-27 Thread Eduardo Vieira
On Tue, Oct 27, 2009 at 10:14 AM, Dave Angel wrote: > Benno Lang wrote: >> >> On Tue, Oct 27, 2009 at 8:21 AM, Dave Angel wrote: >> >>> >>> I agree with Luke's comments.  But I'd like to point out an apparent bug >>> (I >>> haven't tried the code, this is just by inspection). >>> >>> You use the

Re: [Tutor] How to load a dict into a dict subclass?

2009-10-27 Thread Alan Gauld
"Wayne" wrote My favorite example (and the easiest to understand) deals with shapes: class Shape: def __init__(self): self.sides = 0 self.area = 0 class Triangle(Shape): Shape.__init__(self) def __init__(self, base=0, height=0): self.sides = 3 self.

Re: [Tutor] How to load a dict into a dict subclass?

2009-10-27 Thread Alan Gauld
"John" wrote > >>> class Bar(dict): > >>> pass > >>> > >>> foo = {'a':100, 'b':200, 'c': 300} > >>> myvar = Bar() > >>> myvar.update(foo) > >>> myvar > > {'a': 100, 'c': 300, 'b': 200} Hey guru's could one of you explain why such a subclass is needed. How would it be used. I'm not su

Re: [Tutor] New to Python

2009-10-27 Thread Alan Gauld
wrote How do you connect to a different server using python? (I have not used python before) Have you programmed before? If so in what languages? If you are a complete novice any kind of network programming is quite a challenge. If you are experienced can you give us a bit more context? -

[Tutor] ANN: Python course, San Francisco, Nov 9-11

2009-10-27 Thread wesley chun
hey gang, not sure i made the original announcement on this list a few months ago, but if you're on this list because you need to learn Python as quickly and as in-depth as possible for an immediate need, i have few more openings in my upcoming course in San Francisco, and below is the reminder i'v

Re: [Tutor] New to Python

2009-10-27 Thread Kent Johnson
On Tue, Oct 27, 2009 at 11:35 AM, wrote: > Hi there, > > How do you connect to a different server using python? (I have not used > python before) What kind of connection? The Python standard library includes modules which support raw sockets, http, ftp, smtp, xml-rpc and probably a few others. P

Re: [Tutor] New to Python

2009-10-27 Thread Wayne
On Tue, Oct 27, 2009 at 10:35 AM, wrote: > Hi there, > > How do you connect to a different server using python? (I have not used > python before) > What kind of server? What do you ultimately want to do? see: http://catb.org/~esr/faqs/smart-questions.html#beprecise for more info about asking

[Tutor] New to Python

2009-10-27 Thread asterix09
Hi there, How do you connect to a different server using python? (I have not used python before) Your help would be much appreciated. Kindest Regards, Dave ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http:/

Re: [Tutor] Compute data usage from log

2009-10-27 Thread Dave Angel
(For some reason you keep top-posting. Add your comments to the end, or inline if appropriate) bibi midi wrote: Yep it works! I understand now it iterates on each line and replaces the old elements with the new ones. In the end you get the latest date of the last line of log. I will work on t

Re: [Tutor] Function design

2009-10-27 Thread Dave Angel
Benno Lang wrote: On Tue, Oct 27, 2009 at 8:21 AM, Dave Angel wrote: I agree with Luke's comments. But I'd like to point out an apparent bug (I haven't tried the code, this is just by inspection). You use the test if '0' in row[.] that's not going to check for a zero value, it's g

Re: [Tutor] How to load a dict into a dict subclass?

2009-10-27 Thread Wayne
On Tue, Oct 27, 2009 at 10:20 AM, John wrote: > > Hey guru's could one of you explain why such a subclass is needed. How > would > it be used. I'm not sure but does not the deepcopy() work as above? A subclass is useful for when you want to do pretty much what another class does, only with so

Re: [Tutor] How to load a dict into a dict subclass?

2009-10-27 Thread John
On Tuesday 27 October 2009 06:25:13 am John wrote: > I use a 'SuperDict' all the time in my code. Not sure it's a good idea, but > I find it convenient. Also, I wouldn't mind comments on why/why not to use > something like this: > > class SuperDict(dict): > def __getattr__(self, attr): >

Re: [Tutor] How to load a dict into a dict subclass?

2009-10-27 Thread John
I use a 'SuperDict' all the time in my code. Not sure it's a good idea, but I find it convenient. Also, I wouldn't mind comments on why/why not to use something like this: class SuperDict(dict): def __getattr__(self, attr): return self[attr] def __setattr__(self, attr, value):

Re: [Tutor] Compute data usage from log

2009-10-27 Thread bibi midi
Yep it works! I understand now it iterates on each line and replaces the old elements with the new ones. In the end you get the latest date of the last line of log. I will work on the exception handling and other refinements. Thanks. On Tue, Oct 27, 2009 at 8:41 AM, Christian Witts wrote: > >

Re: [Tutor] How to load a dict into a dict subclass?

2009-10-27 Thread Christian Witts
Modulok wrote: List, I'm new to the list, (somewhat new to python too). My code feels hacky. I'd like to know if there is a more eloquent way (more below). If not, a general thumbs up from more experienced programmers would be great! Assume I have a dict, 'foo'. I also have my own class, 'Bar',

Re: [Tutor] Compute data usage from log

2009-10-27 Thread Christian Witts
bibi midi wrote: Hey Christian, There seems to be a missing parenthesis in your join function below. Correct me if I'm wrong. I can live with ppp's time format for now. My script is not world-changing anyway :-). How do i know I'm on the last line of the log file per the code below? Just as

Re: [Tutor] Compute data usage from log

2009-10-27 Thread bibi midi
Hey Christian, There seems to be a missing parenthesis in your join function below. Correct me if I'm wrong. I can live with ppp's time format for now. My script is not world-changing anyway :-). How do i know I'm on the last line of the log file per the code below? Just asking as I'm away from m

[Tutor] How to load a dict into a dict subclass?

2009-10-27 Thread Modulok
List, I'm new to the list, (somewhat new to python too). My code feels hacky. I'd like to know if there is a more eloquent way (more below). If not, a general thumbs up from more experienced programmers would be great! Assume I have a dict, 'foo'. I also have my own class, 'Bar', which subclasses

Re: [Tutor] Compute data usage from log

2009-10-27 Thread Christian Witts
bibi midi wrote: #!/usr/bin/env python # -*- coding: utf-8 -*- ''' Calculate internet data consumption of service provider Code as per help of python tutor mailing list Created: 26-Oct-2009 ''' intro = raw_input('press enter to view your internet data consumption: ') log_file = '/home/bboymen/

Re: [Tutor] Compute data usage from log

2009-10-27 Thread bibi midi
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Calculate internet data consumption of service provider Code as per help of python tutor mailing list Created: 26-Oct-2009 ''' intro = raw_input('press enter to view your internet data consumption: ') log_file = '/home/bboymen/mobily.data.plan' to

Re: [Tutor] Function design

2009-10-27 Thread Benno Lang
On Tue, Oct 27, 2009 at 8:21 AM, Dave Angel wrote: > I agree with Luke's comments.  But I'd like to point out an apparent bug (I > haven't tried the code, this is just by inspection). > > You use the test >     if '0' in row[.] > > that's not going to check for a zero value, it's going to chec