Re: error from Popen only when run from cron

2018-01-27 Thread Dan Stromberg
If you have your script set $PATH and $HOME, you can test it with: env - ./my-script The difference between running a script from the command line, and running a script from cron, is often environment variables. env - clears the environment. On Sat, Jan 27, 2018 at 7:58 AM, Larry Martell wrote:

Re: Data-structure for multiway associativity in Python

2018-01-27 Thread Dan Stromberg
It's possible, but not common, to do association lists in Python. They're pretty inefficient in just about any language. I'm not totally clear on what you need, but it might be a good thing to do a list of sets - if you're looking for an in-memory solution. On Sat, Jan 27, 2018 at 10:33 AM, Denni

Re: Sentiment analysis using sklearn

2018-01-27 Thread Dan Stromberg
On Sat, Jan 27, 2018 at 1:05 PM, qrious wrote: > I am attempting to understand how scikit learn works for sentiment analysis > and came across this blog post: > > https://marcobonzanini.wordpress.com/2015/01/19/sentiment-analysis-with-python-and-scikit-learn > > The corresponding code is at this

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Dan Stromberg
How about: >>> os.write(1, message) On Sun, Jan 28, 2018 at 4:51 PM, Jason Qian via Python-list wrote: > print(repr(message)) out : > > *does not exist\r\n\tat com.* > > > for ch in message: > printf("%d %c",ch, chr(ch)) > > > %d %c 110 n > %d %c 111 o > %d %c 116 t > %d %c 32 > %d %c 101 e >

Re: Where has the practice of sending screen shots as source code come from?

2018-01-28 Thread Dan Stromberg
I'm afraid the perspective may be: Text == primitive GUI == modern It feel like it'd be possible to train a neural network to translate text in a screenshot to plain text though. On Sun, Jan 28, 2018 at 7:04 AM, Steven D'Aprano wrote: > I'm seeing this annoying practice more and more often. Even

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 5:35 PM, Steven D'Aprano wrote: > On Sun, 28 Jan 2018 17:04:56 -0800, Dan Stromberg wrote: >> How about: >>>>> os.write(1, message) > > What do you think that will do that print() doesn't do? >>> message = b'*does n

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 6:04 PM, Steven D'Aprano wrote: > On Sun, 28 Jan 2018 17:49:44 -0800, Dan Stromberg wrote: > So what was the clue that it was bytes that you saw that (nearly) > everyone else missed? Especially me. Can I get away with saying "it was just a good guess

Re: Where has the practice of sending screen shots as source code come from?

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 5:46 PM, Steven D'Aprano wrote: > On Sun, 28 Jan 2018 17:13:05 -0800, Dan Stromberg wrote: >> It feel like it'd be possible to train a neural network to translate >> text in a screenshot to plain text though. > > That would be OCR, which has

Re: Where has the practice of sending screen shots as source code come from?

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 8:24 PM, Dan Stromberg wrote: > If an NN can ... play go on a level that can beat the best human in the > world Correcting myself: I think Google's AlphaGo used more than one NN, plus perhaps a little traditional reading algorithm. So I probably should have sa

Re: python not working

2018-01-29 Thread Dan Stromberg
Please google for "pythonw.exe system error: The program can't start because api-ms-win-crt-runtime-|1-1-0.dll is missing from your computer. try reinstalling the program to fix this problem.". I believe the Windows binaries for Python are built with a proprietary compiler that requires a separa

Re: New to Python and understanding problem

2018-01-29 Thread Dan Stromberg
On Mon, Jan 29, 2018 at 9:01 AM, Michelle Konzack wrote: > OK, I tried to install "blueman" (Bluetooth Manager) on my Debian 9.2 > (Stretch system and discovered a problem: > > [ c 'blueman-applet' ]-- > Traceback (most recent call last): > File

Re: 2.6.7: Does socket.gethostbyaddr truncate?

2018-01-30 Thread Dan Stromberg
dig -x should return a single PTR in all cases, shouldn't it? What IP are you using? 2.6 is very old. You probably should move to at Least 2.7, and plan a move to 3.x. On Tue, Jan 30, 2018 at 4:05 AM, Antoon Pardon wrote: > I am using python 2.6.7 to do a little network programming, but it see

Re: for info

2018-02-01 Thread Dan Stromberg
On Wed, Jan 31, 2018 at 7:55 AM, wrote: > from where we learn python for free of cost. i am begineer in python.plzz > help me If you already know another programming language: https://wiki.python.org/moin/BeginnersGuide/Programmers If you're making Python your first language: https://wiki.pyth

Re: Why not have a recvall method?

2018-02-04 Thread Dan Stromberg
On Sun, Feb 4, 2018 at 5:26 AM, 陶青云 wrote: > Hello, all > The socket object has a `sendall` method that can send all bytes you > specified. > Oppositely, socket only has a recv method. I wonder why there is not a > `recvall` method? > To workaround this, I use `f = socket.makefile('rb')`, then a

Fwd: [Python-Dev] libxml2 installation/binding issue

2018-02-06 Thread Dan Stromberg
Perhaps look over (or use) http://stromberg.dnsalias.org/~strombrg/cpythons/ ? It defaults to building many versions of CPython, but can build just one if you prefer. It knows how to build GTK+ as well, for some newer versions of CPython. -- Forwarded message -- From: Priest, Mat

Re: Benchmarking Django on PyPy with unittest?

2018-02-07 Thread Dan Stromberg
You could probably use the "requests" module to time how long various operations take in your Django website. On Wed, Feb 7, 2018 at 2:26 AM, Etienne Robillard wrote: > Also, i need to isolate and measure the speed of gevent loop engine > (gevent.monkey), epoll, and python-specific asyncio corout

Re: [Python-Dev] How to set/update value in a xml file using requests in python

2018-02-08 Thread Dan Stromberg
This is more relevant to python-list than python-dev. I've added python-list to the To header. Gmail doesn't appear to allow setting a reply-to for a single message, so I've not set that; please, when replying, drop python-dev from the to: header. You'll likely want to set up some kind of REST en

Re: Incremental compression

2018-02-09 Thread Dan Stromberg
Perhaps: import lzma lzc = lzma.LZMACompressor() out1 = lzc.compress(b"Some data\n") out2 = lzc.compress(b"Another piece of data\n") out3 = lzc.compress(b"Even more data\n") out4 = lzc.flush() # Concatenate all the partial results: result = b"".join([out1, out2, out3, out4]) ? lzma compresses ha

Re: Jython info

2018-02-10 Thread Dan Stromberg
On Sat, Feb 10, 2018 at 6:43 AM, Prahallad Achar wrote: > Hello team, > Is it right to ask Jython related query here? If so kindly check my q here > otherwise sorry for posting here... I believe it can be done: http://lmgtfy.com/?q=jython+swing By the way, Jython 2.5 is pretty old. -- https://m

Re: Packaging uwsgi flask app for non-programmers?

2018-02-13 Thread Dan Stromberg
On Tue, Feb 13, 2018 at 9:28 AM, Israel Brewster wrote: > As such, I'm considering three possible solutions: > > 1) Make some sort of installer package that includes the python3 installer > 2) Somehow automate the download and install of Python3, or > 3) re-write my code to be python 2 compatible

Re: How to make Python run as fast (or faster) than Julia

2018-02-23 Thread Dan Stromberg
On Fri, Feb 23, 2018 at 1:32 PM, bartc wrote: > On 23/02/2018 20:12, Chris Angelico wrote: > So I'll keep it generic. Let's say the Tiny C compiler is not taken > seriously because it might be a couple of times slower than gcc-O3, even > thought it's 1% of the size and compiles 1000% as fast. Wha

Re: How to make Python run as fast (or faster) than Julia

2018-02-23 Thread Dan Stromberg
On Fri, Feb 23, 2018 at 6:06 PM, bartc wrote: > On 24/02/2018 00:45, Dan Stromberg wrote: >> But again, those techniques are only infrequently relevant, and pretty >> much never relevant to an entire application. > That your page lists 23 different approaches to making Python

Re: matrix multiplication

2018-02-26 Thread Dan Stromberg
On Mon, Feb 26, 2018 at 8:53 AM, Seb wrote: > On Sun, 25 Feb 2018 18:52:14 -0500, > Terry Reedy wrote: > > [...] > >> numpy has a matrix multiply function and now the '@' matrix multiply >> operator. > > Yes, but what I was wondering is whether there's a faster way of > multiplying each row (1x3)

Re: matrix multiplication

2018-02-26 Thread Dan Stromberg
On Mon, Feb 26, 2018 at 2:07 PM, Ian Kelly wrote: > On Mon, Feb 26, 2018 at 2:40 PM, Dan Stromberg wrote: >> On Mon, Feb 26, 2018 at 8:53 AM, Seb wrote: >>> On Sun, 25 Feb 2018 18:52:14 -0500, >>> Terry Reedy wrote: >>> >>> [...] >>>

Re: Questions about `locals` builtin

2018-02-26 Thread Dan Stromberg
On Mon, Feb 26, 2018 at 4:25 PM, Steven D'Aprano wrote: > On Mon, 26 Feb 2018 21:55:35 +0300, Kirill Balunov wrote: >> 2. The documentation has a note that "The contents of this dictionary >> should not be modified". Which implies that it is a read only mapping. >> So the question why it is `dict`

Re: [newbie] how to remove empty lines from webpage/file

2018-02-27 Thread Dan Stromberg
Perhaps replace: lines=soup.get_text() file.write(lines) ...with something like: text = soup.get_text() lines = text.split('\n') for line in lines: if line.strip(): file.write('%s\n' % (line, )) (untested) On Tue, Feb 27, 2018 at 2:50 AM, wrote: > Dear all, > I try to get the nume

Re: How to make Python run as fast (or faster) than Julia

2018-03-05 Thread Dan Stromberg
On Mon, Mar 5, 2018 at 3:53 PM, Python wrote: > On Sat, Mar 03, 2018 at 08:18:03AM +1100, Chris Angelico wrote: >> > Python is often a preferred solution because it is often fantastic for >> > rapid implementation and maintainability. The GIL's interference >> > with threaded code performance has

Re: Why no list as dict key?

2022-04-20 Thread Dan Stromberg
On Wed, Apr 20, 2022 at 7:23 PM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > Maybe hashes should point to an object rather than being the hash of an > object themselves. > Maybe the speed drop is not worth it. > If you need mutable keys, you /might/ create a dict-like-object using wh

Re: Style for docstring

2022-04-23 Thread Dan Stromberg
On Fri, Apr 22, 2022 at 12:56 PM Michael F. Stemper < michael.stem...@gmail.com> wrote: > I'm writing a function that is nearly self-documenting by its name, > but still want to give it a docstring. Which of these would be > best from a stylistic point of view: > > >Tells caller whether or not

Re: logging library python

2022-04-27 Thread Dan Stromberg
You probably want getLogger(__name__) ...or something close to it. ‪On Wed, Apr 27, 2022 at 12:58 PM ‫תמר ווסה‬‎ wrote:‬ > hello, > we have many scripts of one project. what is the right way to define the > logger to all scripts? we tried to create class that define the logger > configuration+g

Re: new sorting algorithm

2022-05-01 Thread Dan Stromberg
This probably should start out as a module on Pypi. Is the sorting stable? Python guarantees that. On Sun, May 1, 2022 at 8:53 AM Nas Bayedil wrote: > *Dear, Sir/Madam* > > > Let me first tell you briefly who we are and where we are from, what we do. > > My name is Nas (full name Nasipa Bayedil

Re: tail

2022-05-01 Thread Dan Stromberg
On Sun, May 1, 2022 at 3:19 PM Cameron Simpson wrote: > On 01May2022 18:55, Marco Sulla wrote: > >Something like this is OK? > Scanning backward for a byte == 10 in ASCII or ISO-8859 seems fine. But what about Unicode? Are all 10 bytes newlines in Unicode encodings? If not, and you have a hu

Re: new sorting algorithm

2022-05-01 Thread Dan Stromberg
On Sun, May 1, 2022 at 1:44 PM Chris Angelico wrote: > On Mon, 2 May 2022 at 06:43, Dan Stromberg wrote: > > On Sun, May 1, 2022 at 11:10 AM Chris Angelico wrote: > >> > >> On Mon, 2 May 2022 at 01:53, Nas Bayedil wrote: > >> > We believe that using this

Re: new sorting algorithm

2022-05-02 Thread Dan Stromberg
On Mon, May 2, 2022 at 2:25 AM jan via Python-list wrote: > Hi, > > > The median-of-three partitioning technique makes that work reasonably > well, so it won't be pathologically slow > > Just to be clear because I've wondered but haven't looked into it, we > know naive quicksorting of already-sor

Re: Python/New/Learn

2022-05-04 Thread Dan Stromberg
If you already know at least one other imperative programming language: https://wiki.python.org/moin/BeginnersGuide/Programmers If you don't: https://wiki.python.org/moin/BeginnersGuide/NonProgrammers On Wed, May 4, 2022 at 7:49 PM Patrick 0511 wrote: > Hello, I'm completely new here and don't

Re: tail

2022-05-07 Thread Dan Stromberg
I believe I'd do something like: #!/usr/local/cpython-3.10/bin/python3 """ Output the last 10 lines of a potentially-huge file. O(n). But technically so is scanning backward from the EOF. It'd be faster to use a dict, but this has the advantage of working for huge num_lines. """ import d

Re: [Python-ideas] Re: New Tool Proposal

2022-05-10 Thread Dan Stromberg
On Tue, May 10, 2022 at 3:15 AM Chris Angelico wrote: > > It is often the case that developer write Code in Python and then > convert to a C extension module for performance regions. > > > > A C extension module has a lot of boiler plate code - for instance the > Structures required for each clas

"py" command for Linux and Mac?

2022-05-12 Thread Dan Stromberg
Hi folks. I heard there's a Windows-like "py" command for Linux (and Mac?). I'm finally getting to porting a particular project's Python 2.7 code to 3.x, and one of the first steps will probably be changing a lot of "python2 script.py" to use #!/usr/bin/env python2 and chmod +x. Then we can upda

Mypy alternatives

2022-05-14 Thread Dan Stromberg
Hello people. I've used Mypy and liked it in combination with MonkeyType. I've heard there are alternatives to Mypy that are faster, and I'm looking at using something like this on a 457,000 line project. Are there equivalents to MonkeyType that will work with these alternatives to Mypy? And ha

Re: Non-deterministic set ordering

2022-05-15 Thread Dan Stromberg
On Sun, May 15, 2022 at 8:01 PM Rob Cliffe via Python-list < python-list@python.org> wrote: > I was shocked to discover that when repeatedly running the following > program (condensed from a "real" program) under Python 3.8.3 > > for p in { ('x','y'), ('y','x') }: > print(p) > > the output wa

Re: Question about building Python-3.9.12 on OpenBSD 7.1

2022-06-02 Thread Dan Stromberg
It's been my understanding that there is a fundamental difference between the *BSD's and the Linuxes. The *BSD's have their ports system, that collects deltas against third-party packages to build them on a *BSD. These deltas become part of the ports system. The Linuxes port an application, and

Re: min, max with position

2022-06-04 Thread Dan Stromberg
On Sat, Jun 4, 2022 at 9:07 PM Greg Ewing wrote: > On 5/06/22 10:07 am, dn wrote: > > On 05/06/2022 09.50, Chris Angelico wrote: > > min(enumerate(l), key=lambda x: x[1]) > >> (0, 1.618033) > > > > But, but, but which of the above characters is an 'el' and which a > 'one'??? > > (please have

Re: How to replace characters in a string?

2022-06-08 Thread Dan Stromberg
On Wed, Jun 8, 2022 at 1:11 AM Dave wrote: > I've got two that appear to be identical, but fail to compare. After > getting the ascii encoding I see that they are indeed different, my > question is how can I replace the \u2019m with a regular single quote mark > (or apostrophe)? > Perhaps try ht

Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Dan Stromberg
On Thu, Jun 9, 2022 at 1:52 PM Michael F. Stemper wrote: > On 09/06/2022 12.52, Chris Angelico wrote: > > On Fri, 10 Jun 2022 at 03:44, Dave wrote: > > >> Before I write my own I wondering if anyone knows of a function that > will print a nicely formatted dictionary? > >> > >> By nicely formatte

python.org wiki, not allowing me to log in?

2022-06-11 Thread Dan Stromberg
Hi folks. I have a little elbow grease available, so I thought I'd edit https://wiki.python.org/moin/BeginnersGuide/Download ...a little. However, signing in with my google creds by clicking the little Google button, gives me: OpenID discovery failure, not a valid OpenID.

Re: Subtract n months from datetime

2022-06-21 Thread Dan Stromberg
On Mon, Jun 20, 2022 at 9:45 PM Paul Bryan wrote: > Here's how my code does it: > > > import calendar > > def add_months(value: date, n: int): > """Return a date value with n months added (or subtracted if > negative).""" > year = value.year + (value.month - 1 + n) // 12 > month = (value.mo

Re: Extract the space group generators from Bilbao Crystallographic Server.

2022-07-14 Thread Dan Stromberg
It's good to include what you want to see as output, but it's important to also include what you have as input. It's also good to include what you've coded so far. It's considered good etiquette to give it a try yourself before asking the list. On Thu, Jul 14, 2022 at 1:03 PM hongy...@gmail.com

Re: script folder is empty

2022-07-18 Thread Dan Stromberg
This is another reason to use: python -m pip ... ...instead of: pip ... (Or many systems want python3 -m pip) HTH On Sun, Jul 17, 2022 at 10:42 PM dn wrote: > On 18/07/2022 16.53, Scott Baer wrote: > > I just installed Python 3.10.5 on a Windows 10 home ( Ver 21H2 OS build > > 190443182

Dictionary order?

2022-08-01 Thread Dan Stromberg
Hi folks. I'm still porting some code from Python 2.7 to 3.10. As part of that, I saw a list being extended with a dict.values(), and thought perhaps it wasn't ordered as intended on Python 2.7, even though the problem would conceivably just disappear on 3.10. So I decided to write a little test

Re: Dictionary order?

2022-08-01 Thread Dan Stromberg
On Mon, Aug 1, 2022 at 1:41 PM Dan Stromberg wrote: > On 1.4 through 2.1 I got descending key order. I expected the keys to be > scattered, but they weren't. > I just noticed that 1.4 was ascending order too - so it was closer to 2.2 than 1.5. I guess that's kind of besi

Re: Dictionary order?

2022-08-01 Thread Dan Stromberg
On Mon, Aug 1, 2022 at 3:25 PM <2qdxy4rzwzuui...@potatochowder.com> wrote: > On 2022-08-02 at 07:50:52 +1000, > Chris Angelico wrote: > > > On Tue, 2 Aug 2022 at 07:48, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > > > > > On 2022-08-01

Re: Dictionary order?

2022-08-01 Thread Dan Stromberg
On Mon, Aug 1, 2022 at 4:42 PM Dan Stromberg wrote: > > > Yes, but I'm pretty sure that's been true for a LONG time. The hashes >> > for small integers have been themselves for as long as I can remember. >> > But the behaviour of the dictionary, when

Re: Trying to understand nested loops

2022-08-05 Thread Dan Stromberg
On Fri, Aug 5, 2022 at 12:35 AM wrote: > Hello, I’m new to learning python and I stumbled upon a question nested > loops. This is the question below. Can you please how they arrived at 9 as > the answer. Thanks > > var = 0 > for i in range(3): > for j in range(-2,-7,-2): > var += 1 > p

Re: Trying to understand nested loops

2022-08-05 Thread Dan Stromberg
On Fri, Aug 5, 2022 at 12:30 PM GB wrote: > On 05/08/2022 08:56, Frank Millman wrote: > > > BTW, there is an indentation error in your original post - line 5 should > > line up with line 4. > > As a Python beginner, I find that Python is annoyingly picky about > indents. And, the significance of

Re: Trying to understand nested loops

2022-08-05 Thread Dan Stromberg
On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards wrote: > In C, this doesn't do what it looks like it's supposed to do. > >if (foo) > do_this(); > and_this(); >then_do_this(); > It's been quite a while since I used C, but with the right compiler flag(s), I think this may be a thing

Re: Parallel(?) programming with python

2022-08-08 Thread Dan Stromberg
Queues are better than lists for concurrency. If you get the right kind, they have implicit locking, making your code simpler and more robust at the same time. CPython threading is mediocre for software systems that have one or more CPU-bound threads, and your FFT might be CPU-bound. Rather than

setup.py + cython == chicken and the egg problem

2022-08-16 Thread Dan Stromberg
Hi folks. I'm attempting to package up a python package that uses Cython. Rather than build binaries for everything under the sun, I've been focusing on including the .pyx file and running cython on it at install time. This requires a C compiler, but I'm OK with that. However, when I try to ins

Re: setup.py + cython == chicken and the egg problem

2022-08-16 Thread Dan Stromberg
On Tue, Aug 16, 2022 at 2:08 PM Chris Angelico wrote: > On Wed, 17 Aug 2022 at 07:05, Dan Stromberg wrote: > > > > Hi folks. > > > > I'm attempting to package up a python package that uses Cython. > > > > Rather than build binaries for everythin

Re: setup.py + cython == chicken and the egg problem

2022-08-17 Thread Dan Stromberg
On Wed, Aug 17, 2022 at 10:20 AM Christian Gollwitzer wrote: > Am 16.08.22 um 23:03 schrieb Dan Stromberg: > > I'm attempting to package up a python package that uses Cython. > > > > Rather than build binaries for everything under the sun, I've been > focusing

Re: setup.py + cython == chicken and the egg problem

2022-08-17 Thread Dan Stromberg
On Wed, Aug 17, 2022 at 1:58 PM Dan Stromberg wrote: > On Wed, Aug 17, 2022 at 10:20 AM Christian Gollwitzer > wrote: > >> Am 16.08.22 um 23:03 schrieb Dan Stromberg: >> > I'm attempting to package up a python package that uses Cython. >> > >> >

Re: setup.py + cython == chicken and the egg problem

2022-08-17 Thread Dan Stromberg
On Wed, Aug 17, 2022 at 3:05 PM Dan Stromberg wrote: > I commented out those too lines, but I'm still getting errors. They seem >> to stem from: >> $ "/home/dstromberg/venv/pyx-treap-testing/bin/python3", >> ["/home/dstromberg/venv/pyx-treap-testing/bi

Re: setup.py + cython == chicken and the egg problem

2022-08-18 Thread Dan Stromberg
On Tue, Aug 16, 2022 at 2:03 PM Dan Stromberg wrote: > Hi folks. > > I'm attempting to package up a python package that uses Cython. > > Rather than build binaries for everything under the sun, I've been > focusing on including the .pyx file and running cython on

Re: subprocess.popen how wait complete open process

2022-08-21 Thread Dan Stromberg
On Sun, Aug 21, 2022 at 2:05 PM Chris Angelico wrote: > On Mon, 22 Aug 2022 at 05:39, simone zambonardi > wrote: > > > > Hi, I am running a program with the punishment subrocess.Popen(...) what > I should do is to stop the script until the launched program is fully open. > How can I do this? I u

Re: Coffee

2022-08-29 Thread Dan Stromberg
On Mon, Aug 29, 2022 at 1:10 PM Meredith Montgomery wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > > > |Python's obviously a great tool for all kinds of programming things, > > |and I would say if you're only gonna use one programming > > |language in your live, Python will probably the

Re: Local variable definition in Python list comprehension

2022-09-02 Thread Dan Stromberg
On Thu, Sep 1, 2022 at 9:16 AM Chris Angelico wrote: > On Fri, 2 Sept 2022 at 02:10, James Tsai wrote: > > > > Hello, > > > > I find it very useful if I am allowed to define new local variables in a > list comprehension. For example, I wish to have something like > > [(x, y) for x in range(10) f

Re: How to replace an instance method?

2022-09-16 Thread Dan Stromberg
On Fri, Sep 16, 2022 at 2:06 PM Ralf M. wrote: > I would like to replace a method of an instance, but don't know how to > do it properly. > You appear to have a good answer, but... are you sure this is a good idea? It'll probably be confusing to future maintainers of this code, and I doubt sta

Re: Python 3.9.14

2022-09-16 Thread Dan Stromberg
‪On Wed, Sep 14, 2022 at 6:05 AM ‫אורי‬‎ wrote:‬ > Hi, > > Python 3.9.14 has been released on Sept. 6, 2022. As I can see written on > https://www.python.org/downloads/release/python-3914/: > > According to the release calendar specified in PEP 596, Python 3.9 is now > in the "security fixes only

Re: for -- else: what was the motivation?

2022-10-07 Thread Dan Stromberg
The else is executed if you don't "break" out of the loop early. It cuts down on boolean flags. On Fri, Oct 7, 2022 at 8:40 PM Axy via Python-list wrote: > Hi there, > > this is rather a philosophical question, but I assume I miss something. > I don't remember I ever used else clause for years

Re: flattening lists

2022-10-11 Thread Dan Stromberg
On Tue, Oct 11, 2022 at 12:48 PM SquidBits _ wrote: > Does anyone else think there should be a flatten () function, which just > turns a multi-dimensional list into a one-dimensional list in the order > it's in. e.g. > > [[1,2,3],[4,5,6,7],[8,9]] becomes [1,2,3,4,5,6,7,8,9]. > > I have had to fla

Re: Find the path of a shell command

2022-10-14 Thread Dan Stromberg
On Wed, Oct 12, 2022 at 11:13 AM Paulo da Silva < p_d_a_s_i_l_v_a...@nonetnoaddress.pt> wrote: > Hi! > > The simple question: How do I find the full path of a shell command > (linux), i.e. how do I obtain the corresponding of, for example, > "type rm" in command line? > > The reason: > I have pyth

Re: Find the path of a shell command [POSTPONED]

2022-10-15 Thread Dan Stromberg
On Wed, Oct 12, 2022 at 9:57 PM Cameron Simpson wrote: > On 13Oct2022 03:25, Paulo da Silva > wrote: > >There is another problem involved. The script, works fine except when > >launched by cron! Why? > > Record the script output: > > # record all output > exec >/tmp/script.$$.out 2>&1

Re: A trivial question that I don't know - document a function/method

2022-10-22 Thread Dan Stromberg
I don't think there is a "correct" way. It depends somewhat on what tools you're using. I like pydocstyle, which I have hung off of vim with syntastic. pydocstyle checks for https://peps.python.org/pep-0257/ conformance. Also, rather than describe the types of formal parameters to functions in

Re: Typing: Is there a "cast operator"?

2022-10-23 Thread Dan Stromberg
On Sun, Oct 23, 2022 at 2:11 PM Paulo da Silva < p_d_a_s_i_l_v_a...@nonetnoaddress.pt> wrote: > Hello! > > I am in the process of "typing" of some of my scripts. > Using it should help a lot to avoid some errors. > But this is new for me and I'm facing some problems. > > Let's I have the following

Re: str.replace() when str contains \

2022-10-29 Thread Dan Stromberg
I believe you would do well to print a, before trying to transform it into something else. '\2' is chr(2). '\a' is the bell character, and is unprintable. '\_' is two characters though. On Sat, Oct 29, 2022 at 2:12 PM Bernard LEDRU wrote: > Hello, > > https://docs.python.org/3/library/stdtypes.

Re: Are these good ideas?

2022-11-14 Thread Dan Stromberg
On Mon, Nov 14, 2022 at 11:33 AM Axy via Python-list wrote: > On 14/11/2022 17:14, Stephen Tucker wrote: > > Hi, > > > > I have two related issues I'd like comments on. > > > > Issue 1 - Global Values > > Your "global variables" module acts exactly as a singleton class. > Which is apparently a d

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-25 Thread Dan Stromberg
On Sun, Nov 13, 2022 at 4:45 PM DFS wrote: > In code, list.clear is just ignored. > At the terminal, list.clear shows > > > > in code: > x = [1,2,3] > x.clear > print(len(x)) > 3 > > at terminal: > x = [1,2,3] > x.clear > > print(len(x)) > 3 > > > Caused me an hour of frustration before I notic

Re: count consecutive elements

2021-01-13 Thread Dan Stromberg
On Wed, Jan 13, 2021 at 5:59 PM Tim Chase wrote: > On 2021-01-13 21:20, Bischoop wrote: > > I want to to display a number or an alphabet which appears mostly > > consecutive in a given string or numbers or both > > Examples > > s= ' aabskaaabad' > > output: c > > # c appears 4 consecutive ti

Re: count consecutive elements

2021-01-14 Thread Dan Stromberg
On Wed, Jan 13, 2021 at 6:20 PM Dan Stromberg wrote: > On Wed, Jan 13, 2021 at 5:59 PM Tim Chase > wrote: > >> On 2021-01-13 21:20, Bischoop wrote: >> > I want to to display a number or an alphabet which appears mostly >> > consecutive in a given string or num

Re: count consecutive elements

2021-01-16 Thread Dan Stromberg
On Thu, Jan 14, 2021 at 2:01 PM Wolfram Hinderer via Python-list < python-list@python.org> wrote: > Am 13.01.2021 um 22:20 schrieb Bischoop: > > I want to to display a number or an alphabet which appears mostly > > consecutive in a given string or numbers or both > > Examples > > s= ' aabskaaabad

Python flask logging: two different formats, but want one format

2021-01-21 Thread Dan Stromberg
I am working on a REST API using Flask. The API is currently divided across two Python 3.6 modules: update.py and vmware_exporters_support.py. update.py logs the way I want. vmware_exporters_support.py does not log the way I want. I want vmware_exporters_support.py to use update.py's logging form

Re: How do you debug in Python? Coming from a Matlab and R user. I'm already aware of pdb.

2021-01-26 Thread Dan Stromberg
On Tue, Jan 26, 2021 at 4:01 PM C W wrote: > Hello everyone, > > I'm a long time Matlab and R user working on data science. How do you > troubleshooting/debugging in Python? > I frequently read tracebacks and think about what's up in the code. I also often add print functions or logging - empir

Re: How do you debug in Python? Coming from a Matlab and R user. I'm already aware of pdb.

2021-01-26 Thread Dan Stromberg
On Tue, Jan 26, 2021 at 8:13 PM Dan Stromberg wrote: > > On Tue, Jan 26, 2021 at 4:01 PM C W wrote: > >> Hello everyone, >> >> I'm a long time Matlab and R user working on data science. How do you >> troubleshooting/debugging in Python? >> > > I

Re: Best practice for handling exceptions raised at lower levels?

2021-02-02 Thread Dan Stromberg
On Tue, Feb 2, 2021 at 12:00 PM Barry Scott wrote: > When I write packages I aim to trap the exceptions from the lower levels > and convert into a package specific exceptions or document that a low > level exception can propagate. > But how do you know what exceptions could be raised? I love Pyt

Re: Files can only be modified in IDLE, but not via Powershell

2021-02-09 Thread Dan Stromberg
On Mon, Feb 8, 2021 at 4:22 PM Stefan Ritter wrote: > > Hi, > > It would be highly appreciated if you could offer me some advice to > solve a problem I'm currently facing: > > afterwards in the file . However it does not work if run it in > Powershell (or anything else), there are no changes ma

Re: New Python implementation

2021-02-11 Thread Dan Stromberg
On Thu, Feb 11, 2021 at 4:35 AM Mr Flibble wrote: > > Hi! > > I am starting work on creating a new Python implementation from scratch > using "neos" my universal compiler that can compile any programming > language. I envision this implementation to be significantly faster than > the currently e

Re: New Python implementation

2021-02-11 Thread Dan Stromberg
On Thu, Feb 11, 2021 at 10:21 AM Mr Flibble wrote: > For a language to transition from "toy" status it has to be formally > standardized. It is unacceptable to define a language in terms of a > particular implementation. A git repo of Source code and associated > observable dynamic behaviour whe

Re: New Python implementation

2021-02-11 Thread Dan Stromberg
On Thu, Feb 11, 2021 at 2:00 PM Mr Flibble wrote: > On 11/02/2021 21:13, Dan Stromberg wrote: > > Does your project have a name yet? I'd like to follow it through google > > alerts or an announcement mailing list. > > "neos" - https://neos.dev/ https://githu

Re: mutating a deque whilst iterating over it

2021-02-13 Thread Dan Stromberg
On Sat, Feb 13, 2021 at 10:25 AM duncan smith wrote: > On 12/02/2021 03:04, Terry Reedy wrote: > > On 2/11/2021 3:22 PM, duncan smith wrote: > > > >>It seems that I can mutate a deque while iterating over it if I > >> assign to an index, but not if I append to it. Is this the intended > >

Re: Change first occurrence of character x in a string - how?

2021-02-14 Thread Dan Stromberg
Check out re.sub's "count" parameter. https://stackoverflow.com/questions/3951660/how-to-replace-the-first-occurrence-of-a-regular-expression-in-python On Sun, Feb 14, 2021 at 1:20 PM Chris Green wrote: > What's the easiest way to change the first occurrence of a specified > character in a stri

Re: New Python implementation

2021-02-14 Thread Dan Stromberg
On Sun, Feb 14, 2021 at 3:05 PM Christian Gollwitzer wrote: > Am 14.02.21 um 11:12 schrieb Paul Rubin: > > Christian Gollwitzer writes: > >> He wants that neoGFX is scriptable in Python, but instead of linking > >> with CPython, he will write his own Python implementation instead, > >> because C

Re: New Python implementation

2021-02-15 Thread Dan Stromberg
On Mon, Feb 15, 2021 at 3:25 PM Grant Edwards wrote: > On 2021-02-15, Avi Gross via Python-list wrote: > Of all the languages I've used, Prolog was by far the hardest to get > my head around. The dialect I used the most (which still wasn't much) > was part of Digitalk's Smalltalk system. I don't

Re: New Python implementation

2021-02-15 Thread Dan Stromberg
On Mon, Feb 15, 2021 at 8:52 PM Igor Korot wrote: > Hi, guys, > Let me try to throw in another one - PL/1. > This guys used to be very popular with the accounting community... > Actually PL/I is basically proprietary Pascal - from IBM. My Intro Comp Sci classes at the University of Cincinnati w

Re: New Python implementation

2021-02-15 Thread Dan Stromberg
On Mon, Feb 15, 2021 at 9:37 PM dn via Python-list wrote: > On 16/02/2021 17.57, Dan Stromberg wrote: > > On Mon, Feb 15, 2021 at 8:52 PM Igor Korot wrote: > > > >> Hi, guys, > >> Let me try to throw in another one - PL/1. > >> This guys used to be

Re: New Python implementation

2021-02-16 Thread Dan Stromberg
On Tue, Feb 16, 2021 at 1:23 PM Tarjei Bærland via Python-list < python-list@python.org> wrote: > Sure, Brainfuck is two steps too far, but Scheme or Logo I'd wager be > excellent languages to get the students into computational > thinking. Haskell might be a good choice as well, I do not have eno

Re: [Python-Dev] Re: Python 0.9.1

2021-02-18 Thread Dan Stromberg
On Thu, Feb 18, 2021 at 9:39 PM David Mertz wrote: > As Skip pointed out to me privately, there are some minor limitations with > this version. E.g.: > > % python > >>> import glob > >>> import sys > >>> print 'hello' > hello > >>> print 2+2 > 4 > >>> print 2*2 > Unhandled exception: run-time er

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread Dan Stromberg
Convert to a str. Convert to a list of ints, one for each digit Add 7 mod 10, for each digit in the list Convert to a list of single-character str's Catenate those str's back together Convert to a single int On Sat, Feb 20, 2021 at 6:45 AM C W wrote: > Hello everyone, > > I'm curious if there

Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread Dan Stromberg
On Sat, Feb 20, 2021 at 7:13 PM Ming wrote: > I just wrote a very short code can fulfill your needs: > > a = 2342 > b = int("".join(map(lambda x: str((int(x)-3)%10) ,list(str(a) > I tend to favor plenty of temporary variables with descriptive names, but this is indeed short. Apart from that,

Re: Logging with 2 process in application

2021-02-21 Thread Dan Stromberg
On Sun, Feb 21, 2021 at 9:10 PM gayatri funde wrote: > Hello, > > Greetings!! Have a good day! > > This is regarding logging issue i am facing in my application. My > requirement is to create log on daily basis while my application is > running, So to do this i am creating new log file at midnigh

Re: python 2.6: Need some advise for installing modules on a legacy system

2021-02-24 Thread Dan Stromberg
I don't think pip supports 2.x anymore. You might be able to: 1) Look up what versions of your desired modules support Python 2.x on pypi's website 2) Install them on another system that has Python 3.x using pip 3) Copy them to the moribund system 4) Test On Wed, Feb 24, 2021 at 5:15 AM Antoon P

Re: python 2.6: Need some advise for installing modules on a legacy system

2021-02-24 Thread Dan Stromberg
You also could try getting the modules (of suitable versions) you need from their homepage, possibly github, and then use the setup.py to install your packages. pypi usually has a link to a project's homepage. On Wed, Feb 24, 2021 at 6:08 AM Dan Stromberg wrote: > > I don't th

<    1   2   3   4   5   6   7   8   9   10   >