Re: How to exit program with custom code and custom message?

2023-03-13 Thread Chris Angelico
On Tue, 14 Mar 2023 at 15:28, Thomas Passin wrote: > > On 3/13/2023 10:34 PM, scruel tao wrote: > > Interesting, `raise SystemExit` seems to have the same behavior as > > `sys.exit`: > > > > ```shell > > python -c "raise SystemExit(100)" > > echo $? > > <<< 100 > > > > python -c " import sys;

Re: How to exit program with custom code and custom message?

2023-03-13 Thread Thomas Passin
On 3/13/2023 10:34 PM, scruel tao wrote: Interesting, `raise SystemExit` seems to have the same behavior as `sys.exit`: ```shell python -c "raise SystemExit(100)" echo $? <<< 100 python -c " import sys; sys.exit(100)" echo $? <<< 100 OTOH, you don't want to get too tricky: (on Windows,

Re: How to exit program with custom code and custom message?

2023-03-13 Thread Thomas Passin
On 3/13/2023 11:50 PM, MRAB wrote: On 2023-03-14 03:29, Thomas Passin wrote: On 3/13/2023 10:34 PM, scruel tao wrote: Lars: I totally understand your reasoning here, but in some way it follows the unix philosophy: Do only one thing, but do that good. I understand, python is not strongly

Re: How to exit program with custom code and custom message?

2023-03-13 Thread MRAB
On 2023-03-14 03:29, Thomas Passin wrote: On 3/13/2023 10:34 PM, scruel tao wrote: Lars: I totally understand your reasoning here, but in some way it follows the unix philosophy: Do only one thing, but do that good. I understand, python is not strongly typed, so `sys.exit` will be able to

Re: How to exit program with custom code and custom message?

2023-03-13 Thread Thomas Passin
On 3/13/2023 10:34 PM, scruel tao wrote: Lars: I totally understand your reasoning here, but in some way it follows the unix philosophy: Do only one thing, but do that good. I understand, python is not strongly typed, so `sys.exit` will be able to accept any types parameters rather than just

Re: How to exit program with custom code and custom message?

2023-03-13 Thread scruel tao
Lars: > I totally understand your reasoning here, but in some way it follows the unix > philosophy: Do only one thing, but do that good. I understand, python is not strongly typed, so `sys.exit` will be able to accept any types parameters rather than just integer. In order to handle such

Re: =- and -= snag

2023-03-13 Thread Thomas Passin
On 3/13/2023 9:47 PM, Chris Angelico wrote: On Tue, 14 Mar 2023 at 12:38, Thomas Passin wrote: On 3/13/2023 9:07 PM, Chris Angelico wrote: Of course, all this is predicated on you actually putting whitespace around your equals signs. If you write it all crunched together as "x=-5", there's

Re: =- and -= snag

2023-03-13 Thread Chris Angelico
On Tue, 14 Mar 2023 at 12:38, Thomas Passin wrote: > > On 3/13/2023 9:07 PM, Chris Angelico wrote: > > Of course, all this is predicated on you actually putting whitespace > > around your equals signs. If you write it all crunched together as > > "x=-5", there's no extra clues to work with. > > >

Re: =- and -= snag

2023-03-13 Thread Thomas Passin
On 3/13/2023 9:07 PM, Chris Angelico wrote: Of course, all this is predicated on you actually putting whitespace around your equals signs. If you write it all crunched together as "x=-5", there's no extra clues to work with. Linters and code reviewers can make use of all the available

RE: =- and -= snag

2023-03-13 Thread avi.e.gross
Morten, Suggesting something is UNPYTHONIC is really not an argument I take seriously. You wrote VALID code by the rules of the game and it is not a requirement that it guesses at what you are trying to do and calls you an idiot! More seriously, python lets you do some completely obscure things

Re: =- and -= snag

2023-03-13 Thread MRAB
On 2023-03-14 00:28, Gary Herron wrote: On 3/13/23 2:26 PM, morp...@gmail.com wrote: Hi. I was working in Python today, and sat there scratching my head as the numbers for calculations didn't add up. It went into negative numbers, when that shouldn't have been possible. Turns out I had a

Re: =- and -= snag

2023-03-13 Thread Chris Angelico
On Tue, 14 Mar 2023 at 11:37, Gary Herron wrote: > > > On 3/13/23 2:26 PM, morp...@gmail.com wrote: > > Hi. > > > > I was working in Python today, and sat there scratching my head as the > > numbers for calculations didn't add up. It went into negative numbers, > > when that shouldn't have been

Re: =- and -= snag

2023-03-13 Thread Gary Herron
On 3/13/23 2:26 PM, morp...@gmail.com wrote: Hi. I was working in Python today, and sat there scratching my head as the numbers for calculations didn't add up. It went into negative numbers, when that shouldn't have been possible. Turns out I had a very small typo, I had =- instead of -=.

=- and -= snag

2023-03-13 Thread Morten W. Petersen
Hi. I was working in Python today, and sat there scratching my head as the numbers for calculations didn't add up. It went into negative numbers, when that shouldn't have been possible. Turns out I had a very small typo, I had =- instead of -=. Isn't it unpythonic to be able to make a mistake

Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread a a
On Monday, 13 March 2023 at 16:12:04 UTC+1, Thomas Passin wrote: > On 3/13/2023 12:39 AM, a a wrote: > > But some unknown reasons Matplotlib and numpy crash my Python 3.8 for > > Windows , 32-bit and no support is offered > It is possible, using pip, to downgrade versions (e.g., of Matplotlob >

Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread a a
On Monday, 13 March 2023 at 16:16:28 UTC+1, Thomas Passin wrote: > On 3/13/2023 12:39 AM, a a wrote: > > But what I need is analysis of seismograms from 4,000 seismographs world > > wide to detect P-wave energy distribution underground around the earthquake > > to verify EQ Domino Effect > In

Re: 转发: How to exit program with custom code and custom message?

2023-03-13 Thread Cameron Simpson
On 13Mar2023 10:18, scruel tao wrote: Chris: but for anything more complicated, just print and then exit. It's worth noting, by the way, that sys.exit("error message") will print that to STDERR, not to STDOUT, which mean that the equivalent is: Yes, I know, but don’t you think if `sys.exit`

RE: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread avi.e.gross
Hi, This seems again to be a topic wandering. Was the original question whether Python could be used for dealing with Seismic data of some unspecified sort as in PROCESSING it and now we are debating how to clean various aspects of data and make things like data.frames and extract subsets for

Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Thomas Passin
On 3/13/2023 11:54 AM, Rich Shepard wrote:> On Mon, 13 Mar 2023, Thomas Passin wrote: > >> No doubt, depending on the data formats used. But it's still going >> to be a big task. > > Thomas, > > True, but once you have a dataframe with all the information about > all the earthquakes you can

Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Rich Shepard
On Mon, 13 Mar 2023, Thomas Passin wrote: No doubt, depending on the data formats used. But it's still going to be a big task. Thomas, True, but once you have a dataframe with all the information about all the earthquakes you can extract data for every analysis you want to do. If you've not

Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Thomas Passin
On 3/13/2023 11:23 AM, Rich Shepard wrote: On Mon, 13 Mar 2023, Thomas Passin wrote: But what I need is analysis of seismograms from 4,000 seismographs world wide to detect P-wave energy distribution underground around the earthquake to verify EQ Domino Effect In that case, you will have

Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Rich Shepard
On Mon, 13 Mar 2023, Thomas Passin wrote: But what I need is analysis of seismograms from 4,000 seismographs world wide to detect P-wave energy distribution underground around the earthquake to verify EQ Domino Effect In that case, you will have to do a great deal of work to get all that

Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Thomas Passin
On 3/13/2023 12:39 AM, a a wrote: But what I need is analysis of seismograms from 4,000 seismographs world wide to detect P-wave energy distribution underground around the earthquake to verify EQ Domino Effect In that case, you will have to do a great deal of work to get all that data into

Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Thomas Passin
On 3/13/2023 12:39 AM, a a wrote: But some unknown reasons Matplotlib and numpy crash my Python 3.8 for Windows , 32-bit and no support is offered It is possible, using pip, to downgrade versions (e.g., of Matplotlob and numpy) to see if you can find versions that work. Of course moving to

Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread a a
On Sunday, 12 March 2023 at 06:17:54 UTC+1, avi.e...@gmail.com wrote: > I have used GNU Octave as a sort of replacement for MATLAB as a free > resource. I have no idea if it might meet your needs. > > Although Python is a good environment for many things, if you have no > knowledge of it yet,

Re: 转发: How to exit program with custom code and custom message?

2023-03-13 Thread Lars Liedtke
I totally understand your reasoning here, but in some way it follows the unix philosophy: Do only one thing, but do that good. And exiting is something different from printing to STDOUT or STDERR. Yes sometimes you want to print something before exiting. But then you should do that explicitly

转发: How to exit program with custom code and custom message?

2023-03-13 Thread scruel tao
Chris: > It doesn't actually take a list of arguments; the square brackets indicate that arg is optional here. Oh, I see, it seems that I mistunderstood the document. > but for anything more complicated, just print and then exit. > It's worth noting, by the way, that sys.exit("error message")

Re: How to exit program with custom code and custom message?

2023-03-13 Thread Chris Angelico
On Mon, 13 Mar 2023 at 20:00, scruel tao wrote: > > Currently, I use `sys.exit([arg])` for exiting program and it works fine. > As described in the document: > > If another type of object is passed, None is equivalent to passing zero, > > and any other object is printed to stderr and results in

How to exit program with custom code and custom message?

2023-03-13 Thread scruel tao
Currently, I use `sys.exit([arg])` for exiting program and it works fine. As described in the document: > If another type of object is passed, None is equivalent to passing zero, and > any other object is printed to stderr and results in an exit code of 1. However, if I want to exit the program