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
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
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
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
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
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
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
First of all, the reason that private members can be hacked in C++ because of
pointers. I don't know Java, so I don't know how it's possible there. But
Python doesn't have pointers and getattr, settatr can be adjusted to work with
private members. The only way the hack is possible if someone wro
On Thu, May 6, 2021 at 10:49 PM Shreyan Avigyan
wrote:
> The benefit of private is actually debugging. If somehow, someone finds that
> the private member has changed they would immediately know that it was a
> memory leak or the value was changed through a set method defined in the
> class (Th
Please read my whole comment.
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.o
Most of the time when someone fixes a bug using a private member of another
class then it's completely considered private code. Sometimes applications can
cause crashes if there's memory leak or modification. Like there's an example
where you change the name attribute of a bank account class and
On Thu, May 6, 2021 at 11:14 PM Shreyan Avigyan
wrote:
>
> Please read my whole comment.
Please actually quote some text so we know who you're responding to,
what you're talking about, etc.
ChrisA
___
Python-ideas mailing list -- python-ideas@python.or
On 2021-05-06 12:46:40, Shreyan Avigyan wrote:
> But Python doesn't have pointers and getattr, settatr can be adjusted
> to work with private members.
Not really, this is explicitly mentioned on the docs.
Here's an example:
> >>> from dataclasses import dataclass
> >>> @dataclass(frozen=True)
>
Chris :-
> Please actually quote some text so we know who you're responding to,
what you're talking about, etc.
I'm actually telling to read my comment here
https://mail.python.org/archives/list/python-ideas@python.org/message/426EPANCVEGZV2AZL7MWNG67BTZMORNG.
See the Conclusion section in there
On Thu, May 6, 2021 at 10:16 AM Shreyan Avigyan
wrote:
> Most of the time when someone fixes a bug using a private member of
> another class then it's completely considered private code. Sometimes
> applications can cause crashes if there's memory leak or modification. Like
> there's an example w
Again. See what I suggested. I changed my suggestion from "Private" to
"Non-modifiable member variables".
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailm
On Thu, May 6, 2021 at 11:22 AM Shreyan Avigyan
wrote:
Quoting the entire content:
Again. See what I suggested. I changed my suggestion from "Private" to
> "Non-modifiable member variables".
>
I have no idea if this is in response to my own email or someone else as
you do not include any context
André Roberge:
> My own email specifically referred to two instances where I found it
necessary to **modify** methods that are indicated as being private as
their names begin with double underscores. So, I am strongly opposed to
your suggestion.
Actually as I explained in this comment
https://mai
I am a strong -1 on this.
On Thu, May 6, 2021 at 2:41 PM Shreyan Avigyan
wrote:
> André Roberge:
> > My own email specifically referred to two instances where I found it
> necessary to **modify** methods that are indicated as being private as
> their names begin with double underscores. So, I am
David Mertz:
> I am a strong -1 on this
Thanks for your feedback. But I'm not suggesting introducing a new behavior.
The @property already creates read-only member variables. What I'm suggesting
is that introducing a new keyword or decorator as required to create a variable
that can be modified
On Fri, May 7, 2021 at 1:12 AM Shreyan Avigyan
wrote:
>
> David Mertz:
> > I am a strong -1 on this
>
> Thanks for your feedback. But I'm not suggesting introducing a new behavior.
> The @property already creates read-only member variables. What I'm suggesting
> is that introducing a new keyword
Chris:
> That would require some definition of what's "within" and what's
> "outside" the class, and whatever definition you use, it won't work
> with all forms of dynamic code.
Yes, implementing that will be hard. But the question is I can't quite
understand why this is not acceptable by the Py
On Fri, May 7, 2021 at 4:04 AM Shreyan Avigyan
wrote:
>
> Chris:
>
> > That would require some definition of what's "within" and what's
> > "outside" the class, and whatever definition you use, it won't work
> > with all forms of dynamic code.
>
> Yes, implementing that will be hard. But the quest
I *have* used @property to suggest that variables be read-only.
That said, I believe that using the (I believe fairly common) pattern of
defining a property as a no-op wrapper around a corresponding "private"
(single underscore) attribute tends to be a more pythonic solution to the
read-only dilem
Chris:
> I'm not sure about other people, but I have never, not once, used
> @property as a means of controlling access. So giving me another way
> to do something that I am not, and don't want to, do... isn't much of
> an argument. :)
Ok. I'm giving you another example that doesn't cause security
On 2021-05-06 at 18:34:55 -,
Shreyan Avigyan wrote:
> Chris:
> > I'm not sure about other people, but I have never, not once, used
> > @property as a means of controlling access. So giving me another way
> > to do something that I am not, and don't want to, do... isn't much of
> > an argument
On Thu, May 6, 2021, 11:12 AM Shreyan Avigyan
wrote:
> David Mertz:
> > I am a strong -1 on this
>
> Thanks for your feedback. But I'm not suggesting introducing a new
> behavior. The @property already creates read-only member variables. What
> I'm suggesting is that introducing a new keyword or
The problem is that whatever programming language it is, there's always a hack
to do things. And since it also doesn't make sense to introduce readonly
function names (What a terrible nightmare!), maybe readonly variable also
doesn't make sense to be added. Anyway, this was quite a discussion. T
06.05.21 15:46, Shreyan Avigyan пише:
> But Python doesn't have pointers and getattr, settatr can be adjusted to work
> with private members.
It doesn't work this way. You cannot distinguish the use of getattr()
which breaks encapsulation from the one which does not. Inside getattr()
you only hav
On Thu, May 06, 2021 at 03:09:33PM -, Shreyan Avigyan wrote:
> What I'm suggesting is that introducing a new keyword or decorator as
> required to create a variable that can be modified from within the
> class but not outside the class.
That's an interesting suggestion, but how do you defin
Steven D'Aprano:
> My guess is that you have used a lot of Java, or at least read a lot of
> Object Oriented Programming theory that is based on the Java model
I've never used Java. I don't even know Java so well. But the Java and C++
model is similar and since I know C/C++ I'm guessing about Ja
On 5/6/21 10:44 PM, Shreyan Avigyan wrote:
> Anyway this thread is closed.
As you may have noticed, this is a mailing list -- no thread is closed. I've
seen posts to three-year-old threads.
--
~Ethan~
___
Python-ideas mailing list -- python-ideas@py
Ethan:
> As you may have noticed, this is a mailing list -- no thread is closed. I've
> seen posts to three-year-old threads.
Since the discussion has come to a halt and it's decided that we'll continue to
use the Pythonic way for private and it's also very hard to implement what I
suggested,
I think the only reason to introduce something like `private` is
refactoring. If you added a `_variable` and later you decided to
expose it, you have to change it to `variable`. This is something that
in languages like Java is not necessary, you have only to change the
variable from private to publ
On Sun, May 23, 2021 at 10:30 PM Marco Sulla
wrote:
>
> I think the only reason to introduce something like `private` is
> refactoring. If you added a `_variable` and later you decided to
> expose it, you have to change it to `variable`. This is something that
> in languages like Java is not neces
On Sun, 23 May 2021 at 14:35, Chris Angelico wrote:
>
> On Sun, May 23, 2021 at 10:30 PM Marco Sulla
> wrote:
> >
> > I think the only reason to introduce something like `private` is
> > refactoring. If you added a `_variable` and later you decided to
> > expose it, you have to change it to `vari
On Sun, May 23, 2021 at 10:42 PM Marco Sulla
wrote:
>
> On Sun, 23 May 2021 at 14:35, Chris Angelico wrote:
> >
> > On Sun, May 23, 2021 at 10:30 PM Marco Sulla
> > wrote:
> > >
> > > I think the only reason to introduce something like `private` is
> > > refactoring. If you added a `_variable` a
On Sun, 23 May 2021 at 14:50, Chris Angelico wrote:
>
> On Sun, May 23, 2021 at 10:42 PM Marco Sulla
> wrote:
> >
> > On Sun, 23 May 2021 at 14:35, Chris Angelico wrote:
> > >
> > > On Sun, May 23, 2021 at 10:30 PM Marco Sulla
> > > wrote:
> > > >
> > > > I think the only reason to introduce so
On 2021-05-23 at 16:30:35 +0200,
Marco Sulla wrote:
> On Sun, 23 May 2021 at 14:50, Chris Angelico wrote:
> >
> > On Sun, May 23, 2021 at 10:42 PM Marco Sulla
> > wrote:
> > >
> > > On Sun, 23 May 2021 at 14:35, Chris Angelico wrote:
> > > >
> > > > On Sun, May 23, 2021 at 10:30 PM Marco Sulla
Greetings list,
This whole thread reminds me of a comment of
Miguel Grinberg i remember somewhere when discussing
secrets. Some go for .env some for env variables but he suggested
focusing the attention on not letting people getting access to the
server instead of trying to be clever about hiding
On Sun, 23 May 2021 at 17:43, <2qdxy4rzwzuui...@potatochowder.com> wrote:
>
> On 2021-05-23 at 16:30:35 +0200,
> Marco Sulla wrote:
>
> > On Sun, 23 May 2021 at 14:50, Chris Angelico wrote:
> > >
> > > On Sun, May 23, 2021 at 10:42 PM Marco Sulla
> > > wrote:
> > > >
> > > > On Sun, 23 May 2021
On Mon, May 24, 2021 at 3:38 AM Marco Sulla
wrote:
> > > > Do you yearn for actual refactoring tools - which do exist?
> > >
> > > Renaming tools of IDE do not work in 100% of the cases. For example,
> > > if you have _variable in an eval string, it's not replaced.
> >
> > Another reason not to us
On Sun, 23 May 2021 at 19:50, Chris Angelico wrote:
>
> On Mon, May 24, 2021 at 3:38 AM Marco Sulla
> wrote:
> > > > > Do you yearn for actual refactoring tools - which do exist?
> > > >
> > > > Renaming tools of IDE do not work in 100% of the cases. For example,
> > > > if you have _variable in
Abdur-Rahmaan Janhangeer writes:
> This whole thread reminds me of a comment of
> Miguel Grinberg i remember somewhere when discussing
> secrets. Some go for .env some for env variables but he suggested
> focusing the attention on not letting people getting access to the
> server instead of t
On Tue, May 25, 2021 at 04:24:39PM +0900, Stephen J. Turnbull wrote:
> In Support For Private, however, we're talking about a positive-sum
> game. Code writers need to communicate with code readers, both human
> and machine, while avoiding mistakes. In fact, this is almost a
> purely cooperative
Greetings,
> In fact, this is almost a
purely cooperative game.
This sums it up the difference between secrets and the private
use case. I was echoing the sentiments of the thread. The
mere putting of private does not ensure complete isolation. It's
for developers to understand that they should
Steven D'Aprano writes:
> On Tue, May 25, 2021 at 04:24:39PM +0900, Stephen J. Turnbull wrote:
> It's not really purely cooperative. API consumers always want more than
> the API designers are willing or able to give.
True enough as stated, but "purely cooperative" doesn't mean "if I
optimize
47 matches
Mail list logo