Re: urllib2 error

2010-11-17 Thread asit dhal
On Wed, Nov 17, 2010 at 5:31 PM, Kushal Kumaran
 wrote:
> On Wed, Nov 17, 2010 at 5:18 PM, asit  wrote:
>> I have this piece of code
>>
>> import urllib2
>>
>> proc_url = 'http://www.nse-india.com/content/historical/EQUITIES/2001/
>> JAN/cm01JAN2001bhav.csv.zip'
>> print 'processing', proc_url
>> req = urllib2.Request(proc_url)
>> res = urllib2.urlopen(req)
>>
>> when i run this...following error comes
>>
>> Traceback (most recent call last):
>> 
>> HTTPError: HTTP Error 403: Forbidden
>>
>
> The web server is probably trying to forbid downloads using automated
> tools by examining the user agent header (downloading using wget also
> fails, for example).  You can work around that by setting the
> User-Agent header to the same value as a browser that works.
>
> The urllib2 documentation covers how to set headers in requests.
>
> --
> regards,
> kushal
>



-- 
Regards,
Asit Kumar Dhal
TCS, Mumbai
blog: http://asitdhal.blogspot.com/

Thanx...it worked
-- 
http://mail.python.org/mailman/listinfo/python-list


urllib2 error

2010-11-17 Thread asit
I have this piece of code

import urllib2

proc_url = 'http://www.nse-india.com/content/historical/EQUITIES/2001/
JAN/cm01JAN2001bhav.csv.zip'
print 'processing', proc_url
req = urllib2.Request(proc_url)
res = urllib2.urlopen(req)

when i run this...following error comes

Traceback (most recent call last):
  File "C:/Python26/reqnse.py", line 92, in 
res = urllib2.urlopen(req)
  File "C:\Python26\lib\urllib2.py", line 124, in urlopen
return _opener.open(url, data, timeout)
  File "C:\Python26\lib\urllib2.py", line 395, in open
response = meth(req, response)
  File "C:\Python26\lib\urllib2.py", line 508, in http_response
'http', request, response, code, msg, hdrs)
  File "C:\Python26\lib\urllib2.py", line 433, in error
return self._call_chain(*args)
  File "C:\Python26\lib\urllib2.py", line 367, in _call_chain
result = func(*args)
  File "C:\Python26\lib\urllib2.py", line 516, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden

would anyone help me why ??
-- 
http://mail.python.org/mailman/listinfo/python-list


indentation error

2010-03-05 Thread asit
Consider the following code

import stat, sys, os, string, commands

try:
pattern = raw_input("Enter the file pattern to search for :\n")
commandString = "find " + pattern
commandOutput = commands.getoutput(commandString)
findResults = string.split(commandOutput, "\n")
print "Files : "
print commandOutput
print "="
for file in findResults:
mode = stat.S_IMODE(os.lstat(file)[stat.ST_MODE])
print "\nPermissions for file", file, ":"
for level in "USR", "GRP", "OTH":
for perm in "R", "W", "X":
if mode & getattr(stat,"S_I"+perm+level):
print level, " has ", perm, " permission"
else:
print level, " does NOT have ", perm, "
permission"
except:
print "There was a problem - check the message above"


According to me, indentation is ok. but the python interpreter gives
an indentation error

[asit ~/py] $ python search.py
  File "search.py", line 7
findResults = string.split(commandOutput, "\n")
  ^
IndentationError: unindent does not match any outer indentation level
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: process mp3 file

2010-03-03 Thread asit

> Define "processing".

getting the title, song name, etc of the file and updating in a
database
-- 
http://mail.python.org/mailman/listinfo/python-list


process mp3 file

2010-03-03 Thread asit
Somebody suggest me a python library for processing mp3 file.  Here I
don't want to play the file.

Thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


fetch all tweets..

2009-11-08 Thread asit
This question is for any python-twitter developer

I want to develop an application using python twitter .

Just look at the code...

import twitter

api = twitter.Api();
sta = api.GetUserTimeline('ShashiTharoor')
i = 0
for s in sta:
i +=1
print str(i) + "  " + s.text
print
print



The above code only fetches 20 tweets. How can I fetch all tweets ??
-- 
http://mail.python.org/mailman/listinfo/python-list


database handling

2009-11-07 Thread asit
I need some tutorial about python-mysql connectivity(database
handling).

Somebody please help me !!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exception due to NoneType

2009-11-07 Thread asit
On Nov 7, 10:36 pm, Bruno Desthuilliers
 wrote:
> asit a écrit :
>
> > In my program I want to catch exception which is caused by accessing
> > NoneType object.
>
> > Can anyone suggest me how this can be done ??
>
> Not without the minimal working code exposing your problem, or the full
> traceback you got. Merely "accessing NoneType object" doesn't by itself
> raise any exception... I suspect you get the None object where you
> expected something else and try to access an attribute of this
> 'something else', and ends up getting an AttributeError, but there are
> other possible scenarii that might fit your (very poor) description of
> the problem, so no way too help you without more informations. As a
> general rule, remember that the traceback is actually meant to *help*
> finding out what went wring.

I could have described the error, but the problem is that it's
dependent of a third party library..

Let me write the code here...

import twitter

api = twitter.Api('asitdhal','swordfish')
users = api.GetFriends()
for s in users:
print
print "##"
try:
print "user id : " + str(s.id)
print "user name : " + s.name
print "user location : " + s.location
print "user description : " + s.description
print "user profile image url : " + s.profile_image_url
print "user url : " + s.url
print "user status : " + str(s.status)
except TypeError:
pass


look at the except TypeError. This is supposed to catch only exception
thrown by NoneType.

please help me.
-- 
http://mail.python.org/mailman/listinfo/python-list


exception due to NoneType

2009-11-07 Thread asit
In my program I want to catch exception which is caused by accessing
NoneType object.

Can anyone suggest me how this can be done ??
-- 
http://mail.python.org/mailman/listinfo/python-list


exception in urllib2

2009-02-01 Thread asit
I hv been developing a link scanner. Here the objective is to
recursively scan a particular web site.

During this, my script met http://images.google.co.in/imghp?hl=en&tab=wi
and passed it to the scan function, whose body is like this..

def scan(site):
log=open(logfile,'a')
log.write(site + "\n")
site = "http://"; + site.lower()
try:
site_data = urllib.urlopen(site)
parser = MyParser()
parser.parse(site_data.read())
except(IOError),msg:
print "Error in connecting site ", site
print msg
links = parser.get_hyperlinks()
for l in links:
log.write(l + "\n")

But it throws a weird exception like this...

Traceback (most recent call last):
  File "I:\Python26\linkscan1.py", line 104, in 
main()
  File "I:\Python26\linkscan1.py", line 95, in main
scan(lk)
  File "I:\Python26\linkscan1.py", line 65, in scan
site_data = urllib.urlopen(site)
  File "I:\Python26\lib\urllib.py", line 87, in urlopen
return opener.open(url)
  File "I:\Python26\lib\urllib.py", line 203, in open
return getattr(self, name)(url)
  File "I:\Python26\lib\urllib.py", line 327, in open_http
h = httplib.HTTP(host)
  File "I:\Python26\lib\httplib.py", line 984, in __init__
self._setup(self._connection_class(host, port, strict))
  File "I:\Python26\lib\httplib.py", line 656, in __init__
self._set_hostport(host, port)
  File "I:\Python26\lib\httplib.py", line 668, in _set_hostport
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: ''

How can i handle this ???
--
http://mail.python.org/mailman/listinfo/python-list


Re: Handle SystemExit exception

2009-02-01 Thread asit
Thanx everyone

This is my fault. Exception was thrown before the main function.
--
http://mail.python.org/mailman/listinfo/python-list


Handle SystemExit exception

2009-02-01 Thread asit
My program contains some sys.exit(1) and when its executed an
exception known as SystemExit is thrown.

I tried to handle bu using following code snippet

if __name__ == "__main__":
try:
main()  #main contains sys.exit(1)
except KeyboardInterrupt:
print "aborted by user"
except SystemExit:
pass

But it does not work.

Can anyone help me out ???

Though KeyboradInterrupt is handled, but why SystemExit is not
handles 

Regards
Asit Dhal
--
http://mail.python.org/mailman/listinfo/python-list


process command line parameter

2009-01-17 Thread asit
Recently I was coding a link extractor. It's a command line stuff and
takes parameter as argument.
I found that the in operator is not always helpful.
eg. if "--all" in sys.argv:
   print "all links will be printed"

its not helpful when some attribute value is sent in command line
parameter.
hence I want to process some data like find=".co.uk"

How can i do this ???
--
http://mail.python.org/mailman/listinfo/python-list


Re: why o/p is different ???

2009-01-15 Thread asit
On Jan 15, 11:47 am, "James Mills" 
wrote:
> On Thu, Jan 15, 2009 at 4:34 PM, asit  wrote:
> > I recently faced a peculiar o/p.
>
> > My objective is to remove the command name(my script name) from
> > sys.argv[0].
> > I coded like this
>
> If you _really_ want to remove your script_name from
> sys.argv, then do this:
>
> del sys.argv[0]
>
> If you're just after what the name of your script is
> that's being run (for human readability) try the
> following function (taken from pymills):
>
> def getProgName():
>    """getProgName() -> str
>
>    Return the name of the current program being run
>    by working it out from the script's basename.
>    """
>
>    return os.path.basename(sys.argv[0])
>
> --
>
> cheers
> James

Thank you everyone
--
http://mail.python.org/mailman/listinfo/python-list


why o/p is different ???

2009-01-14 Thread asit
I recently faced a peculiar o/p.

My objective is to remove the command name(my script name) from
sys.argv[0].
I coded like this

import urllib
import sys


print "\n\n\t\tlipun4u[at]gmail[dot]com"
print "\t\t"

apppath = sys.argv[0].split("/")
appname = apppath[len(apppath)-1]
print appname

if len(sys.argv) not in [2,3]:
print "Usage : " + appname + "  [options]"
print "e.g. : " + appname + "www.google.com --verbose"
print "\n\t[option]"
print "\t\t--verbose/-V for verbose output"
print "\t\t-r for recursive scan"
sys.exit(1)

site = appname.replace("http://","";).rsplit("/",1)[0]
site = "http://"; + site.lower()
print site


It showed the required o/p in the IDLE
here is the o/p

lipun4u[at]gmail[dot]com

linkscan.py
Usage : linkscan.py  [options]
e.g. : linkscan.pywww.google.com --verbose

[option]
--verbose/-V for verbose output
-r for recursive scan

Traceback (most recent call last):
  File "I:/Python26/linkscan.py", line 18, in 
sys.exit(1)
SystemExit: 1

But in command prompt the o/p is still faulty

lipun4u[at]gmail[dot]com

I:\Python26\linkscan.py
Usage : I:\Python26\linkscan.py  [options]
e.g. : I:\Python26\linkscan.pywww.google.com --verbose

[option]
--verbose/-V for verbose output
-r for recursive scan

I:\Python26>

regards
asit dhal
--
http://mail.python.org/mailman/listinfo/python-list


fetch image

2009-01-05 Thread asit
import httplib

class Server:
#server class
def __init__(self, host):
self.host = host
def fetch(self, path):
http = httplib.HTTPConnection(self.host)
http.request("GET", path)
r = http.getresponse()
print str(r.status) + "  :  " + r.reason

server = Server("www.python.org")
fp=open("phpvuln.txt")
x=fp.readlines();
for y in x:
 server.fetch("/" + y);

The above code fetches only the html source of the webpage. How to get
the image, flash animation and other stuffs 
--
http://mail.python.org/mailman/listinfo/python-list


Re: ResponseNotReady exception

2009-01-03 Thread asit
On Jan 4, 1:59 am, "Chris Rebert"  wrote:
> On Sat, Jan 3, 2009 at 12:38 PM, asit  wrote:
> > import httplib
>
> > class Server:
> >    #server class
> >    def __init__(self, host):
> >        self.host = host
> >    def fetch(self, path):
> >        http = httplib.HTTPConnection(self.host)
> >        http.putrequest("GET", path)
>
> According to the docs, if you use .putrequest(), you have to also then
> call .putheader() [as many times as necessary], .endheaders(), and
> .send(), in that order. I'd advise just changing .putrequest() to
> .request() instead.
>
> And you should also read the fine docs 
> yourself:http://docs.python.org/library/httplib.html
>
> Cheers,
> Chris
>
> --
> Follow the path of the Iguana...http://rebertia.com

Thanx
--
http://mail.python.org/mailman/listinfo/python-list


ResponseNotReady exception

2009-01-03 Thread asit
import httplib

class Server:
#server class
def __init__(self, host):
self.host = host
def fetch(self, path):
http = httplib.HTTPConnection(self.host)
http.putrequest("GET", path)
r = http.getresponse()
print str(r.status) + "  :  " + r.reason


server = Server("www.python.org")
fp=open("phpvuln.txt")
x=fp.readlines();
for y in x:
 server.fetch("/" + y);

In the above code the phpvuln.txt file contains a list of directories.

Why the above code throws ResponseNotReady exception ???

--
http://mail.python.org/mailman/listinfo/python-list


Re: best IDE

2008-11-26 Thread asit
On Nov 26, 11:09 pm, "Chris Rebert" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 26, 2008 at 9:59 AM, asit <[EMAIL PROTECTED]> wrote:
> > Which one is the best IDE for python 
>
> This was recently discussed. To avoid needlessly rehashing said
> discussion, see the thread 
> athttp://groups.google.com/group/comp.lang.python/browse_thread/thread/...
>
> Cheers,
> Chris
> --
> Follow the path of the Iguana...http://rebertia.com
>
> > --
> >http://mail.python.org/mailman/listinfo/python-list

Thanx
--
http://mail.python.org/mailman/listinfo/python-list


best IDE

2008-11-26 Thread asit
Which one is the best IDE for python 
--
http://mail.python.org/mailman/listinfo/python-list


Re: compare items in list to x

2008-11-02 Thread asit
On Nov 2, 9:54 pm, "Pete Kirkham" <[EMAIL PROTECTED]> wrote:
> 2 is not equal to '2'

As the error is correctly marked, u have to convert '2' to 2 by using
int() function

so the write code is

x = 2

def compare():
for y in ['12', '33', '2']:
y=int(y)  #string '2' is converted to int 2
if x < y:
print x, "is less than", y
elif x > y:
print x, "is greater than", y
else:
print x, "and", y, "are equal"

compare()

Regards
Asit Dhal
--
http://mail.python.org/mailman/listinfo/python-list


Re: project in python

2008-10-29 Thread asit
On Oct 28, 10:02 am, alex23 <[EMAIL PROTECTED]> wrote:
> On Oct 26, 2:51 am, Stefan Behnel <[EMAIL PROTECTED]> wrote:
>
> > The more you spam people with your repetitive postings, the less likely it
> > becomes that they are willing to answer you.
>
> In asit's defence, the Google Groups interface has been woefully
> broken for the past 3-4 days. If e had posted via it, messages
> wouldn't have been visible to em until today at the earliest.

After all these search and queries, I have decided to make smething
about Google API.

Is there an API available for google group ???
--
http://mail.python.org/mailman/listinfo/python-list


XML-RPC

2008-10-26 Thread asit
what is XML-RPC System 
--
http://mail.python.org/mailman/listinfo/python-list


project in python

2008-10-25 Thread asit
I am a newbie and learned python to some extent.

I want to do some project in python based on network programming or
HTML/XML parsing.

Can anyone suggest me about this ???
--
http://mail.python.org/mailman/listinfo/python-list


project in python

2008-10-25 Thread asit
I want to do a project in python.
It should be something based on socket programming, HTML/XML parsing,
etc

plz suggest me 
--
http://mail.python.org/mailman/listinfo/python-list


project in python

2008-10-25 Thread asit
I want to do a project in python.

It should be something based on socket programming, HTML/XML parsing,
etc

please suggest me 
--
http://mail.python.org/mailman/listinfo/python-list


Re: portable python

2008-10-24 Thread asit
On Oct 24, 11:18 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 24, 2008 at 1:42 PM, asit <[EMAIL PROTECTED]> wrote:
> > I code in both windows and Linux. As python is portable, the o/p
> > should be same in both cases. But why the following code is perfect in
> > windows but error one   in Linux ???
>
> What error message do you get in linux?  How are you running your code
> in linux?  Your code seems to generally work on my Ubuntu linux box,
> so you need to give us more information.
>
> --
> Jerry

this the o/p
[EMAIL PROTECTED]:~/hack$ python portscan.py 59.93.128.10 10 20
Traceback (most recent call last):
  File "portscan.py", line 33, in 
print str(port) + " : " + scan(ip,port,timeout)
  File "portscan.py", line 22, in scan
return status[result]
KeyError: 11
[EMAIL PROTECTED]:~/hack$
--
http://mail.python.org/mailman/listinfo/python-list


portable python

2008-10-24 Thread asit
I code in both windows and Linux. As python is portable, the o/p
should be same in both cases. But why the following code is perfect in
windows but error one   in Linux ???

from socket import *
import sys

status={0:"open",10049:"address not available",10061:"closed",
10060:"timeout",10056:"already connected",10035:"filtered",11001:"IP
not found",10013:"permission denied"}

def scan(ip,port,timeout):
s = socket(AF_INET, SOCK_STREAM)
s.settimeout(timeout)
try:
result= s.connect_ex((ip, port))
except:
print "Cannot connect to IP"
return
s.close()
return status[result]

if (len(sys.argv) == 4):
ip=sys.argv[1]
minrange = int(sys.argv[2])
maxrange = int(sys.argv[3])
timeout = 3

ports=range(minrange,maxrange+1)

for port in ports:
print str(port) + " : " + scan(ip,port,timeout)
else:
print "usage : " + sys.argv[0] + "   "
--
http://mail.python.org/mailman/listinfo/python-list


Re: dictionary

2008-10-24 Thread asit
On Oct 24, 8:01 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Fri, 24 Oct 2008 14:53:19 +, Peter Pearson wrote:
> > On 24 Oct 2008 13:17:45 GMT, Steven D'Aprano wrote:
>
> >> What are programmers coming to these days? When I was their age, we
> >> were expected to *read* the error messages our compilers gave us, not
> >> turn to the Interwebs for help as soon there was the tiniest problem.
>
> > Yes, and what's more, the text of the error message was "IEH208".  After
> > reading it several times, one looked it up in a big fat set of books,
> > where one found the explanation:
>
> >   IEH208: Your program contains an error. Correct the error and resubmit
> >   your job.
>
> > An excellent system for purging the world of the weak and timid.
>
> You had reference books? You were lucky! When I was lad, we couldn't
> afford reference books. If we wanted to know what an error code meant, we
> had to rummage through the bins outside of compiler vendors' offices
> looking for discarded documentation.
>
> --
> Steven

I don't have a reference book. I read from e-buks and some print outs
of Reference Card. Again, I had this error becoz my console has no
colour highlighting feature.
--
http://mail.python.org/mailman/listinfo/python-list


Re: dictionary

2008-10-24 Thread asit
On Oct 24, 3:06 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
>  ["%s="%s" % (k,v) for k,v in d.items()]
> >   File "", line 1
> > ["%s="%s" % (k,v) for k,v in d.items()]
> >   ^
> > SyntaxError: EOL while scanning single-quoted string
>
> You have three quotation marks...  you want
>
>"%s=%s"
>
> not
>
>"%s="%s"
>
> -tkc

Thanx
--
http://mail.python.org/mailman/listinfo/python-list


dictionary

2008-10-24 Thread asit
what the wrong with the following code 

>>> d={"server":"mpilgrim","database":"master",
... "uid":"sa",
... "pwd":"secret"}

>>> d
{'pwd': 'secret', 'database': 'master', 'uid': 'sa', 'server':
'mpilgrim'}

>>> ["%s="%s" % (k,v) for k,v in d.items()]
  File "", line 1
["%s="%s" % (k,v) for k,v in d.items()]
  ^
SyntaxError: EOL while scanning single-quoted string
--
http://mail.python.org/mailman/listinfo/python-list


Re: mulithreaded server

2008-03-11 Thread asit
On Mar 11, 9:10 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Tue, 11 Mar 2008 08:24:54 -0700 (PDT), asit <[EMAIL PROTECTED]> wrote:
> >import socket
> >import sys
> >import thread
>
> >p=1
> >PORT=11000
> >BUFSIZE=1024
>
> >def getData(cSocket):
> >global stdoutlock,cSocketlock
> >while True:
> >cSocketlock.acquire()
> >data=cSocket.recv(BUFSIZE)
> >if data=='q':
> >data='client exited'
> >cSocket.close()
> >p=0
> >cSocketlock.release()
> >stdoutlock.acquire()
> >stdout.write(data)
> >stdoutlock.release()
>
> >def sendData(cSocket):
> >global stdoutlock,cSocketlock
> >while True:
> >stdoutlock.acquire()
> >data=raw_input('>>')
> >cSocketlock.acquire_lock()
> >if data=='q':
> >stdout.write('server exited')
> >stdout.release()
> >p=0
> >cSocket.close()
> >sSocket.send(data)
> >sSocketlock.release()
>
> Could it be because `sSocketlock´ here
>
>
>
> >stdout=sys.stdout
> >host=''
> >sSocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
> >sSocket.bind((host,PORT,))
> >sSocket.listen(1)
> >#sSocketlock=thread.allocate_lock()
>
> is never bound since the line above here is commented out?
>
> >stdoutlock=thread.allocate_lock()
> >print 'waiting for connection'
> >cSocket,addr=sSocket.accept()
> >print 'connection from',addr
> >cSocketlock=thread.allocate_lock()
> >thread.start_new_thread(sendData,(cSocket,))
> >thread.start_new_thread(getData,(cSocket,))
> >if p==0:
> >sSocket.close()
>
> >In the above program, why there is an unhandeled exception ???
>
> Just a guess. You should really include the traceback when you ask a
> question like this.
>
> Jean-Paul

It's not a traceback error. It's an unhandeled exception..please help
-- 
http://mail.python.org/mailman/listinfo/python-list


mulithreaded server

2008-03-11 Thread asit
import socket
import sys
import thread

p=1
PORT=11000
BUFSIZE=1024

def getData(cSocket):
global stdoutlock,cSocketlock
while True:
cSocketlock.acquire()
data=cSocket.recv(BUFSIZE)
if data=='q':
data='client exited'
cSocket.close()
p=0
cSocketlock.release()
stdoutlock.acquire()
stdout.write(data)
stdoutlock.release()

def sendData(cSocket):
global stdoutlock,cSocketlock
while True:
stdoutlock.acquire()
data=raw_input('>>')
cSocketlock.acquire_lock()
if data=='q':
stdout.write('server exited')
stdout.release()
p=0
cSocket.close()
sSocket.send(data)
sSocketlock.release()


stdout=sys.stdout
host=''
sSocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sSocket.bind((host,PORT,))
sSocket.listen(1)
#sSocketlock=thread.allocate_lock()
stdoutlock=thread.allocate_lock()
print 'waiting for connection'
cSocket,addr=sSocket.accept()
print 'connection from',addr
cSocketlock=thread.allocate_lock()
thread.start_new_thread(sendData,(cSocket,))
thread.start_new_thread(getData,(cSocket,))
if p==0:
sSocket.close()



In the above program, why there is an unhandeled exception ???
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: message entry box at center

2008-02-28 Thread asit
On Feb 28, 7:53 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> asit wrote:
> > i want to show the entry button at the center of the window. How is it
> > possible ??
> > from Tkinter import *
>
> > def callback():
> > print e.get()
>
> > master=Tk()
> > e=Entry(master)
>
> e.pack(expand=True)
>
> > e.focus_set()
>
> > b=Button(master,text="get",width=10,command=callback)
> > b.pack(anchor=CENTER)
>
> > master.mainloop()
>
> For more complex layouts have a look at the grid geometry manager.
>
> Peter

but here there is another problem. there is a huge gap between get
button and message entry button when maximized.

pl z help. !!
-- 
http://mail.python.org/mailman/listinfo/python-list


message entry box at center

2008-02-28 Thread asit
from Tkinter import *


def callback():
print e.get()


master=Tk()
e=Entry(master)
e.pack(anchor=CENTER)
e.focus_set()


b=Button(master,text="get",width=10,command=callback)
b.pack(anchor=CENTER)

master.mainloop()


i want to show the entry button at the center of the window. How is it
possible ??
-- 
http://mail.python.org/mailman/listinfo/python-list


class object using widget

2008-02-20 Thread asit
from Tkinter import *  # get widget classes
from tkMessageBox import askokcancel   # get canned std dialog

class Quitter(Frame):  # subclass our GUI
def __init__(self, parent=None):   # constructor method
Frame.__init__(self, parent)
self.pack()
widget = Button(self, text='Quit', command=self.quit)
widget.pack(side=LEFT)
def quit(self):
ans = askokcancel('Verify exit', "Really quit?")
if ans: Frame.quit(self)

if __name__ == '__main__':  Quitter().mainloop()

In the above program, why the error comes ??
-- 
http://mail.python.org/mailman/listinfo/python-list


inode number in windows XP

2008-01-25 Thread asit
why this program shows ambiguous behavior ??

import os
import stat
import time
#import types

file_name=raw_input("Enter file name : ")
print file_name, "information"
st=os.stat(file_name)
print "mode", "=>", oct(stat.S_IMODE(st[stat.ST_MODE]))

print "type","=>",
if stat.S_ISDIR(st[stat.ST_MODE]):
print "DIReCTORY"
elif stat.S_ISREG(st[stat.ST_MODE]):
print "REGULAR"
elif stat.S_ISLINK(st[stat.ST_MODE]):
print "LINK"

print "file size", "=>",st[stat.ST_SIZE]
print "inode number", "=>",st[stat.ST_INO]
print "device inode resides on", "=>",st[stat.ST_DEV]
print "number of links to this inode", "=>",st[stat.ST_NLINK]
print "last accessed", "=>", time.ctime(st[stat.ST_ATIME])
print "last modified", "=>", time.ctime(st[stat.ST_MTIME])
print "inode changed", "=>", time.ctime(st[stat.ST_CTIME])



i ran this program in Winows XP SP2 in python 2.5.
-- 
http://mail.python.org/mailman/listinfo/python-list


time.gmtime

2008-01-25 Thread asit
we know that time.gmtime(secs) takes a parameter secs. what does this
secs suggest ??What is it's significance ??
-- 
http://mail.python.org/mailman/listinfo/python-list