[Tutor] endless loop

2010-07-05 Thread prasad rao
hi I am trying problem 6 in projecteuler.org. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? def rr(z,m=1): q=lambda n:m%n==0 s=lambda False : 0 a=filter(s,map(q,range(1,z))) if not a: m+=1

[Tutor] Doubts galore.

2010-06-10 Thread prasad rao
Hi def cript(doc=None,data =None): if doc==None and data==None:doc=sys.agv1 elif doc: data=open(doc,'r').read() data_c= binascii.hexlify(data) else:data_c= binascii.hexlify(data) if doc: q=tempfile.TemporaryFile() q.write(data_c)

Re: [Tutor] Doubts galore.

2010-06-10 Thread prasad rao
Never NEVER compare for equality with None. What you want is: if doc is None and data is None: Also, what is sys.agv1? Did you mean sys.argv[1]? yes elif doc: data=open(doc,'r').read() data_c= binascii.hexlify(data) else:data_c=

[Tutor] writing csv files

2010-05-22 Thread prasad rao
hello! I got a problem writing csv file. 1) csvw=csv.writer(open('/home/prasad/kkm','w'), dialect='excel',fieldnames=names) Traceback (most recent call last): File stdin, line 1, in module TypeError: 'fieldnames' is an invalid keyword argument for this function 2) for x in csvr: ...

[Tutor] writing csv files

2010-05-22 Thread prasad rao
Thanks I got it. I reached the old PEP document by searching the keyword 'excel' Thanks or the help ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] parsing pyc files

2010-03-23 Thread prasad rao
Hi . If you want to see what is in a pyc file,just type od pycfile at bash command prompt. You can see only rows of numbers. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

[Tutor] ex-ftp

2009-09-21 Thread prasad rao
hello friends I am trying to write a class to save a url.page. But it is not working.It is saving the html.page.But not getting images.I am unable to show the list (object.links). Please take a look at it and show me how to rectify it. import urllib2,ftplib,re class Collect: def

Re: [Tutor] How to convert binary files back to text files?

2009-08-30 Thread prasad rao
. I don't understand what you are trying to do. Do you mean compiled Python files, e.g. .pyc files? ?Kent Yes I want to examine pyc files.(ex:itertools). itertools.py is not available inPython26. pyc files are binaryfiles.Isn't it. ___ Tutor

[Tutor] How to convert binary files back to text files?

2009-08-29 Thread prasad rao
Hello! I want to convert compiled files to text files. I believe compiled files are binary files. I am able to convert a given string to binary and back to text. But when it comes to a file it is proving to be impossible. code def p(a): s=open(a,'rb') for x in s:

Re: [Tutor] How to convert binary files back to text files?

2009-08-29 Thread prasad rao
On 8/29/09, Geneviève DIAGORN g...@teamlog.com wrote: Bonjour, Je suis absente jusqu'au 02/09 inclus. En cas d'urgence Soprane, contacter notre adresse générique projet.sopr...@teamlog.com. Cordialement. Geneviève I dont know your language.Please communicate in English. I am using the

Re: [Tutor] To write data in two different fonts?

2009-08-12 Thread prasad rao
xml.sax.saxutils.escape(/data/[, /entities/]) Escape '', '', and '' in a string of data. You can escape other strings of data by passing a dictionary as the optional /entities/ parameter. The keys and values must all be strings; each key will be replaced with its corresponding

[Tutor] To write data in two different fonts?

2009-08-11 Thread prasad rao
Hello I am wtriting some dat on to a file in which headings should be of different size than other data. Is it possible?If possible please tell me how to do it. code def sc(adir): import os,myfiles dest=open('C:/scripts.txt','w') s=myfiles.myfiles(adir) for x in s:

Re: [Tutor] To write data in two different fonts?

2009-08-11 Thread prasad rao
Hello I modified my code.But I am gettingmy my lines stripped of indentation. What should I do to avoid it?Sorry if it is not about Python. code def sc(adir): import os,myfiles dest=open('C:/scripts.html','w') s=myfiles.myfiles(adir) dest.write('html') for x

Re: [Tutor] To write data in two different fonts?

2009-08-11 Thread prasad rao
But I think you want the pre tag, which means the text is pre-formatted. And you could put that around the whole sorce file, instead of doing p for each line. See http://www.w3schools.com/tags/tag_pre.asp Thank you Dave. I put in tag pre and it worked. But at one particular line in a

[Tutor] How to pass arguments to struct.pack()?

2009-08-03 Thread prasad rao
Hello I am finding it difficult to pass arguments to struct.pack(). Please some one tell me how to do it. def structpack(alist): import struct a='%di'%len(alist) print a b=[a] print alist print b

[Tutor] flag to call methods on objects?

2009-07-30 Thread prasad rao
hello I wanted to prevent other users of my computers to read my files. So tried to creat a module to achieve it. I used a flag to deside which methods to be called on the object. somehow it is not working.I realise after 2 days of struggle that as it is usuel , I am blind to my faults. I

Re: [Tutor] flag to call methods on objects?

2009-07-30 Thread prasad rao
On 7/30/09, Rich Lovely roadier...@googlemail.com wrote: 2009/7/30 prasad rao prasadarao...@gmail.com: I'm sure there are modules available for PGP that are either part of the stdlib, or available from a quick google. PGP (or GPG) encryopts I never know there is an encryption

Re: [Tutor] flag to call methods on objects?

2009-07-30 Thread prasad rao
On 7/30/09, Dave Angel da...@ieee.org wrote: prasad rao wrote: hello it is not working. is not very descriptive. DaveA Hello! Sorry, I forgot to mention the problem. It simply wipes clean the file,resulting in empty file. Yes .I should compare with a string.Hope I will get

[Tutor] flag to call methods on objects?

2009-07-30 Thread prasad rao
hello I removed the bugs.But still getting error report. import mcript Traceback (most recent call last): File pyshell#6, line 1, in module import mcript File C:\Python26\mcript.py, line 78, in module a.main() File C:\Python26\mcript.py, line 58, in main

[Tutor] Text.insert()

2009-06-03 Thread prasad rao
Hello I created a gui app.I am finding it impossible to use Text.insert().please some one give an example of using it. Look in my tutorial at event driven programming and the Case study. Both use the Text widget. For more detailed info try this introduction:

[Tutor] my first gui

2009-06-03 Thread prasad rao
Hello. I made my first mager gui program.I need your openions suggestions and improvements. #! usr\\bin\\env python from Tkinter import * def myfiles (n='',m=''): import os mf=[os.path.join(x,i)for x,y,z in os.walk(n) for i in z if i.endswith(m)] return mf def fshow():

[Tutor] Text.index()

2009-06-02 Thread prasad rao
Hello I created a gui app.I am finding it impossible to use Text.insert().please some one give an example of using it. def fshow(): x=entry1.get() try: value1,value2=x.split(',') text.insert(len(myfiles(value1,value2)),myfiles(value1,value2)) except:

[Tutor] ?????

2009-05-25 Thread prasad rao
hello I get a problem while trying to print non callable items in dir(module).May be as the items are strings. for x in dir(sys): ?? if sys.x is callable: print sys.x() ?? else:print sys.x Traceback (most recent call last): File pyshell#10, line 2, in module if sys.x is

Re: [Tutor] ?????

2009-05-25 Thread prasad rao
Any particular reason why you need to be able to do this, just wondering about the use case for such automation ? -- Kind Regards, Christian Witts Thank you Christian for the prompt repply. I am learning python. I am just examining what are all the available items in each module . I

Re: [Tutor] ?????

2009-05-25 Thread prasad rao
for attrib in dir(sys): if callable('sys.%s' % attrib): print 'Callable: sys.%s' % attrib else: print 'Not Callable: sys.%s' % attrib Any particular reason why you need to be able to do this, just wondering about the use case for such automation ? -- Kind Regards,

[Tutor] Is it syntactic,semantic or runtime?

2009-04-25 Thread prasad rao
helloI wrote a function to fetch data using urllib and displaying the data using internet Explorer. it is not preparing the html file So opening blank Explorer after complaining th html file not found. Where is the problem? Can I display the data read from a site without preparing a html file?

[Tutor] re Format a file

2009-02-28 Thread prasad rao
Hello for line in so: if len(line)70:de.write(line+'\n') if len(line)70: da=textwrap.fill(line,width=60) de.write(da+'\n') What happens if the line is exactly 70 characters long? I think you want an else instead of the second if Alan G

[Tutor] re Format a file

2009-02-27 Thread prasad rao
HelloFinally I managed to writ a function to format a file. Thank to everybody for their tips. def mmm(a): import os,textwrap so=open(a) d=os.path.dirname(a)+os.sep+'temp.txt' de=open(d,'w') import textwrap for line in so: if

[Tutor] format a file

2009-02-26 Thread prasad rao
hello I find it difficult to use horizontal scroll bar to read text documents. So I want to split lines in the text file in to two lines. code def myforrmat(source,desty): so=open(source) de=open(desty,'w') for line in so: ? if len(line)60:de.write(line) ? if

[Tutor] re.format a file

2009-02-26 Thread prasad rao
helloThank you Lie and Kent. I forgot about newline character and the fact that string can be sliced. Thanks for your timely help BTW I have gone through the Python library reference and find no examples in fileinput module. z=fileinput.input(file,inplace=1) for line in z: ???if

[Tutor] re Format a file

2009-02-26 Thread prasad rao
HelloI don't know why, but this I think going into infinite loop. I cant see anything wrong in it. Please show me where the problem is. def myform(s): import os so=open(s) d=os.path.dirname(s)+os.sep+'temp.txt' de=open(d,'w') for line in so: while len(line)60:

[Tutor] Formatting

2009-02-25 Thread prasad rao
hi for license in licenses: m = licenseRe.search(license) print m.group(1, 2) ('ABTA', 'No.56542') ('ATOL', None) ('IATA', None) ('ITMA', None) Yes It is working Thank you Prasad ___ Tutor maillist - Tutor@python.org

[Tutor] Formatting

2009-02-24 Thread prasad rao
hi. s = 'Association of British Travel Agents (ABTA) No.56542\nAir Travel Organisation Licence (ATOL)\nAppointed Agents ofIATA (IATA)\nIncentive Travel Meet. Association (ITMA)' licenses = re.split(\n+, s) licenseRe = re.compile(r'\(([A-Z]+)\)( No. (\d+))?') for license in licenses:

[Tutor] re Binding Event

2009-02-10 Thread prasad rao
HelloI changed the code as follows.But still the callback function is not working. The he() is working well but clicking on the frame has no result. class app: def __init__(self,root): frame=Frame(root) frame.bind(Button-1, callback) frame.pack()

[Tutor] Binding Events

2009-02-09 Thread prasad rao
Hi I am unable to bind an event to a widget despite of my best efforts. Some one please help me. class app: def __init__(self,root): frame=Frame(root) frame.bind('Button-1',self.callback) frame.pack() self.event=event self.button=Button(root,text='quit',fg='red',command=frame.quit)

[Tutor] re.Binding Events

2009-02-09 Thread prasad rao
HelloI tried various permutations of the code.Nothing worked. I am mixing 2 examples given in an-introduction-to- tkinter by Fredrik Lundh.(and got this code) Today I got this error message Traceback (most recent call last): File pyshell#5, line 1, in module pp() File pyshell#4, line 18,

[Tutor] re division problem

2009-02-04 Thread prasad rao
hi I modified my function ' vertical' by adding a few characters to eliminate the division problem. def vertical(columns): if columns7: columns=7 import string v=string.printable v=v.replace('\n','') v=v.replace('\t','') if len(v)%columns !=0:

[Tutor] Division problems

2009-02-03 Thread prasad rao
HelloI wrote a function named vertical to print string .printable characters and ASCII values in a table. 1)It is swallowing some characters. 2)It output some characters 2 or 3 times. 3)It prints one column more than what I asked for. It may be a division problem(floating point). Its sibling

[Tutor] re division problem

2009-02-03 Thread prasad rao
I wrote a function named vertical to print string .printable characters and . ASCII values in a table. 1)It is swallowing some characters. 2)It output some characters 2 or 3 times. 3)It prints one column more than what I asked for. def vertical(columns): import string

[Tutor] re weird bool

2009-02-03 Thread prasad rao
helloyes.you are right. 2==True False It is an unexpected result to me. I thought any value other than 0 is True. And the solution provided by you(bool(a/1)) is useful to me. Thank you Prasad ___ Tutor maillist - Tutor@python.org

[Tutor] weird bool

2009-02-03 Thread prasad rao
hi a=2.1 a%1==True False a%1==False False b=3.8 b%1==True False b%1==False False If it gives correct bool, it could be put to good use. Prasad ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] re division problem

2009-02-03 Thread prasad rao
hiRight now you skip by x+((len(v))/columns) which will be different for each row. How is it possible. len(v)=98.A constant. Is it not. Does len(v) changes with each iteration? Prasad ___ Tutor maillist - Tutor@python.org

[Tutor] set key to sort

2009-01-31 Thread prasad rao
hellI got a problem sorting a list of lists. ml= [[112, 'p'], [114, 'r'], [97, 'a'], [115, 's'], [97, 'a'], [100, 'd'], [97, 'a'], [114, 'r'], [97, 'a'], [111, 'o']] sorted(ml,key=?) How can I formulate a key to sort based on the first element of each list. sorting list of lists might have been

[Tutor] Thank you

2009-01-31 Thread prasad rao
Hello Thanks .Today I learned to use operator.itemgetter() to set key. Thank you prasad ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] multiplication table

2009-01-10 Thread prasad rao
HiI tried to print multiplication table using (*args) to pass parameters.and tried to print tables side by side.But the code looks messy .Is there a better way to do it. def mtab(*arg): for x in range(1,11): print '%3d'%(x),'x','%3d'%(arg[0]),'=','%3d'%(x*arg[0]),(' '*5),\

[Tutor] Thanks

2009-01-10 Thread prasad rao
Hello Your code is concise and neat.It will take some time for me to understand how it is doing the job. Thank you You have a lot of duplicated code. You can reduce the duplication by using functions and loops. The first step is to put all the print code into a function rather than

Re: [Tutor] Convert values in a list back and forth from ints

2009-01-07 Thread prasad rao
. class Value:def __init__(self, vs = ): ... self.vs = vs ... self.v = self.asInt() ...def asInt(self): ... try: self.v = int(self.vs) ... except: self.v = None ... return self.v ...def asString(self): ...vs = str(self.vs) ...return

[Tutor] re

2009-01-07 Thread prasad rao
Hello I am trying to get a value as integer and a string. class Value: def __init__(self,inte='',stri=''): self.inte=inte self.stri=stri def setvalue(self,inte='',stri=''): self.stri=str(self.inte) self.inte=int(self.stri) v=Value(45) print

[Tutor] repply

2009-01-04 Thread prasad rao
hi I got it right. z=[] for x in range(1000): if divmod(x,3)[1]==0:z.append(x) if divmod(x,5)[1]==0:z.append(x) sum(set(z)) 233168 I am sorry if this is outside the perimeter of this list. ___ Tutor maillist - Tutor@python.org

[Tutor] project euler

2009-01-04 Thread prasad rao
hello! I got it 266333. My code== t=0 for x in range(1000): if divmod(x,3)[1]==0:t+=x if divmod(x,5)[1]==0:t+=x t=266333 Am I correct in comprehention of the problem? Prasad ___ Tutor maillist - Tutor@python.org

[Tutor] reply

2008-12-30 Thread prasad rao
Hello. Thank you.Just a small change at the optional parameter made all the difference. It seems to be a mirracle.It is an enlitenment to me. Thank you. Prasad ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] optional parameter in list comprehension

2008-12-29 Thread prasad rao
hello!I am a novice looking up to the tutor as my Guide. I got a problem while using optional parameter. #! user/bin/env python import os def myfiles(directory,extension=None): for x in [os.path.join(x,i) for x,y,z in os.walk(directory)\ for i in z if

[Tutor] Repply

2008-12-26 Thread prasad rao
Thanks for help. http://svn.python.org/view/python/trunk/Objects/listobject.c?rev=67498view=markup Kent ! This is grek and latin to me.From the presence of header files it looks C++.But headerfiles are not between '' and '' . But why are you trying to sort in this fashion? Alan Gauld!

[Tutor] to sort

2008-12-25 Thread prasad rao
hello I am trying to sort a list(I know there is a builtin sort method). a=[21,56,35,47,94,12] b=[] for x in a: b.append (min(a)) a.remove (min(a)) a [56, 47, 94] b [12, 21, 35] It is not Compleating .Doing only 3 rounds.Why? By the way how can I view the builtin code for

[Tutor] To print docstrings

2008-12-04 Thread prasad rao
Hello friends. I am new to programing.I am learning Python. I failed in my attempts to retrive doc strings of methods in a module. for x in dir(logging): print x,x.__doc__ = for x in dir(collections): print x,collections.x.__doc__ == def dd(o): zx=dir (o) for