RE: extend behaviour of assignment operator

2024-01-19 Thread AVI GROSS via Python-list
change the language so it pays attention to what it is giving a pointer too and then goes and tells ... -Original Message- From: Python-list On Behalf Of Guenther Sohler via Python-list Sent: Tuesday, January 9, 2024 2:15 AM To: python-list@python.org Subject: extend behaviour of assign

Re: extend behaviour of assignment operator

2024-01-10 Thread Dieter Maurer via Python-list
Guenther Sohler wrote at 2024-1-9 08:14 +0100: >when i run this code > >a = cube([10,1,1]) >b = a > >i'd like to extend the behaviour of the assignment operator >a shall not only contain the cube, but the cube shall also know which >variable name it >was assigned

extend behaviour of assignment operator

2024-01-10 Thread Guenther Sohler via Python-list
Hi, when i run this code a = cube([10,1,1]) b = a i'd like to extend the behaviour of the assignment operator a shall not only contain the cube, but the cube shall also know which variable name it was assigned to, lately. I'd like to use that for improved user interaction. effe

Re: Techniques to extend code without modifying it? (besides modules and decorators)

2020-05-01 Thread Christian Seberino
Paul Thanks! I'm glad there is theory about my concern. I knew I wasn't the only one with that question. cs > > https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle > > Also: > > https://en.wikipedia.org/wiki/Expression_problem -- https://mail.python.org/mailman/listinfo/python-lis

Re: Techniques to extend code without modifying it? (besides modules and decorators)

2020-04-29 Thread Christian Seberino
> > a pattern like: > if : > elif : > > Thanks. I really like this simple yet powerful suggestion you made. See this... import new_code ... if foo: new_code.do_new_stuff(..) We can massively modify existing code by *ONLY* adding one import and a 2 line if snippet!!! Very nice! cs -

Re: Techniques to extend code without modifying it? (besides modules and decorators)

2020-04-29 Thread Christian Seberino
If you want to know, I'm trying to add metaprogramming (macros!) to a tiny Lisp interpreter I wrote. I'm hesitant to mess with all that nice debugged code to add this new stuff. -- https://mail.python.org/mailman/listinfo/python-list

Techniques to extend code without modifying it? (besides modules and decorators)

2020-04-29 Thread Christian Seberino
I have some code I'd like to extend without modifying it. I'm sure this is a common pattern. I wondered what the options were for "extending without modifying (much)". I'm aware one can import a module and add functions to decorators. Are there other ways?

Re: How to extend an object?

2019-12-20 Thread DL Neil via Python-list
On 21/12/19 2:50 pm, Greg Ewing wrote: On 21/12/19 1:59 am, Stefan Ram wrote:    I would like to add a method to a string.    This is not possible in Python? It's not possible. Built-in classes can't have methods added to them. You can define your own subclass of str and give it whatever met

Re: How to extend an object?

2019-12-20 Thread Greg Ewing
On 21/12/19 1:59 am, Stefan Ram wrote: I would like to add a method to a string. This is not possible in Python? It's not possible. Built-in classes can't have methods added to them. You can define your own subclass of str and give it whatever methods you want. But in your case: for

Re: Extend NTFS with "version" of file and "version" of folder, also optionally GIT integration or something like it.

2018-11-19 Thread skybuck2000
Described also as: (Versioning System Integration with Windows Explorer) Anyway Googling NTFS and GIT turned up this: https://blogs.msdn.microsoft.com/devops/2017/02/03/announcing-gvfs-git-virtual-file-system/ The objective of this project seems to be a bit different. To handle very large pr

Re: Extend NTFS with "version" of file and "version" of folder, also optionally GIT integration or something like it.

2018-11-19 Thread Rhodri James
On 19/11/2018 16:42, skybuck2...@hotmail.com wrote: As far as I know currently NTFS is missing a key feature for code development and compare: "versioning information" per file and per folder. While I appreciate your desire for Files-11 (the OpenVMS filing system), I'm struggling to see how t

Re: Extend NTFS with "version" of file and "version" of folder, also optionally GIT integration or something like it.

2018-11-19 Thread Ethan Furman
On 11/19/2018 08:42 AM, skybuck2...@hotmail.com wrote: As far as I know currently NTFS is missing a key feature for code development and compare: "versioning information" per file and per folder. This is not a mailing list for the purpose of discussing Microsoft Windows enhancements. How i

Extend NTFS with "version" of file and "version" of folder, also optionally GIT integration or something like it.

2018-11-19 Thread skybuck2000
As far as I know currently NTFS is missing a key feature for code development and compare: "versioning information" per file and per folder. This sucks badly. Currently I have files as follows: folder version 0.01\ some_source_code_file_version_1.pas some_other_source_code_file_version1.pas an

Re: How to extend a tuple of tuples?

2016-09-13 Thread Thomas 'PointedEars' Lahn
John Gordon wrote: > […] Thomas 'PointedEars' Lahn […] writes: It is supposed to be an attribution *line*, _not_ an attribution novel. >> >> The obvious way does not work - >> >> >> >> a += (5, 6) >> ^^ >> > Right, because a tuple is immutable. > >> How did you get that

Re: How to extend a tuple of tuples?

2016-09-13 Thread Random832
On Mon, Sep 12, 2016, at 17:29, Chris Angelico wrote: > old_id = id(a) > a += something > if id(a) == old_id: > print("We may have an optimization, folks!") > > But that can have false positives. If two objects do not concurrently > exist, they're allowed to have the same ID number. But the t

Re: How to extend a tuple of tuples?

2016-09-13 Thread Sibylle Koczian
Am 13.09.2016 um 12:09 schrieb Chris Angelico: On Tue, Sep 13, 2016 at 8:01 PM, Antoon Pardon wrote: Then python seems to be broken: ]]] a = range(3) ]]] old_a = a ]]] a += [8, 13] ]]] id(a), id(old_a) (140062018784792, 140062018784792) ]]] a, old_a ([0, 1, 2, 8, 13], [0, 1, 2, 8, 13]) A r

Re: How to extend a tuple of tuples?

2016-09-13 Thread Chris Angelico
On Tue, Sep 13, 2016 at 8:01 PM, Antoon Pardon wrote: >>> You could do the following: >>> >>> old_a = a >>> a += something >>> if old_a is a: >>> print("We have an optimization, folks!") >>> >> Uhm... that defeats the whole point of it being an optimization. See >> above, "there are no other r

Re: How to extend a tuple of tuples?

2016-09-13 Thread Antoon Pardon
Op 13-09-16 om 11:27 schreef Chris Angelico: > On Tue, Sep 13, 2016 at 5:25 PM, Antoon Pardon > wrote: >> Op 12-09-16 om 23:29 schreef Chris Angelico: >>> On Tue, Sep 13, 2016 at 7:19 AM, BartC wrote: By the same argument, then strings and ints are also mutable. Here, the original

Re: How to extend a tuple of tuples?

2016-09-13 Thread Chris Angelico
On Tue, Sep 13, 2016 at 5:25 PM, Antoon Pardon wrote: > Op 12-09-16 om 23:29 schreef Chris Angelico: >> On Tue, Sep 13, 2016 at 7:19 AM, BartC wrote: >>> By the same argument, then strings and ints are also mutable. >>> >>> Here, the original tuple that a refers to has been /replaced/ by a new on

Re: How to extend a tuple of tuples?

2016-09-13 Thread Antoon Pardon
Op 12-09-16 om 23:29 schreef Chris Angelico: > On Tue, Sep 13, 2016 at 7:19 AM, BartC wrote: >> By the same argument, then strings and ints are also mutable. >> >> Here, the original tuple that a refers to has been /replaced/ by a new one. >> The original is unchanged. (Unless, by some optimisatio

Re: How to extend a tuple of tuples?

2016-09-12 Thread Ned Batchelder
On Monday, September 12, 2016 at 4:31:37 PM UTC-4, Thomas 'PointedEars' Lahn wrote: > Ben Finney wrote: > > So instead, you want a different tuple. You do that by creating it, > > explicitly constructing a new sequence with the items you want:: > > > > b = tuple([ > > item for ite

Re: How to extend a tuple of tuples?

2016-09-12 Thread Chris Angelico
On Tue, Sep 13, 2016 at 7:19 AM, BartC wrote: > By the same argument, then strings and ints are also mutable. > > Here, the original tuple that a refers to has been /replaced/ by a new one. > The original is unchanged. (Unless, by some optimisation that recognises > that there are no other referen

Re: How to extend a tuple of tuples?

2016-09-12 Thread BartC
On 12/09/2016 21:31, Thomas 'PointedEars' Lahn wrote: Ben Finney wrote: "Frank Millman" writes: Assume you have a tuple of tuples - a = ((1, 2), (3, 4)) You want to add a new tuple to it, so that it becomes As you acknowledge, the tuple ‘a’ can't become anything else. Instead, you need to

Re: How to extend a tuple of tuples?

2016-09-12 Thread John Gordon
In <2349538.mvxudi8...@pointedears.de> Thomas 'PointedEars' Lahn writes: > >> The obvious way does not work - > >> > >> a += (5, 6) > ^^ > > Right, because a tuple is immutable. > How did you get that idea? It has been mutated in the very statement that > you are quot

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-10 Thread Rustom Mody
On Saturday, September 10, 2016 at 3:56:37 PM UTC+5:30, Veek 'this_is_not_my_name' M wrote: > Veek 'this_is_not_my_name' M wrote: Recursion… Self-Reference…Inversion Heh! On the way to becoming another Gödel/Turing?? You may be interested in this collection of some evidence(s) of recursion bei

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-10 Thread Tim Golden
On 10/09/2016 11:26, Veek 'this_is_not_my_name' M wrote: Veek 'this_is_not_my_name' M wrote: /me claps TJG -- https://mail.python.org/mailman/listinfo/python-list

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-10 Thread Veek 'this_is_not_my_name' M
Veek 'this_is_not_my_name' M wrote: > Rustom Mody wrote: > >> On Saturday, September 3, 2016 at 5:25:48 PM UTC+5:30, Veek. M wrote: >>> https://mail.python.org/pipermail//python-ideas/2014-October/029630.htm >>> >>> Wanted to know if the above link idea, had been implemented and if >>> there's a

Re: How to extend a tuple of tuples?

2016-09-09 Thread Lawrence D’Oliveiro
On Saturday, September 10, 2016 at 12:21:48 AM UTC+12, Frank Millman wrote: > The short answer is that I am using it as a dictionary key. Another option is, if it takes several steps to construct the tuple, to build it incrementally as a list and then cast it to a tuple. -- https://mail.python.o

Re: How to extend a tuple of tuples?

2016-09-09 Thread Rustom Mody
On Friday, September 9, 2016 at 5:58:16 PM UTC+5:30, Chris Angelico wrote: > On Fri, Sep 9, 2016 at 10:21 PM, Frank Millman wrote: > > I am building a series of JOINs for a SQL statement. Some of them can be > > nested - table A is joined from table B is joined from table C. In other > > parts of t

Re: How to extend a tuple of tuples?

2016-09-09 Thread Chris Angelico
On Fri, Sep 9, 2016 at 10:21 PM, Frank Millman wrote: > I am building a series of JOINs for a SQL statement. Some of them can be > nested - table A is joined from table B is joined from table C. In other > parts of the same SQL statement, table A could be joined from table D which > is joined from

Re: How to extend a tuple of tuples?

2016-09-09 Thread Frank Millman
"Ned Batchelder" wrote in message news:44e067ce-f499-4ca8-87bd-94b18dfc0...@googlegroups.com... On Friday, September 9, 2016 at 6:13:37 AM UTC-4, Frank Millman wrote: > "Frank Millman" wrote in message news:nqtlue$unj$1...@blaine.gmane.org... > > The one I was looking for was > > a += (5,

Re: How to extend a tuple of tuples?

2016-09-09 Thread Ned Batchelder
On Friday, September 9, 2016 at 6:13:37 AM UTC-4, Frank Millman wrote: > "Frank Millman" wrote in message news:nqtlue$unj$1...@blaine.gmane.org... > > > Assume you have a tuple of tuples - > > > a = ((1, 2), (3, 4)) > > > You want to add a new tuple to it, so that it becomes - > > > ((1,

Re: How to extend a tuple of tuples?

2016-09-09 Thread Frank Millman
"Frank Millman" wrote in message news:nqtlue$unj$1...@blaine.gmane.org... Assume you have a tuple of tuples - a = ((1, 2), (3, 4)) You want to add a new tuple to it, so that it becomes - ((1, 2), (3, 4), (5, 6)) Thanks all. The one I was looking for was a += (5, 6), I und

Re: How to extend a tuple of tuples?

2016-09-09 Thread Steve D'Aprano
On Fri, 9 Sep 2016 04:47 pm, Frank Millman wrote: > Hi all > > This should be easy, but I cannot figure it out. > > Assume you have a tuple of tuples - > > a = ((1, 2), (3, 4)) > > You want to add a new tuple to it, so that it becomes - > > ((1, 2), (3, 4), (5, 6)) a = a + ((5, 6),) Y

Re: How to extend a tuple of tuples?

2016-09-09 Thread Jussi Piitulainen
Ben Finney writes: > Frank Millman writes: > >> Assume you have a tuple of tuples - >> >> a = ((1, 2), (3, 4)) >> >> You want to add a new tuple to it, so that it becomes > > As you acknowledge, the tuple ‘a’ can't become anything else. Instead, > you need to create a different value. > >> The obv

Re: How to extend a tuple of tuples?

2016-09-09 Thread Ben Finney
"Frank Millman" writes: > Assume you have a tuple of tuples - > > a = ((1, 2), (3, 4)) > > You want to add a new tuple to it, so that it becomes As you acknowledge, the tuple ‘a’ can't become anything else. Instead, you need to create a different value. > The obvious way does not work - > > a +

Re: How to extend a tuple of tuples?

2016-09-09 Thread Rustom Mody
On Friday, September 9, 2016 at 12:18:24 PM UTC+5:30, Frank Millman wrote: > Hi all > > This should be easy, but I cannot figure it out. > > Assume you have a tuple of tuples - > > a = ((1, 2), (3, 4)) > > You want to add a new tuple to it, so that it becomes - > > ((1, 2), (3, 4), (5, 6))

Re: How to extend a tuple of tuples?

2016-09-09 Thread dieter
"Frank Millman" writes: > Hi all > > This should be easy, but I cannot figure it out. > > Assume you have a tuple of tuples - > > a = ((1, 2), (3, 4)) > > You want to add a new tuple to it, so that it becomes - > >((1, 2), (3, 4), (5, 6)) > > The obvious way does not work - > > a += (5, 6) >

How to extend a tuple of tuples?

2016-09-08 Thread Frank Millman
Hi all This should be easy, but I cannot figure it out. Assume you have a tuple of tuples - a = ((1, 2), (3, 4)) You want to add a new tuple to it, so that it becomes - ((1, 2), (3, 4), (5, 6)) The obvious way does not work - a += (5, 6) ((1, 2), (3, 4), 5, 6) I have discovered that

Re: Extend unicodedata with a name/pattern/regex search for character

2016-09-06 Thread jladasky
From: jlada...@itu.edu On Saturday, September 3, 2016 at 7:49:14 PM UTC-7, Steve D'Aprano wrote: > On Sun, 4 Sep 2016 12:19 pm, Chris Angelico wrote: > > Killfile him and move on... > > But but but... I couldn't do that. > > https://www.xkcd.com/386/ I strongly suspected it would be that particu

Re: Extend unicodedata with a name/pattern/regex search for character

2016-09-06 Thread jladasky
On Saturday, September 3, 2016 at 7:49:14 PM UTC-7, Steve D'Aprano wrote: > On Sun, 4 Sep 2016 12:19 pm, Chris Angelico wrote: > > Killfile him and move on... > > But but but... I couldn't do that. > > https://www.xkcd.com/386/ I strongly suspected it would be that particular XKCD. :^) -- http

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-06 Thread jladasky
On Saturday, September 3, 2016 at 7:49:14 PM UTC-7, Steve D'Aprano wrote: > On Sun, 4 Sep 2016 12:19 pm, Chris Angelico wrote: > > Killfile him and move on... > > But but but... I couldn't do that. > > https://www.xkcd.com/386/ I strongly suspected it would be that particular XKCD. :^) -- htt

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-06 Thread Veek 'this_is_not_my_name' M
Rustom Mody wrote: > On Saturday, September 3, 2016 at 5:25:48 PM UTC+5:30, Veek. M wrote: >> https://mail.python.org/pipermail//python-ideas/2014-October/029630.htm >> >> Wanted to know if the above link idea, had been implemented and if >> there's a module that accepts a pattern like 'cap' and

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-05 Thread Ned Batchelder
On Monday, September 5, 2016 at 2:15:58 AM UTC-4, Thomas 'PointedEars' Lahn wrote: > How can I trust a person > who does not even have the decency and the courage to stand by their > statements with their real name? Feel free to ignore people you don't trust. We'll help them. --Ned. -- https

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-05 Thread alister
On Mon, 05 Sep 2016 08:15:42 +0200, Thomas 'PointedEars' Lahn wrote: > >> So Veek should be able to appease P.E. by calling himself 'Veek "David >> Smith" M'. > > That would not help. “Veek” might be (the transcription of) a given > name or a family name, but “Veek M” is not a real name. [Real

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-05 Thread Veek. M
Thomas 'PointedEars' Lahn wrote: > Gregory Ewing wrote: > >> Larry Hudson wrote: >>> If you continue to read this forum, you will quickly learn to ignore >>> "Pointy-Ears". He rarely has anything worth while to post, and his >>> unique fetish about Real Names shows him to be a hypocrite as well.

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Michael Torrie
On 09/04/2016 04:22 PM, Gregory Ewing wrote: > Larry Hudson wrote: >> If you continue to read this forum, you will quickly learn to ignore >> "Pointy-Ears". He rarely has anything worth while to post, and his >> unique fetish about Real Names shows him to be a hypocrite as well. > > To be fair,

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Ned Batchelder
On Sunday, September 4, 2016 at 7:52:44 PM UTC-4, Chris Angelico wrote: > FWIW, hex is much more common for displaying Unicode codepoints than > decimal is. So I'd print it like this (incorporating the 'not CAPITAL' > filter): You are right, I went too quickly, and didn't realize until after I pos

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Chris Angelico
On Mon, Sep 5, 2016 at 9:40 AM, Ned Batchelder wrote: > But, 'CAP' appears in 'CAPITAL', which gives more than 1800 matches: > > >>> for c in range(32, 0x11): > ... try: > ... name = unicodedata.name(chr(c)) > ... except ValueError: > ... continue > ... if

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Ned Batchelder
On Saturday, September 3, 2016 at 7:55:48 AM UTC-4, Veek. M wrote: > https://mail.python.org/pipermail//python-ideas/2014-October/029630.htm > > Wanted to know if the above link idea, had been implemented and if > there's a module that accepts a pattern like 'cap' and give you all the > instance

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Gregory Ewing
Larry Hudson wrote: If you continue to read this forum, you will quickly learn to ignore "Pointy-Ears". He rarely has anything worth while to post, and his unique fetish about Real Names shows him to be a hypocrite as well. To be fair, it's likely that Thomas Lahn is his real name, and he's n

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Larry Hudson via Python-list
On 09/04/2016 09:00 AM, Veek. M wrote: Steve D'Aprano wrote: On Sun, 4 Sep 2016 06:53 pm, Thomas 'PointedEars' Lahn wrote: Regarding the name (From field), my name *is* Veek.M […] Liar. *plonk* You have crossed a line now Thomas. That is absolutely uncalled for. You have absolutely no l

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Veek. M
Steve D'Aprano wrote: > On Sun, 4 Sep 2016 06:53 pm, Thomas 'PointedEars' Lahn wrote: > >>> Regarding the name (From field), my name *is* Veek.M […] >> >> Liar. *plonk* > > You have crossed a line now Thomas. > > That is absolutely uncalled for. You have absolutely no legitimate > reason to b

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Steve D'Aprano
On Sun, 4 Sep 2016 06:53 pm, Thomas 'PointedEars' Lahn wrote: >> Regarding the name (From field), my name *is* Veek.M […] > > Liar. *plonk* You have crossed a line now Thomas. That is absolutely uncalled for. You have absolutely no legitimate reason to believe that Veek is not his or her real

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Rustom Mody
On Sunday, September 4, 2016 at 11:18:07 AM UTC+5:30, Rustom Mody wrote: > On Sunday, September 4, 2016 at 9:32:28 AM UTC+5:30, Veek. M wrote: > > Regarding the name (From field), my name *is* Veek.M though I tend to > > shorten it to Vek.M on Google (i think Veek was taken or some such > > thing

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-03 Thread Jussi Piitulainen
Chris Angelico writes: > On Sun, Sep 4, 2016 at 12:49 PM, Steve D'Aprano > wrote: >> On Sun, 4 Sep 2016 12:19 pm, Chris Angelico wrote: >> >> [...] Please either comply, or give up your stupid and pointless obsession with trying to be the Internet Police for something that isn't even a

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-03 Thread Rustom Mody
On Sunday, September 4, 2016 at 9:32:28 AM UTC+5:30, Veek. M wrote: > Regarding the name (From field), my name *is* Veek.M though I tend to > shorten it to Vek.M on Google (i think Veek was taken or some such > thing). Just to be clear, my parents call me something closely related > to Veek that

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-03 Thread Rustom Mody
On Saturday, September 3, 2016 at 5:25:48 PM UTC+5:30, Veek. M wrote: > https://mail.python.org/pipermail//python-ideas/2014-October/029630.htm > > Wanted to know if the above link idea, had been implemented and if > there's a module that accepts a pattern like 'cap' and give you all the > insta

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-03 Thread Veek. M
Access” for how to get it dynamically) > into whatever form suits you for querying it. > >> Would be nice if you could search html/xml character entity >> references as well. > > For what purpose? > > Your posting is lacking a real name in the “From” header field. >

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-03 Thread Chris Angelico
On Sun, Sep 4, 2016 at 12:49 PM, Steve D'Aprano wrote: > On Sun, 4 Sep 2016 12:19 pm, Chris Angelico wrote: > > [...] >>> Please either comply, or give up your stupid and pointless obsession with >>> trying to be the Internet Police for something that isn't even a real >>> rule. >> >> His posts ar

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-03 Thread Steve D'Aprano
On Sun, 4 Sep 2016 12:19 pm, Chris Angelico wrote: [...] >> Please either comply, or give up your stupid and pointless obsession with >> trying to be the Internet Police for something that isn't even a real >> rule. > > His posts aren't making it across the news->list gateway any more. > Killfile

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-03 Thread Chris Angelico
On Sun, Sep 4, 2016 at 11:51 AM, Steve D'Aprano wrote: > On Sun, 4 Sep 2016 06:47 am, Thomas 'PointedEars' Lahn wrote: > >> Your posting is lacking a real name in the “From” header field. > > > Thomas, if that is really your name, how do we know that: > > Thomas 'PointedEars' Lahn > > is a rea

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-03 Thread Steve D'Aprano
On Sun, 4 Sep 2016 06:47 am, Thomas 'PointedEars' Lahn wrote: > Your posting is lacking a real name in the “From” header field. Thomas, if that is really your name, how do we know that: Thomas 'PointedEars' Lahn is a real name? Is sounds made up to me. I'm afraid that we're going to have

Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-03 Thread Veek. M
https://mail.python.org/pipermail//python-ideas/2014-October/029630.htm Wanted to know if the above link idea, had been implemented and if there's a module that accepts a pattern like 'cap' and give you all the instances of unicode 'CAP' characters. ⋂ \bigcap ⊓ \sqcap ∩ \cap ♑ \capricornus

Re: How do I extend a class that I never instantiate myself?

2015-10-11 Thread Chris Angelico
On Mon, Oct 12, 2015 at 10:09 AM, wrote: > On Saturday, October 10, 2015 at 11:32:24 PM UTC-7, Chris Angelico wrote: >> If you REALLY want to look like Ruby, > > Ha! This thread has provided so many interesting monkey-patching techniques, > but this might be the most perverse. Very cute. Thank

Re: How do I extend a class that I never instantiate myself?

2015-10-11 Thread speeze . pearson
On Saturday, October 10, 2015 at 11:32:24 PM UTC-7, Chris Angelico wrote: > If you REALLY want to look like Ruby, Ha! This thread has provided so many interesting monkey-patching techniques, but this might be the most perverse. Very cute. -- https://mail.python.org/mailman/listinfo/python-list

Re: How do I extend a class that I never instantiate myself?

2015-10-11 Thread speeze . pearson
On Saturday, October 10, 2015 at 3:55:17 PM UTC-7, Steven D'Aprano wrote: > # Solution 1: inject a new method into each and every instance in the tree. > > node.foo = MethodType(foo, node) Ooh, interesting. I'll meditate on that for a while. > # Solution 2: hack the node type of each instanc

Re: How do I extend a class that I never instantiate myself?

2015-10-11 Thread speeze . pearson
On Saturday, October 10, 2015 at 10:40:15 AM UTC-7, Ian wrote: > name mangling Awesome! I didn't know this was a feature. > There's nothing wrong with [functional programming] IMO. In fact, Python > does this in the standard library, e.g. len(objects) rather than > objects.len(). ...good point.

Re: How do I extend a class that I never instantiate myself?

2015-10-10 Thread Chris Angelico
On Sun, Oct 11, 2015 at 4:53 PM, dieter wrote: > Otherwise, you can likely use a technique called "monkey patching". > This is dynamically changing code at startup time. > In your case, it could look like: > >from ... import Node > >def new_method(self, ...): > ... > >Node.new_me

Re: How do I extend a class that I never instantiate myself?

2015-10-10 Thread dieter
speeze.pear...@gmail.com writes: > ... > Someone wrote a library that creates and manipulates `Node`s. > I would like to write another layer on top of this, to make > trees that behave just like the library's trees, but whose nodes > have some extra methods. If you are happy, the library supports

Re: How do I extend a class that I never instantiate myself?

2015-10-10 Thread Gregory Ewing
Laura Creighton wrote: don't fear mixins and multiple inheritance unduly. They are a practical solution for a lot of problems. You might have one of them. I don't think mixins are a solution here, because they still require controlling the instantiation of the classes so that you can substitu

Re: How do I extend a class that I never instantiate myself?

2015-10-10 Thread Steven D'Aprano
hing against functional programming, but mixing it > so closely with OO would, I think, result in a confusing, > schizophrenic interface. Do you find len(alist) to be confusing and schizophrenic? > Last possibly relevant fact: the library I want to extend is > `xml.dom.minidom`. By `Node` I mean `Element`, and the specific > methods I want to add will modify attributes used for CSS/JavaScript. It may be relevant. Try it and see. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How do I extend a class that I never instantiate myself?

2015-10-10 Thread Laura Creighton
In a message of Sat, 10 Oct 2015 10:02:24 -0700, speeze.pear...@gmail.com write s: >I should just use the existing library's `Node` class, and write >my library in a functional style. Don't define `MyNode.foo()`, >instead define `mylibrary.foo(my_node)`. >I've got nothing against functional progra

Re: How do I extend a class that I never instantiate myself?

2015-10-10 Thread Ian Kelly
On Sat, Oct 10, 2015 at 11:02 AM, wrote: > (This is a long post, but the question is simple. Most of this is > just me enumerating what I've already tried.) > > Someone wrote a library that creates and manipulates `Node`s. > I would like to write another layer on top of this, to make > trees that

How do I extend a class that I never instantiate myself?

2015-10-10 Thread speeze . pearson
d just use the existing library's `Node` class, and write my library in a functional style. Don't define `MyNode.foo()`, instead define `mylibrary.foo(my_node)`. I've got nothing against functional programming, but mixing it so closely with OO would, I think, result in a confusing

Re: extend methods of decimal module

2014-03-01 Thread Mark H. Harris
On Saturday, March 1, 2014 12:55:07 AM UTC-6, Anssi Saari wrote: > I recently watched a presentation by Jessica McKellar of PSF about what > Python needs to stay popular. Other than the obvious bits (difficulties > of limited support of Python on major platforms like Windows and mobile) > the sligh

Re: extend methods of decimal module

2014-02-28 Thread Anssi Saari
Terry Reedy writes: > On 2/27/2014 7:07 AM, Mark H. Harris wrote: > >> Oh, and one more thing... whoever is doing the work on IDLE these >> days, nice job! It is stable, reliable, and just works/ >> appreciate it! > > As one of 'them', thank you for the feedback. There are still some > bugs, bu

Re: extend methods of decimal module

2014-02-28 Thread Mark H. Harris
On Friday, February 28, 2014 1:39:11 PM UTC-6, Mark H. Harris wrote: > On Friday, February 28, 2014 1:34:27 AM UTC-6, Steven D'Aprano wrote: > > > > > Now that Python has a fast C implementation of Decimal, I would be happy > > > for Python 4000 to default to decimal floats, and require specia

Re: extend methods of decimal module

2014-02-28 Thread Mark H. Harris
On Friday, February 28, 2014 1:34:27 AM UTC-6, Steven D'Aprano wrote: > Now that Python has a fast C implementation of Decimal, I would be happy > for Python 4000 to default to decimal floats, and require special syntax > for binary floats. Say, 0.1b if you want a binary float, and 0.1 for a >

Re: extend methods of decimal module

2014-02-28 Thread Mark H. Harris
On Friday, February 28, 2014 12:37:37 PM UTC-6, Chris Angelico wrote: > > Are you aware that IEEE 754 includes specs for decimal floats? :) > Yes. I am from back in the day... way back... so 754 1985 is what I have been referring to. IEEE 854 1987 and the generalized IEEE 754 2008 have

Re: extend methods of decimal module

2014-02-28 Thread Chris Angelico
On Sat, Mar 1, 2014 at 5:34 AM, Mark H. Harris wrote: > Yes. ... and for clarification back to one of my previous comments, when I > refer to 'float' I am speaking of the IEEE binary floating point > representation built-in everywhere... including the processor!... not the > concept of tra

Re: extend methods of decimal module

2014-02-28 Thread Mark H. Harris
On Friday, February 28, 2014 9:11:49 AM UTC-6, Steven D'Aprano wrote: > >> Now that Python has a fast C implementation of Decimal, I would be > >> happy for Python 4000 to default to decimal floats, and require special > >> syntax for binary floats. Say, 0.1b if you want a binary float, and 0.1 >

Re: extend methods of decimal module

2014-02-28 Thread Mark H. Harris
On Friday, February 28, 2014 2:54:12 AM UTC-6, Wolfgang Maier wrote: > Since by now, I guess, we all agree that using the string representation is > the wrong approach, you can simply use Decimal instead of D() throughout > your code. > Best, > Wolfgang hi Wolfgang, ...right... I'm going to

Re: extend methods of decimal module

2014-02-28 Thread Mark H. Harris
On Friday, February 28, 2014 8:41:49 AM UTC-6, Wolfgang Maier wrote: > Hi Mark, > > here is an enhancement for your epx function. > > Wolfgang hi Wolfgang, thanks much! As a matter of point in fact, I ran into this little snag and didn't understand it, because I was thinking that outside o

Re: extend methods of decimal module

2014-02-28 Thread Chris Angelico
On Sat, Mar 1, 2014 at 2:11 AM, Steven D'Aprano wrote: >> or there needs to be a system for constructing literals >> of non-built-in types. And if Decimal becomes built-in, then why that >> and not <>? > > 'Cos we have ten fingers and in count in decimal :-P We talk in words and characters, so we

Re: extend methods of decimal module

2014-02-28 Thread Steven D'Aprano
On Fri, 28 Feb 2014 19:52:45 +1100, Chris Angelico wrote: > On Fri, Feb 28, 2014 at 6:34 PM, Steven D'Aprano > wrote: >> On Fri, 28 Feb 2014 16:00:10 +1100, Chris Angelico wrote: >> >>> If we had some other tag, like 'd', we could actually construct a >>> Decimal straight from the source code. Si

Re: extend methods of decimal module

2014-02-28 Thread Wolfgang
Uhh, the curse of not copy-pasting everything: > >>> exp(20) should, of course, read >>> epx(19) > Traceback (most recent call last): > File "", line 1, in > epx(19) > File "C:\Python34\dmath_rev.py", line 27, in epx > n *= q > decimal.Overflow: [] > -- https://mail.py

Re: extend methods of decimal module

2014-02-28 Thread Wolfgang Maier
Mark H. Harris gmail.com> writes: > > If you get a chance, take a look at the dmath.py code on: > >https://code.google.com/p/pythondecimallibrary/ > Hi Mark, here is an enhancement for your epx function. Your current version comes with the disadvantage of potentially storing extremely l

Re: extend methods of decimal module

2014-02-28 Thread casevh
On Thursday, February 27, 2014 2:33:35 AM UTC-8, Mark H. Harris wrote: > No... was not aware of gmpy2... looks like a great project! I am wondering > why it would be sooo much faster? For multiplication and division of ~1000 decimal digit numbers, gmpy2 is ~10x faster. The numbers I gave were f

Re: extend methods of decimal module

2014-02-28 Thread Wolfgang Maier
Mark H. Harris gmail.com> writes: > > On Thursday, February 27, 2014 10:26:59 PM UTC-6, Chris Angelico wrote: > > > Create Decimal values from strings, not from the str() of a float, > > which first rounds in binary and then rounds in decimal. > > > > Thanks Chris... another excellent point.

Re: extend methods of decimal module

2014-02-28 Thread Chris Angelico
On Fri, Feb 28, 2014 at 6:34 PM, Steven D'Aprano wrote: > On Fri, 28 Feb 2014 16:00:10 +1100, Chris Angelico wrote: > >> If we had some other tag, like 'd', we could actually construct a >> Decimal straight from the source code. Since source code is a string, >> it'll be constructed from that stri

Re: extend methods of decimal module

2014-02-27 Thread Steven D'Aprano
On Fri, 28 Feb 2014 16:00:10 +1100, Chris Angelico wrote: > If we had some other tag, like 'd', we could actually construct a > Decimal straight from the source code. Since source code is a string, > it'll be constructed from that string, and it'll never go via float. Now that Python has a fast C

Re: extend methods of decimal module

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 4:18 PM, Mark H. Harris wrote: > do I make the assumption that all functions will take a string as argument > and then let interactive users bare the responsibility to enter a string or > decimal... avoiding floats... Just have your users pass in Decimal objects. They ca

Re: extend methods of decimal module

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 10:26:59 PM UTC-6, Chris Angelico wrote: > Create Decimal values from strings, not from the str() of a float, > which first rounds in binary and then rounds in decimal. > Thanks Chris... another excellent point... ok, you guys have about convinced me (which is sp

Re: extend methods of decimal module

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 3:41 PM, Mark H. Harris wrote: > So, I am thinking I need to mods... maybe an idmath.py for interactive > sessions, and then dmath.py for for running within my scientific scripts... > ?? No; the solution is to put quotes around your literals in interactive mode, too.

Re: extend methods of decimal module

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 9:15:36 PM UTC-6, Steven D'Aprano wrote: > Decimal uses base 10, so it is a better fit for numbers we > write out in base 10 like "0.12345", but otherwise it suffers from the > same sort of floating point rounding issues as floats do. > > > py> Decimal('1.2345'

Re: extend methods of decimal module

2014-02-27 Thread Chris Angelico
On Fri, Feb 28, 2014 at 1:15 PM, Mark H. Harris wrote: > Its just easier to type D(2.78) than Deciaml('2.78'). It's easier to type 2.78 than 2.718281828, too, but one of them is just plain wrong. Would you tolerate using 2.78 for e because it's easier to type? I mean, it's gonna be close. Creat

Re: extend methods of decimal module

2014-02-27 Thread Steven D'Aprano
On Thu, 27 Feb 2014 15:00:45 -0800, Mark H. Harris wrote: > Decimal does not keep 0.1 as a floating point format (regardless of > size) which is why banking can use Decimal without having to worry about > the floating formatting issue... in other words, 0.0 is not stored in > Decimal as any k

Re: extend methods of decimal module

2014-02-27 Thread Mark H. Harris
On Thursday, February 27, 2014 5:50:55 PM UTC-6, Oscar Benjamin wrote: > . . . Calling Decimal on a float performs an exact binary to > decimal conversion. Your reasoning essentially assumes that every > float should be interpreted as an approximate representation for a > nearby decimal value.

Re: extend methods of decimal module

2014-02-27 Thread Oscar Benjamin
On 27 February 2014 23:00, Mark H. Harris wrote: > On Thursday, February 27, 2014 10:24:23 AM UTC-6, Oscar Benjamin wrote: > > from decimal import Decimal as D >> >>> D(0.1) >> Decimal('0.155511151231257827021181583404541015625') > > hi Oscar, well, that's not what I'm doing

  1   2   3   >