Re: [Tutor] Read-create-edit file

2009-12-13 Thread bibi midi
Here's the link: http://paste.debian.net/53933/ On Mon, Dec 14, 2009 at 6:10 AM, bibi midi wrote: > > > Yes my bad, found out too late. Sorry for that. Will post in pastebin or > equal and give the link. > > > -- > Best Regards, > bibimidi

Re: [Tutor] Read-create-edit file

2009-12-13 Thread bibi midi
On Mon, Dec 14, 2009 at 6:09 AM, bibi midi wrote: > > > On Mon, Dec 14, 2009 at 1:17 AM, Rich Lovely wrote: > >> >> First of all it's too long to paste into an email, especially if >> you'rte using a client that strips leading whitespace. Paste it

Re: [Tutor] Read-create-edit file

2009-12-13 Thread bibi midi
On Mon, Dec 14, 2009 at 1:17 AM, Rich Lovely wrote: > > First of all it's too long to paste into an email, especially if > you'rte using a client that strips leading whitespace. Paste it into > a pastebin. I personally prefer python.codepad.org, as it lets you > test code on the server, unless i

Re: [Tutor] Equivalent exception of os.path.exists()

2009-11-30 Thread bibi midi
Thanks to all of you that replied. Your inputs are very helpful and informative. On Tue, Dec 1, 2009 at 12:14 AM, Sander Sweers wrote: > > There is no exception to alert you a file already exists. Depending on > how you open the file (mode) it will either read, write or append to > the file. If

Re: [Tutor] proxy switcher - was Re: I love python / you guys :)

2009-11-19 Thread bibi midi
-- Forwarded message -- From: bibi midi Date: Tue, Nov 17, 2009 at 11:12 PM Subject: Re: [Tutor] proxy switcher - was Re: I love python / you guys :) To: Dave Angel Cc: Luke Paireepinart , tutor Hi guys! Thank you all for the brainstorming. As much as i love to follow all

Re: [Tutor] proxy switcher - was Re: I love python / you guys :)

2009-11-17 Thread bibi midi
Hi guys! Thank you all for the brainstorming. As much as i love to follow all your tips but sorry I got lost in the sea of discussion :-) Therefore i thought i start to roll out my own and i hope you guys can chime in. The print lines in my code are just for debugging. Of course they can be omitt

Re: [Tutor] I love python / you guys :)

2009-11-16 Thread bibi midi
On Mon, Nov 16, 2009 at 1:58 AM, Stefan Lesicnik wrote: > hi, > > Although not a question, i just want to tell you guys how awesome you are! > > I am not a programmer, i can do a bit of bash. I have never officially > learnt programming, but numerous times looked at some perl, c, java > and never

Re: [Tutor] Should a beginner learn Python 3.x

2009-11-14 Thread bibi midi
On Sun, Nov 15, 2009 at 10:37 AM, wesley chun wrote: > >> My brother in law is learning python. He's downloaded 3.1 for > >> Windows, and is having a play. It's already confused him that print > >> "hello world" gives a syntax error > >> > >> He's an absolute beginner with no programming ex

Re: [Tutor] Local vs global

2009-11-08 Thread bibi midi
On Sun, Nov 8, 2009 at 8:38 AM, Dave Angel wrote: > > You have the following line at top-level: > > if ask.lower not in reply: > > But you're not calling the method str.lower(), you're just creating a > function object from it. You need those parentheses. > > if ask.lower() not in reply: > >

Re: [Tutor] Local vs global

2009-11-08 Thread bibi midi
On Sun, Nov 8, 2009 at 6:20 AM, bibi midi wrote: > Thank you all for the helpful insights. I will keep in mind the naming > rules in Python, so as not to have it in collision with Python's > builtins. > > The mention to tidy up e.g. "compartmentalize" code is al

Re: [Tutor] Local vs global

2009-11-07 Thread bibi midi
On Sat, Nov 7, 2009 at 3:26 PM, Dave Angel wrote: > Alan Gauld wrote: >> > Alan - Excellent comments, as usual. > > bibimidi - I would point out that after you remove the 'global choose' line > as Alan said, you should rename the global variable you're using to store > the return value. They're a

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] Compute data usage from log

2009-10-27 Thread bibi midi
s I'm away from my linux box atm. for line in open(log_file): last_log_date = ' '.join(line.split(' ')[:3]) Thanks. On Tue, Oct 27, 2009 at 2:56 PM, Christian Witts wrote: > bibi midi wrote: > >> #!/usr/bin/env python >> # -*- coding: utf-8 -*- >

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] Compute data usage from log

2009-10-26 Thread bibi midi
On Mon, Oct 26, 2009 at 2:12 PM, Luke Paireepinart wrote: > > > On Mon, Oct 26, 2009 at 3:20 AM, Christian Witts > wrote: > >> fInput = open('/path/to/log.file', 'rb') >> total_usage = 0 >> for line in fInput: >> total_usage += int(line.split(' ')[9].strip()) >> print total_usage >> > > It's ac

[Tutor] Compute data usage from log

2009-10-26 Thread bibi midi
Hi all! I have a file with data structure derived from wvdial log: Oct 14 11:03:45 cc02695 pppd[3092]: Sent 3489538 bytes, received 43317854 bytes. I want to get the 10th field of each line and get the sum for all lines (total my net data usage). In awk u can easily pop it using field variabl