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

Re: Bug report

2021-02-24 Thread Dan Stromberg
I'm getting: /usr/local/cpython-2.7/bin/python (2.7.16) bad ('numpy version:', '1.16.6') Traceback (most recent call last): File "./nii", line 31, in assert left == right, "{} != {}".format(left, right) AssertionError: 86374.0371429 != 86374.0371429 /usr/local/cpython-3.0

Re: Bug report

2021-02-24 Thread Dan Stromberg
On Wed, Feb 24, 2021 at 12:58 PM Peter Otten <__pete...@web.de> wrote: > On 24/02/2021 20:36, Carla Molina wrote: > This is not a bug. Have a look at the array's dtype: > > >>> n = 60461826 > >>> a = np.array([1, 50, 100, 150, 200, 250, 300]) > >>> a.dtype > dtype('int32') > I'm getting dtypes

Re: editor recommendations?

2021-02-26 Thread Dan Stromberg
On Fri, Feb 26, 2021 at 6:51 AM Ethan Furman wrote: > I'm looking for an editor to use for Python programming, as well as > related incidentals such as markdown files, restructured text, etc. > > I'm currently using vim, and the primary reason I've stuck with it for so > long is because I can get

Re: editor recommendations?

2021-03-02 Thread Dan Stromberg
On Tue, Mar 2, 2021 at 8:00 PM Russell wrote: > Ethan Furman wrote: > > I'm currently using vim, and the primary reason I've stuck with it for > so long is because I can get truly black screens with it. By which I mean > that I have a colorful window title bar, a light-grey menu bar, and then a

Re: editor recommendations?

2021-03-02 Thread Dan Stromberg
On Tue, Mar 2, 2021 at 8:11 PM Dan Stromberg wrote: > > On Tue, Mar 2, 2021 at 8:00 PM Russell wrote: > >> Ethan Furman wrote: >> > I'm currently using vim, and the primary reason I've stuck with it for >> so long is because I can get truly black scr

Re: Choosable dependency

2021-03-07 Thread Dan Stromberg
I sometimes do things like: try: import rtoml as toml except ImportError: import toml ...but I don't like it very much, because it tends to confuse static analyzers like pyflakes and pylint. Maybe mypy will deal with it better? Not sure yet. On Sat, Mar 6, 2021 at 3:05 AM Manfred Lotz

Re: How to loop over a text file (to remove tags and normalize) using Python

2021-03-10 Thread Dan Stromberg
If you want text without tags, sometimes it's easier to use a text-based web browser, EG: #!/bin/sh # for mutt to view html e-mails #where html2txt is a shell script that performs the conversion, e.g. by #calling links -html-numbered-links 1 -html-images 1 -dump "file://$@" #or # #lynx -force_

Re: .title() - annoying mistake

2021-03-19 Thread Dan Stromberg
On Fri, Mar 19, 2021 at 11:51 AM Grant Edwards wrote: > On 2021-03-19, MRAB wrote: > > On 2021-03-19 17:19, Abdur-Rahmaan Janhangeer wrote: > >> Aie sorry, > >> > >> Did not know it targetted the non-english speakers. > >> > > You want English "man's" to become "Man's", but French "l'homme" to >

Re: Pips for python2 and python3

2021-03-21 Thread Dan Stromberg
On Sun, Mar 21, 2021 at 6:14 PM MRAB wrote: > Tn 2021-03-21 23:13, Tim Johnson wrote: > > Using ubuntu 20.04 as a recent install > > with python3 (3.8.5) which was installed as part of the > > original distribution install > > and > > python2 (2.7.18) that has been installed using apt. > > > > I

Re: python documentation

2021-03-26 Thread Dan Stromberg
On Fri, Mar 26, 2021 at 10:37 PM Chris Angelico wrote: > On Sat, Mar 27, 2021 at 4:20 PM wrote: > > By the way, some months ago I started trying to migrate to Python 3 and > > gave up in favor of creating said compilation. Compatibility of Python > > and its Packages decreased with V3 significan

Re: python documentation

2021-03-27 Thread Dan Stromberg
On Sat, Mar 27, 2021 at 9:56 AM wrote: > May I ask, do you have any knowledge or even experience about if resp. > how good Tauthon and Pypy2 works together with Qt 4.8? > I've never used Qt. I do my GUI's with PyGOBject. I've moved all of my personal code that I care about from Python 2.x to 3

Re: memory consumption

2021-03-30 Thread Dan Stromberg
On Tue, Mar 30, 2021 at 1:25 AM Alexey wrote: > > I'm sorry. I didn't understand your question right. If I have 4 workers, > they require 4Gb > in idle state and some extra memory when they execute other tasks. If I > increase workers > count up to 16, they`ll eat all the memory I have (16GB) on

Re: Yield after the return in Python function.

2021-04-05 Thread Dan Stromberg
On Mon, Apr 5, 2021 at 10:46 AM Terry Reedy wrote: > If there were a 'dead > (unreachable) code' exception, a reader or compiler would have to > analyze each use of 'yield' and decide whether it is reachable or not. > It's also subject to how hard the compiler feels like trying in any given rele

Re: Style qeustion: Multiple return values

2021-04-12 Thread Dan Stromberg
On Mon, Apr 12, 2021 at 1:30 AM Steve Keller wrote: > Just a short style question: When returning multiple return values, do > you use parenthesis? > > E.g. would you write > > def foo(): > return 1, 2 > > a, b = foo() > > or do you prefer > > def foo(): > return (1, 2

Re: googletrans in python

2021-04-12 Thread Dan Stromberg
Does this help? https://zetcode.com/python/googletrans/ It was the first google search hit on 'googletrans python example'. On Mon, Apr 12, 2021 at 9:49 AM Quentin Bock wrote: > Can someone explain the basics of googletrans in python? > I want to make a program that translates stories into En

Re: translating external files type thing

2021-04-13 Thread Dan Stromberg
Hi. Does this give you any ideas? #!/usr/bin/env python3 """Quick translation program - English to Icelandic.""" # import pprint import googletrans # pprint.pprint(googletrans.LANGUAGES) translator = googletrans.Translator() with open('input-file', 'r') as file_: english_text = file_.re

Re: FileNotFoundError: [Errno 2] No such file or directory: ''

2021-04-14 Thread Dan Stromberg
On Wed, Apr 14, 2021 at 9:14 AM Quentin Bock wrote: > I receive this error when I try to open a file > The file (what I'm trying to open) is in the same folder as the program I'm > trying to open it from; why is it saying no such file or directory? > > this is the only part of the code that cause

Re: FileNotFoundError: [Errno 2] No such file or directory: ''

2021-04-14 Thread Dan Stromberg
o python other than just a variable name. You can replace it, as your code below (and my example above) does, but it obscures the thing you're replacing. That's why I like to use file_ instead of file. On Wed, Apr 14, 2021 at 10:42 AM Quentin Bock wrote: > Okay, how exactly do I do

Re: port to PDOS (especially mainframe)

2021-04-16 Thread Dan Stromberg
On Fri, Apr 16, 2021 at 1:05 PM Paul Edwards wrote: > On Saturday, April 17, 2021 at 5:13:31 AM UTC+10, Paul Rubin wrote: > > Paul Edwards writes: > > > I have succeeded in producing a Python 3.3 executable despite being > > > built with a C library that only supports C90. > > > It seems to me t

Re: port to PDOS (especially mainframe)

2021-04-16 Thread Dan Stromberg
On Fri, Apr 16, 2021 at 3:40 PM Paul Edwards wrote: > On Saturday, April 17, 2021 at 7:52:07 AM UTC+10, jak wrote: > > > Hi, > > one thing is not clear to me, do you absolutely need to use "asma"? > > > > http://www.z390.org/ > > The link you provided is to something that runs on PC > environment

Re: Determine what the calling program is

2021-04-18 Thread Dan Stromberg
I use this little program for shell-level locking. It just checks for a pid file. If the pid file does not exist, or the pid no longer exists, it'll start the process, and write the new process' pid to the pid file. It's at: https://stromberg.dnsalias.org/svn/just-one/ ...and usage looks like:

Re: Determine what the calling program is

2021-04-18 Thread Dan Stromberg
It's now at: https://stromberg.dnsalias.org/~strombrg/just-one/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Current thinking on required options

2021-04-19 Thread Dan Stromberg
On Mon, Apr 19, 2021 at 2:55 AM Loris Bennett wrote: > However, the options -o, -u, and -g are required, not optional. > > The documentation > > https://docs.python.org/3/library/argparse.html#required > > advises against required options and here > > > https://stackoverflow.com/questions/24180

Re: Current thinking on required options

2021-04-19 Thread Dan Stromberg
;. On Mon, Apr 19, 2021 at 9:30 AM Paul Bryan wrote: > Calling them options—when they're required—seems like a problem. 🙂 > > On Mon, 2021-04-19 at 09:04 -0700, Dan Stromberg wrote: > > On Mon, Apr 19, 2021 at 2:55 AM Loris Bennett > wrote: > > However, the opt

Re: Current thinking on required options

2021-04-19 Thread Dan Stromberg
On Mon, Apr 19, 2021 at 12:36 PM Grant Edwards wrote: > On 2021-04-19, Dan Stromberg wrote: > > On Mon, Apr 19, 2021 at 2:55 AM Loris Bennett < > loris.benn...@fu-berlin.de> wrote: > > > >> However, the options -o, -u, and -g are required, not opti

Re: do ya still use python?

2021-04-19 Thread Dan Stromberg
On Mon, Apr 19, 2021 at 5:55 PM Jon Ribbens via Python-list < python-list@python.org> wrote: > On 2021-04-20, Paul Rubin wrote: > > Ethan Furman writes: > >> List, my apologies -- not sure how that one got through. > > > > It was trollishly written but was a reasonable observation on the state >

Re: Fun Generators

2021-04-23 Thread Dan Stromberg
On Fri, Apr 23, 2021 at 10:30 AM Travis Griggs wrote: > > On Apr 23, 2021, at 05:55, Frank Millman wrote: > > > > On 2021-04-23 7:34 AM, Travis Griggs wrote: > >> Doing an "industry experience" talk to an incoming class at nearby > university tomorrow. Have a couple points where I might do some

Re: The split() function of Python's built-in module has changed in a puzzling way - is this a bug?

2021-04-23 Thread Dan Stromberg
On Thu, Apr 22, 2021 at 8:53 PM Andy AO wrote: > Upgrading from Python 3.6.8 to Python 3.9.0 and executing unit tests > revealed a significant change in the behavior of re.split(). > > but looking at the relevant documentation — Changelog python.org/3/whatsnew/changelog.html> and

Re: learning python ...

2021-05-24 Thread Dan Stromberg
On Sun, May 23, 2021 at 12:35 PM hw wrote: > I don't know about shadowing. If I have defeated a whole variable type > by naming a variable like a variable type, I would think it is a bad > idea for python to allow this without warning. It seems like a recipie > for creating chaos. > It strikes

Re: Definition of "property"

2021-05-30 Thread Dan Stromberg
On Sun, May 30, 2021 at 9:57 AM Irv Kalb wrote: > I am doing some writing (for an upcoming book on OOP), and I'm a little > stuck. > > I understand what a "property" is, how it is used and the benefits, but > apparently my explanation hasn't made the light bulb go on for my editor. > The editor i

Re: Python app setup

2021-06-01 Thread Dan Stromberg
What you've got there is a REPL, or Read-Evaluate-Print-Loop. It's good for quick little exploratory tests. For actually writing code, most people would prefer to use PyCharm or VSCode or IDLE. You may find that IDLE has come with your CPython install. Personally, I prefer vim+syntastic+jedi, but

Re: python 3.9.5

2021-06-01 Thread Dan Stromberg
On Tue, Jun 1, 2021 at 10:12 AM Dennis Lee Bieber wrote: > On Mon, 31 May 2021 02:15:28 -0500, said ganoune > declaimed the following: > > is this the third one in the last week... > > Does the Python FAQ address contemporary FAQ's? It seems like https://docs.python.org/3/faq/windows.h

Re: Has anone seen or know of a CFFI wrapper for PDCurses?

2021-06-13 Thread Dan Stromberg
On Sun, Jun 13, 2021 at 12:50 AM wrote: > Hi All, > > I have been investigating the possibility of wrapping the PDCurses DLL on > Windows (or even better the PDCursesMod fork) using cffi instead of > ctypes. > The unicurses project tried this using ctypes 11 years ago but unicurses > hasn't been

Re: Has anone seen or know of a CFFI wrapper for PDCurses?

2021-06-14 Thread Dan Stromberg
On Sun, Jun 13, 2021 at 10:42 PM wrote: > > From: Dan Stromberg > > Sent: Monday, June 14, 2021 12:36 AM > > To: pjfarl...@earthlink.net > > Cc: Python List > > Subject: Re: Has anone seen or know of a CFFI wrapper for PDCurses? > > > > > On

Re: Cant find sorcecode

2021-06-14 Thread Dan Stromberg
I don't know where your source code is specifically, but here's an example of looking up where a file lives: $ python3 below cmd output started 2021 Mon Jun 14 09:05:54 PM PDT Python 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for mo

Re: How to check if an image contains an element I am searchig for

2021-06-16 Thread Dan Stromberg
On Wed, Jun 16, 2021 at 2:04 PM Barry wrote: > >>> On Thu, Jun 17, 2021 at 6:06 AM Arak Rachael > wrote: > >>> > >>> Hi guys, > >>> > >>> I have an image from google maps to say and I need to check if it has > road markings, in order to do that, I believe I need to change the effects > on the im

Re: How to check if an image contains an element I am searchig for

2021-06-16 Thread Dan Stromberg
On Wed, Jun 16, 2021 at 2:44 PM Chris Angelico wrote: > On Thu, Jun 17, 2021 at 7:35 AM Dan Stromberg wrote: > > > >> How well can you define the things you're looking for? > > > >> > > > >> https://xkcd.com/1425/ > > > >> &g

Re: create an empty RGB image with specified number of cells (rows, columns)

2021-06-21 Thread Dan Stromberg
I don't know about OpenCV, but here's a way of creating a ppm image file of arbitrary size and arbitrary solid color: https://stromberg.dnsalias.org/svn/solid/trunk On Mon, Jun 21, 2021 at 4:01 AM Arak Rachael wrote: > Hi guys! > > Does anyone know how to do this, if possible with OpenCv? > -- >

Python threading comparison

2021-06-22 Thread Dan Stromberg
I put together a little python runtime comparison, with an embarallel, cpu-heavy threading microbenchmark. It turns out that the performance-oriented Python implementations, Pypy3 and Nuitka3, are both poor at threading, as is CPython of course. On the plus side for CPython, adding cpu-heavy thre

Verify independence and uniform distribution of discrete values in Python?

2021-07-09 Thread Dan Stromberg
I've posted a question about CPython 3.[0-9]'s random.SystemRandom().choice(list_) at https://stackoverflow.com/questions/68319071/verify-independence-and-uniform-distribution-of-discrete-values-in-python In short, we need to be able to support CPython's a little older than the secrets module goes

Re: argparse support of/by argparse

2021-07-14 Thread Dan Stromberg
On Mon, Jul 12, 2021 at 12:34 PM Chris Angelico wrote: > On Tue, Jul 13, 2021 at 5:22 AM lucas wrote: > > Running CPython on it will raise a TypeError, and running Mypy on it > > will indicate that no issues were found. > > > > I was wondering if there is any way for me to have mypy detecting th

Re: Defining a Python enum in a C extension - am I doing this right?

2021-07-23 Thread Dan Stromberg
On Fri, Jul 23, 2021 at 1:20 AM Bartosz Golaszewski wrote: > Hi! > > I'm working on a Python C extension and I would like to expose a > custom enum (as in: a class inheriting from enum.Enum) that would be > entirely defined in C. > I'm probably missing something obvious, but why would you write

Re: argparse: delimiter for argparse list arguments

2021-08-02 Thread Dan Stromberg
Isn't -- usually used to signal the end of options? On Mon, Aug 2, 2021 at 12:52 PM Sven R. Kunze wrote: > Hi everyone, > > maybe, I am missing something here but is it possible to specify a > delimiter for list arguments in argparse: > > https://docs.python.org/3/library/argparse.html > > Usual

Cyclic imports

2021-08-16 Thread Dan Stromberg
Hi folks. I'm working on a large codebase that has at least one cyclic import. In case I end up needing to eliminate the cyclic imports, is there any sort of tool that will generate an import graph and output Just the cycles? I tried pyreverse, but it produced too big a graph to be very useful;

Re: Cyclic imports

2021-08-21 Thread Dan Stromberg
On Tue, Aug 17, 2021 at 11:20 AM Chris Angelico wrote: > The main advantage of ast.parse() is that it no longer cares about > code layout, and it won't be fooled by an import statement inside a > docstring, or anything like that. It's also pretty easy to handle > multiple variants (note how "impo

Re: Cyclic imports

2021-08-21 Thread Dan Stromberg
On Sat, Aug 21, 2021 at 3:35 PM Dan Stromberg wrote: > On Tue, Aug 17, 2021 at 11:20 AM Chris Angelico wrote: > >> The main advantage of ast.parse() is that it no longer cares about >> code layout, and it won't be fooled by an import statement inside a >> docstring

from foo import bar and the ast module

2021-08-22 Thread Dan Stromberg
In 'from foo import bar': With the ast module, I see how to get bar, but I do not yet see how to get the foo. There are clearly ast.Import and ast.ImportFrom, but I do not see the foo part in ast.ImportFrom. ? Thanks! -- https://mail.python.org/mailman/listinfo/python-list

Re: from foo import bar and the ast module

2021-08-22 Thread Dan Stromberg
On Sun, Aug 22, 2021 at 7:14 AM Chris Angelico wrote: > On Mon, Aug 23, 2021 at 12:08 AM Dan Stromberg > wrote: > > > > In 'from foo import bar': > > > > With the ast module, I see how to get bar, but I do not yet see how to > get > >

Re: Request for argmax(list) and argmin(list)

2021-09-02 Thread Dan Stromberg
How about this?: python3 -c 'list_ = [1, 3, 5, 4, 2]; am = max((value, index) for index, value in enumerate(list_)); print(am)' On Wed, Sep 1, 2021 at 6:51 AM ABCCDE921 wrote: > Because that does 2 passes over the entire array when you only need one > and there is no option to specify if you w

Re: XML Considered Harmful

2021-09-21 Thread Dan Stromberg
On Tue, Sep 21, 2021 at 7:26 PM Michael F. Stemper < michael.stem...@gmail.com> wrote: > If XML is not the way to package data, what is the recommended > approach? > I prefer both JSON and YAML over XML. XML has both elements and tags, but it didn't really need both. This results in more complex

Re: XML Considered Harmful

2021-09-23 Thread Dan Stromberg
On Thu, Sep 23, 2021 at 8:12 PM Chris Angelico wrote: > One good hybrid is to take a subset of Python syntax (so it still > looks like a Python script for syntax highlighting etc), and then > parse that yourself, using the ast module. For instance, you can strip > out comments, then look for "VAR

McCabe complexity for just changed files in a commit?

2021-10-02 Thread Dan Stromberg
Hi folks. Is there a way of getting the McCabe Complexity of just the functions and methods (in Python) changed in a git commit? I found radon, and it looks good. But I think it wants to do entire files, no? Thanks! -- https://mail.python.org/mailman/listinfo/python-list

Re: python.exe - System Error

2021-10-05 Thread Dan Stromberg
Hi. You'll likely get more help if you include more context, like more text in your cut and paste. Also, how did you install it? And where did you get the installer from? HTH. On Thu, Sep 30, 2021 at 8:00 AM jitendrabeura001 wrote: >Hello Sir/Madam, please help me to out from this diffic

Re: sum() vs. loop

2021-10-11 Thread Dan Stromberg
On Mon, Oct 11, 2021 at 2:54 PM Steve Keller wrote: > I have found the sum() function to be much slower than to loop over the > operands myself: > > def sum_products(seq1, seq2): > return sum([a * b for a, b in zip(seq1, seq2)]) > > def sum_products2(seq1, seq2): > sum = 0 > for a, b

Re: about python

2021-10-14 Thread Dan Stromberg
Please try to be more specific. What setup? What problem? On Thu, Oct 14, 2021 at 10:29 AM Amsalu Fentahun wrote: > there is a problem when I install the setup > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list

Re: Why so fast a web framework?

2021-10-28 Thread Dan Stromberg
I care, and I suspect the OP does too. Usually machine time doesn't matter as much as developer time, but API overhead Can matter - especially on a busy server. I wonder if Pypy would do any better? Or Micropython? Or Cython? CPython != Python. Sometimes this group reminds me of a certain lar

Re: Python script seems to stop running when handling very large dataset

2021-10-29 Thread Dan Stromberg
On Fri, Oct 29, 2021 at 4:04 PM dn via Python-list wrote: > On 30/10/2021 11.42, Shaozhong SHI wrote: > > Python script works well, but seems to stop running at a certain point > when > > handling very large dataset. > > > > Can anyone shed light on this? > > Storage space? > Taking time to load/

CWD + relative path + import name == resultant relative path?

2021-10-29 Thread Dan Stromberg
Is there a predefined function somewhere that can accept the 3 things on the LHS in the subject line, and give back a resultant relative path - relative to the unchanged CWD? To illustrate, imagine: 1) You're sitting in /home/foo/coolprog 2) You look up the AST for /home/foo/coolprog/a/b/c.py 3) /

Re: Alternatives to Jupyter Notebook

2021-11-14 Thread Dan Stromberg
Does this help? On Wed, Oct 20, 2021 at 8:48 AM Shaozhong SHI wrote: > Hello, > > Is anyone familiar with alternatives to Jupyter Notebook. > > My Jupyter notebook becomes unresponsive in browsers. > > Are there alternatives to read, edit and run Jupyter Notebook? > > Regards, > > David > -- >

Re: Alternatives to Jupyter Notebook

2021-11-14 Thread Dan Stromberg
Sorry, gmail got in a hurry to send my message :) Does this help? https://lwn.net/Articles/855875/ On Sun, Nov 14, 2021 at 4:22 PM Dan Stromberg wrote: > > Does this help? > > > On Wed, Oct 20, 2021 at 8:48 AM Shaozhong SHI > wrote: > >> Hello, >> >>

Re: import question

2021-11-18 Thread Dan Stromberg
On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico wrote: > If you're trying to make a Python-in-Python sandbox, I recommend not. > Instead, use an OS-level sandbox (a chroot, probably some sort of CPU > usage limiting, etc), and use that to guard the entire Python process. > Python-in-Python will b

Re: import question

2021-11-18 Thread Dan Stromberg
On Thu, Nov 18, 2021 at 6:19 PM Chris Angelico wrote: > On Fri, Nov 19, 2021 at 11:24 AM Dan Stromberg > wrote: > > > > > > On Thu, Nov 18, 2021 at 12:21 PM Chris Angelico > wrote: > >> > >> If you're trying to make a Python-in-Python sandb

Re: pytest segfault, not with -v

2021-11-20 Thread Dan Stromberg
On Fri, Nov 19, 2021 at 9:49 AM Marco Sulla wrote: > I have a battery of tests done with pytest. My tests break with a > segfault if I run them normally. If I run them using pytest -v, the > segfault does not happen. > > What could cause this quantical phenomenon? > Pure python code shouldn't do

Re: pytest segfault, not with -v

2021-11-20 Thread Dan Stromberg
On Sat, Nov 20, 2021 at 10:09 AM Marco Sulla wrote: > I know how to check the refcounts, but I don't know how to check the > memory usage, since it's not a program, it's a simple library. Is > there not a way to check inside Python the memory usage? I have to use > a bash script (I'm on Linux)? >

Re: pytest segfault, not with -v

2021-11-20 Thread Dan Stromberg
On Sat, Nov 20, 2021 at 10:59 AM Dan Stromberg wrote: > > > On Sat, Nov 20, 2021 at 10:09 AM Marco Sulla > wrote: > >> I know how to check the refcounts, but I don't know how to check the >> memory usage, since it's not a program, it's a simple libr

Re: Subprocess Connection error

2021-11-23 Thread Dan Stromberg
Hi. It's important to include the full text of whatever error messages you're getting. If you can, you should also include your code, or better: include an http://sscce.org/ Can you start the python interpreter from bash, powershell or cmd.exe? If not, please again include the full text of any e

Re: pyinstaller wrong classified as Windows virus

2021-11-25 Thread Dan Purgert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Ulli Horlacher wrote: > When I compile my programs with pyinstaller, Windows classifies them as > virus and even deletes them! > [...] > What can I do? Stop writing viruses ;) Have you tried compiling from a different machine? Maybe there's somethi

Re: Call julia from Python: which package?

2021-12-17 Thread Dan Stromberg
On Fri, Dec 17, 2021 at 7:02 AM Albert-Jan Roskam wrote: > Hi, > > I have a Python program that uses Tkinter for its GUI. It's rather slow so > I hope to replace many or all of the non-GUI parts by Julia code. Has > anybody experience with this? Any packages you can recommend? I found three > alt

Re: Call julia from Python: which package?

2021-12-21 Thread Dan Stromberg
Last I heard, Pypy itself will remain written in a statically typed dialect of Python that is closest to Python 2.7. However, what's written in that language includes JIT-compiled interpreters for both Python 2.x and Python 3.x. On Tue, Dec 21, 2021 at 9:15 AM Albert-Jan Roskam wrote: >Hi a

Re: PYTHON NOT WORKING

2022-01-01 Thread Dan Stromberg
On Sat, Jan 1, 2022 at 1:52 PM the derek team wrote: > HI, I am trying to use python 3.10-1 on windows but, When I try to open > python, it crashes. Anaconda also does not work. When I try to use the > powershell, it gives me an error message saying that this is not recognized > as a valid cmdlet

Re: Starting using Python

2022-01-04 Thread Dan Stromberg
On Mon, Jan 3, 2022 at 8:06 AM Joao Marques wrote: > Good morning: I have a very simple question: I want to start writing > programs in Python so I went to the Microsoft Store and installed > Python3.9. No problem so far. I would prefer to have a gui interface, an > interface that I can use file-

Re: A Newspaper for Python Mailing Lists

2022-01-20 Thread Dan Stromberg
There's also Python Weekly: https://www.pythonweekly.com/ On Sat, Jan 8, 2022 at 10:29 PM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > Well yes XD though LWN covers Py topics well when it wants > > > 1. Yes sure, did not expect RSS interest > 2. Excuse my blunder, will do! > > > --

Re: "undefined symbol" in C extension module

2022-01-22 Thread Dan Stromberg
Perhaps try: https://stromberg.dnsalias.org/svn/find-sym/trunk It tries to find symbols in C libraries. In this case, I believe you'll find it in -lpythonx.ym On Sat, Jan 22, 2022 at 12:43 PM Robert Latest via Python-list < python-list@python.org> wrote: > Hi guys, > > I've written some CPytho

mac app from a python script?

2022-01-23 Thread Dan Stromberg
Hi folks. I have a Python 3 script (built on top of gi.respository.Gtk) that runs on Linux and macOS 11.5. It's at https://stromberg.dnsalias.org/~strombrg/hcm/ if you're curious. It works the way I want on Linux, but on macOS I seem to have to start it from the command line, like: hcm --gui

Re: "undefined symbol" in C extension module

2022-01-23 Thread Dan Stromberg
On Sun, Jan 23, 2022 at 9:02 AM Robert Latest via Python-list < python-list@python.org> wrote: > Dan Stromberg wrote: > > Perhaps try: > > https://stromberg.dnsalias.org/svn/find-sym/trunk > > > > It tries to find symbols in C libraries. > > > &

Re: mac app from a python script?

2022-01-24 Thread Dan Stromberg
On Sun, Jan 23, 2022 at 1:37 PM Barry wrote: > > I do not have experience with great, but you might try pyinstaller. > I use it to make a PyQt Mac app successfully. > > It’s command line plus setup script. > I wound up doing: 1) pyinstaller, as normal, but this created a broken all-encompassing

Re: mac app from a python script?

2022-01-25 Thread Dan Stromberg
On Tue, Jan 25, 2022 at 2:23 PM Barry wrote: > > On 25 Jan 2022, at 02:56, Dan Stromberg wrote: > >  > > On Sun, Jan 23, 2022 at 1:37 PM Barry wrote: > >> >> I do not have experience with great, but you might try pyinstaller. >> I use it to make a PyQt M

Re: mac app from a python script?

2022-01-25 Thread Dan Stromberg
On Tue, Jan 25, 2022 at 6:41 PM Dan Stromberg wrote: > > On Tue, Jan 25, 2022 at 2:23 PM Barry wrote: > >> >> On 25 Jan 2022, at 02:56, Dan Stromberg wrote: >> >>  >> >> On Sun, Jan 23, 2022 at 1:37 PM Barry wrote: >> >>> >>&g

Re: mac app from a python script?

2022-01-26 Thread Dan Stromberg
On Wed, Jan 26, 2022 at 2:35 PM Barry wrote: > > > On 26 Jan 2022, at 05:17, Dan Stromberg wrote: > > > On Tue, Jan 25, 2022 at 6:41 PM Dan Stromberg wrote: > >> >> On Tue, Jan 25, 2022 at 2:23 PM Barry wrote: >> >>> >>> On 25 Jan 2022,

Re: Pypy with Cython

2022-02-03 Thread Dan Stromberg
The best answer to "is this slower on Pypy" is probably to measure. Sometimes it makes sense to rewrite C extension modules in pure python for pypy. On Thu, Feb 3, 2022 at 7:33 AM Albert-Jan Roskam wrote: >Hi, >I inherited a fairly large codebase that I need to port to Python 3. > Since

Re: Long running process - how to speed up?

2022-02-19 Thread Dan Stromberg
On Sat, Feb 19, 2022 at 3:29 AM Shaozhong SHI wrote: > I have a cvs file of 932956 row and have to have time.sleep in a Python > script. It takes a long time to process. > > How can I speed up the processing? Can I do multi-processing? > How are you doing it right now? Are you using the csv m

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Dan Stromberg
On Sun, Feb 20, 2022 at 7:33 AM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > Greetings list. > > Out of curiosity, why doesn't Python accept > def (): > return '---' > > () > > Where the function name is ''? > () is already an empty tuple. It would break code to change this. --

Re: One-liner to merge lists?

2022-02-22 Thread Dan Stromberg
On Tue, Feb 22, 2022 at 7:46 AM David Raymond wrote: > > Is there a simpler way? > > >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} > >>> [a for b in d.values() for a in b] > ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] > >>> > I like that way best. But I'd still: 1) use a little more descriptive

Re: C is it always faster than nump?

2022-02-25 Thread Dan Stromberg
On Fri, Feb 25, 2022 at 9:03 PM Chris Angelico wrote: > On Sat, 26 Feb 2022 at 15:39, Avi Gross via Python-list > wrote: > > Take interpreted languages including Python and R that specify all kinds > of functions that may be written within the language at first. Someone may > implement a functio

Re: C is it always faster than nump?

2022-02-25 Thread Dan Stromberg
On Fri, Feb 25, 2022 at 8:12 AM BELAHCENE Abdelkader < abdelkader.belahc...@enst.dz> wrote: > Hi, > a lot of people think that C (or C++) is faster than python, yes I agree, > but I think that's not the case with numpy, I believe numpy is faster than > C, at least in some cases. > This is all "la

Re: One-liner to merge lists?

2022-02-26 Thread Dan Stromberg
On Fri, Feb 25, 2022 at 3:15 PM Chris Angelico wrote: > But ultimately, that's still the same as sum(), and it's no more > readable than chain(), so I'd still be inclined to go with chain and > then wrap it in a function if you need the clarity. > "Need" the clarity? Please tell me you don't th

Re: Behavior of the for-else construct

2022-03-03 Thread Dan Stromberg
On Thu, Mar 3, 2022 at 5:24 AM computermaster360 < computermaster...@gmail.com> wrote: > I want to make a little survey here. > > Do you find the for-else construct useful? Have you used it in > practice? Do you even know how it works, or that there is such a thing > in Python? > > I have used it

Re: Python

2022-03-03 Thread Dan Stromberg
Whatever happened to sending a URL to a specific answer in a FAQ list? On Thu, Mar 3, 2022 at 12:52 PM Dan Ciprus (dciprus) via Python-list < python-list@python.org> wrote: > if OP formulates question the way he/she did, it's not worth to respond to > it. > There is plenty

Re: mac app from a python script?

2022-03-06 Thread Dan Stromberg
On Sun, Jan 23, 2022 at 9:59 AM Dan Stromberg wrote: > > Hi folks. > > I have a Python 3 script (built on top of gi.respository.Gtk) that runs on > Linux and macOS 11.5. It's at > https://stromberg.dnsalias.org/~strombrg/hcm/ if you're curious. > > It works the

Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-10 Thread Dan Stromberg
On Thu, Mar 10, 2022 at 5:04 AM Marco Sulla wrote: > On Thu, 10 Mar 2022 at 04:50, Michael Torrie wrote: > > > > On 3/9/22 13:05, Marco Sulla wrote: > > > So my laziness pays. I use only LTS distros, and I update only when > > > there are security updates. > > > PS: any suggestions for a new LTS

Weird strace of #! python script

2022-03-14 Thread Dan Stromberg
Hi folks. First off, I know, python2 is ancient history. Porting to 3.x is on my list of things to do (though I'm afraid it's not yet at the top of the list), and the same thing happens with python3. So anyway, I'm strace'ing a #!/usr/bin/python2 script. I expected to see an exec of /usr/bin/py

Re: Compiling and Linking pre-built Windows Python libraries with C++ files on Linux for Windows

2022-03-19 Thread Dan Stromberg
On Fri, Mar 18, 2022 at 8:03 PM Ankit Agarwal wrote: > Hi, > > This is a very specific question. I am trying to figure out whether or not > I can use pre-built python libraries and headers on Windows in a MinGW > build on Linux. Essentially I have some python and C++ code which interface > via cy

Re: Sharing part of a function

2022-04-03 Thread Dan Stromberg
On Sun, Apr 3, 2022 at 2:46 PM Cecil Westerhof via Python-list < python-list@python.org> wrote: > Betty Hollinshead writes: > > > "Memoising" is the answer -- see "Python Algorithms" by Magnus Lie > Hetland. > > In the mean time, here a simplified version of "memoising" using a dict. > > This ver

Re: The Cython compiler is 20 years old today !

2022-04-04 Thread Dan Stromberg
On Mon, Apr 4, 2022 at 7:42 AM Stefan Behnel wrote: > Dear Python community, > > it's now 20 years since Greg Ewing posted his first announcement of Pyrex, > the tool that is now known and used under the name Cython. > > https://mail.python.org/pipermail/python-list/2002-April/126661.html > That

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