[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
  rr(z,m)
  else:return m

This code is going into endless loop.

   rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
  File "", line 7, in rr
rr(z,m)
I tried dime a dozen  permutations oF the code.
Can some one show me  why it is going into Endless loop?

Thank you
Prasad
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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= binascii.hexlify(data)
>  >if doc:
>  > q=tempfile.TemporaryFile()
>  > q.write(data_c)
>  > os.rename(q,doc)
>  > return
>  >return data_c


> It would probably be cleaner to use one-line
>  conditional statements (sparingly) where they make
>  sense on their own, but not to mix multi-line and
>  single line styles in the same if-else structure.

I am a newbie.I couldn't understand that comment.

>  I'm not sure the logical flow through there
>  does what you think it does, though.


>  > cript(doc='./language.txt')
>  > Traceback (most recent call last):
>  >   File "", line 1, in 
>  >   File "", line 10, in cript
>  > TypeError: coercing to Unicode: need string or buffer, file found



> Is this the actual code or did you retype it?

I just copied from .py file and pasted.

>  It has some typos which makes me wonder.  If you copy/paste
>  the actual code that can remove any confusion introduced
>  by simple typing mistakes, so we are sure we're all looking
>  at the same thing here.
>
>
>  > 1)Why I got the above error message with  the above function?How to 
> correct it?
>
>
> The binascii.hexlify() function converts a binary data string into
>  hexadecimal digits.  You didn't give it a data string to work from,
>  you gave it an open file object.  You'll need to actually read the
>  data from the file and give that to the function.
>
>
>  > 2)Is it reasonable to have 2 if blocks in a function as above?
>
>
> Sure
>
>
>  > 3)Dose the tempfile create a fileobject on harddisk or in memory(Dose it 
> save my
>  >   file as I expect it to do)
>
>
> It creates a TEMPORARY file.  That means you can expect it to
>  exist on disk until you close it, and then if at all possible,
>  it will automatically be destroyed for you.  Hence "temporary".
>  Depending on your platform, while there will be a physical disk
>  file, it might not even show up in a directory or be openable by
>  other applications.
>
>  If you want a file to not be temporary, use open() to create it.

>  Steve Willoughby|  Using billion-dollar satellites
>  st...@alchemy.com   |  to hunt for Tupperware.

Thanks for the reply..Now I will try to correct my code.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[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)
os.rename(q,doc)
return
   return data_c


cript(doc='./language.txt')
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 10, in cript
TypeError: coercing to Unicode: need string or buffer, file found

1)Why I got the above error message with  the above function?How to correct it?
2)Is it reasonable to have 2 if blocks in a function as above?
3)Dose the tempfile create a fileobject on harddisk or in memory(Dose it save my
  file as I expect it to do)

Please someone enlighten me.

Prasad
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[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] 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 "", line 1, in 
TypeError: 'fieldnames' is an invalid keyword argument for this function

2)
 for x in csvr:
...y=lambda x: ''.join([x.split()[3],x.split()[-3],x.split()[-6]])
...csvw.write(y)
...
Traceback (most recent call last):
  File "", line 3, in 
AttributeError: '_csv.writer' object has no attribute 'write'

At  http://www.python.org/dev/peps/pep-0305/  they are using  the function write
 and the argument fieldnames.

Where is the problem?Please someone show me  a way to do it.

Prasad
___
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:
http://mail.python.org/mailman/listinfo/tutor


[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 __init__(self,parent):
self.parent=parent
self.links=[]
self.ims=[]
s=urllib2.urlopen(self.parent)
data=s.read()
self.data=data
a=re.compile ('<[aA].*[\'"](.*)[\'"].*>'); b=re.compile('http://www.asstr.org')
c.save(c.data)
c.bring()
#c.show(c.ims)
c.links

Thanks in advance.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


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 maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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

2009-08-29 Thread prasad rao
>On 8/29/09, Geneviève DIAGORN  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 code below to conver string to bin and back.


def tobin(astr):
   z=map(lambda x: bin(ord(x)),astr)
   return z

def tostring(blist):
   z=map(lambda x: chr(int(x,2)),l)
   return ''.join(z)

I dont believe it is impossible on files.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/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.




def p(a):
s=open(a,'rb')
for x in s:

d=map(lambda y:chr(int(y,2)),x)
print d
   s.close()

>>> p("C:/pp.txt")

Traceback (most recent call last):
  File "", line 1, in 
p("C:/pp.txt")
  File "", line 5, in p
d=map(lambda y:chr(int(y,2)),x)
  File "", line 5, in 
d=map(lambda y:chr(int(y,2)),x)
ValueError: invalid literal for int() with base 2: 'f'



Please some one point where  the problem is.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 value. The
>   >characters '&', '<' and '>' are always escaped, even if /entities/
>   >is provided.
>
> >Let us know if that doesn't do the trick.
>
> >DaveA


Thank you Dave

 It is working perfectly with the modifications you suggested.




def sc(adir):
entities = {'&' : '&',
   '<' : '<',
   '>' : '>',
   '"' : '"',
   "'" : '''}

import os,myfiles,xml.sax.saxutils
dest=open('C:/scripts.html','w')
s=myfiles.myfiles(adir)
dest.write('')
for x in s:
  if os.path.isfile(x):
   sorce=open(x,'r')

   dest.write('')
   dest.write(x)
   dest.write('')


   for l in sorce:
l=xml.sax.saxutils.escape(l,entities)
dest.write('')
dest.write(l)
   dest.write('')
   sorce.close()
  else:pass
dest.write('')
dest.close()
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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

2009-08-11 Thread prasad rao
> > But I think you want the  tag, which means the text is
> pre-formatted.  And you could >put that around the whole sorce file, instead
> of doing  for each line.
>
> >See   http://www.w3schools.com/tags/tag_pre.asp


Thank you Dave.
I put in tag  and it worked. But at one particular line in a module
the font changed colour.After that all the lines are in blue colour and
under lined.
I removed that module from the directory and now it is working well.I could
not
figure out why the change of colour of font took place.

Thank you
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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.




def sc(adir):
   import os,myfiles
   dest=open('C:/scripts.html','w')
   s=myfiles.myfiles(adir)
   dest.write('')
   for x in s:
  if os.path.isfile(x):
  sorce=open(x,'r')

  dest.write('')
  dest.write(x)
  dest.write('')


  for l in sorce:
   dest.write('')
   dest.write(l)
   dest.write('')
  sorce.close()
  else:pass
   dest.write('')
   dest.close()


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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.



def sc(adir):
  import os,myfiles
  dest=open('C:/scripts.txt','w')
  s=myfiles.myfiles(adir)
  for x in s:
 if os.path.isfile(x):
 sorce=open(x,'r')
 data=sorce.readlines()
 dest.write(x+'\n','bold')

 dest.write(('-'*len(x))+'\n')
 for l in data:
  dest.write(l)
 sorce.close()
   else:pass
   dest.close()


>>> sc('C:\Python26\mscripts')

Traceback (most recent call last):
  File "", line 1, in 
sc('C:\Python26\mscripts')
  File "", line 9, in sc
dest.write(x+'\n','bold')
TypeError: function takes exactly 1 argument (2 given)


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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

 for x in alist:
b.append(x)
arg1=b[0]
arg2=b[1:]


return struct.pack.tuple(arg1,arg2)

>>> structpack([112, 114, 97, 115, 97, 100, 97, 32, 114, 97, 111, 32, 110])
13i
[112, 114, 97, 115, 97, 100, 97, 32, 114, 97, 111, 32, 110]
['13i']

Traceback (most recent call last):
  File "", line 1, in 
pstruct([112, 114, 97, 115, 97, 100, 97, 32, 114, 97, 111, 32, 110])
  File "", line 16, in pstruct
return struct.pack.tuple(b)
AttributeError: 'builtin_function_or_method' object has no attribute 'tuple'
>>>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 "", line 1, in 
import mcript
  File "C:\Python26\mcript.py", line 78, in 
a.main()
  File "C:\Python26\mcript.py", line 58, in main
nl=__compress(__digi(__lengthen(line.strip(+'\n'
NameError: global name '_Cripto__compress' is not defined

There is no string  '_Cripto__compress'  any whare in the script.

So I dont know what corrections Ineed to make in the script.

I am giving my code below again again .



#! usr/bin/env python

import ast,random,os,zlib,string
key=5
class Cripto(object):
def __init__(self,afile):
self.afile=afile
def __digi(self,astring):
y=[]
for x in astring:
y.append(ord(x))
y=str(y)

return y
def __undigi(self,astring):

alist=ast.literal_eval(astring)
y=[]
for x in alist:
y.append(chr(x))
astring=''.join(y)
return astring
def __gen_string(self):
s=''
nl=random.sample(string.ascii_letters,key)
for x in nl:s+=x
return s

def __lengthen(self,astring):
 s=list(astring)
 ns=''
 for x in s:
 ns+=x
 ns+=gen_string()
 return ns
def __shorten(self,astring):

 s=list(astring)
 ns=''
 for x in range(0,len(s),key+1):
ns+=s[x]
return ns
def __compress(self,astring):
astring=zlib.compress(astring)
return astring
def __decompress(self,astring):
astring=zlib.decompress(astring)
return astring
def main(self):
sorce=open(self.afile,'r')
data=(sorce.readlines())
dest=open((os.path.split(self.afile)[0]+os.sep+'temp'),'w')
if (data[0]).strip()=='flag1':

ns='flag0\n'
data=data[1:]
for line in data:
   nl= __compress(__digi(__lengthen(line.strip(+'\n'
   ns+=nl
dest.write(ns)
elif data[0].strip()=='flag0':
ns='flag1\n'
data=data[1:]
for line in data:
nl= __shorten((__undigi(__decompress(line.strip()+'\n'
ns+=nl
dest.write(ns)
else:prind 'File does not begin with the flag'

sorce.close()
dest.close()

os.remove(self.afile)
os.rename((os.path.split(self.afile)[0]+os.sep+'temp'),self.afile)


#
a=Cripto('C:/pp.txt')
a.main()

<\code>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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

2009-07-30 Thread prasad rao
On 7/30/09, Dave Angel  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 it
right with that correction.


Thank you Wayne.
I never know string module can be used for encryption.
I will try all those methods(shown by you) in my module.

Thank you all

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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

2009-07-30 Thread prasad rao
On 7/30/09, Rich Lovely  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 module in stdlib.
What is its name?

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 tested all the metheds except main() in idle interactively,found them
working.
So there is a bug in the main(), kan anyone point it out to me?




#! usr/bin/env python

import ast,random,os,zlib,string
key=5
class Cripto(object):
def __init__(self,afile):
self.afile=afile
def __digi(self,astring):
y=[]
for x in astring:
y.append(ord(x))
y=str(y)

return y
def __undigi(self,astring):

alist=ast.literal_eval(astring)
y=[]
for x in alist:
y.append(chr(x))
astring=''.join(y)
return astring
def __gen_string(self):
s=''
 nl=random.sample(string.ascii_letters,key)
 for x in nl:s+=x
 return s

def __lengthen(self,astring):
 s=list(astring)
  ns=''
  for x in s:
  ns+=x
  ns+=gen_string()
  return ns
def __shorten(self,astring):

 s=list(astring)
  ns=''
  for x in range(0,len(s),key+1):
  ns+=s[x]
  return ns
def __compress(self,astring):
astring=zlib.compress(astring)
return astring
def __decompress(self,astring):
astring=zlib.decompress(astring)
return astring
def main(self):
sorce=open(self.afile,'r')
data=(sorce.readlines())
dest=open ((os.path.split(self.afile)[0]+os.sep+'temp'),'w')
if data[:1]=='flag1\n':
ns='flag0\n'
data=data[1:]
for line in data:
   nl=__compress((__digi(__lengthen(line.strip()+'\n'
   ns+=nl
dest.write(ns)
elif data[:1]=='flag0\n':
ns='flag1\n'
data=data[1:]
for line in data:
nl=__decompress((__undigi(__shorten(line.strip()+'\n'
ns+=nl
dest.write(ns)

sorce.close()
dest.close()

os.remove(self.afile)
os.rename((os.path.split(self.afile)[0]+os.sep+'temp'),self.afile)


#
a=Cripto('C:/pp.txt')
a.main()


<\code>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] my first gui

2009-06-03 Thread prasad rao
Hello

Thanks I  will implement your suggestions.

True .Names and parameters are not descriptive.

There are no comments(docstrings) in the program
.
There is scope to reduce number of functions.

Thank you

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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():
tclear()
x=entry1.get()

try:
   value1,value2=x.split(',')
   mf=myfiles(value1,value2)

   text.insert(END,('Total files in %s are %d
\n'%(entry1.get(),len(mf)))+ mystring(mf))
except:
mf=myfiles(x)
text.insert(END,('Total files in %s are %d
\n'%(entry1.get(),len(mf)))+ mystring(mf))

def atime(x):

   import time
   import os
   atime=time.strftime("%c",time.localtime(os.path.getatime(x)))
   return atime

def mtime(x):

 import time
 import os
 mtime=time.strftime("%c",time.localtime(os.path.getmtime(x)))
 return mtime

def ctime(x):
 import time
 import os
 ctime=time.strftime("%c",time.localtime(os.path.getctime(x)))
 return ctime
def mystring(x):
 q=''
 for n,m in  enumerate(x,start=1):

   o=str(n)+'.'+str(m)
   q+=(o+'\n')
 return q+'\n'

def info():
tclear()
import glob,os
mf=''
md=''
mfl,mdl=[],[]
mdd=glob.glob(entry1.get()+os.sep+'*')
for x in mdd:
if os.path.isfile(x)==True:
  mfl.append(x)
else:mdl.append(x)

mf+=mystring(mfl)
md+=mystring(mdl)
mf=("Total files in %s are %d \n\n"%(entry1.get(),len(mfl)))+mf
md=('Total directories in %s are %d
\n\n'%(entry1.get(),len(mdl)))+md
mf+='\n\n'
text.insert(END,mf+md)
def destroy():
root.destroy()
def eclear():
entry1.delete(0,END)
entry2.delete(0,END)
entry3.delete(0,END)
entry4.delete(0,END)
def tclear():
text.delete(1.0,END)
def ashow():
x=entry1.get()
try:
n,m=x.split(',')

value=atime(n)
except:value=atime(x)
entry2.insert(0,value)
def mshow():

x=entry1.get()
try:
n,m=x.split(',')

value=mtime(n)
except:value=mtime(x)

entry3.insert(0,value)
def cshow():

x=entry1.get()
try:
n,m=x.split(',')

value=ctime(n)
except:value=ctime(x)

entry4.insert(0,value)

root = Tk()

frame1=Frame(root,relief='sunken',border=1)
frame1.pack(side='top',expand="true")

frame2=Frame(root,relief='sunken',border=1)
frame2.pack(side='top',expand="true")

frame3=Frame(root,relief='sunken',border=1)
frame3.pack(side='top',expand="true")

frame4=Frame(root,relief='sunken',border=1,)
frame4.pack(side='top',expand="true")

frame5=Frame(root,relief='sunken',border=1)
frame5.pack(side='top',expand="true")

label5=Label(frame1,text="Enter file path to get information about the file
\
or enter directory(or directory,fileextension) to get files init ",border=1)
label5.pack(side='top',fill='both')

b1=Button(frame2,text='quit',command=destroy,border=1)
b1.pack(side='left',padx=5,pady=5)

b2=Button(frame2,text='clear',command=eclear,border=1)
b2.pack(side='left',padx=5,pady=5)

b3=Button(frame2,text='accessed',command=ashow,border=1)
b3.pack(side='left',padx=5,pady=5)

b4=Button(frame2,text='modified',command=mshow,border=1)
b4.pack(side='left',padx=5,pady=5)

b5=Button(frame2,text='created',command=cshow,border=1)
b5.pack(side='left',padx=5,pady=5)

b5=Button(frame2,text='files',command=fshow,border=1)
b5.pack(side='left',padx=5,pady=5)

b6=Button(frame2,text='deltxt',command=tclear,border=1)
b6.pack(side='left',padx=5,pady=5)

b7=Button(frame2,text='files+dirs',command=info,border=1)
b7.pack(side='left',padx=5,pady=5)

label4=Label(frame3,text="Enter full path",border=1)
label4.pack(side='left',fill='both')

entry1=Entry(frame3,relief='sunken',border=1)
entry1.pack(side='left',fill='both')

lable1=Label(frame3,text='access time',border=1)
lable1.pack(side='left',fill='both')

entry2=Entry(frame3,relief='sunken',border=1)
entry2.pack(side='left',fill='both')

lable2=Label(frame3,text='modifide time',border=1)
lable2.pack(side='left',fill='both')

entry3=Entry(frame3,relief='sunken',border=1)
entry3.pack(side='left',fill='both')

lable3=Label(frame3,text='created time',border=1)
lable3.pack(side='left',fill='both')

entry4=Entry(frame3,relief='sunken',border=1)
entry4.pack(side='left',fill='both')

text=Text(frame4,relief='sunken',border=1,width=130,height=40,padx=5,pady=5)
text.pack(side='top')
text.xview(SCROLL,30,UNITS)
text.yview(SCROLL,30,UNITS)

root.title("info of file")

root.mainloop()

==

Thank you

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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:

>http://www.linuxjournal.com/article/7357

>Or for more detailed info:

>http://www.pythonware.com/library/tkinter/introduction/x7883->concepts.htm


Thank you,I got it right.I am reading your tutor for the 3rd time.
The web sights you pointed above  are  of good help.

Thank you

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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:
text.insert(len(myfiles(value1,value2)),myfiles(x))

>>> import example4
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
  File "C:\Python26\example4.py", line 37, in fshow
text.insert(len(myfiles(value1,value2)),myfiles(x))
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 3001, in insert
self.tk.call((self._w, 'insert', index, chars) + args)
TclError: bad text index "178"

 import example4
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
  File "C:\Python26\example4.py", line 37, in fshow
text.insert(None,myfiles(x))
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 3001, in insert
self.tk.call((self._w, 'insert', index, chars) + args)
TclError: wrong # args: should be ".18428952.18430232 insert index chars
?tagList chars tagList ...?"
I cant understand what these error messages are telling.

Thanking you

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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,
> Christian Witts
>
>
>
Hello
It is printing wether the item is callable or not.
I want it to print
sys.getdefaultencoding
ASCII
sys.getfilesystemencoding
mbcs

Like that

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 tried to use getatter but somehow I could not
succeed.

Thank you

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 "", line 2, in 
if sys.x is callable:
AttributeError: 'module' object has no attribute 'x'



Some one please tell me How  can I do that?

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Is it syntactic,semantic or runtime?

2009-04-25 Thread prasad rao
hellothanks .After inserting back slashes and
de.close it is working well

thanks for the help

prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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?



def pp():
@@@ import urllib
@@@ import subprocess
@@@ so=urllib.urlopen('http://www.asstr.org')
@@@ data=so.read()
@@@ de=open('C:pp.html','w')
@@@ de.write(data)
@@@ subprocess.Popen(['C:\Program Files\Internet
xplorer\\IEXPLORE','C:pp.html'])





prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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
>Author of the Learn to Program web site


True.Thanks  for pointing out  the folly.
I might have lost bits of data.

Thank you
Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 len(line)<70:de.write(line+'\n')
  if len(line)>70:
 da=textwrap.fill(line,width=60)
 de.write(da+'\n')
 so.close()
 de.close()

Any improvements and suggestions are welcome.

Thanks
Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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:
tem=line[60:]
try:
??? a,b=tem.split(' ',1)
??? de.write(line[:60]+a+'\n')
??? line=b
except ValueError:pass
 de.write(line+'\n')
 so.close()
 de.close()
 os.remove(s)
 os.rename(d,s)

Thank you
Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 len(line)<60:pass
???if len(line)>60:
??line=line[:60]+'\n'+line[60:]
Is it the right way to do?

Thank you
Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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.


def  myforrmat(source,desty):
 so=open(source)
 de=open(desty,'w')
 for line in so:
? if len(line)<60:de.write(line)
? if len(line)>60:
de.write(''.join(list(line)[:60]))
de.write(''.join(list(line)[60:]))
so.close()
de.close()

This code is not working.Destination file have the same length of lines
to source file
Some one please show where the problem is.
I tried to do it using fileinput module and inplace flag. in vain.
please some one show me how to do it.

Thank you
Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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
http://mail.python.org/mailman/listinfo/tutor


[Tutor] re Formating

2009-02-25 Thread prasad rao
hi
>>> licenseRe = re.compile(r'\(([A-Z]+)\)\s*(No.\d+)?')
>>> for license in licenses:
  m = licenseRe.search(license)
  print m.group(1, 3)



Traceback (most recent call last):
  File "", line 3, in 
print m.group(1, 3)
IndexError: no such group

Something wrong with this code.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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:
   m = licenseRe.search(license)
   print m.group(1, 3)


('ABTA', None)
('ATOL', None)
('IATA', None)
('ITMA', None)

The no 56542 is not getting into  m.group()
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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("", callback)
frame.pack()
self.button=Button(root,text='quit',fg='red',command=frame.quit)
self.button.pack(side='left')
self.hi=Button(root,text='hi',fg='SystemWindowFrame',command=self.hi)
self.hi.pack(side='right')
self.callback
  def hi (self): print 'hello! there'
  def callback(self,event):
print "clicked at", event.x, event.y


>>> root=Tk()
>>> xx=app(root)
>>> root.mainloop()
hello! there
hello! there
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 "", line 1, in 
pp()
  File "", line 18, in pp
xx=app(root,event)
NameError: global name 'event' is not defined

Example1=
# File: hello2.py
from Tkinter import *
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
self.button.pack(side=LEFT)
self.hi_there = Button(frame, text="Hello", command=self.say_hi)
self.hi_there.pack(side=LEFT)
def say_hi(self):
print "hi there, everyone!"
root = Tk()
app = App(root)
root.mainloop()
Running the Example
Example2=
# File: bind1.py
from Tkinter import *
root = Tk()
def callback(event):
print "clicked at", event.x, event.y
frame = Frame(root, width=100, height=100)
frame.bind("", callback)
frame.pack()
root.mainloop()
How can I mix the two?
Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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('',self.callback)
frame.pack()
self.event=event
self.button=Button(root,text='quit',fg='red',command=frame.quit)
self.button.pack(side='left')
self.hi=Button(root,text='hi',fg='SystemWindowFrame',command=self.hi)
self.hi.pack(side='right')
self.callback
def hi (self): print 'hello! there'
def callback(self,event):
print "clicked at", event.x, event.y
from Tkinter import *
root=Tk()
xx=app(root,event)
root.mainloop()


Thanks in advance

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 columns>7:
columns=7

import string
v=string.printable

v=v.replace('\n','')
v=v.replace('\t','')
if len(v)%columns !=0:
v=v+ v[:columns-(len(v)%columns)]
 for x in range(len(v)/columns):
for y in range(x,len(v),len(v)/columns):
print v[y],'=','%3d'%ord(v[y]),' '*3,
print
Thank you
Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] re division problem

2009-02-03 Thread prasad rao
hi>Right 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
http://mail.python.org/mailman/listinfo/tutor


[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
http://mail.python.org/mailman/listinfo/tutor


[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
>> v=string.printable
>> v=v.replace('\n','')
>> v=v.replace('\t','')

>What is len(v) here? What is len(v)/columns?
There are 100 characters  in the string(string.printable)
I deleted '\n\t'. So 98/say 4==24.5 So if there is a fraction
I have to round it off to 1. So 24.5 should be rounded off
to 25..But is there a better way to print it  in given number
of columns

>> for x in range((len(v))/columns):
>> for y in range(x,len(v),x+((len(v))/columns)):

>The third argument to range() is the step size. Do you want to use a
>different step size for each row?
No. How can I ensure that every value is an integer  but without missing
in retrieving an element in the string.

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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] 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 called horizontal got no problems.
please examine it  and give suggestions and improvements to set it right.

#!usr\\bin\\env python
def horizontal(columns):
import string
n=0
v=string.printable
v=v.replace('\n','')
v=v.replace('\t','')
while n___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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] 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 discussed in the resent past.
Is there a repository of all threads of this list on the web.


thank you

prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 repeating the same three formatting expressions over and over:

>def show(x, y):
>   print '%3d'%(x),'x','%3d'%(y),'=','%3d'%(x*y),(' '*5),

>Then mtab() can be written like this:

>def mtab(*arg):
  > for x in range(1,11):
   show(x, arg[0])
   show(x, arg[1])
   show(x, arg[2])
   print
   print(('-')*10).center(78)
   for x in range (1,11):
   show(x, arg[3])
   show(x, arg[4])
   show(x, arg[5])
   print

>Now you can see that the show() statements are still repetitive, they
>can be put into a loop:

>def mtab(*arg):
  > for x in range(1,11):
   for i in range(0, 3):
   show(x, arg[i])
   print
   print(('-')*10).center(78)
   for x in range (1,11):
   for i in range(3, 6):
   show(x, arg[i])
   print

>This is OK except the interface is awkward; do you really want to tell
>it each number for the table, or would you rather give it a range of
>numbers? Also you can use another loop to eliminate the duplicated
>printing of the tables:

>def mtab(lower, upper):
   for start in range(lower, upper+1, 3):
   for x in range(1,11):
   for y in range(start, start+3):
   show(x, y)
   print
   print(('-')*10).center(78)

>mtab(1, 11)

>This does not give quite the same result as your original - it prints
>the divider after each table - and it always prints three tables per
>group, even if you didn't ask for it - but it is much simpler and more
>flexible than your original.

>Kent
___
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),\
'%3d'%(x),'x','%3d'%(arg[1]),'=','%3d'%(x*arg[1]),(' '*5),\
'%3d'%(x),'x','%3d'%(arg[2]),'=','%3d'%(x*arg[2]),(' '*5)
print(('-')*10).center(78)
for x in range (1,11):
  print '%3d'%(x),'x','%3d'%(arg[3]),'=','%3d'%(x*arg[3]),(' '*5),\
'%3d'%(x),'x','%3d'%(arg[4]),'=','%3d'%(x*arg[4]),(' '*5),\
'%3d'%(x),'x','%3d'%(arg[5]),'=','%3d'%(x*arg[5]),(' '*5)
Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 v.stri

>>> v.inte
45
>>> v.stri
''
>>> c=Value('36')
>>> c.stri
''
>>>
But it is not converting.How can I do it?

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


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 self.vs
>...def setStringValue(self, s):
>...self.vs = s
>...self.asInt()
>...def setIntValue(self, i):
>...self.v = int(i)
>...self.vs = str(self.v)

hello
Sorry to interject.
This class seems asymmetric.

Class Value:
def __init__(self,inte='',stri=''):
  self.inte=inte
  self.stri=stri
def setvalue(inte='',stri=''):
 self.stri=str(self.inte)
 self.int=int(self.stri)
I tried. But failed.What is wrong with above code?

 >>> Class Value:
  def __init__(self,inte='',stri=''):
  self.inte=inte
  self.stri=stri
  def setvalue(inte='',stri=''):
 self.stri=str(self.inte)
 self.int=int(self.stri)

SyntaxError: invalid syntax

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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
http://mail.python.org/mailman/listinfo/tutor


[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
http://mail.python.org/mailman/listinfo/tutor


[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 i.endswith(extension)]:print x

if __name__=='__main__':
  import sys
  myfiles(sys.argv[1],sys.argv[2])

>>> myfiles.myfiles('C:\\python26')

Traceback (most recent call last):
  File "", line 1, in 
myfiles.myfiles('C:\\python26')
  File "C:\Python26\lib\site-packages\myfiles.py", line 6, in myfiles
for i in z if i.endswith(extension)]:print x
TypeError: expected a character buffer object
>>> myfiles.myfiles('C:\\python26','doc')
C:\python26\Doc\examples.doc

How can I rectify this?

Thanks

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Repply

2008-12-26 Thread prasad rao
Thanks for help.

>
http://svn.python.org/view/python/trunk/Objects/listobject.c?rev=67498&view=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! Basic exercises in C++ are to find min , malimum and sorting.So
I
am just trying it in python.

Thank you Mark.

Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 sort method?

Wish you all Happy Xmass.
thanks
 Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[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 x in zx:
  ax=o+x
  print ax.__doc__


>>> dd(collections)



def dd(o):
 zx=dir (o)
 for x in zx:
  ax=str(o)+x

  print ax.__doc__


>>>
>>> dd(collections)

"""

Above snippets of code generates str.__doc__ for every iteration.

Please someone tell me how I can retrive all the docstrings

ina module

thanks in advance

 Prasad
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor