[PyKDE] KURL.List

Russell Valentine russ at coldstonelabs.org
Wed Sep 17 22:12:01 BST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 17 Sep 2003 09:33:54 -0700
Jim Bublitz <jbublitz at nwinternet.com> wrote:

> urllist = KURL.List()
> urllist.append (KURL ("http://slashdot.org"))
> <append more urls>
> listBegin  = urllist [0]    # begin ()
> listEnd     = urllist [-1]   # end ()
> listCount = len (urllist)  # count ()
> ...
> x = urllist [i]                 # at (i)
> ...
> for i in range (len (urllist)):
> ...
> sublist = urllist [3:6]

I attached the file I used to try.
I tried and I get this:

1
Traceback (most recent call last):
  File "./testKURLLIst.py", line 15, in ?
    listBegin = urllist [0] # begin ()
AttributeError: List instance has no attribute '__getitem__'


> 
> Other stuff ("for url in urllist", list comprehensions) should 
> also work, I think. In Python 2.2.x and later, you should also 
> be able to write generators based on KURL.List. The same should 
> hold for any other QValueList subclass in PyQt or PyKDE.
> 
> Let me know if anything is broken (actually, manualtest.py and 
> autotest.py in the tests/ directory do some testing on 
> KURL.List, but the "subscripting" was added after the test was 
> written, and it needs to be updated).

Ok I tried manualtest.py and this came up during the Locale test. Which
looks like the same thing my test file did.

In line 431, k is a KURL.List

Testing KURL.Operators ...

== (KURL) *** Fails
== QString *** Fails
QString: http://riverbankcomputing.co.uk
KURL:    <kdecore.KURL instance at 0x81d99f4>

!= KURL OK
!= QString *** Fails

Testing KURL.List ...

Traceback (most recent call last):
  File "manualtest.py", line 109, in doTest
    test = TestKURLList ()
  File "manualtest.py", line 431, in __init__
    print k [i].url ()
AttributeError: List instance has no attribute '__getitem__'

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/aL/oO0EDJO5MgRYRAqBDAJ40QTR8ztcgNBEAMYJFsoAJo2wLsQCdFox7
Awf8Ko6bZMeYs2DOfBooC0k=
=HqPK
-----END PGP SIGNATURE-----
-------------- next part --------------
#!/bin/env python

import sys
from kdecore import KURL, KApplication, KCmdLineArgs, KAboutData
from kdeui import KMainWindow

aboutData = KAboutData("testKURLList", "testKURLList", "1")
KCmdLineArgs.init(sys.argv, aboutData)
app = KApplication()

urllist = KURL.List()
#urllist = KURL.List(KURL ("http://slashdot.org"))
urllist.append(KURL("http://slashdot.org"))
print len(urllist)
listBegin = urllist [0] # begin ()
win = KMainWindow()
win.show()
app.exec_loop()


More information about the PyQt mailing list