Why the nonsense number appears?

2005-10-31 Thread Johnny Lee
Hi, Pls take a look at this code: -- >>> t1 = "1130748744" >>> t2 = "461" >>> t3 = "1130748744" >>> t4 = "500" >>> time1 = t1+"."+t2 >>> time2 = t3+"."+t4 >>> print time1, time2 1130748744.461 1130748744.500 >>> float(time2) - float(time1) 0.03934332275391 >>> Why are there so m

Re: How to translate python into C

2005-10-29 Thread Johnny Lee
Thanks Szabolcs and Laurence, it's not the crash of python but the crash of cygwin. We can locate the line number but when we submit the crash to cygwin's mail list, they told us they don't speak python. So I'm just trying to re-produce the crash in C. Regards, Johnny -- http://mail.python.org

Re: How to translate python into C

2005-10-28 Thread Johnny Lee
Thanks for your tips Niemann:) Regards, Johnny -- http://mail.python.org/mailman/listinfo/python-list

Re: How to translate python into C

2005-10-28 Thread Johnny Lee
Szabolcs Nagy wrote: > python creates bytecode (like java classes) > > > you cannot translate python directly to c or machine code, but there > are some projects you probably want to look into > > > Pypy is a python implemetation in python and it can be used to > translate a python scrip to c or l

How to translate python into C

2005-10-28 Thread Johnny Lee
Hi, First, I want to know whether the python interpreter translate the code directly into machine code, or translate it into C then into machine code? Second, if the codes are translated directly into machine codes, how can I translate the codes into C COMPLETELY the same? if the codes are tr

Re: Question on class member in python

2005-10-20 Thread Johnny Lee
It looks like there isn't a last word of the differrences -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on class member in python

2005-10-18 Thread Johnny Lee
Alex Martelli 写道: > Johnny Lee <[EMAIL PROTECTED]> wrote: > > > But I still wonder what's the difference between the A().getMember and > > A().member besides the style > > Without parentheses after it, getMember is a method. The difference > between a meth

Re: Question on class member in python

2005-10-18 Thread Johnny Lee
But I still wonder what's the difference between the A().getMember and A().member besides the style -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on class member in python

2005-10-17 Thread Johnny Lee
Peter Otten 写道: > Johnny Lee wrote: > > > Class A: > >def __init__(self): > > self.member = 1 > > > >def getMember(self): > > return self.member > > > > a = A() > > > > So, is there any difference betw

Question on class member in python

2005-10-17 Thread Johnny Lee
Class A: def __init__(self): self.member = 1 def getMember(self): return self.member a = A() So, is there any difference between a.member and a.getMember? thanks for your help. :) Regards, Johnny -- http://mail.python.org/mailman/listinfo/python-list

Re: A problem while using urllib

2005-10-13 Thread Johnny Lee
Steve Holden 写道: > Good catch, John, I suspect this is a possibility so I've added the > following note: > > """The Windows 2.4.1 build doesn't show this error, but the Cygwin 2.4.1 > build does still have uncollectable objects after a urllib2.urlopen(), > so there may be a platform dependency her

Re: A problem while using urllib

2005-10-12 Thread Johnny Lee
Steve Holden wrote: > Steve Holden wrote: > > Johnny Lee wrote: > > [...] > > > >>I've sent the source, thanks for your help. > >> > > > > [...] > > Preliminary result, in case this rings bells with people who use urllib2 > >

Re: A problem while using urllib

2005-10-12 Thread Johnny Lee
Steve Holden wrote: > Johnny Lee wrote: > > Alex Martelli wrote: > > > >>Johnny Lee <[EMAIL PROTECTED]> wrote: > >> ... > >> > >>> try: > >>> webPage = urllib2.urlopen(url) > >>> excep

Re: A problem while using urllib

2005-10-11 Thread Johnny Lee
Alex Martelli wrote: > Johnny Lee <[EMAIL PROTECTED]> wrote: >... > >try: > > webPage = urllib2.urlopen(url) > >except urllib2.URLError: >... > >webPage.close() > >return True > > --

A problem while using urllib

2005-10-11 Thread Johnny Lee
Hi, I was using urllib to grab urls from web. here is the work flow of my program: 1. Get base url and max number of urls from user 2. Call filter to validate the base url 3. Read the source of the base url and grab all the urls from "href" property of "a" tag 4. Call filter to validate every u

A problem while using anygui

2005-09-30 Thread Johnny Lee
Hi, I've met a problem while using anygui to create a GUI. Here is a brief example from Dave: ### def guidialog(): def ok(**kw): win.destroy() app.remove(win) # anygui.link(btn_ok, ok) # app.run() return n #qtgui will NEVER get here ### As you can see, the progra

Re: Help on regular expression match

2005-09-23 Thread Johnny Lee
Fredrik Lundh wrote: > ".*" gives the longest possible match (you can think of it as searching back- > wards from the right end). if you want to search for "everything until a > given > character", searching for "[^x]*x" is often a better choice than ".*x". > > in this case, I suggest using some

Help on regular expression match

2005-09-22 Thread Johnny Lee
Hi, I've met a problem in match a regular expression in python. Hope any of you could help me. Here are the details: I have many tags like this: xxxhttp://xxx.xxx.xxx"; xxx>xxx xx xxxhttp://xxx.xxx.xxx"; xxx>xxx . And I want to find all the "http://xxx.xxx.

Re: No newline using printf

2005-09-15 Thread Johnny Lee
Roy Smith wrote: > > For closer control over output, use the write() function. You want > something like: > > import sys > for i in range(3): >sys.stdout.write (str(i)) here is the output of my machine: >>> import sys >>> for i in range(3): ... sys.stdout.write(str(i)) ... 012>>>

Re: An interesting python problem

2005-09-14 Thread Johnny Lee
bruno modulix wrote: > > I dont see anything interesting nor problematic here. If you understand > the difference between class attributes and instance attributes, the > difference between mutating an object and rebinding a name, and the > attribute lookup rules in Python, you'll find that all thi

An interesting python problem

2005-09-14 Thread Johnny Lee
Hi, Look at the follow command in python command line, See what's interesting?:) >>> class A: i = 0 >>> a = A() >>> b = A() >>> a.i = 1 >>> print a.i, b.i 1 0 --- >>> class A: arr = [] >>> a = A() >>> b = A() >>> a <__main__.A instance at 0x

Would you pls tell me a tool to step debug python program?

2005-09-12 Thread Johnny Lee
Hi, I've met a problem to understand the code at hand. And I wonder whether there is any useful tools to provide me a way of step debug? Just like the F10 in VC... Thanks for your help. Regards, Johnny -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the difference between VAR and _VAR_?

2005-09-08 Thread Johnny Lee
Erik Max Francis wrote: > > You're going to have to be more clear; I don't understand your question. > What's the difference between > > a = 1 > > and > > b = 1 > > besides the difference of name? > I thought there must be something special when you named a VAR with '_' the first ch

Re: What's the difference between VAR and _VAR_?

2005-09-08 Thread Johnny Lee
Erik Max Francis wrote: > > No, of course not. One defines a class varaible named `_passxxx_', the > other defines one named `passsxxx'. > I mean besides the difference of name... -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the difference between VAR and _VAR_?

2005-09-08 Thread Johnny Lee
As what you said, the following two code section is totally the same? (I) class TestResult: _passxxx_ = "pass" (II) class TestResult: passxxx = "pass" -- http://mail.python.org/mailman/listinfo/python-list

What's the difference between VAR and _VAR_?

2005-09-08 Thread Johnny Lee
Hi, I'm new in python and I was wondering what's the difference between the two code section below: (I) class TestResult: _pass_ = "pass" _fail_ = "fail" _exception_ = "exception" (II) class TestResult: pass = "pass" fail = "fail" exception = "ex

What's the matter with this code section?

2005-08-24 Thread Johnny Lee
Here is the source: #! /bin/python [EMAIL PROTECTED] This is a xunit test framework for python, see TDD for more details class TestCase: def setUp(self): print "setUp in TestCase" pass def __init__(self, name): print "__init__ in Te