Re: Choose: class with static methods or module with functions

2009-04-17 Thread Dan Sommers
ct Oriented as a Second Language. Dan -- Dan Sommers A death spiral goes clock- <http://www.tombstonezero.net/dan/> wise north of the equator. Atoms are not things. -- Werner Heisenberg -- Dilbert's PHB -- http://mail.python.org/mailman/listinfo/python-list

Re: The Python standard library and PEP8

2009-04-19 Thread Dan Sommers
On Sun, 19 Apr 2009 18:43:10 +0200, Emmanuel Surleau wrote: > On an unrelated note, it would be *really* nice to have a length > property on strings. Even Java has that! And even in Java, they have sin(x) rather than x.sin(). Dan -- Dan Sommers A death

Re: Lisp mentality vs. Python mentality

2009-04-26 Thread Dan Sommers
gt; generators (or iterators) and "zip" or "all" function -- although I > appreciate it as it comes close to FP -- is not what I would call > readable and understandable by non-guru programmers... I finally got it through my thick head that I've been *doing* functiona

Re: Lisp mentality vs. Python mentality

2009-04-27 Thread Dan Sommers
On Mon, 27 Apr 2009 07:57:00 +0300, Ciprian Dorin, Craciun wrote: > On Mon, Apr 27, 2009 at 2:14 AM, Dan Sommers > wrote: >> Also from the Zen:  flat is better than nested.  One of the aspects of >> flatter call trees and object hierarchies is that I hit the bottom >> (

Re: Lisp mentality vs. Python mentality

2009-04-28 Thread Dan Sommers
On Tue, 28 Apr 2009 02:00:22 -0300, namekuseijin wrote: > Dan Sommers wrote: >> On Mon, 27 Apr 2009 07:57:00 +0300, Ciprian Dorin, Craciun wrote: >>> I agree with your opinion about keeping the abstraction layers >>> shallow, but in my view high-order and helper fu

[OT] .DS_Store files (was Re: Removing .DS_Store files from mac folders)

2006-03-09 Thread Dan Sommers
ld be created after I've made the list and before I've made the tarball. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: andmap and ormap

2006-03-14 Thread Dan Sommers
t) is True for some t in L and False otherwise? import operator reduce( L, operator.and_ ) # andmap reduce( L, operator.or_ ) # ormap > One can use a list comprehension like [ ... ] > Is this good enough? If it works, and works correctly, then it's good enough. Reg

Re: Remote teamwork anecdotes (was: Where can we find top-notch python developers?)

2006-03-20 Thread Dan Sommers
opportunity, which was back in 2001 or so, video conferences and "smart boards" didn't function as advertised. Color me skeptical. -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiplying sequences with floats

2006-03-23 Thread Dan Sommers
her this should be allowed, i.e. multiplication of > a sequence with a float. There could be either an implicit typecast to > int (i.e. rounding) ... Explicit is better than implicit. At least until some future version of python in which math.sqrt( 4.0 ) returns an integer. ;-) Regards

Re: Difference between 'is' and '=='

2006-03-27 Thread Dan Sommers
gt; a == 123456789 True >>> a is 123456789 False >>> Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'is' and '=='

2006-03-27 Thread Dan Sommers
On Mon, 27 Mar 2006 11:08:36 -0300, Felipe Almeida Lessa <[EMAIL PROTECTED]> wrote: > Em Seg, 2006-03-27 às 08:23 -0500, Dan Sommers escreveu: >> On Mon, 27 Mar 2006 14:52:46 +0200, >> Joel Hedlund <[EMAIL PROTECTED]> wrote: >> >> > ... According to PEP8

Re: Connecting to gnuplot with Popen?

2006-03-30 Thread Dan Sommers
lot-py.sourceforge.net/ Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: How to determine if a line of python code is a continuation of the line above it

2006-04-08 Thread Dan Sommers
de each other, and arbitrarily nested delimeters are beyond the ability of regexen. Is this merely an academic exercise, or is there a larger purpose for wanting this information? Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical o

Re: Loop with float increments (frange)?

2006-04-14 Thread Dan Sommers
guarantee that f will actually be final_value; see also <http://docs.python.org/tut/node16.html>. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Python certification/training

2006-04-16 Thread Dan Sommers
ions will give you a good way to hone >> your own knowledge. > Which is? :-) http://mail.python.org/mailman/listinfo/tutor Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Manyfile Processing

2009-12-04 Thread Dan Sommers
On Fri, 04 Dec 2009 10:00:53 +0200, user wrote: > sorry if i bother you with a beginners question but i have an issue > with processing a bunch of files. They are some arithmetic lists the > processing of one file is an easy task but how do i process many files? > I tried reading that files in to

Re: OS independent way to check if a python app is running?

2009-12-14 Thread Dan Sommers
On Mon, 14 Dec 2009 14:14:05 -0500, python wrote: > Is there an os independent way to check if a python app is running? > > Goal: I have a server program based on cherrypy that I only want to have > running once. If a system administrator accidentally attempts to run > this program more than once

Re: OS independent way to check if a python app is running?

2009-12-27 Thread Dan Sommers
On Sun, 27 Dec 2009 19:07:12 -0500, python wrote: > Hans, > >> Unfortunately, Windows is not a respectable OS. Unlike Unix, it allows >> two processes to bind to the same port. The theory is that this somehow >> allows the two processes to share their workload. One thing the OP can >> portably do

Re: Does someone has a 5-line working example of SOAP server request ?

2009-10-26 Thread Dan Sommers
or it is in sad shape. HTH, Dan -- Dan Sommers A death spiral goes clock- <http://www.tombstonezero.net/dan/> wise north of the equator. Atoms are not things. -- Werner Heisenberg -- Dilbert's PHB -- http://mail.python.org/mailman/listinfo/python-list

Re: Python "why" questions

2010-08-18 Thread Dan Sommers
On Wed, 18 Aug 2010 16:56:22 -0400, AK wrote: > Contrast this with _one_ example that was repeated in this thread of > there being ground floor, 1st floor, 2nd, and so on. However! Consider > that ground floor is kind of different from the other floors. It's the > floor that's not built up over gr

Re: int vs. float

2017-02-10 Thread Dan Sommers
On Fri, 10 Feb 2017 20:46:16 +, Erik wrote: > Python 3.5.2 (default, Nov 17 2016, 17:05:23) > [GCC 5.4.0 20160609] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> 0.5 > 1.0 > >>> f = float("0.5") > >>> i = int(f) > >>>

Re: Quick questions about globals and database connections

2017-04-05 Thread Dan Sommers
On Wed, 05 Apr 2017 10:54:29 -0400, DFS wrote: > I have identical databases in sqlite and postgres. I want to run the > same code against them, but am having a small issue. > > Current code below throws the dreaded: > > NameError: global name 'db' is not defined > > on line 12 > > How do I f

Re: Quick questions about globals and database connections

2017-04-05 Thread Dan Sommers
On Wed, 05 Apr 2017 14:56:12 -0400, DFS wrote: > I split the database connection code and settings into a module, so > the connection and setting values are available to other code modules > I have. Good work. > dbset.py > - > import sqlite3, psyco

Re: Quick questions about globals and database connections

2017-04-05 Thread Dan Sommers
On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote: > I have a simple hard-coded check in place before even trying to connect: > > if dbtype not in ('sqlite postgres'): >print "db type must be sqlite or postgres" >exit() That's not doing what you think it is. Hint: What is ('sqlite postgres

Re: Survey: improving the Python std lib docs

2017-05-12 Thread Dan Sommers
On Fri, 12 May 2017 21:14:01 +1000, Chris Angelico wrote: > On Fri, May 12, 2017 at 8:02 PM, Steve D'Aprano > wrote: >> (2) The PHP documentation allows you to search for a term by typing it into >> the URL after the domain, e.g. to search for "split", go to: >> >> http://php.net/split >> >> >> I

Re: Test 0 and false since false is 0

2017-07-06 Thread Dan Sommers
On Thu, 06 Jul 2017 19:29:00 -0700, Sayth Renshaw wrote: > I have tried or conditions of v == False etc but then the 0's being > false also aren't moved. How can you check this at once? Maybe this will help: Python 3.5.3+ (default, Jun 7 2017, 23:23:48) [GCC 6.3.0 20170516] on linux

Re: Test 0 and false since false is 0

2017-07-06 Thread Dan Sommers
On Fri, 07 Jul 2017 02:48:45 +, Stefan Ram wrote: def isfalse( x ): > ... return x == 0 and str( type( x )) == "" > ... > Don't depend on string representations of objects, unless you know what you're doing. Do this instead: def isfalse(x): return x == 0 and type(x) is b

Re: Falsey Enums

2017-07-27 Thread Dan Sommers
On Fri, 28 Jul 2017 12:15:20 +1000, Steve D'Aprano wrote: > I has some Enums: > > from enum import Enum > class X(Enum): > Falsey = 0 > Truthy = 1 > Fakey = 2 > > > and I want bool(X.Falsey) to be False, and the others to be True. What should > I > do? Add the following to your en

Re: ANN: A new version (0.5.1) of python-gnupg has been released.

2023-07-22 Thread Dan Sommers via Python-list
On 2023-07-22 at 11:04:35 +, Vinay Sajip via Python-list wrote: > What Changed? > = What changed, indeed. Maybe I'm old, and curmudgeonly, but it would be nice if the body of these annoucement emails (not just this one) contained the name of the program and a one-line summary of

Re: Why doc call `__init__` as a method rather than function?

2023-09-15 Thread Dan Sommers via Python-list
On 2023-09-15 at 10:49:10 +, scruel tao via Python-list wrote: > ```python > >>> class A: > ... def __init__(self): > ... pass > ... > >>> A.__init__ > > >>> a = A() > >>> a.__init__ > > > ``` > > On many books and even the official documents, it seems that many authors > prefer to c

Re: Beep on WIndows 11

2023-11-12 Thread Dan Sommers via Python-list
On 2023-11-11 at 23:44:19 +, Y Y via Python-list wrote: > I am curious and humble to ask: What is the purpose of a BEEP? It's a simple way for a terminal-based program to alert (hence '\a') a user or an operator that their attention is requested or required. See also

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread Dan Sommers via Python-list
On 2023-11-29 at 21:44:01 -0300, Julieta Shem via Python-list wrote: > How would you write this procedure? > > --8<---cut here---start->8--- > def powers_of_2_in(n): > s = 0 > while "I still find factors of 2 in n...": > q, r = divmod(n, 2) > if r

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Dan Sommers via Python-list
On 2023-12-06 at 09:32:02 +, Chris Green via Python-list wrote: > Thomas Passin wrote: [...] > > Just go with an .ini file. Simple, well-supported by the standard > > library. And it gives you key/value pairs. > > > My requirement is *slightly* more complex than just key value pairs, > i

Re: Extract lines from file, add to new files

2024-01-12 Thread Dan Sommers via Python-list
On 2024-01-13 at 02:02:39 +0100, Left Right via Python-list wrote: > Actually, after some Web search. I think, based on this: > https://docs.python.org/3/reference/simple_stmts.html#grammar-token-python-grammar-augtarget > that in Python you call this "augmented assignment target". The term > is

Re: Extract lines from file, add to new files

2024-01-13 Thread Dan Sommers via Python-list
On 2024-01-13 at 11:34:29 +0100, Left Right wrote: > > The Python term, at least colloquially, is "tuple unpacking." That quote is from me. Please do preserve attributions. > Well, why use colloquialism if there's a language specification? Also, > there weren't any tuples used in my example, a

Re: Configuring an object via a dictionary

2024-03-15 Thread Dan Sommers via Python-list
On 2024-03-15 at 15:48:17 -0400, Thomas Passin via Python-list wrote: > [...] And I suppose there is always the possibility that sometime in > the future an "or" clause like that will be changed to return a > Boolean, which one would expect anyway. Not only is the current value is way more usefu

Re: Configuring an object via a dictionary

2024-03-20 Thread Dan Sommers via Python-list
On 2024-03-20 at 09:49:54 +0100, Roel Schroeven via Python-list wrote: > You haven't only checked for None! You have rejected *every* falsish value, > even though they may very well be acceptable values. OTOH, only you can answer these questions about your situations. Every application, every i

Re: how to discover what values produced an exception?

2024-05-04 Thread Dan Sommers via Python-list
On 2024-05-03 at 10:56:39 -0300, Johanne Fairchild via Python-list wrote: > How to discover what values produced an exception? Or perhaps---why > doesn't the Python traceback show the values involved in the TypeError? > For instance: > > --8<-

Re: Terminal Emulator (Posting On Python-List Prohibited)

2024-05-19 Thread Dan Sommers via Python-list
On 2024-05-19 at 18:13:23 +, Gilmeh Serda via Python-list wrote: > Was there a reason they chose the name Pip? Package Installer for Python https://pip.pypa.io/en/stable/index.html Every time I see PIP, I think Peripheral Interchange Program, but I'm old. -- https://mail.python.org/mailma

Re: Terminal Emulator (Posting On Python-List Prohibited)

2024-05-19 Thread Dan Sommers via Python-list
On 2024-05-19 at 18:13:23 +, Gilmeh Serda via Python-list wrote: > Was there a reason they chose the name Pip? Package Installer for Python https://pip.pypa.io/en/stable/index.html -- https://mail.python.org/mailman/listinfo/python-list

Re: Any marginally usable programming language approaches an ill defined barely usable re-implementation of half of Common-Lisp

2024-05-27 Thread Dan Sommers via Python-list
On 2024-05-27 at 12:37:01 -0700, HenHanna via Python-list wrote: > > On 5/27/2024 7:18 AM, Cor wrote: > > Some entity, AKA "B. Pym" , > > wrote this mindboggling stuff: > > (selectively-snipped-or-not-p) > > > > > On 12/16/2023, c...@clsnet.nl wrote: > > > > > > > Any marginally usable program

Formatted Output and Argument Parsing (was: Re: Flubbed it in the second interation through the string: range error... HOW?)

2024-05-29 Thread Dan Sommers via Python-list
On 2024-05-29 at 17:14:51 +1000, Chris Angelico via Python-list wrote: > I wouldn't replace str.format() everywhere, nor would I replace > percent encoding everywhere - but in this case, I think Thomas is > correct. Not because it's 2024 (f-strings were brought in back in > 2015, so they're hardl

Re: Any marginally usable programming language approaches an ill defined barely usable re-implementation of half of Common-Lisp

2024-05-29 Thread Dan Sommers via Python-list
On 2024-05-29 at 11:39:14 -0700, HenHanna via Python-list wrote: > On 5/27/2024 1:59 PM, 2qdxy4rzwzuui...@potatochowder.com wrote: > > https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule [...] > Are the Rules 1--9 by Greenspun good too? I don't know; let me look it up. Oh, there it i

Re: Best use of "open" context manager

2024-07-06 Thread Dan Sommers via Python-list
On 2024-07-06 at 11:49:06 +0100, Rob Cliffe via Python-list wrote: > Is there a better / more Pythonic solution? https://docs.python.org/3/library/fileinput.html At least this attempts to abstract the problem of iterating over a file (or multiple files) into a library routine. I've used it a l

Re: new here

2024-08-21 Thread Dan Sommers via Python-list
On 2024-08-20 at 23:16:48 -0400, AVI GROSS via Python-list wrote: > I do wonder if the people at python.org want multiple forums. There is > also one that sort of tutors people that obviously has an overlapping > but different audience. $ python -m this The Zen of Python, by Tim Peters [...] The

Re: Is there a better way? [combining f-string, thousands separator, right align]

2024-08-26 Thread Dan Sommers via Python-list
On 2024-08-26 at 20:42:32 +1200, dn via Python-list wrote: > and if we really want to go over-board: > > >>> RIGHT_JUSTIFIED = ">" > >>> THOUSANDS_SEPARATOR = "," > >>> s_format = F"{RIGHT_JUSTIFIED}{S_FIELD_WIDTH}{THOUSANDS_SEPARATOR}" > > or (better) because right-justification is the default

Re: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API

2024-10-01 Thread Dan Sommers via Python-list
On 2024-10-01 at 23:03:01 +0200, Left Right wrote: > > If I recognize the first digit, then I *can* hand that over to an > > external function to accumulate the digits that follow. > > And what is that external function going to do with this information? > The point is you didn't parse anything

Re: shutil.rmtree() fails when used in Fedora (rpm) "mock" environment

2024-10-24 Thread Dan Sommers via Python-list
On 2024-10-24 at 20:54:53 +0100, MRAB via Python-list wrote: > On 2024-10-24 20:21, Left Right wrote: > > > > > The stack is created on line 760 with os.lstat and entries are > > > > > appended > > > > > on lines 677 (os.rmdir), 679 (os.close) and 689 (os.lstat). > > > > > > > > > > 'func' is po

Re: Common objects for CLI commands with Typer

2024-09-21 Thread Dan Sommers via Python-list
On 2024-09-21 at 06:38:05 +0100, Barry via Python-list wrote: > > On 20 Sep 2024, at 21:01, Loris Bennett via Python-list > > wrote: > > > > Hi, > > > > Apologies if the following description is to brief - I can expand if no > > one knows what I'm on about, but maybe a short description is e

Re: Common objects for CLI commands with Typer

2024-09-23 Thread Dan Sommers via Python-list
On 2024-09-23 at 19:00:10 +0100, Barry Scott wrote: > > On 21 Sep 2024, at 11:40, Dan Sommers via Python-list > > wrote: > But once your code gets big the disciple of using classes helps > maintenance. Code with lots of globals is problematic. Even before your code gets big

Re: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API

2024-09-30 Thread Dan Sommers via Python-list
On 2024-09-30 at 11:44:50 -0400, Grant Edwards via Python-list wrote: > On 2024-09-30, Left Right via Python-list wrote: > > Whether and to what degree you can stream JSON depends on JSON > > structure. In general, however, JSON cannot be streamed (but commonly > > it can be). > > > > Imagine a

Re: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API

2024-09-30 Thread Dan Sommers via Python-list
On 2024-10-01 at 09:09:07 +1000, Chris Angelico via Python-list wrote: > On Tue, 1 Oct 2024 at 08:56, Grant Edwards via Python-list > wrote: > > > > On 2024-09-30, Dan Sommers via Python-list wrote: > > > > > In Common Lisp, integers can be written in any inte

Re: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API

2024-10-01 Thread Dan Sommers via Python-list
On 2024-09-30 at 18:48:02 -0700, Keith Thompson via Python-list wrote: > 2qdxy4rzwzuui...@potatochowder.com writes: > [...] > > In Common Lisp, you can write integers as #nnR[digits], where nn is the > > decimal representation of the base (possibly without a leading zero), > > the # and the R are

Re: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API

2024-10-01 Thread Dan Sommers via Python-list
On 2024-09-30 at 21:34:07 +0200, Regarding "Re: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API," Left Right via Python-list wrote: > > What am I missing? Handwavingly, start with the first digit, and as > > long as the next character is a digit, multipliy th

Re: Help with Streaming and Chunk Processing for Large JSON Data (60 GB) from Kenna API

2024-09-30 Thread Dan Sommers via Python-list
On 2024-10-01 at 04:46:35 +1000, Chris Angelico via Python-list wrote: > On Tue, 1 Oct 2024 at 04:30, Dan Sommers via Python-list > wrote: > > > > But why do I need to start with the least > > significant digit? > > If you start from the most significant, you d

Re: Division-Bug in decimal and mpmath

2024-12-14 Thread Dan Sommers via Python-list
On 2024-12-14 at 12:08:29 +, Mark Bourne via Python-list wrote: > Martin Ruppert wrote: > > Hi, > > > > the division 0.4/7 provides a wrong result. It should give a periodic > > decimal fraction with at most six digits, but it doesn't. > > > > Below is the comparison of the result of decima

<    1   2   3   4   5