[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-05 Thread Serhiy Storchaka
05.05.21 17:18, Shreyan Avigyan пише: > I don't know if it's worth adding private to python modules but what about > classes? Private in class is an important feature in OOP that Python lacks > (Most OOP languages have private like Java, C++, etc.). I don't know why it > was introduced in the fi

[Python-ideas] Re: Support more conversions in format string

2021-05-05 Thread Cameron Simpson
On 06May2021 03:43, Dennis Sweeney wrote: >Maybe I'm missing something, but why do you need the SimpleNamespace at all? >Why not make your own mapping as in > >class StringMapper: >... >def __getitem__(self, s): ># Whatever arbitrary behavior you want >

[Python-ideas] Re: Support more conversions in format string

2021-05-05 Thread Dennis Sweeney
Maybe I'm missing something, but why do you need the SimpleNamespace at all? Why not make your own mapping as in class StringMapper: ... def __getitem__(self, s): # Whatever arbitrary behavior you want # Process suffixes, etc here, for example:

[Python-ideas] Re: Support more conversions in format string

2021-05-05 Thread Cameron Simpson
On 25Apr2021 10:54, Cameron Simpson wrote: >On 24Apr2021 22:35, Stephen J. Turnbull >wrote: >[...] >> > My use case is presupplied strings, eg a command line supplied >> > format string. >> >>In that case the format string is user input, and x is a variable in >>the program that the user can hav

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-05 Thread Steven D'Aprano
Hi Shreyan, You say: On Wed, May 05, 2021 at 02:18:55PM -, Shreyan Avigyan wrote: > I don't know if it's worth adding private to python modules but what > about classes? Private in class is an important feature in OOP that > Python lacks (Most OOP languages have private like Java, C++, etc

[Python-ideas] Re: Changing The Theme of Python Docs Site

2021-05-05 Thread Neil Girdhar
I agree with the comment about removing full justification. Also, I think the Masonite docs' navigation is far superior to the Python docs. I like the full contents on the left, along with the version button, and the local jump on the right. The python docs require you to navigate somehwere e

[Python-ideas] Re: Namespaces!

2021-05-05 Thread Wes Turner
On Wed, May 5, 2021, 02:11 Steven D'Aprano wrote: > My comments follow, interleaved with Matt's. > > > On Mon, May 03, 2021 at 11:30:51PM +0100, Matt del Valle wrote: > > > But you've pretty much perfectly identified the benefits here, I'll just > > elaborate on them a bit. > > > > - the indentat

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-05 Thread Shreyan Avigyan
See my comment here - https://mail.python.org/archives/list/python-ideas@python.org/message/L5LUQDNNV5ZTF4E33L2JSOYIKPJUJJK5/ ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://m

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-05 Thread Shreyan Avigyan
I don't know if it's worth adding private to python modules but what about classes? Private in class is an important feature in OOP that Python lacks (Most OOP languages have private like Java, C++, etc.). I don't know why it was introduced in the first place but it's kind of a convention to hav

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-05 Thread Stestagg
One issue with many common programming languages is that they appear to offer access protections via private/protected etc, but seldom do so securely (`private` modifiers are never, to my knowledge, intended to be a security mechanism). / Take for example C++: #include #include clas

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-05 Thread Chris Angelico
On Wed, May 5, 2021 at 11:43 PM Shreyan Avigyan wrote: > > Private methods, functions and variables are very common in programming > languages. But Python doesn't support private. It has conventions for naming > so considered private but not private. Most of the time private is never > required

[Python-ideas] Re: Add support for private variables, methods and functions in Python

2021-05-05 Thread Felipe Rodrigues
Hey Shreyan, >From what I understand, Python's design focuses on enabling the developer to do whatever she feels right. Having a class attribute or something marked as "private" is more of a warning to people _using_ that class that they shouldn't tinker with that field. If I'm using a class that

[Python-ideas] Add support for private variables, methods and functions in Python

2021-05-05 Thread Shreyan Avigyan
Private methods, functions and variables are very common in programming languages. But Python doesn't support private. It has conventions for naming so considered private but not private. Most of the time private is never required, what Python provides is more than enough. But the need for priva

[Python-ideas] Re: Namespaces!

2021-05-05 Thread Steven D'Aprano
Thanks Paul, you channelled my thinking exactly correctly. I am not an expert on C++, but I think that's roughly how C++ namespaces work. Any C++ coders care to confirm or correct me? Steve On Wed, May 05, 2021 at 12:05:56PM +0100, Paul Moore wrote: > On Wed, 5 May 2021 at 11:33, Matt del Va

[Python-ideas] Re: Namespaces!

2021-05-05 Thread Matt del Valle
Whoops. I totally misread that! My brain unhelpfully supplied string quotes in the return statement of the `eggs` methods, rather than parsing them as function calls. ...for some reason I could not explain to you. Maybe I've grown too dependent on syntax highlighting! I see what Steven meant now.

[Python-ideas] Re: Namespaces!

2021-05-05 Thread Paul Moore
On Wed, 5 May 2021 at 11:33, Matt del Valle wrote: >> To give an example: >> >> def spam(): >> return "spam spam spam!" >> >> def eggs(): >> return spam() >> >> namespace Shop: >> def spam(): >> return "There's not much call for spam here." >>

[Python-ideas] Re: Namespaces!

2021-05-05 Thread Chris Angelico
On Wed, May 5, 2021 at 8:33 PM Matt del Valle wrote: > Creating lots of unnecessary classes just for namespacing, as we currently > have to resort to, isn't ideal. > > What you're calling 'an unnecessary level of indirection', quickly becomes a > big boost to clarity (both in the written code an

[Python-ideas] Re: Namespaces!

2021-05-05 Thread Matt del Valle
> > So if A is capable of looking up "B.C.D", but it's also capable of > looking up "B" and following the chain... what happens when you > reassign something? What does this line of code do? > A is capable of looking up B.C.D in one step if you use `getattr` because the way A forwards on attribute