[issue36568] Typo in socket.CAN_RAW_FD_FRAMES library documentation

2019-04-08 Thread Carl Cerecke
Carl Cerecke added the comment: See section 4.1.5 at https://www.kernel.org/doc/Documentation/networking/can.txt -- ___ Python tracker <https://bugs.python.org/issue36

[issue36568] Typo in socket.CAN_RAW_FD_FRAMES library documentation

2019-04-08 Thread Carl Cerecke
New submission from Carl Cerecke : https://docs.python.org/3/library/socket.html#socket.CAN_RAW_FD_FRAMES The wording "...however, you one must accept..." doesn't make sense. I think the "you one" should be "your application", but I'm not sure. -- as

Re: invert the order of a string

2006-02-13 Thread Carl Cerecke
Eric McGraw wrote: Well, it turns out to be the best way to invert a string, IMO. The reversed() feature returns a reversed object... not a reversed string. In short, I have to fool with it again _after_ it has been inverted. The slicing takes care of the job right away and gives me what I want...

Re: Loop Backwards

2006-02-13 Thread Carl Cerecke
Dave wrote: This should be simple, but I can't get it: How do you loop backwards through a list? For example, in, say, Javascript: for (var i = list.length - 1; i =0; i--) { do_stuff() } I mean, I could reverse the list, but I don't want to. I want it to stay exactly the same,

Re: how do you pronounce 'tuple'?

2006-02-13 Thread Carl Cerecke
Erik Max Francis wrote: Terry Hancock wrote: I doubt that helps much: I pronounce all of those words (when I use them, which is not too often) as -toopel. The only tuple I pronounce with the -uh- is couple, and I usually call that a two-tuple when dealing with Python. I prefer the name

Re: CLI

2006-02-09 Thread Carl Cerecke
mwt wrote: I want to do programmatic terminal commands on unix with python - i.e. I want my program to issue commands to start and stop scripts, other programs, etc. I'm sure this must be fairly straightforward, but haven't been able to find a reference for it. Any help? Try:

Re: 2-dimensional data structures

2006-01-26 Thread Carl Cerecke
anthonyberet wrote: Hello again - rather a newbie here... I want to work on a sudoku brute-forcer, just for fun. I know what you mean. I wrote one just for fun too. I am considering different strategies, but first I need to decide on the data-structure to use for the progress/solution

while/break - The pure-python FSM implementation to Rule Them All.

2006-01-25 Thread Carl Cerecke
Well, it doesn't quite rule them all, but it is fast: About three times faster than using one function per state. Faster than using generators. Faster than using code objects. Some, possibly minor, problems: 1. The generated code is ugly. 2. The generated code can be quite large, depending on

Re: while/break - The pure-python FSM implementation to Rule Them All.

2006-01-25 Thread Carl Cerecke
Paul Rubin wrote: Carl Cerecke [EMAIL PROTECTED] writes: 3. Not as fast as byte code hacks, or using pyrex/psyco. Peter Hansen is right. One of those is likely a better solution if you don't need pure python. If you don't need pure python than your approach still beats everything else

Weird generator id() behaviour (was Re: Python code written in 1998, how to improve/change it?)

2006-01-24 Thread Carl Cerecke
Wolfgang Keller wrote: On Fri, 20 Jan 2006 05:16:57 +0100, Peter Hansen wrote (in article [EMAIL PROTECTED]): I believe the more modern approach to this is to use generators in some way, yield each other as the next state. This way you avoid all almost all the function call overhead (the

Re: Weird generator id() behaviour (was Re: Python code written in1998, how to improve/change it?)

2006-01-24 Thread Carl Cerecke
Fredrik Lundh wrote: Carl Cerecke wrote: It turns out that generators are more efficient than the eval function excuting bits of compiled code. About 20-25% faster. why are you using generators to return things from a function, when you can just return the things ? Trying to find

Re: Weird generator id() behaviour (was Re: Python code written in1998, how to improve/change it?)

2006-01-24 Thread Carl Cerecke
Carl Cerecke wrote: Fredrik Lundh wrote: Carl Cerecke wrote: It turns out that generators are more efficient than the eval function excuting bits of compiled code. About 20-25% faster. why are you using generators to return things from a function, when you can just return the things

Re: Weird generator id() behaviour (was Re: Python code written in1998, howto improve/change it?)

2006-01-24 Thread Carl Cerecke
Adding a continue statemtent after the yield statements yields :-) a speed increase. Still not as good as functions though. (about 30% slower) Cheers, Carl Carl Cerecke wrote: Carl Cerecke wrote: Generator FSM done properly (well, better anyway). They are still almost twice as slow as plain

Re: ANN: Introduction to Event-Driven Programming

2006-01-23 Thread Carl Cerecke
Randall Parker wrote: Steve, This is an aside: I'd love to see someone implement in Python a framework similar to the Quantum Leaps Quantum Framework for event-driven programming. I think Python has some features that lend themselves to a neater implementation than what can be done in

Re: Python code written in 1998, how to improve/change it?

2006-01-22 Thread Carl Cerecke
Bengt Richter wrote: On Thu, 19 Jan 2006 23:16:57 -0500, Peter Hansen [EMAIL PROTECTED] wrote: How about something like actions = dict( ...a=compile('print A; state=b','','exec'), ...b=compile('print B; state=c','','exec'), ...c=compile('print C; state=None','','exec')

Re: Python code written in 1998, how to improve/change it?

2006-01-22 Thread Carl Cerecke
Petr Jakes wrote: Sorry, I can't get in. Can you please show me, how to use your approach on the simple push/push ON/OFF button for example please? PS: seriously it is not a homework :) and I feel it like a shame I am asking such a simple questions :( States: ON, OFF Transition event:

Re: Python code written in 1998, how to improve/change it?

2006-01-19 Thread Carl Cerecke
Petr Jakes wrote: Hello, I am trying to study/understand OOP principles using Python. I have found following code http://tinyurl.com/a4zkn about FSM (finite state machine) on this list, which looks quite useful for my purposes. As this code was posted long time ago (November 1998) I would

Goto in python - NO! (was Re: Python code written in 1998, how to improve/change it?)

2006-01-19 Thread Carl Cerecke
Dave Hansen wrote: On Fri, 20 Jan 2006 10:27:58 +1300 in comp.lang.python, Carl Cerecke [EMAIL PROTECTED] wrote: [...] Python has no goto. +1 [...] We want a goto. -1 I agree entirely. My (rather unclearly made) point was that, for the particular application (FSM

Re: Python code written in 1998, how to improve/change it?

2006-01-19 Thread Carl Cerecke
Dan Sommers wrote: On Fri, 20 Jan 2006 10:27:58 +1300, Carl Cerecke [EMAIL PROTECTED] wrote: ... now you have a function-call overhead on each state transition ... Have you profiled your code and demonstrated that this particular function call consumes too much time? Yes. For a parser

Re: [OT] no goto (WAS: Python code written in 1998...)

2006-01-19 Thread Carl Cerecke
Steven Bethard wrote: Carl Cerecke wrote: Python has no goto. Not in the standard library. You have to download the module: http://www.entrian.com/goto/ Haha! Sure. But have you seen how it's implemented? I don't think it will win many performace prizes. Nifty hack though. Cheers

Re: Python code written in 1998, how to improve/change it?

2006-01-19 Thread Carl Cerecke
Chris Mellon wrote: I'm not sure why nobody else in this thread said it, but the most common way of implementing state machines I've seen in Python (unless theres only a couple states you can manage with if/elif) is to use a dict to map states to callables. Ah. Well, my post suggested, as

Re: Python code written in 1998, how to improve/change it?

2006-01-19 Thread Carl Cerecke
Carl Cerecke wrote: Chris Mellon wrote: I'm not sure why nobody else in this thread said it, but the most common way of implementing state machines I've seen in Python (unless theres only a couple states you can manage with if/elif) is to use a dict to map states to callables. Ah. Well

Re: Sudoku solver: reduction + brute force

2006-01-18 Thread Carl Cerecke
2005 Carl Cerecke # Permission is granted to use, copy, modify, and distribute the code and/or derived works of the code. #import psyco #psyco.full() import copy def compute_edge_cells(): global edge_ls edge_ls = [] for x in range(9): for y in range(9): ls