String Identity Test

2005-11-01 Thread Thomas Moore
Hi:

I am confused at string identity test:

Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a="test"
>>> b="test"
>>> a is b
True
>>>

About identity, I think a is not b, but "a is b" returns True.
Does that mean equality and identity is the same thing for strings?


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

Re: String Identity Test

2005-11-02 Thread Thomas Moore
Hi:
> Were you planning to write code that relied on id(x) being different
> for different but identical strings x or do you just try to understand
> what's going on?
> 
Just try to understand what's going on.

Thanks All.



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

It looks like my mails to @python.org are all blocked

2005-11-15 Thread Thomas Moore
Hi:

What's wrong with this?
The python-anounce tells me that my message has a suspicious header?

--Thomas


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


Is there any Iterator type example?

2005-11-15 Thread Thomas Moore
Hi:

Is there any example about how to use Iterator type?

--Thomas


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


Re: Is there any Iterator type example?

2005-11-15 Thread Thomas Moore
Hi:

Nice example too!
But what I really want to know is how to use __iter()__ and next() in a
class with an example.


>> How about this one:
>>..


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


Is there any Iterator type example?

2005-11-16 Thread Thomas Moore
 Hi:
 
 Is there any example about how to use the Iterator type?
 
--Thomas
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Is there any Iterator type example?

2005-11-16 Thread Thomas Moore
Hi:

Thanks, it does help. Besides, I search the web and find several other
examples, too.
--Thomas

- Original Message -
From: "Fredrik Lundh" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, November 16, 2005 4:02 PM
Subject: Re: Is there any Iterator type example?


> Thomas Moore wrote:
>
> > But what I really want to know is how to use __iter()__ and next() in a
> > class with an example.
>
> here's a simple iterator class that iterators over itself once:
>
> class Iterator1:
> def __init__(self, size=10):
> self.count = 0
> self.size = size
> def __iter__(self):
> return self
> def next(self):
> count = self.count + 1
> if count >= self.size:
> raise StopIteration
> self.count = count
> return count
>
> it = Iterator1()
> print it
> for i in it:
> print i
> for i in it:
> print i
>
> if you run this, you'll see that only the first for-statement will
actually
> print anything.  when you loop over the iterator again, it's already ex-
> hausted.
>
> here's a more general variant, where the Iterable class can be iterated
> over several times.  to do this, its __iter__ method uses a separate
helper
> class to do the actual iteration:
>
> class Iterable2:
> def __init__(self, size=10):
> self.size = size
> def __iter__(self):
> return Iterator2(self)
>
> class Iterator2:
> def __init__(self, target):
> self.target = target
> self.count = 0
> def __iter__(self):
> return self
> def next(self):
> count = self.count + 1
> if count >= self.target.size:
> raise StopIteration
> self.count = count
> return count
>
> it = Iterable2()
> print it
> for i in it:
> print i
> for i in it:
> print i
>
> to get a better view of what happens when you run the code, try adding
> print statements to the __iter__ and next methods.
>
> hope this helps!
>
> 
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

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


Re: PyOpenGL

2005-08-10 Thread Thomas Moore
> Hey I'm a programmer looking to port some of my opengl ...although
> limited into a python app I've made... I'd like to know where to find
> any python/opengl source or a tutorial etc.. whatever I'd like to get a
> series of points that represent a 3d slope presented to the user.

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


Re: UselessPython 2.0

2005-04-10 Thread Thomas Moore
I guess when useless, nothing cannot be done.

- Original Message - 
From: <[EMAIL PROTECTED]>
Newsgroups: comp.lang.python
To: 
Sent: Monday, April 11, 2005 12:17 AM
Subject: Re: UselessPython 2.0


> Nice idea for a site, but I suggest renaming it to something like
> FunPython.com . My guess from reading the subject of your message was
> that you hated Python! Besides, "fun" is shorter than "useless" and is
> therefore more Pythonic :).
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


A bug for unicode strings in Python 2.4?

2006-01-10 Thread Thomas Moore
Hi:

Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> u=u'\u9019\u662f\u4e2d\u6587\u5b57\u4e32'
>>> u.split()
[u'\u9019\u662f\u4e2d\u6587\u5b57\u4e32']
>>>

I think u should get split.

--Frank


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


A bug about unicode string in Python 2.4?

2006-01-10 Thread Thomas Moore
Hi:

Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> u=u'\u9019\u662f\u4e2d\u6587\u5b57\u4e32'
>>> u.split()
[u'\u9019\u662f\u4e2d\u6587\u5b57\u4e32']
>>>

I think u should get split.

--Frank

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

Re: A bug for unicode strings in Python 2.4?

2006-01-10 Thread Thomas Moore
> Thomas Moore:
>
> >>>>u=u'\u9019\u662f\u4e2d\u6587\u5b57\u4e32'
> >>>>u.split()
> >
> > [u'\u9019\u662f\u4e2d\u6587\u5b57\u4e32']
> >
> >
> > I think u should get split.
>
> Where do you think "這是中文字串" should be split and why?

Isn't a unicode string character by character?

-Frank


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

Re: A bug for unicode strings in Python 2.4?

2006-01-10 Thread Thomas Moore
Hi:

Thanks. I'll write my own split().

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


Re: pyfcp

2006-06-19 Thread Thomas Moore
>  http://www.python.org/pyfcp
> 

It gets me to Error 404.



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