Re: [Tutor] (no subject)

2010-05-11 Thread ramya natarajan
I really thank you all for  the quick response,   It was really helpful!!

On Tue, May 11, 2010 at 7:28 PM, Dave Angel  wrote:

> (1. Please don't top-post.  It gets everything out of sequence, and is the
> wrong convention for this forum
> 2. Be sure and do a reply-all, so that the message goes to the forum.  I'm
> not here to give private advice.
> 3. Use your editor's reply-quoting so that we can tell who wrote which
> parts.  Normally, you'll see that as either a leading ">" character or as a
> "!" character.  And one can tell which parts were written by whom by
> counting the number of those at the beginning of each line)
>
> For my real response, see the end of the message, where it belongs.
>
> Sivapathasuntha Aruliah wrote:
>
>> Dave
>> Thank you very much for your response. I think I have problem with both
>> Python23 & Python31. Please help.
>>
>> Python23 : The program works but programs written by Mark Summerfield in
>> his book Programming in Python3 does not work.
>> Python 31: When I run this program it says in the pop up window "
>> C:\py3eg\csv2html1_ans.py is not a valid Win32 application" and on the the
>> dos box it says Access is denied.
>> Below is the dos box contents
>>
>>
>> C:\>cd python31
>>
>> C:\Python31>python C:\py3eg\quadratic.py
>> Access is denied.
>>
>> C:\Python31>python C:\py3eg\quadratic.py
>> Access is denied.
>>
>> C:\Python31>python C:\py3eg\hello.py
>> Access is denied.
>>
>> C:\Python31>python.exe C:\py3eg\hello.py
>> Access is denied.
>>
>> C:\Python31>cd..
>>
>> C:\>cd python23
>>
>> C:\Python23>python.exe C:\py3eg\hello.py
>> ('Hello', 'World!')
>>
>> C:\Python23>python.exe C:\py3eg\print_unicode.py
>> Traceback (most recent call last):
>>  File "C:\py3eg\print_unicode.py", line 30, in ?
>>print_unicode_table(word)
>> NameError: name 'print_unicode_table' is not defined
>>
>> C:\Python23>python.exe C:\py3eg\quadratic.py
>>  File "C:\py3eg\quadratic.py", line 14
>>except ValueError as err:
>>   ^
>> SyntaxError: invalid syntax
>>
>>
>>
>>
>> Regards,
>> Siva
>> Test Equipment Engineering
>> Amkor Technology (S) Pte Ltd
>> 1 Kaki Bukit View
>> #03-28 TechView Building
>> Singapore 415941
>> Tel: (65) 6347 1131
>> Fax: (65) 6746 4815
>>
>>
>>
>> Dave Angel 
>>
>>
>> 05/12/2010 09:50 AM
>>
>>
>> To
>> Sivapathasuntha Aruliah/S1/a...@amkor
>> cc
>> tutor@python.org
>> Subject
>> Re: [Tutor] (no subject)
>>
>>
>>
>>
>>
>>
>>
>>
>> Sivapathasuntha Aruliah wrote:
>>
>>
>>> Hi
>>> I am learning Python. When I tried to run any of the program for example
>>>
>>>
>>
>>
>>
>>> csv2html1_ans.py it displays the following message. This error is coming
>>>
>>>
>>
>>
>>
>>> on both Python24 & Python 31. That is whether i give the any one of the
>>> following command
>>>
>>> COMMAND GIVEN
>>> 1.C:\python24\python.exe C:\py3eg\quadratic.py
>>> 2.C:\python31\python.exe C:\py3eg\quadratic.py
>>>
>>> A message below appears with the program name. Please advice me how to
>>>
>>>
>> get
>>
>>> over from this issue
>>> ERROR MESSAGE
>>> command  C:\py3eg\csv2html1_ans.py is not a valid Win32 application
>>>
>>> Regards,
>>> Siva
>>> Test Equipment Engineering
>>> Amkor Technology (S) Pte Ltd
>>> 1 Kaki Bukit View
>>> #03-28 TechView Building
>>> Singapore 415941
>>> Tel: (65) 6347 1131
>>> Fax: (65) 6746 4815
>>>
>>>
>>>
>> Please copy and paste the actual contents of your DOS box, rather than
>> paraphrasing.  COMMAND hasn't been the normal shell name since Win95 days.
>>  You can't use numbers in front of commands in any shell I've used.  The
>> error message refers to a different file than anything you specified in your
>> commands.
>>
>> What OS are you using?
>>
>> DaveA
>>
>>
>>
>>
>>
> Again, what OS are you using?
>
> I have no idea what the pop up comes from, but I suspect you have some
> non-trivial code in that python program, perhaps that creates a gui.  Is
> there any tkinter stuff in it?
>
> As for "Access is Denied", it usually means you tried to access a
> non-existent drive, or one which isn't currently mounted.  For example,
> referencing your CD drive with no platter in it.
>
> I don't know why "print_unicode_table" is undefined, but apparently you're
> missing some code.
>
>
> And the except clause changed between 2.x and 3.x, so you need to change
> the syntax to match the particular interpreter you're using.  They're not
> compatible, although there's a utility to convert from 2.x to 3.x, I don't
> think there's anything that reverses it.
>
> I'd suggest picking one version, and using only books and references that
> are compatible with it till you're comfortable with the language.
>
> DaveA
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/l

[Tutor] Help required to count no of lines that are until 1000 characters

2010-05-11 Thread ramya natarajan
Hello,

I am very  beginner to programming, I  got task to Write a loop that reads
each line of a file and counts the number of lines that are read until the
total length of the lines is 1,000 characters. I have to read lines from
files exactly upto 1000 characters.

Here is my code:
 I created file under /tmp/new.txt  which has 100 lines and 2700 characters
, I wrote code will read exactly 1000 characters and count lines upto those
characters.But the problem is its reading entire line and not stopping
excatly in 1000 characters. Can some one help what mistake i am doing here?.

   log = open('/tmp/new.txt','r')
   lines,char = 0,0
   for line in log.readlines():
while char < 1000 :
for ch in line :
 char += len(ch)
lines += 1
  print char , lines
  1026 , 38    Its counting entire line  instead of character upto 1000
-- can some one point out what mistake am i doing here , where its not
stopping at 1000 . I am reading only char by car

My new.txt -- cotains content like
this is my new number\n

Can some one please help. I spent hours and hours to find issue but i am not
able to figure out, Any help would be greatly appreciated.
Thank you
Ramya
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor