Jayron Soares wrote:
Hi Felipe,
I did, however I got this error:
Traceback (most recent call last):
File "/home/jayron/Downloads/grafos.py", line 48, in <module>
g, e = ministro_lei()
File "/home/jayron/Downloads/grafos.py", line 34, in ministro_lei
for i in G.degree():
TypeError: 'int' object is not iterable
I could not understood what's going on, I've tried so many different
approaches to solve this problem, but unfortunately no success.
Cheers
2011/11/28 Felipe Vinturini <felipe.vintur...@gmail.com
<mailto:felipe.vintur...@gmail.com>>
Hi Jayron,
Instead of using "Q" to loop over the result, use: "dbcursor".
resp = dbcursor.fetchall()
I hope it helps.
Regards,
Felipe.
On Mon, Nov 28, 2011 at 9:54 AM, Jayron Soares
<jayronsoa...@gmail.com <mailto:jayronsoa...@gmail.com>> wrote:
Hi guys!
I'm stuck at a problem, when I run the follow code:
http://pastebin.com/4Gd9V325
I get this error:
Traceback (most recent call last):
File "/home/jayron/Downloads/grafos.py", line 49, in <module>
g, e = ministro_lei()
File "/home/jayron/Downloads/grafos.py", line 24, in
ministro_lei
resp = Q.fetchall()
AttributeError: 'long' object has no attribute 'fetchall'
Please any help ?
cheers
Hello,
You are iterating on G.degree(), which is fine when it is a dictionary.
However regarding DiGraph documentation:
"Returns :
nd : dictionary, or number
A dictionary with nodes as keys and degree as values or a number if a
single node is specified."
So you may get an integer and thus cannot iterate on it.
You could use
if type(G.degree()) is int:
lista.append(G.degree())
else:
for i in G.degree().values():
lista.append(i)
I'm quite surprised that a distributed graph API uses such inconsistent
interface. I guess you'll have to live with it.
JM
PS : Try to code & document in English, it's much better especially when
asking for help on this list, mixing spanish and english has few
benefits since you may bother both spanish and english ppl :o)
--
http://mail.python.org/mailman/listinfo/python-list