Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105733 > unrolled thread

PLEASE HELP -- TOTALLY NEW TO PYTHON

Started byJuan Dent <juandent@mac.com>
First post2016-03-25 23:31 -0600
Last post2016-03-26 22:52 +1100
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  PLEASE HELP -- TOTALLY NEW TO PYTHON Juan Dent <juandent@mac.com> - 2016-03-25 23:31 -0600
    Re: PLEASE HELP -- TOTALLY NEW TO PYTHON Ned Batchelder <ned@nedbatchelder.com> - 2016-03-26 04:51 -0700
    Re: PLEASE HELP -- TOTALLY NEW TO PYTHON Steven D'Aprano <steve@pearwood.info> - 2016-03-26 22:52 +1100

#105733 — PLEASE HELP -- TOTALLY NEW TO PYTHON

FromJuan Dent <juandent@mac.com>
Date2016-03-25 23:31 -0600
SubjectPLEASE HELP -- TOTALLY NEW TO PYTHON
Message-ID<mailman.23.1458986352.28225.python-list@python.org>
I am trying to run ‘python cppdep.py’ but get the following:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
analyzing dependencies among all components ...
Traceback (most recent call last):
  File "cppdep.py", line 675, in <module>
    main()
  File "cppdep.py", line 643, in main
    calculate_graph(digraph)
  File "cppdep.py", line 570, in calculate_graph
    (cycles, dict_node2cycle) = make_DAG(digraph, key_node)
  File "/Users/juandent/Downloads/cppdep-master/networkx_ext.py", line 79, in make_DAG
    for ind in range(len(subgraphs)-1, -1, -1):
TypeError: object of type 'generator' has no len()


Please, I know no python and am in a hurry to get this working… Please help


Regards,
Juan

[toc] | [next] | [standalone]


#105748

FromNed Batchelder <ned@nedbatchelder.com>
Date2016-03-26 04:51 -0700
Message-ID<770f81e2-02bc-4a9c-9bbf-a9abb257b4cb@googlegroups.com>
In reply to#105733
On Saturday, March 26, 2016 at 5:59:30 AM UTC-4, Juan Dent wrote:
> I am trying to run 'python cppdep.py' but get the following:
> 
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> analyzing dependencies among all components ...
> Traceback (most recent call last):
>   File "cppdep.py", line 675, in <module>
>     main()
>   File "cppdep.py", line 643, in main
>     calculate_graph(digraph)
>   File "cppdep.py", line 570, in calculate_graph
>     (cycles, dict_node2cycle) = make_DAG(digraph, key_node)
>   File "/Users/juandent/Downloads/cppdep-master/networkx_ext.py", line 79, in make_DAG
>     for ind in range(len(subgraphs)-1, -1, -1):
> TypeError: object of type 'generator' has no len()
> 
> 
> Please, I know no python and am in a hurry to get this working... Please help

It looks like you are not the first to encounter this:
https://github.com/yuzhichang/cppdep/issues/2

I don't see a quick fix to this in the code.  If you fix this one spot,
likely there will be other problem.

It looks to me like you should install NetworkX 1.7 to get it to work.

--Ned.

[toc] | [prev] | [next] | [standalone]


#105749

FromSteven D'Aprano <steve@pearwood.info>
Date2016-03-26 22:52 +1100
Message-ID<56f677f5$0$1614$c3e8da3$5496439d@news.astraweb.com>
In reply to#105733
On Sat, 26 Mar 2016 04:31 pm, Juan Dent wrote:

> 
> I am trying to run ‘python cppdep.py’ but get the following:
> 
>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> analyzing dependencies among all components ...
> Traceback (most recent call last):
>   File "cppdep.py", line 675, in <module>
>     main()
>   File "cppdep.py", line 643, in main
>     calculate_graph(digraph)
>   File "cppdep.py", line 570, in calculate_graph
>     (cycles, dict_node2cycle) = make_DAG(digraph, key_node)
>   File "/Users/juandent/Downloads/cppdep-master/networkx_ext.py", line 79,
>   in make_DAG
>     for ind in range(len(subgraphs)-1, -1, -1):
> TypeError: object of type 'generator' has no len()
> 
> 
> Please, I know no python and am in a hurry to get this working… 

Left your homework for the very last day, did you? I'm sorry that you are in
a hurry, but that's not our problem.

Look at the last two lines of the error traceback. The second last tells you
the line that failed:

    for ind in range(len(subgraphs)-1, -1, -1):

and the last line tells you the error:

    TypeError: object of type 'generator' has no len()

The error tells you that "subgraphs" is a "generator", not a list. So you
have two choices:

- you can change "subgraphs" to be a list;

- or you can change the for-loop to not need the length of subgraphs, or the
index.


The smaller change would probably be the first, changing subgraphs. But the
better change would probably be to change the for-loop.




-- 
Steven

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web