Re: Detecting a cycle in a graph

2018-01-14 Thread Frank Millman
"Christian Gollwitzer" wrote in message news:p3gh84$kfm$1...@dont-email.me... Am 14.01.18 um 22:04 schrieb Christian Gollwitzer: > Am 14.01.18 um 09:30 schrieb Frank Millman: >> I need to detect when a 'cycle' occurs - when a path loops back on >> itself and revisits a node previously visited.

Re: Why does pylint give this warning?

2018-01-14 Thread breamoreboy
On Sunday, January 14, 2018 at 10:32:44 PM UTC, Skip Montanaro wrote: > > I cannot replicate this with > > > > $ pylint --version > > Using config file /home/petto/.pylintrc > > pylint 1.8.1, > > astroid 1.6.0 > > Python 3.4.0 (default, Apr 11 2014, 13:05:11) > > [GCC 4.8.2] > > > > $ cat pylint_fo

Re: Where is the usage of (list comprehension) documented?

2018-01-14 Thread Dan Stromberg
On Sun, Jan 14, 2018 at 3:01 PM, Peng Yu wrote: > Hi, > > I see the following usage of list comprehension can generate a > generator. Does anybody know where this is documented? Thanks. Here's the (a?) generator expression PEP: https://www.python.org/dev/peps/pep-0289/ Here's a presentation I pu

Re: Where is the usage of (list comprehension) documented?

2018-01-14 Thread Ben Finney
Peng Yu writes: > > When you use square brackets, you're creating a generator, as in your > > second example. Your first example is a slightly different beast > > called a "generator expression". If you search for that in the docs or > > on the web, you'll find what you want. > > Thanks. Can the

Re: Where is the usage of (list comprehension) documented?

2018-01-14 Thread Peng Yu
> When you use square brackets, you're creating a generator, as in your > second example. Your first example is a slightly different beast > called a "generator expression". If you search for that in the docs or > on the web, you'll find what you want. Thanks. Can the documentation be found by `he

Re: Where is the usage of (list comprehension) documented?

2018-01-14 Thread Chris Angelico
On Mon, Jan 15, 2018 at 10:01 AM, Peng Yu wrote: > Hi, > > I see the following usage of list comprehension can generate a > generator. Does anybody know where this is documented? Thanks. > > $ cat main.py > #!/usr/bin/env python > > import sys > lines = (line.rstrip('\n') for line in sys.stdin) >

Where is the usage of (list comprehension) documented?

2018-01-14 Thread Peng Yu
Hi, I see the following usage of list comprehension can generate a generator. Does anybody know where this is documented? Thanks. $ cat main.py #!/usr/bin/env python import sys lines = (line.rstrip('\n') for line in sys.stdin) print lines lines = [line.rstrip('\n') for line in sys.stdin] print

Re: Generating SVG from turtle graphics

2018-01-14 Thread Niles Rogoff
On Sun, 14 Jan 2018 16:32:53 +0400, Abdur-Rahmaan Janhangeer wrote: > maybe save to .png then use another tool to svg PNG is a bitmap format[1], so you can't covert it to an SVG (a vector format) without guessing things like the start/end points of the lines, their slopes, etc... not to mention

Re: Why does pylint give this warning?

2018-01-14 Thread Skip Montanaro
> I cannot replicate this with > > $ pylint --version > Using config file /home/petto/.pylintrc > pylint 1.8.1, > astroid 1.6.0 > Python 3.4.0 (default, Apr 11 2014, 13:05:11) > [GCC 4.8.2] > > $ cat pylint_fodder.py > class FooBar: > def __len__(self): > return 42 > def __repr__(se

Re: Why does pylint give this warning?

2018-01-14 Thread Peter Otten
breamore...@gmail.com wrote: > Why does pylint give this warning? No idea. > The warning is 'C0103:Method name "__len__" doesn't conform to > '_?_?[a-z][A-Za-z0-9]{1,30}$' pattern' but it doesn't complain about > __repr__ or __str__. If there is an explanation out in the wild my search > fu has

Re: Detecting a cycle in a graph

2018-01-14 Thread Christian Gollwitzer
Am 14.01.18 um 22:04 schrieb Christian Gollwitzer: Am 14.01.18 um 09:30 schrieb Frank Millman: I need to detect when a 'cycle' occurs - when a path loops back on itself and revisits a node previously visited. I have figured out a way to do this, but I have a problem. I don't know if that help

Why does pylint give this warning?

2018-01-14 Thread breamoreboy
The warning is 'C0103:Method name "__len__" doesn't conform to '_?_?[a-z][A-Za-z0-9]{1,30}$' pattern' but it doesn't complain about __repr__ or __str__. If there is an explanation out in the wild my search fu has missed it :-( My setup on Ubuntu 17.10 is:- $ pylint --version Using config file

Re: Detecting a cycle in a graph

2018-01-14 Thread Christian Gollwitzer
Am 14.01.18 um 09:30 schrieb Frank Millman: I need to detect when a 'cycle' occurs - when a path loops back on itself and revisits a node previously visited. I have figured out a way to do this, but I have a problem. I don't know if that helps, but there is a classic graph theory algorithm ca

Re: Generating SVG from turtle graphics

2018-01-14 Thread Serhiy Storchaka
11.01.18 13:03, Steven D'Aprano пише: I'd like to draw something with turtle, then generate a SVG file from it. Is this possible? If not, is there something I can do which lets me plot lines, shapes and curves and output to SVG? You can translate the following Tcl/Tk recipe to Python/Tkinter:

Re: Generating SVG from turtle graphics

2018-01-14 Thread Abdur-Rahmaan Janhangeer
maybe save to .png then use another tool to svg On 11 Jan 2018 15:06, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > I'd like to draw something with turtle, then generate a SVG file from it. > > Is this possible? > > If not, is there something I can do which lets me plot lines

Re: Detecting a cycle in a graph

2018-01-14 Thread Frank Millman
"Steven D'Aprano" wrote in message news:p3f9uh$ar4$1...@blaine.gmane.org... On Sun, 14 Jan 2018 10:30:31 +0200, Frank Millman wrote: > I can detect a cycle in a path. It is possible for there to be more than > one gateway in the path. I want to identify the gateway that actually > triggered th

Re: Generating SVG from turtle graphics

2018-01-14 Thread Peter Otten
Steven D'Aprano wrote: > I'd like to draw something with turtle, then generate a SVG file from it. > > Is this possible? If this is a one-off job consider creating Postscript from the underlying Canvas: >>> import turtle >>> for i in range(12): ... turtle.forward(100) ... turtle.left(1

Re: Detecting a cycle in a graph

2018-01-14 Thread Steven D'Aprano
On Sun, 14 Jan 2018 10:30:31 +0200, Frank Millman wrote: > I can detect a cycle in a path. It is possible for there to be more than > one gateway in the path. I want to identify the gateway that actually > triggered the cycle, but I have not figured out a way to do this. You don't need a gateway

Detecting a cycle in a graph

2018-01-14 Thread Frank Millman
Hi all I am adding a bpm (Business Process Management) module to my accounting app. A process is laid out as a flowchart, and is therefore a form of directed graph, so I am getting into a bit of graph theory. I got some good ideas from this essay - https://www.python.org/doc/essays/graphs/ I