Re: Get a Joke in Python

2021-10-28 Thread Chris Angelico
On Fri, Oct 29, 2021 at 12:29 PM Jon Ribbens via Python-list wrote: > > On 2021-10-28, Greg Ewing wrote: > > On 29/10/21 11:34 am, Chris Angelico wrote: > >> On Fri, Oct 29, 2021 at 7:31 AM Mostowski Collapse > >> wrote: > >>> QA engineer walks into a bar. Orders a beer. Orders 0 beers. > >>> O

Re: Get a Joke in Python

2021-10-28 Thread Jon Ribbens via Python-list
On 2021-10-28, Greg Ewing wrote: > On 29/10/21 11:34 am, Chris Angelico wrote: >> On Fri, Oct 29, 2021 at 7:31 AM Mostowski Collapse >> wrote: >>> QA engineer walks into a bar. Orders a beer. Orders 0 beers. >>> Orders 9 beers. Orders a lizard. Orders -1 beers. >>> Orders a sfdeljknesv.

Re: Get a Joke in Python

2021-10-28 Thread Greg Ewing
On 29/10/21 11:34 am, Chris Angelico wrote: On Fri, Oct 29, 2021 at 7:31 AM Mostowski Collapse wrote: QA engineer walks into a bar. Orders a beer. Orders 0 beers. Orders 9 beers. Orders a lizard. Orders -1 beers. Orders a sfdeljknesv. Orders 1 пиво and is served a пиво. QA engin

Re: Get a Joke in Python

2021-10-28 Thread Chris Angelico
On Fri, Oct 29, 2021 at 7:31 AM Mostowski Collapse wrote: > > QA engineer walks into a bar. Orders a beer. Orders 0 beers. > Orders 9 beers. Orders a lizard. Orders -1 beers. > Orders a sfdeljknesv. > Orders 1 пиво and is served a пиво. QA engineer sighs "not again". ChrisA -- https

Re: Get a Joke in Python

2021-10-28 Thread Mostowski Collapse
QA engineer walks into a bar. Orders a beer. Orders 0 beers. Orders 9 beers. Orders a lizard. Orders -1 beers. Orders a sfdeljknesv. LoL joel.d...@gmail.com schrieb am Mittwoch, 27. Oktober 2021 um 21:00:29 UTC+2: > Get a Joke in Python. Pyjokes - is a python library / module for one lin

Re: Get a function definition/implementation hint similar to the one shown in pycharm.

2021-10-19 Thread Chris Angelico
On Wed, Oct 20, 2021 at 4:45 AM hongy...@gmail.com wrote: > > On Tuesday, October 19, 2021 at 5:22:25 AM UTC+8, cameron...@gmail.com wrote: > > On 18Oct2021 01:43, Hongyi Zhao wrote: > > >I've written the following python code snippet in pycharm: > > >```python > > >import numpy as np > > >from n

Re: Get a function definition/implementation hint similar to the one shown in pycharm.

2021-10-19 Thread hongy...@gmail.com
On Tuesday, October 19, 2021 at 5:22:25 AM UTC+8, cameron...@gmail.com wrote: > On 18Oct2021 01:43, Hongyi Zhao wrote: > >I've written the following python code snippet in pycharm: > >```python > >import numpy as np > >from numpy import pi, sin > > > >a = np.array([1], dtype=bool) > >if np.

Re: Get a function definition/implementation hint similar to the one shown in pycharm.

2021-10-18 Thread hongy...@gmail.com
On Tuesday, October 19, 2021 at 5:22:25 AM UTC+8, cameron...@gmail.com wrote: > On 18Oct2021 01:43, Hongyi Zhao wrote: > >I've written the following python code snippet in pycharm: > >```python > >import numpy as np > >from numpy import pi, sin > > > >a = np.array([1], dtype=bool) > >if np.

Re: Get a function definition/implementation hint similar to the one shown in pycharm.

2021-10-18 Thread Cameron Simpson
On 18Oct2021 01:43, Hongyi Zhao wrote: >I've written the following python code snippet in pycharm: >```python >import numpy as np >from numpy import pi, sin > >a = np.array([1], dtype=bool) >if np.in|vert(a) == ~a: >print('ok') >``` >When putting the point/cursor in the above code snippet at t

Re: Get a region from a larger data

2020-04-18 Thread Peter Otten
J Conrado wrote: > I have GOES16 full disk data with the dimensions (5424, 5424) and my > latitude and longitude arrays have the same dimension. > > How can I seletct a small region of this data, using this limits for > lat=[-30,10] and lon = [-90,-30] for my sector. I try to select my > region

Re: Get __name__ in C extension module

2019-10-08 Thread Barry Scott
> On 7 Oct 2019, at 00:44, Ian Pilcher wrote: > > On 10/6/19 12:55 PM, Barry Scott wrote: >> Then the answer to your question is simple. Do it in python and passt >> logger into the C++ module. > > Funny thing, that's exactly where I started this journey. I couldn't > figure out how to get t

Re: Get __name__ in C extension module

2019-10-07 Thread Ian Pilcher
On 10/7/19 2:09 AM, Barry Scott wrote: I meant pass in the specific named logger that you C code will use. Right, but I'm assuming that your C/C++ code will receive the logger object by calling PyArg_ParseTuple (or similar), and I further assume that you want to validate that the object actuall

Re: Get __name__ in C extension module

2019-10-07 Thread Barry Scott
> On 7 Oct 2019, at 00:44, Ian Pilcher wrote: > > On 10/6/19 12:55 PM, Barry Scott wrote: >> Then the answer to your question is simple. Do it in python and passt >> logger into the C++ module. > > Funny thing, that's exactly where I started this journey. I couldn't > figure out how to get t

Re: Get __name__ in C extension module

2019-10-07 Thread Barry Scott
> On 7 Oct 2019, at 04:34, MRAB wrote: > > On 2019-10-07 00:38, Ian Pilcher wrote: >> On 10/6/19 11:55 AM, MRAB wrote: >> > Don't you already have the module's name? You have to specify it in the > >> > PyModuleDef struct that you pass to PyModule_Create. >> >> I do. Perhaps I'm trying to b

Re: Get __name__ in C extension module

2019-10-06 Thread MRAB
On 2019-10-07 00:38, Ian Pilcher wrote: On 10/6/19 11:55 AM, MRAB wrote: > Don't you already have the module's name? You have to specify it in the > PyModuleDef struct that you pass to PyModule_Create. I do. Perhaps I'm trying to be too Pythonic, but there's so much advice out there about usi

Re: Get __name__ in C extension module

2019-10-06 Thread Ian Pilcher
On 10/6/19 12:55 PM, Barry Scott wrote: Then the answer to your question is simple. Do it in python and passt logger into the C++ module. Funny thing, that's exactly where I started this journey. I couldn't figure out how to get the logging.Logger type object, so that I could use a "O!" format

Re: Get __name__ in C extension module

2019-10-06 Thread Ian Pilcher
On 10/6/19 11:55 AM, MRAB wrote: Don't you already have the module's name? You have to specify it in the PyModuleDef struct that you pass to PyModule_Create. I do. Perhaps I'm trying to be too Pythonic, but there's so much advice out there about using getLogger(__name__) in Python code, rather

Re: Get __name__ in C extension module

2019-10-06 Thread Barry Scott
> On 5 Oct 2019, at 18:55, Ian Pilcher wrote: > > On 10/4/19 4:30 PM, Ian Pilcher wrote: >> Ideally, I would pass my existing Logging.logger object into my C >> function and use PyObject_CallMethod to call the appropriate method on >> it (info, debug, etc.). > > As I've researched this furthe

Re: Get __name__ in C extension module

2019-10-06 Thread MRAB
On 2019-10-06 15:48, Ian Pilcher wrote: On 10/5/19 12:55 PM, Ian Pilcher wrote: This is straightforward, except that I cannot figure out how to retrieve the __name__. Making progress. I can get a __name__ value with: PyDict_GetItemString(PyEval_GetGlobals(), "__name__") I say "a __name_

Re: Get __name__ in C extension module

2019-10-06 Thread Ian Pilcher
On 10/5/19 12:55 PM, Ian Pilcher wrote: This is straightforward, except that I cannot figure out how to retrieve the __name__. Making progress. I can get a __name__ value with: PyDict_GetItemString(PyEval_GetGlobals(), "__name__") I say "a __name__ value" because the returned value is actu

Re: Get Count of function arguments passed in

2019-09-11 Thread Roel Schroeven
Sayth Renshaw schreef op 11/09/2019 om 12:11: I want to allow as many lists as needed to be passed into a function. But how can I determine how many lists have been passed in? I expected this to return 3 but it only returned 1. matrix1 = [[1, -2], [-3, 4],] matrix2 = [[2, -1], [0, -1]] matrix3

Re: Get Count of function arguments passed in

2019-09-11 Thread David Lowry-Duda
> I expected this to return 3 but it only returned 1. > > matrix1 = [[1, -2], [-3, 4],] > matrix2 = [[2, -1], [0, -1]] > matrix3 = [[2, -1], [0, -1]] > > def add(*matrix): > print(len(locals())) > > print(add(matrix1, matrix2)) In this case, locals will be a dictionary with exactly one key.

Re: Get Count of function arguments passed in

2019-09-11 Thread ast
Le 11/09/2019 à 12:11, Sayth Renshaw a écrit : Hi I want to allow as many lists as needed to be passed into a function. But how can I determine how many lists have been passed in? I expected this to return 3 but it only returned 1. matrix1 = [[1, -2], [-3, 4],] matrix2 = [[2, -1], [0, -1]] mat

Re: Get Count of function arguments passed in

2019-09-11 Thread Sayth Renshaw
On Wednesday, 11 September 2019 20:25:32 UTC+10, Sayth Renshaw wrote: > On Wednesday, 11 September 2019 20:11:21 UTC+10, Sayth Renshaw wrote: > > Hi > > > > I want to allow as many lists as needed to be passed into a function. > > But how can I determine how many lists have been passed in? > >

Re: Get Count of function arguments passed in

2019-09-11 Thread Sayth Renshaw
On Wednesday, 11 September 2019 20:11:21 UTC+10, Sayth Renshaw wrote: > Hi > > I want to allow as many lists as needed to be passed into a function. > But how can I determine how many lists have been passed in? > > I expected this to return 3 but it only returned 1. > > matrix1 = [[1, -2], [-3,

Re: Get the source of a class reliably?!?

2019-04-29 Thread Chris Angelico
On Tue, Apr 30, 2019 at 4:40 PM dieter wrote: > > "computermaster360 ." writes: > > > Does anyone have an idea why classes don't contain their definition > > line number as functions or methods do? > > > some_fun.__code__.co_firstlineno > > 123 > > Because classes do not have associated "cod

Re: Get the source of a class reliably?!?

2019-04-29 Thread dieter
"computermaster360 ." writes: > Does anyone have an idea why classes don't contain their definition > line number as functions or methods do? > some_fun.__code__.co_firstlineno > 123 Because classes do not have associated "code" objects. As you see above, it is not the function itself ("so

Re: get the terminal's size

2019-01-16 Thread Akkana Peck
> On Mon, 14 Jan 2019 11:57:33 +, Alex Ternaute wrote: > > > Hi there, > > > > I want to know the number of columns of the terminal where python2 writes > > it's outputs. A couple days late to the party, a discussion of several ways I tried: http://shallowsky.com/blog/hardware/serial-24-lin

Re: get the terminal's size

2019-01-16 Thread Wildman via Python-list
On Mon, 14 Jan 2019 11:57:33 +, Alex Ternaute wrote: > Hi there, > > I want to know the number of columns of the terminal where python2 writes > it's outputs. > > In a terminal, I type > $ echo $COLUMNS > 100 > > But in Python, os.getenv("COLUMNS") gets nothing. > It gets nothing as well i

Re: get the terminal's size

2019-01-16 Thread Grant Edwards
On 2019-01-16, Karen Shaeffer wrote: [fixed quoting and formatting] >> That will tell you the terminal size at the time Python was started. >> >> If the terminal size has changed while Python was running, those >> environment variables will be wrong. You need to use the TIOCGWINSZ >> ioctl call

Re: get the terminal's size

2019-01-15 Thread Karen Shaeffer
That will tell you the terminal size at the time Python was started. If the terminal size has changed while Python was running, those environment variables will be wrong. You need to use the TIOCGWINSZ ioctl call: http://www.delorie.com/djgpp/doc/libc/libc_495.html And to detect the si

Re: get the terminal's size

2019-01-15 Thread Cameron Simpson
On 15Jan2019 13:08, Alex Ternaute wrote: I tried : P = Popen(['stty', '-a'], stdout=subprocess.PIPE, universal_newlines=True) and it runs fine too, so the output seems not really related to that fd. But it is! stty(1) fetches the terminal settings from its standard input, so "fd" is used to s

Re: get the terminal's size

2019-01-15 Thread Alex Ternaute
Hi Cameron, >>I tried : P = Popen(['stty', '-a'], stdout=subprocess.PIPE, >>universal_newlines=True) and it runs fine too, so the output seems not >>really related to that fd. > But it is! stty(1) fetches the terminal settings from its standard > input, so "fd" is used to supply this. In your Po

Re: get the terminal's size

2019-01-15 Thread Cameron Simpson
On 15Jan2019 10:26, Alex Ternaute wrote: My cs.tty module (on PyPI) has a ttysize function: https://pypi.org/project/cs.tty/ which just parses the output of the stty command. [...] Fine, indeed ! I've installed cs.ttyy. I just don't understand the reason why it takes "fd" as an argument.

Re: get the terminal's size

2019-01-15 Thread Alex Ternaute
Hi there : > On 2019-01-14, Bob van der Poel wrote: >> http://stackoverflow.com/questions/566746/how-to-get-console-window- width-in-python Simple and direct, I think I'll use this one. Thanks a lot. John Doe : > and have a look at this one too: > https://stackoverflow.com/questions/1396820/apt

Re: get the terminal's size

2019-01-15 Thread Alex Ternaute
Hi Cameron, > My cs.tty module (on PyPI) has a ttysize function: > https://pypi.org/project/cs.tty/ > which just parses the output of the stty command. > If you don't want the cs.tty module, the ttysize code is just this: > > WinSize = namedtuple('WinSize', 'rows columns') > > def tty

Re: get the terminal's size

2019-01-14 Thread eryk sun
On 1/14/19, Schachner, Joseph wrote: > I just tested the fix I proposed, in Python 2.7.13 > > Code: > from win32api import GetSystemMetrics > > def main(): > print "Width =", GetSystemMetrics(0) > print "Height =", GetSystemMetrics(1) That gets the monitor size, i.e: SM_CXSCREEN (0)

Re: get the terminal's size

2019-01-14 Thread John Doe
On 2019-01-14, Bob van der Poel wrote: > try this: > > > http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python > and have a look at this one too: https://stackoverflow.com/questions/1396820/apt-like-column-output-python-library/1446973#1446973 > -- https://mail.pyth

Re: get the terminal's size

2019-01-14 Thread Cameron Simpson
On 14Jan2019 17:16, Alex Ternaute wrote: Looking on the internet for a hint, I see that python3 has an os.get_terminal_size(). Use that then. Up to now I wanted to keep compatibility with a big bunch of code in Python2 that I do no maintain by myself. Well, I saw that get_terminal_size() fol

Re: get the terminal's size

2019-01-14 Thread Bob van der Poel
On Mon, Jan 14, 2019 at 4:57 AM Alex Ternaute wrote: > Hi there, > > I want to know the number of columns of the terminal where python2 writes > it's outputs. > > In a terminal, I type > $ echo $COLUMNS > 100 > > But in Python, os.getenv("COLUMNS") gets nothing. > It gets nothing as well if I try

RE: get the terminal's size

2019-01-14 Thread Schachner, Joseph
I just tested the fix I proposed, in Python 2.7.13 Code: from win32api import GetSystemMetrics def main(): print "Width =", GetSystemMetrics(0) print "Height =", GetSystemMetrics(1) if __name__ == '__main__': main() Result: Width = 1536 Height = 864 -Original Message- From:

Re: get the terminal's size

2019-01-14 Thread Grant Edwards
On 2019-01-14, Schachner, Joseph wrote: > Note sure why you couldn't capture $ echo $COLUMNS from a subprocess > call. You can. But, the subprocess is going to inherit the value from the Python program's environment, so it's just pointless complexity. -- Grant Edwards grant.b.edw

RE: get the terminal's size

2019-01-14 Thread Schachner, Joseph
Note sure why you couldn't capture $ echo $COLUMNS from a subprocess call. But, how about this (found on the web): from win32api import GetSystemMetrics print "Width =", GetSystemMetrics(0) print "Height =", GetSystemMetrics(1) -Original Message- From: Alex Ternaute Sent: Monday, Ja

Re: get the terminal's size

2019-01-14 Thread Alex Ternaute
Hi, Grant Edwards : >>export COLUMNS LINES > That will tell you the terminal size at the time Python was started. Ok, I think tracking these changes in real time is not worth the work to be done using Python2. I think at last I'll rewrite this (little) programe in Python3 in order to use get_

Re: get the terminal's size

2019-01-14 Thread Alex Ternaute
Hi Thomas >> Looking on the internet for a hint, I see that python3 has an >> os.get_terminal_size(). > Use that then. Up to now I wanted to keep compatibility with a big bunch of code in Python2 that I do no maintain by myself. Well, I saw that get_terminal_size() follows the windows resizings

Re: get the terminal's size

2019-01-14 Thread Grant Edwards
On 2019-01-14, Peter Otten <__pete...@web.de> wrote: > Grant Edwards wrote: > > os.environ["COLUMNS"] > >> [...] will tell you the terminal size at the time Python was started. > > I admit that none of my scripts is ambitious enough to try and track > changes in terminal size. > > But still, Grant'

Re: get the terminal's size

2019-01-14 Thread Peter Otten
Grant Edwards wrote: os.environ["COLUMNS"] > [...] will tell you the terminal size at the time Python was started. I admit that none of my scripts is ambitious enough to try and track changes in terminal size. But still, Grant's post prompted me to reread the doc and source of shutil.get_ter

Re: get the terminal's size

2019-01-14 Thread Grant Edwards
On 2019-01-14, Peter Otten <__pete...@web.de> wrote: > >> I want to know the number of columns of the terminal where python2 writes >> it's outputs. >> >> In a terminal, I type >> $ echo $COLUMNS >> 100 >> >> But in Python, os.getenv("COLUMNS") gets nothing. >> It gets nothing as well if I try to

Re: get the terminal's size

2019-01-14 Thread Thomas Jollans
On 14/01/2019 12.57, Alex Ternaute wrote: > Hi there, > > I want to know the number of columns of the terminal where python2 writes > it's outputs. > > In a terminal, I type > $ echo $COLUMNS > 100 > > But in Python, os.getenv("COLUMNS") gets nothing. > It gets nothing as well if I try to read

Re: get the terminal's size

2019-01-14 Thread Alex Ternaute
Hi, Peter Otten : >> In a terminal, I type $ echo $COLUMNS 100 >> But in Python, os.getenv("COLUMNS") gets nothing. >> I feel that I'm missing something but what ? > $ export COLUMNS Thank you very much ! -- Aelx -- https://mail.python.org/mailman/listinfo/python-list

Re: get the terminal's size

2019-01-14 Thread Peter Otten
Alex Ternaute wrote: > Hi there, > > I want to know the number of columns of the terminal where python2 writes > it's outputs. > > In a terminal, I type > $ echo $COLUMNS > 100 > > But in Python, os.getenv("COLUMNS") gets nothing. > It gets nothing as well if I try to read the output of "echo $

Re: Get list of attributes from list of objects?

2017-08-02 Thread Ian Kelly
On Wed, Aug 2, 2017 at 11:49 AM, Chris Angelico wrote: > On Thu, Aug 3, 2017 at 3:21 AM, Ian Pilcher wrote: >> Given a list of objects that all have a particular attribute, is there >> a simple way to get a list of those attributes? >> >> In other words: >> >> class Foo(object): >> def __

Re: Get list of attributes from list of objects?

2017-08-02 Thread Ian Pilcher
On 08/02/2017 12:49 PM, Chris Angelico wrote: On Thu, Aug 3, 2017 at 3:21 AM, Ian Pilcher wrote: You can't eliminate the loop, but you can compact it into a single logical operation: namelist = [foo.name for foo in foolist] That's a "list comprehension", and is an elegant way to process a list

Re: Get list of attributes from list of objects?

2017-08-02 Thread Terry Reedy
On 8/2/2017 1:21 PM, Ian Pilcher wrote: Given a list of objects that all have a particular attribute, is there a simple way to get a list of those attributes? In other words: class Foo(object): def __init__(self, name): self.name = name foolist = [ Foo('a'), Foo('b'), F

Re: Get list of attributes from list of objects?

2017-08-02 Thread Chris Angelico
On Thu, Aug 3, 2017 at 3:21 AM, Ian Pilcher wrote: > Given a list of objects that all have a particular attribute, is there > a simple way to get a list of those attributes? > > In other words: > > class Foo(object): > def __init__(self, name): > self.name = name > > foolist =

Re: get value from list using widget

2017-07-06 Thread Rick Johnson
On Wednesday, July 5, 2017 at 4:15:34 PM UTC-5, Terry Reedy wrote: > On 7/5/2017 12:34 PM, jorge.conr...@cptec.inpe.br wrote: > > > I would like know dow can I select and get the value from > > a list of values uisng widgets. > > One way is to learn tkinter and then learn to use the > Listbox wid

Re: get value from list using widget

2017-07-05 Thread Terry Reedy
On 7/5/2017 12:34 PM, jorge.conr...@cptec.inpe.br wrote: I would like know dow can I select and get the value from a list of values uisng widgets. One way is to learn tkinter and then learn to use the Listbox widget. The doc references a couple of decent tutorial web sites. Stackoverflow has

Re: get value from list using widget

2017-07-05 Thread John Gordon
In jorge.conr...@cptec.inpe.br writes: > Hi, > I would like know dow can I select and get the value from a list of > values uisng widgets. You haven't given us nearly enough detail to answer your question. What do you mean by "widget"? Do you mean HTML input elements such as radio buttons o

Re: Get Result based on the Top value

2017-02-06 Thread Meeran Rizvi
On Friday, February 3, 2017 at 5:35:13 PM UTC+5:30, Meeran Rizvi wrote: > Hello guys, > Here i am creating a GUI which will act as a search engine. > When you search for a data in search box it will fetch the results from the > very first page in browser and it is displayed in a Text widget > When

Re: Get Result based on the Top value

2017-02-06 Thread Meeran Rizvi
On Friday, February 3, 2017 at 5:35:13 PM UTC+5:30, Meeran Rizvi wrote: > Hello guys, > Here i am creating a GUI which will act as a search engine. > When you search for a data in search box it will fetch the results from the > very first page in browser and it is displayed in a Text widget > When

Re: Get Result based on the Top value

2017-02-06 Thread Peter Otten
Meeran Rizvi wrote: > Hello guys, > Here i am creating a GUI which will act as a search engine. > When you search for a data in search box it will fetch the results from > the very first page in browser and it is displayed in a Text widget When > the TOP value is 10 it should display only the firs

RE: Get Result based on the Top value

2017-02-06 Thread Deborah Swanson
Meeran Rizvi wrote, on February 03, 2017 4:05 AM > > Hello guys, > Here i am creating a GUI which will act as a search engine. > When you search for a data in search box it will fetch the > results from the very first page in browser and it is > displayed in a Text widget When the TOP value is

Re: Get min and max dates

2016-12-08 Thread Cousin Stanley
DFS wrote: > > Not wanting to use any date parsing libraries, > If you happen reconsider date parsing libraries the strptime function from the datetime module might be useful #!/usr/bin/env python3 from datetime import datetime dates = [ '10-Mar-1998' , '20

Re: Get min and max dates

2016-12-08 Thread Skip Montanaro
Datetime has greater range I believe. I can't paste from my work computer, but try this: min(datetime.datetime.strptime(s, "%d-%b-%Y") for s in dts) You should get the 1908 date instead of the 1969 date. In general, you should always use datetime instead of time for doing date manipulation and d

Re: Get min and max dates

2016-12-08 Thread cantorp
Am Donnerstag, 8. Dezember 2016 14:47:31 UTC+1 schrieb DFS: > On 12/8/2016 12:16 AM, Steven D'Aprano wrote: > > On Thursday 08 December 2016 03:15, DFS wrote: > > > >> dts= ['10-Mar-1998', > >> '20-Aug-1997', > >> '06-Sep-2009', > >> '23-Jan-2010', > >> '12-Feb-2010

Re: Get min and max dates

2016-12-08 Thread Peter Heitzer
DFS wrote: >dts= ['10-Mar-1998', > '20-Aug-1997', > '06-Sep-2009', > '23-Jan-2010', > '12-Feb-2010', > '05-Nov-2010', > '03-Sep-2009', > '07-Nov-2014', > '08-Mar-2013'] >Of course, the naive: >min(dates) = '03-Sep-2009' >max(dates) = '23-Jan-2010'

Re: Get min and max dates

2016-12-07 Thread Steven D'Aprano
On Thursday 08 December 2016 03:15, DFS wrote: > dts= ['10-Mar-1998', > '20-Aug-1997', > '06-Sep-2009', > '23-Jan-2010', > '12-Feb-2010', > '05-Nov-2010', > '03-Sep-2009', > '07-Nov-2014', > '08-Mar-2013'] > > Of course, the naive:

Re: get the sum of differences between integers in a list

2016-09-23 Thread Peter Otten
Daiyue Weng wrote: > i, I am new to the advanced python techniques, and by studying your code, > I understand that when calling grouped function with values[1, 2, 3, 6, 8, > 9, 10, 11, 13, 17, 19], > > tee(values, 3) generated 3 iterators shared values > > left contains [1, 2, 3, 6, 8, 9, 10, 11

Re: get the sum of differences between integers in a list

2016-09-21 Thread Steve D'Aprano
On Thu, 22 Sep 2016 01:51 am, marco.naw...@colosso.nl wrote: > And here is a straightforward one without any helpers: Please don't do people's homework for them. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.p

Re: get the sum of differences between integers in a list

2016-09-21 Thread marco . nawijn
On Wednesday, September 21, 2016 at 4:14:10 PM UTC+2, Daiyue Weng wrote: > Hi, first of all, let me rephase the problem. > > For an arbitrary list of integers (the integers in the list are not > necessary to be sequential), e.g. [1,2,3,6,8,9,10,11,13], > > if a set of consecutive integers having

Re: get the sum of differences between integers in a list

2016-09-21 Thread Peter Otten
Peter Otten wrote: > This is not as efficient as it should be -- the gaps are calculated twice, > the check for the first and the last position is repeated on every > iteration lots of packing and unpacking... -- To address some of my own criticism: def lonely(triple): left, value, right =

Re: get the sum of differences between integers in a list

2016-09-21 Thread Peter Otten
Daiyue Weng wrote: > Hi, first of all, let me rephase the problem. > > For an arbitrary list of integers (the integers in the list are not > necessary to be sequential), e.g. [1,2,3,6,8,9,10,11,13], > > if a set of consecutive integers having a difference of 1 between them, > put them in a list,

Re: get the sum of differences between integers in a list

2016-09-21 Thread Daiyue Weng
Hi, first of all, let me rephase the problem. For an arbitrary list of integers (the integers in the list are not necessary to be sequential), e.g. [1,2,3,6,8,9,10,11,13], if a set of consecutive integers having a difference of 1 between them, put them in a list, i.e. there are two such lists in

Re: get the sum of differences between integers in a list

2016-09-20 Thread John Pote
On 20/09/2016 12:52, Daiyue Weng wrote: Hi, I have a list numbers say, [1,2,3,4,6,8,9,10,11] First, I want to calculate the sum of the differences between the numbers in the list. At least for this first part a little pencil, paper and algebra yields a simple formula of constant and minimal c

Re: get the sum of differences between integers in a list

2016-09-20 Thread mm0fmf
On 20/09/2016 12:52, Daiyue Weng wrote: What's the best way to implement this? With a python script. Show your work and people will help you. -- https://mail.python.org/mailman/listinfo/python-list

Re: get the sum of differences between integers in a list

2016-09-20 Thread Peter Otten
Daiyue Weng wrote: > Hi, I have a list numbers say, > > [1,2,3,4,6,8,9,10,11] > > First, I want to calculate the sum of the differences between the numbers > in the list. > Second, if a sequence of numbers having a difference of 1, put them in a > list, i.e. there are two such lists, > > [1,2,3

Re: get the sum of differences between integers in a list

2016-09-20 Thread Steve D'Aprano
On Tue, 20 Sep 2016 09:52 pm, Daiyue Weng wrote: > Hi, I have a list numbers say, > > [1,2,3,4,6,8,9,10,11] > > First, I want to calculate the sum of the differences between the numbers > in the list. Sounds like homework. What have you tried? Hint: use the sum() function to sum a list of num

Re: Get the output from a Popen instance (was: Failed to update the os.environ with subprocess.Popen.)

2016-04-02 Thread Hongyi Zhao
On Sun, 03 Apr 2016 13:37:24 +1000, Ben Finney wrote: >> But, I meet the following errors: >> >> >> Traceback (most recent call last): >> File "/home/werner/software/hpc/dft-to-study/jasp/jasp.git/jasp/bin/ >> runjasp.py", line 125, in >> os.environ.update(line.partition('=')[:

Re: get Coursera video download link via program

2015-06-30 Thread iMath
I know the two packages : BeautifulSoup and requests may help, I am also able to login in Coursera via requests, the difficulty is how to find out the video download link from the page. -- https://mail.python.org/mailman/listinfo/python-list

Re: Get off the list

2015-06-18 Thread Cecil Westerhof
On Thursday 18 Jun 2015 09:36 CEST, Ian Kelly wrote: > On Thu, Jun 18, 2015 at 1:05 AM, Cecil Westerhof wrote: >> On Wednesday 17 Jun 2015 09:09 CEST, Deogratius Musiige wrote: >> >>> How can i get off this mailing list? >> >> Looking at the headers: List-Unsubscribe: >>

Re: Get off the list

2015-06-18 Thread Ian Kelly
On Thu, Jun 18, 2015 at 1:05 AM, Cecil Westerhof wrote: > On Wednesday 17 Jun 2015 09:09 CEST, Deogratius Musiige wrote: > >> How can i get off this mailing list? > > Looking at the headers: > List-Unsubscribe: , >

Re: Get off the list

2015-06-18 Thread Marc Lucke
there is no way. You are trapped forever. Resistance is futile. On 17/06/2015 5:09 PM, Deogratius Musiige wrote: > Hi, > > How can i get off this mailing list? > > > > Best regards / Med venlig hilsen > > Deogratius Musiige > Software Development Engineer > > *Sennheiser Communications A/

Re: Get off the list

2015-06-18 Thread Cecil Westerhof
On Wednesday 17 Jun 2015 09:09 CEST, Deogratius Musiige wrote: > How can i get off this mailing list? Looking at the headers: List-Unsubscribe: , So I would send an email wi

Re: Get classes from "self.MyClass" to improve subclassability

2015-06-15 Thread Thomas Güttler
Hi, crazy. I develop python since several years. I was not aware, that you can change the defaults of kwargs. I am amazed, but won't use it :-) Am Samstag, 13. Juni 2015 01:09:47 UTC+2 schrieb Terry Reedy: > On 6/12/2015 7:12 AM, Thomas Güttler wrote: > > Here is a snippet from the argparse mo

Re: Get classes from "self.MyClass" to improve subclassability

2015-06-12 Thread Terry Reedy
On 6/12/2015 7:12 AM, Thomas Güttler wrote: Here is a snippet from the argparse module: {{{ def parse_known_args(self, args=None, namespace=None): ... # default Namespace built from parser defaults if namespace is None: namespace = Namespace() # < ===

Re: Get classes from "self.MyClass" to improve subclassability

2015-06-12 Thread Thomas Güttler
Hi Steven, I understand your solution. It is correct and works. But the missing five characters "self." in the upstream code produces a lot of more lines in the final result. Regards, Thomas Güttler Am Freitag, 12. Juni 2015 14:24:06 UTC+2 schrieb Steven D'Aprano: > On Fri, 12 Jun 2015 04:12

Re: Get classes from "self.MyClass" to improve subclassability

2015-06-12 Thread Steven D'Aprano
On Fri, 12 Jun 2015 04:12:52 -0700, Thomas Güttler wrote: > Here is a snippet from the argparse module: > > {{{ > def parse_known_args(self, args=None, namespace=None): > ... > # default Namespace built from parser defaults if namespace is > None: > namespa

Re: Get classes from "self.MyClass" to improve subclassability

2015-06-12 Thread Chris Angelico
On Fri, Jun 12, 2015 at 9:12 PM, Thomas Güttler wrote: > I prefer "self.Namespace()" to namespace kwargs. > > What do you think? Given that the namespace argument already exists, and you're proposing a change, you'll need a much stronger justification than mere preference. What's the downside of

Re: Get html DOM tree by only basic builtin moudles

2015-06-05 Thread Wesley
> On Fri, Jun 5, 2015 at 12:10 PM, Wesley wrote: > > Hi Laura, > > Sure, I got special requirement that just parse html file into DOM tree, > > by only general basic modules, and based on my DOM tree structure, draft an > > bitmap. > > > > So, could you give me an direction how to get the DO

Re: Get html DOM tree by only basic builtin moudles

2015-06-05 Thread Ian Kelly
On Fri, Jun 5, 2015 at 12:10 PM, Wesley wrote: > Hi Laura, > Sure, I got special requirement that just parse html file into DOM tree, by > only general basic modules, and based on my DOM tree structure, draft an > bitmap. > > So, could you give me an direction how to get the DOM tree? > Curr

Re: Get html DOM tree by only basic builtin moudles

2015-06-05 Thread Wesley
Hi Laura, Sure, I got special requirement that just parse html file into DOM tree, by only general basic modules, and based on my DOM tree structure, draft an bitmap. So, could you give me an direction how to get the DOM tree? Currently, I just think out to use something like stack, I mean, m

Re: Get html DOM tree by only basic builtin moudles

2015-06-04 Thread Laura Creighton
Elementtree is part of the Python standard library. You are better off using it than rolling your own. (If you were one of the rare people who have some very strange requirements that make you better off writing your own, you wouldn't be asking us. You'd already know.) https://docs.python.org/

Re: Get nesting of regex groups

2015-04-09 Thread Mattias Ugelvik
(sorry if I'm spamming the mailing list, my reply didn't seem to show up in the archive) I'm making a 'declarative string manipulation' tool, the interface of which should work like this: >>> rules(r'(?P(?Pa?))(?Pb?)', { ... 'separate': '.suffix', ... 'inner': 'abc', ... 'outer': lambda str

Re: Get nesting of regex groups

2015-04-09 Thread Mattias Ugelvik
I'm making a 'declarative string manipulation' tool, the interface of which should work like this: >>> rules(r'(?P(?Pa?))(?Pb?)', { ... 'separate': '.suffix', ... 'inner': 'abc', ... 'outer': lambda string: 'some-{}-manipulation'.format(string) ... }).apply('a') 'some-abc-manipulation.suffix

Re: Get nesting of regex groups

2015-04-08 Thread Cameron Simpson
On 08Apr2015 21:30, Denis McMahon wrote: On Wed, 08 Apr 2015 22:54:57 +0200, Mattias Ugelvik wrote: Example: re.compile('(?P(?Pa))') How can I detect that 'inner' is a nested group of 'outer'? I know that 'inner' comes later, because I can use the `regex.groupindex` (thanks to your help earli

Re: Get nesting of regex groups

2015-04-08 Thread Denis McMahon
On Wed, 08 Apr 2015 22:54:57 +0200, Mattias Ugelvik wrote: > Example: re.compile('(?P(?Pa))') > > How can I detect that 'inner' is a nested group of 'outer'? I know that > 'inner' comes later, because I can use the `regex.groupindex` (thanks to > your help earlier: > https://mail.python.org/piper

Re: Get the numbering of named regex groups

2015-04-08 Thread MRAB
On 2015-04-08 15:28, Peter Otten wrote: Mattias Ugelvik wrote: Example: re.match('(?Pa?)(?Pb?)', '') How can I find out that the group 'first' correlates to the positional regex group 1? I need to know this to resolve crucial ambiguities in a string manipulation tool I'm making. Looking at spa

Re: Get the numbering of named regex groups

2015-04-08 Thread Mattias Ugelvik
Thank god it's that easy! Err, I mean, thank you! I should have read the docs more carefully :) On 08/04/2015, Peter Otten <__pete...@web.de> wrote: > Mattias Ugelvik wrote: > >> Example: re.match('(?Pa?)(?Pb?)', '') >> >> How can I find out that the group 'first' correlates to the positional >> r

Re: Get the numbering of named regex groups

2015-04-08 Thread Peter Otten
Mattias Ugelvik wrote: > Example: re.match('(?Pa?)(?Pb?)', '') > > How can I find out that the group 'first' correlates to the positional > regex group 1? I need to know this to resolve crucial ambiguities in a > string manipulation tool I'm making. Looking at spans, as the example > above illust

Re: get the min date from a list

2014-08-15 Thread Ian Kelly
On Fri, Aug 15, 2014 at 12:21 PM, Denis McMahon wrote: > Output is a sorted list of the actual times and the UTC equivalents of > all the times in the original list. Note that I had to edit several > strings in your times list to ensure they were all in identical format: I > added leading 0s to nu

  1   2   3   4   5   6   7   8   >