Re: Standard class for time *period*?

2023-03-29 Thread Cameron Simpson
On 29Mar2023 08:17, Loris Bennett wrote: I am glad to hear that I am not alone :-) However, my use-case is fairly trivial, indeed less complicated than yours. So, in truth I don't really need a Period class. I just thought it might be a sufficiently generic itch that someone else with a more c

Re: Standard class for time *period*?

2023-03-29 Thread Cameron Simpson
On 30Mar2023 10:13, Cameron Simpson wrote: I do in fact have a `TimePartition` in my timeseries module; it presently doesn't do comparisons because I'm not comparing them - I'm just using them as slices into the timeseries data on the whole. https://github.com/cameron-simpson/css/blob/0ade6d1

Re: Standard class for time *period*?

2023-03-29 Thread Thomas Passin
On 3/29/2023 2:17 AM, Loris Bennett wrote: I am glad to hear that I am not alone :-) However, my use-case is fairly trivial, indeed less complicated than yours. So, in truth I don't really need a Period class. I just thought it might be a sufficiently generic itch that someone else with a more

Re: Standard class for time *period*?

2023-03-29 Thread Loris Bennett
Cameron Simpson writes: > On 28Mar2023 08:05, Dennis Lee Bieber wrote: >> So far, you seem to be the only person who has ever asked for >> asingle >>entity incorporating an EPOCH (datetime.datetime) + a DURATION >>(datetime.timedelta). > > But not the only person to want one. I've got a

Re: Standard class for time *period*?

2023-03-28 Thread Cameron Simpson
On 28Mar2023 08:05, Dennis Lee Bieber wrote: So far, you seem to be the only person who has ever asked for a single entity incorporating an EPOCH (datetime.datetime) + a DURATION (datetime.timedelta). But not the only person to want one. I've got a timeseries data format where (within a fi

Re: Standard class for time *period*?

2023-03-28 Thread dn via Python-list
1. Is there a standard class for a 'period', i.e. length of time specified by a start point and an end point? The start and end points could obviously be datetimes and the difference a timedelta, but the period '2022-03-01 00:00 to 2022-03-02 00:00' would be diff

Re: Standard class for time *period*?

2023-03-28 Thread Grant Edwards
rt would be defining those operations, and as the OP says, it doesn't seem to me like there is an obvious definition for many of them. If there's no obvious common definition for what a class is supposed to do, then there can't really be a standard one... -- Grant -- https://mail.python.org/mailman/listinfo/python-list

Re: Standard class for time *period*?

2023-03-28 Thread Thomas Passin
epoch, January 2022 is obviously different to January 2023, even thought the duration might be the same. I am just surprised that there is no standard Period class, with which I could create objects and then be able to sort, check for identity, equality of length, amount of overlap, etc. I suppose

Re: Standard class for time *period*?

2023-03-28 Thread Grant Edwards
On 2023-03-28, Dennis Lee Bieber wrote: > So far, you seem to be the only person who has ever asked for a > single entity incorporating an EPOCH (datetime.datetime) + a > DURATION (datetime.timedelta). It seems to me that tuple of two timdate objects (start,end) is the more obvious representatio

Aw: Re: Standard class for time *period*?

2023-03-28 Thread Karsten Hilbert
> No, it doesn't. I already know about timedelta. I must have explained > the issue badly, because everyone seems to be fixating on the > formatting, which is not a problem and is incidental to what I am really > interested in, namely: > > 1. Is there a standard class for

Re: Standard class for time *period*?

2023-03-28 Thread rbowman
On Tue, 28 Mar 2023 15:11:14 +0200, Loris Bennett wrote: > But even if I have a single epoch, January 2022 is obviously different > to January 2023, even thought the duration might be the same. I am just > surprised that there is no standard Period class, with which I could > create

Re: Standard class for time *period*?

2023-03-28 Thread Dennis Lee Bieber
idental to what I am really >interested in, namely: > >1. Is there a standard class for a 'period', i.e. length of time > specified by a start point and an end point? The start and end > points could obviously be datetimes and the difference a timedelta, > but the

Re: Standard class for time *period*?

2023-03-28 Thread Loris Bennett
edelta should give the OP exactly what he's talking > about. No, it doesn't. I already know about timedelta. I must have explained the issue badly, because everyone seems to be fixating on the formatting, which is not a problem and is incidental to what I am really interested in, namely:

Re: Standard class for time *period*?

2023-03-28 Thread Loris Bennett
gt;>formatting, which is not a problem and is incidental to what I am really >>interested in, namely: >> >>1. Is there a standard class for a 'period', i.e. length of time >> specified by a start point and an end point? The start and end >> points coul

Re: Standard class for time *period*?

2023-03-27 Thread Thomas Passin
On 3/27/2023 11:34 AM, rbowman wrote: On Mon, 27 Mar 2023 15:00:52 +0200, Loris Bennett wrote: I need to deal with what I call a 'period', which is a span of time limited by two dates, start and end. The period has a 'duration', which is the elapsed time between start and end. The d

Re: Standard class for time *period*?

2023-03-27 Thread Gary Herron
The Python standard library module datetime seems to be what you want.  It has objects representing date/times, and deltatimes (i.e., durations).  These can be timezone aware or not as you wish. Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology On 3/27/23 6:00 AM

Re: Standard class for time *period*?

2023-03-27 Thread rbowman
On Mon, 27 Mar 2023 15:00:52 +0200, Loris Bennett wrote: > I need to deal with what I call a 'period', which is a span of time > limited by two dates, start and end. The period has a 'duration', > which is the elapsed time between start and end. The duration is > essentially a number of

Re: Standard class for time *period*?

2023-03-27 Thread Loris Bennett
atetime_1 = datetime.strptime( '2023-03-27T14:27:23+01:00', format ) > > print( datetime_1 - datetime_0 ) > > sys.stdout > > 0:26:31 > > . Days will also be shown if greater than zero. Thanks for the examples, but I am not really interested in how to write a b

Standard class for time *period*?

2023-03-27 Thread Loris Bennett
s, I would generally want to display the duration in a format such as "dd-hh:mm:ss" My (possibly ill-founded) expectation: There is a standard class which encapsulates this sort of functionality. My (possibly insufficiently researched) conclusion: Such a standard class does not exis

Re: No solution for "--verbose" (on stdout) output in Pythonds standard library?

2023-01-04 Thread Richard Damon
o detailed here about that difference between stdout and stderr > because in the wild (e.g. on StackOverflow) you often find "use logging > log levels" as a solution for that problem, which IMHO isn't one. > > Now the question: > From my research on the docs it seems

Re: No solution for "--verbose" (on stdout) output in Pythonds standard library?

2023-01-04 Thread Eryk Sun
On 1/4/23, c.bu...@posteo.jp wrote: > > often seen "--verbose" switch in command line applications should > affect only the messages given to the users. This means messages on > "stdout". That is what this question is about. Is this additional context information such as help and definitions? If

Re: No solution for "--verbose" (on stdout) output in Pythonds standard library?

2023-01-04 Thread Weatherby,Gerard
ser.parse_args() logger = logging.getLogger(__name__) logger.setLevel(getattr(logging,args.loglevel)) From: Python-list on behalf of c.bu...@posteo.jp Date: Wednesday, January 4, 2023 at 8:55 AM To: python-list@python.org Subject: No solution for "--verbose" (on stdout) output in Pythonds sta

Re: No solution for "--verbose" (on stdout) output in Pythonds standard library?

2023-01-04 Thread Chris Angelico
On Thu, 5 Jan 2023 at 00:54, wrote: > > Hello, > > first I have to say that in my current and fresh humble opinion the > often seen "--verbose" switch in command line applications should > affect only the messages given to the users. This means messages on > "stdout". That is what this question is

No solution for "--verbose" (on stdout) output in Pythonds standard library?

2023-01-04 Thread c.buhtz
uot; as a solution for that problem, which IMHO isn't one. Now the question: >From my research on the docs it seems there is no feature in the standard library which could help me to implement "--verbose" or multiple verbosity levels like "-vvv"? I found some workar

Re: non-standard glibc location

2022-09-29 Thread Sandi Cimerman
> > https://mail.python.org/mailman/listinfo/python-list > > > > > -- > Psss, psss, put it down! - http://www.cafepress.com/putitdown First of all, thank you a lot Fetchinson, it helped on my system (Centos 6) to today recompile the newest Python (3.10.7)! Of course I

Re: Pip standard error warning about dependency resolver

2021-02-24 Thread Lars Liedtke
w resolver. > Is there a way to suppress it? We have some back end operations that fail > when we get output on standard error, and they're dying from that notice. -- --- punkt.de GmbH Lars Liedtke .infrastructure Kaiserallee 13a 76133 Karlsruhe Tel. +49 721 9109 500 https://infra

Pip standard error warning about dependency resolver

2021-02-23 Thread adam....@gmail.com
ere a way to suppress it? We have some back end operations that fail when we get output on standard error, and they're dying from that notice. -- https://mail.python.org/mailman/listinfo/python-list

Re: How python knows where non standard libraries are stored ?

2019-09-07 Thread Terry Reedy
On 9/7/2019 5:51 AM, ast wrote: 'C:\\Program Files\\Python36-32\\lib\\site-packages'] The last path is used as a location to store libraries you install yourself. If I am using a virtual environment (with venv) this last path is different 'C:\\Users\\jean-marc\\Desktop\\myenv\\lib\\site-packa

Re: How python knows where non standard libraries are stored ?

2019-09-07 Thread Eryk Sun
ipt directory. > 'C:\\Users\\jean-marc\\Desktop\\python', Probably this directory is in your %PYTHONPATH% environment variable, which gets inserted here, normally ahead of everything else except for the script directory. > 'C:\\Program Files\\Python36-32\\python36.zip',

Re: How python knows where non standard libraries are stored ?

2019-09-07 Thread dieter
ast writes: > I looked for windows environment variables to tell python > how to fill sys.path at startup but I didn't found. > > So how does it work ? Read the (so called) docstring at the beginning of the module "site.py". Either locate the module source in the file system and read it in an ed

How python knows where non standard libraries are stored ?

2019-09-07 Thread ast
Hello List sys.path contains all paths where python shall look for libraries. Eg on my system, here is the content of sys.path: >>> import sys >>> sys.path ['', 'C:\\Users\\jean-marc\\Desktop\\python', 'C:\\Program Files\\Python36-32\\python36.zip', 'C:\\Program Files\\Python36-32\\DLLs', 'C:\\

Re: how to generate a standard email form by default OS mail client?

2019-07-30 Thread Thomas Jollans
On 30/07/2019 10.06, dmitre...@gmail.com wrote: > Hello, > > is Python capable of generating a email form (from standard data - address, > topic, string message) with raising it by a default OS email client, e.g. > Thunderbird? User would like to have a possibility to revi

how to generate a standard email form by default OS mail client?

2019-07-30 Thread dmitrey15
Hello, is Python capable of generating a email form (from standard data - address, topic, string message) with raising it by a default OS email client, e.g. Thunderbird? User would like to have a possibility to review/modify email content inside the OS email client window before sending it

Re: Version numbers in Standard Library

2019-03-03 Thread Thomas Jollans
ewer version is needed". I searched on > conda, etc. and can't find it and finally realized that 2.4 meant Python > 2.4, not re 2.4. (The 3.7 docs have lines like "Changed in version 3.7".) > > My question to the pros here is what purpose do the __version__/version &

Re: Version numbers in Standard Library

2019-03-01 Thread Skip Montanaro
The point of the "Changed in version ..." or "New in version ..." bits in the documentation is to alert readers who maintain software which needs to remain backward compatible with older versions of Python. If you maintain a package which you support for Python 3.4, 3.5, 3.6, and 3.7, you'll probab

Version numbers in Standard Library

2019-03-01 Thread Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] via Python-list
;Changed in version 3.7".) My question to the pros here is what purpose do the __version__/version variables serve in the Python Standard Library? I can understand in external packages, but once in the Standard Library...? For example, in re.py, that line was last changed 18 years ag

Re: Path-like objects in the standard library

2018-08-24 Thread Terry Reedy
On 8/24/2018 5:28 AM, Paul Moore wrote: On Fri, 24 Aug 2018 at 09:57, Torsten Bronger wrote: Hallöchen! Path-like objects are accepted by all path-processing functions in the standard library since Python 3.6. Unfortunately, this is not made explicit everywhere. In particular, if I pass a

Re: Path-like objects in the standard library

2018-08-24 Thread Paul Moore
On Fri, 24 Aug 2018 at 09:57, Torsten Bronger wrote: > > Hallöchen! > > Path-like objects are accepted by all path-processing functions in > the standard library since Python 3.6. Unfortunately, this is not > made explicit everywhere. In particular, if I pass a Path in the &

Path-like objects in the standard library

2018-08-24 Thread Torsten Bronger
Hallöchen! Path-like objects are accepted by all path-processing functions in the standard library since Python 3.6. Unfortunately, this is not made explicit everywhere. In particular, if I pass a Path in the first argument of subprocess.run, do I use an implementation detail of CPython

Re: Python 3.6 fails to install to non-standard directory under Linux (Posting On Python-List Prohibited)

2018-03-02 Thread bsferrazza
On Friday, March 2, 2018 at 12:27:17 PM UTC-8, Lawrence D’Oliveiro wrote: > On Saturday, March 3, 2018 at 6:42:05 AM UTC+13, bsfer...@avnera.com wrote: > > > ... > > File "/nfs/home/myuser/lfs/sources/Python-3.6.4/Lib/shutil.py", line 476, > > in rmtree > > ... > > NFS trouble? > > I have had

Re: Python 3.6 fails to install to non-standard directory under Linux

2018-03-02 Thread bsferrazza
Here's my configure I need to set ac_cv_fun_utimensat=no and ac_cv_func_futimens=no because presumably the file-system or kernel on my system doesn't support nanosecond timestamps. With these options, and patching the configure/setup.py files to remove references to /usr/lib/ncursesw and replac

Python 3.6 fails to install to non-standard directory under Linux

2018-03-02 Thread bsferrazza
I posted this to Stackoverflow and the original post can be seen here. I'll try and copy and past the contents below. Thank you for your help! https://stackoverflow.com/questions/49074327/python-3-6-fails-to-install-to-non-standard-directory-under-linux I have a completely insulated boostr

Re: Vim, ctags jump to python standard library source

2017-10-30 Thread Cameron Simpson
On 19Oct2017 12:08, Matt Schepers wrote: I prefer to use vim and ctags when developing python, but I'm having trouble getting ctags to index the standard library. Sometimes I would like to see an object's constructor etc... Does anyone know how to do this? Will "ctags -o your-

Vim, ctags jump to python standard library source

2017-10-19 Thread Matt Schepers
I prefer to use vim and ctags when developing python, but I'm having trouble getting ctags to index the standard library. Sometimes I would like to see an object's constructor etc... Does anyone know how to do this? Thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: Standard for dict-contants with duplicate keys?

2017-09-15 Thread Tim Chase
On 2017-09-15 17:45, Terry Reedy wrote: > On 9/15/2017 3:36 PM, Tim Chase wrote: > >d = { > > "a": 0, > > "a": 1, > > "a": 2, > >} > > > > In my limited testing, it appears to always take the last one, > > resulting in > > > >{"a": 2} > > > > Is this guaranteed

Re: Standard for dict-contants with duplicate keys?

2017-09-15 Thread Serhiy Storchaka
16.09.17 00:45, Terry Reedy пише: On 9/15/2017 3:36 PM, Tim Chase wrote: Looking through docs, I was unable to tease out whether there's a prescribed behavior for the results of defining a dictionary with the same keys multiple times d = { "a": 0, "a": 1, "a": 2, }

Re: Standard for dict-contants with duplicate keys?

2017-09-15 Thread Peter Otten
Tim Chase wrote: > Looking through docs, I was unable to tease out whether there's a > prescribed behavior for the results of defining a dictionary with the > same keys multiple times > > d = { > "a": 0, > "a": 1, > "a": 2, > } > > In my limited testing, it appears to alwa

Re: Standard for dict-contants with duplicate keys?

2017-09-15 Thread Terry Reedy
On 9/15/2017 3:36 PM, Tim Chase wrote: Looking through docs, I was unable to tease out whether there's a prescribed behavior for the results of defining a dictionary with the same keys multiple times d = { "a": 0, "a": 1, "a": 2, } In my limited testing, it appears t

Standard for dict-contants with duplicate keys?

2017-09-15 Thread Tim Chase
Looking through docs, I was unable to tease out whether there's a prescribed behavior for the results of defining a dictionary with the same keys multiple times d = { "a": 0, "a": 1, "a": 2, } In my limited testing, it appears to always take the last one, resulting in {"

Re: non-standard glibc location

2017-09-07 Thread Fetchinson . via Python-list
On 9/7/17, Thomas Jollans wrote: > On 2017-09-06 16:14, Fetchinson . via Python-list wrote: >> Hi folks, >> >> I'm trying to install a binary package (tensorflow) which contains >> some binary C extensions. Now my system glibc is 2.15 but the binaries >> in the C extensions were created (apparentl

Re: non-standard glibc location

2017-09-07 Thread Thomas Jollans
On 2017-09-06 16:14, Fetchinson . via Python-list wrote: > Hi folks, > > I'm trying to install a binary package (tensorflow) which contains > some binary C extensions. Now my system glibc is 2.15 but the binaries > in the C extensions were created (apparently) with glibc 2.17. So I > thought no pr

Re: non-standard glibc location

2017-09-07 Thread dieter
"Fetchinson . via Python-list" writes: > I'm trying to install a binary package (tensorflow) which contains > some binary C extensions. Now my system glibc is 2.15 but the binaries > in the C extensions were created (apparently) with glibc 2.17. So I > thought no problemo I installed glibc 2.17 t

non-standard glibc location

2017-09-06 Thread Fetchinson . via Python-list
Hi folks, I'm trying to install a binary package (tensorflow) which contains some binary C extensions. Now my system glibc is 2.15 but the binaries in the C extensions were created (apparently) with glibc 2.17. So I thought no problemo I installed glibc 2.17 to a custom location, built python2.7 f

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-16 Thread Peter Otten
Andre Müller wrote: > # to impress your friends you can do > for chunk in itertools.zip_longest(*[iter(s)]*4): > chunked_str = ''.join(c for c in chunk if c) # generator expression > inside join with condition > print(chunked_str) This can be simplified with a fillvalue >>> s = "abracad

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-16 Thread Andre Müller
Am 15.06.2017 um 07:09 schrieb Jussi Piitulainen: > Andre Müller writes: > >> I'm a fan of infinite sequences. Try out itertools.islice. >> You should not underestimate this very important module. >> >> Please read also the documentation: >> https://docs.python.org/3.6/library/itertools.html >> >>

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Jussi Piitulainen
Andre Müller writes: > I'm a fan of infinite sequences. Try out itertools.islice. > You should not underestimate this very important module. > > Please read also the documentation: > https://docs.python.org/3.6/library/itertools.html > > from itertools import islice > > iterable = range(10

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Andre Müller
I'm a fan of infinite sequences. Try out itertools.islice. You should not underestimate this very important module. Please read also the documentation: https://docs.python.org/3.6/library/itertools.html from itertools import islice iterable = range(100) # since Python 3 range is a lazy e

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Malcolm Greene
Thank you Peter and Jussi - both your solutions were very helpful! Malcolm -- https://mail.python.org/mailman/listinfo/python-list

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Jussi Piitulainen
Malcolm Greene writes: > Wondering if there's a standard lib version of something like > enumerate() that takes a max count value? > Use case: When you want to enumerate through an iterable, but want to > limit the number of iterations without introducing if-condition-break

Re: Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Peter Otten
Malcolm Greene wrote: > Wondering if there's a standard lib version of something like > enumerate() that takes a max count value? > Use case: When you want to enumerate through an iterable, but want to > limit the number of iterations without introducing if-condition-break

Standard lib version of something like enumerate() that takes a max count iteration parameter?

2017-06-14 Thread Malcolm Greene
Wondering if there's a standard lib version of something like enumerate() that takes a max count value? Use case: When you want to enumerate through an iterable, but want to limit the number of iterations without introducing if-condition-break blocks in code. Something like: for counter, k

Re: Discover all non-standard library modules imported by a script

2016-09-16 Thread Malcolm Greene
Thanks for your suggestions Chris and Terry. The answer I was looking for is the modulefinder module which is part of the standard lib. Works like a charm! Quote: This module provides a ModuleFinder class that can be used to determine the set of modules imported by a script. modulefinder.py can

Re: Discover all non-standard library modules imported by a script

2016-09-16 Thread Terry Reedy
On 9/16/2016 7:29 AM, Malcolm Greene wrote: Looking for suggestions on how, given a main script, discover all the non-standard library modules imported across all modules, eg. the modules that other modules import, etc. I'm not looking to discover dynamic imports or other edge cases, jus

Re: Discover all non-standard library modules imported by a script

2016-09-16 Thread Chris Angelico
On Fri, Sep 16, 2016 at 9:29 PM, Malcolm Greene wrote: > Looking for suggestions on how, given a main script, discover all the > non-standard library modules imported across all modules, eg. the > modules that other modules import, etc. I'm not looking to discover > dynamic impo

Discover all non-standard library modules imported by a script

2016-09-16 Thread Malcolm Greene
Looking for suggestions on how, given a main script, discover all the non-standard library modules imported across all modules, eg. the modules that other modules import, etc. I'm not looking to discover dynamic imports or other edge cases, just the list modules loaded via "import &

Re: __qualname__ exposed as a local variable: standard?

2016-07-09 Thread eryk sun
On Sat, Jul 9, 2016 at 4:08 AM, wrote: > > I noticed __qualname__ is exposed by locals() while defining a class. This is an undocumented implementation detail used to pass this information to the metaclass. You'll also see __module__ and, if the class has a docstring, __doc__. For CPython, this

__qualname__ exposed as a local variable: standard?

2016-07-09 Thread carlosjosepita
Hi all, I noticed __qualname__ is exposed by locals() while defining a class. This is handy but I'm not sure about its status: is it standard or just an artifact of the current implementation? (btw, the pycodestyle linter -former pep8- rejects its usage). I was unable to find any referen

Re: Contradictory error messages in Python 3.4 - standard library issue!

2016-06-17 Thread Peter Otten
r, not bytes > Undaunted, I changed the error on line 409. The line then read: > > if first.startswith(BOM_UTF8): As Steven says -- don't change the standard library. Your problem is likely that you are opening the file containing the code you want to tokenize in text mode. Compare:

Re: Contradictory error messages in Python 3.4 - standard library issue!

2016-06-16 Thread Steven D'Aprano
; if first.startswith(BOM_UTF8): I'm not seeing any actual difference between the before and after: if first.startswith(BOM_UTF8): if first.startswith(BOM_UTF8): but in another email, you state that you changed it to: if first.startswith('BOM_UTF8'): Changing the

Re: Re - Contradictory error messages in Python 3.4 - standard library issue!

2016-06-16 Thread Matt Wheeler
On Thu, 16 Jun 2016, 23:31 Harrison Chudleigh, < harrison.chudlei...@education.nsw.gov.au> wrote: > Sorry! I was trying to indent a line and accidentally sent only half of the > message. > It would be helpful if your reply was actually a reply to your previous message, to enable us to follow the

Re: Re - Contradictory error messages in Python 3.4 - standard library issue!

2016-06-16 Thread Ned Batchelder
ize.py", > line 409, in detect_encoding > if first.startswith('BOM_UTF8'): > TypeError: startswith first arg must be bytes or a tuple of bytes, not str. > So, first the interpreter says startswith() takes strings, now it says it > takes bytes? What should the module be doing

Re - Contradictory error messages in Python 3.4 - standard library issue!

2016-06-16 Thread Harrison Chudleigh
a tuple of bytes, not str. So, first the interpreter says startswith() takes strings, now it says it takes bytes? What should the module be doing? This is an error with the standard library of Python 3.4.1, Mac OS X. *** Th

Contradictory error messages in Python 3.4 - standard library issue!

2016-06-16 Thread Harrison Chudleigh
While working on a program, I ran into an error with the usage of the module tokenize. The following message was displayed. File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py", line 467, in tokenize encoding, consumed = detect_encoding(readline) File "/Library/

Re: modifying a standard module?

2016-02-12 Thread Paul Rubin
Ulli Horlacher writes: >> tarfile.TarFile.extractall = new_extractall > > This is more easy than I could imagined :-) It is in my Python notes, > now. This is called "duck punching" or "monkey patching" and sometimes it's necessary, but it's something of an antipattern since the module could chan

Re: modifying a standard module?

2016-02-12 Thread Ulli Horlacher
Matt Wheeler wrote: > > How can I substitute the standard module function tarfile.extractall() with > > my own function? > > import tarfile > def new_extractall(self, *args, **kwargs): > print("I am a function. Woohoo!") > > tarfile.TarFile.extrac

Re: modifying a standard module? (was: Re: tarfile : read from a socket?)

2016-02-12 Thread Matt Wheeler
On 11 February 2016 at 17:10, Ulli Horlacher wrote: > > Ulli Horlacher wrote: > As a hack, I modified the standard library module tarfile.py: > > root@diaspora:/usr/lib/python2.7# vv -d > --- ./.versions/tarfile.py~1~ 2015-06-22 21:59:27.0 +0200 > +++ tarfile

modifying a standard module? (was: Re: tarfile : read from a socket?)

2016-02-11 Thread Ulli Horlacher
ckwards is not allowed") > > Of course, a stream is not seekable. > > Any ideas? As a hack, I modified the standard library module tarfile.py: root@diaspora:/usr/lib/python2.7# vv -d --- ./.versions/tarfile.py~1~ 2015-06-22 21:59:27.0 +0200 +++ tarfile.py 2016-02-11 18

Re: looking for standard/builtin dict-like data object

2015-08-11 Thread Chris Angelico
your handmade solution, but call it SimpleNamespace, and make it entirely compatible with the Python 3.3 one. Then, when you do get a chance to upgrade, all you need to do is change your import statement, and you're using the standard library one. Plus, it's going to be easy for anyone

Re: looking for standard/builtin dict-like data object

2015-08-11 Thread Vladimir Ignatov
>>> I also thought the stdlib had some kind of "namespace" class with this >>> kind >>> of API, but I can't find it now:-( >> >> >> It does - types.SimpleNamespace(). It accepts keyword arguments, and >> will let you create more attributes on the fly (unlike a namedtuple). > > > Yes, that's it. Tha

Re: looking for standard/builtin dict-like data object

2015-08-10 Thread Cameron Simpson
On 11Aug2015 14:09, Chris Angelico wrote: On Tue, Aug 11, 2015 at 1:40 PM, Cameron Simpson wrote: I also thought the stdlib had some kind of "namespace" class with this kind of API, but I can't find it now:-( It does - types.SimpleNamespace(). It accepts keyword arguments, and will let you c

Re: looking for standard/builtin dict-like data object

2015-08-10 Thread Chris Angelico
On Tue, Aug 11, 2015 at 1:40 PM, Cameron Simpson wrote: > I also thought the stdlib had some kind of "namespace" class with this kind > of API, but I can't find it now:-( It does - types.SimpleNamespace(). It accepts keyword arguments, and will let you create more attributes on the fly (unlike a

Re: looking for standard/builtin dict-like data object

2015-08-10 Thread Cameron Simpson
ot a base class called "O" like that: https://pypi.python.org/pypi/cs.obj/ I am curious if anybody knows similar "dummy" class located in standard libraries? I'd be glad to use it instead. namedtuple initialises and accesses like that: >>> from collections import

Re: looking for standard/builtin dict-like data object

2015-08-10 Thread Chris Rebert
class > around my projects and import its module in every code producing data. > > I am curious if anybody knows similar "dummy" class located in > standard libraries? I'd be glad to use it instead. This is commonly known as a "Bunch" class, after the Python C

looking for standard/builtin dict-like data object

2015-08-10 Thread Vladimir Ignatov
ot; class located in standard libraries? I'd be glad to use it instead. Thanks, Vladimir https://itunes.apple.com/us/app/python-code-samples/id1025613117 -- https://mail.python.org/mailman/listinfo/python-list

Test doubles for Python standard library HTTP classes

2015-08-06 Thread Ben Finney
Howdy all, What standard Python library is there to make test doubles of ‘httplib.HTTPConnection’ and ‘urllib2.HTTPBasicAuthHandler’ and so on? I have a code base (Python 2 code) which performs HTTP sessions using the various HTTP-level classes in the standard library. Testing this code will be

EuroPython 2015: Standard rates deadline extended

2015-06-26 Thread M.-A. Lemburg
-07-05, 23:59:59 CEST and still benefit from our Standard Rates: * Student: 120 EUR * Personal: 340 EUR * Business: 530 EUR (all incl. 10% Spanish VAT) Social Event Please also remember to book your Social Event Ticket. The price for this, EUR 40, won’t change, but we only have

Re: Relation: a new standard (PEP) container?

2015-06-20 Thread Ned Batchelder
been waiting for many years (decades actually) to have this concept > incorporated as a standard container in one of the modern programming > languages so we could swap our code with a language-standard container.  To > further these efforts, we have decided to initiate a conversation wit

Relation: a new standard (PEP) container?

2015-06-19 Thread Scott
We've been using a simple container implementation of a mathematical relation (https://simple.wikipedia.org/wiki/Relation_(mathematics)) (i.e. an invertible M:M mapping) for some time. We've been waiting for many years (decades actually) to have this concept incorporated as a standard

EuroPython 2015: Announcing standard ticket prices

2015-03-10 Thread M.-A. Lemburg
us to set the standard ticket prices for this year. We tried to keep student prices as low as possible, since we would like to see more students at the conference: Student: EUR 120.00 Personal: EUR 340.00 Business: EUR 530.00 (incl. 10% Spanish VAT) Early-bird tickets are nearly

Re: Standard

2015-02-23 Thread jkn
On Sunday, 22 February 2015 14:11:54 UTC, Mark Lawrence wrote: > On 19/02/2015 16:27, Phillip Fleming wrote: > > In my opinion, Python will not take off like C/C++ if there is no ANSI > > standard. > > > > Python has already taken off because it doesn't hav

Re: Standard

2015-02-22 Thread Steven D'Aprano
Skip Montanaro wrote: > On Thu, Feb 19, 2015 at 10:27 AM, Phillip Fleming > wrote: >> In my opinion, Python will not take off like C/C++ if there is no ANSI >> standard. > > On one side of your statement, what makes you think Python ever wanted > to "take of

Re: Standard

2015-02-22 Thread Mark Lawrence
On 19/02/2015 16:27, Phillip Fleming wrote: In my opinion, Python will not take off like C/C++ if there is no ANSI standard. Python has already taken off because it doesn't have a standard as such. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can d

Re: Standard

2015-02-22 Thread Skip Montanaro
On Thu, Feb 19, 2015 at 10:27 AM, Phillip Fleming wrote: > In my opinion, Python will not take off like C/C++ if there is no ANSI > standard. On one side of your statement, what makes you think Python ever wanted to "take off like C/C++"? On the other side, there are other lang

Standard

2015-02-22 Thread Phillip Fleming
In my opinion, Python will not take off like C/C++ if there is no ANSI standard. -- https://mail.python.org/mailman/listinfo/python-list

Re: how to parse standard algebraic notation

2014-10-01 Thread Chris Angelico
On Thu, Oct 2, 2014 at 2:45 AM, Steven D'Aprano wrote: > Code for evaluating mathematical expressions are very common, if you google > for "expression parser" I am sure you will find many examples. Don't limit > yourself to Python code, you can learn from code written in other languages > too, e.g

Re: how to parse standard algebraic notation

2014-10-01 Thread Steven D'Aprano
math math wrote: > Hi, > > I am trying to learn Python while solving exercises. > > I want to basically write a program that inputs a polynomial in standard > algebraic notation and outputs its derivative. > > I know that I need to get the exponent somehow,

Re: how to parse standard algebraic notation

2014-10-01 Thread Marco Buttu
On 01/10/2014 09:01, math math wrote: What would be a good starting strategy for writing a program to take the derivative of a polynomial expression, such as this below?: "x**3 + x**2 + x + 1" You can look at sympy: >>> from sympy import * >>> equation = simplify("x**3 + x**2 + x + 1") >>> e

Re: how to parse standard algebraic notation

2014-10-01 Thread Marco Buttu
On 01/10/2014 09:01, math math wrote: What would be a good starting strategy for writing a program to take the derivative of a polynomial expression, such as this below?: "x**3 + x**2 + x + 1" You can look at sympy: >>> from sympy import * >>> equation = simplify("x**3 + x**2 + x + 1") >>> eq

Re: how to parse standard algebraic notation

2014-10-01 Thread math math
Thanks a lot, I will give this a shot. -- https://mail.python.org/mailman/listinfo/python-list

Re: how to parse standard algebraic notation

2014-10-01 Thread Chris Angelico
On Wed, Oct 1, 2014 at 5:01 PM, math math wrote: > What would be a good starting strategy for writing a program to take the > derivative of a polynomial expression, such as this below?: > "x**3 + x**2 + x + 1" > > I am a bit confused about my overall strategy. Should one be writing a parser > cl

  1   2   3   4   5   6   7   8   9   10   >