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

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

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, > >

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

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: 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: 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

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

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: 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

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

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)

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: 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

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 it

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/bin/pyt

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. >> > >> > Rathe

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-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 everyth

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

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

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

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

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 >

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 fed such k

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 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 beside the poi

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

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 > >

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: 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 =

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: 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

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

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: 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: 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

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

"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

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

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

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

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

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: 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

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

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 >

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

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

Re: Python app on a Mac

2022-04-15 Thread Dan Stromberg
On Fri, Apr 15, 2022 at 11:43 AM Alan Gauld wrote: > I've just migrated from a Linux PC to a Mac mini running Monterey. > I'm using a Mac for work lately. I miss Linux. I feel like MacOS isn't nearly as good at multimonitor setups as Cinnamon. Does anyone know how to launch a Python program

Re: Comparing sequences with range objects

2022-04-10 Thread Dan Stromberg
a bloom filter. EG: https://pypi.org/project/drs-bloom-filter/ On Sun, Apr 10, 2022 at 5:31 PM Dan Stromberg wrote: > > It sounds a little like you're looking for interval arithmetic. > > Maybe https://pypi.org/project/python-intervals/1.5.3/ ? > > On Thu, Apr 7, 2022 at 4:19 AM An

Re: Comparing sequences with range objects

2022-04-10 Thread Dan Stromberg
It sounds a little like you're looking for interval arithmetic. Maybe https://pypi.org/project/python-intervals/1.5.3/ ? On Thu, Apr 7, 2022 at 4:19 AM Antoon Pardon wrote: > I am working with a list of data from which I have to weed out duplicates. > At the moment I keep for each entry a

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 >

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

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

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

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

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 way I wan

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 of similar questions

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: 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

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

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

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

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: 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

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. >

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: 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-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-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: "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. > >

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

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

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: 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

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

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

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 >

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

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 library. Is >>

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 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

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 sandbox, I

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

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, >> >&g

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 > -- >

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: 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

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

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: 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: 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

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: 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

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

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

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 > > the fo

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: 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, or

  1   2   3   4   5   6   7   8   9   10   >