Re: Where I do ask for a new feature
Op 20/10/2023 om 5:16 schreef Bongo Ferno via Python-list: On Thursday, October 19, 2023 at 11:26:52 PM UTC-3, [email protected] wrote: > There are many ways to make transient variables that disappear at some time > and do we need yet another? Yes, you can create one of those ways but what > is the big deal with deleting a variable when no longer used? Assigning a variable to something can be anything else than a temporal alias. A with statement makes clear that the alias is an alias and is local, and it automatically clears the variable after the block code is used. Python clutters the variable space with vars that are needed only on certain places, and an alias doesn't has a scope. Convenient alias are short names, and short names are limited in quantity. If the space is cluttered with short alias, it opens risks for wrong utilization. Its like writing a "for i" in a list comprehension and having to worry if "i" was already used in another place.. As long as functions are kept reasonably short, which is a good idea anyway, I don't really see any of that as a problem. -- "Experience is that marvelous thing that enables you to recognize a mistake when you make it again." -- Franklin P. Jones -- https://mail.python.org/mailman/listinfo/python-list
Re: Simple webserver
On 19.10.2023 01:23, Chris Angelico wrote: > > Broadly speaking, your ideas are great. Any programming language CAN > be used for the server (and I've used several, not just Python). Out of curiosity; what where these languages? - If there's one I already know I might save some time implementing the server. :-) Janis -- https://mail.python.org/mailman/listinfo/python-list
Re: Simple webserver
On Fri, 20 Oct 2023 at 22:31, Janis Papanagnou via Python-list
wrote:
>
> On 19.10.2023 01:23, Chris Angelico wrote:
> >
> > Broadly speaking, your ideas are great. Any programming language CAN
> > be used for the server (and I've used several, not just Python).
>
> Out of curiosity; what where these languages? - If there's one I
> already know I might save some time implementing the server. :-)
>
I've done websocket servers in Python, Node.js, and Pike, and possibly
others but I can't recall at the moment. Might have done one in Ruby,
but that would have just been part of playing around and comparing
features ("how easy is it to do in Ruby").
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
Re: Where I do ask for a new feature
On 10/19/2023 11:16 PM, Bongo Ferno via Python-list wrote: On Thursday, October 19, 2023 at 11:26:52 PM UTC-3, [email protected] wrote: There are many ways to make transient variables that disappear at some time and do we need yet another? Yes, you can create one of those ways but what is the big deal with deleting a variable when no longer used? Assigning a variable to something can be anything else than a temporal alias. A with statement makes clear that the alias is an alias and is local, and it automatically clears the variable after the block code is used. Python clutters the variable space with vars that are needed only on certain places, and an alias doesn't has a scope. Convenient alias are short names, and short names are limited in quantity. If the space is cluttered with short alias, it opens risks for wrong utilization. Its like writing a "for i" in a list comprehension and having to worry if "i" was already used in another place.. If a name is temporarily needed in a certain place and in a certain scope then reusing the name shouldn't be a problem. -- https://mail.python.org/mailman/listinfo/python-list
Re: Simple webserver
On 2023-10-20, Chris Angelico wrote:
> On Fri, 20 Oct 2023 at 22:31, Janis Papanagnou via Python-list
> wrote:
>>
>> On 19.10.2023 01:23, Chris Angelico wrote:
>> >
>> > Broadly speaking, your ideas are great. Any programming language CAN
>> > be used for the server (and I've used several, not just Python).
>>
>> Out of curiosity; what where these languages? - If there's one I
>> already know I might save some time implementing the server. :-)
>>
>
> I've done websocket servers in Python, Node.js, and Pike, and possibly
> others but I can't recall at the moment. Might have done one in Ruby,
> but that would have just been part of playing around and comparing
> features ("how easy is it to do in Ruby").
>
> ChrisA
*Big list of http static server one-liners*
Each of these commands will run an ad hoc http static server
in your current (or specified) directory, available at
http://localhost:8000. Use this power wisely.
--
https://mail.python.org/mailman/listinfo/python-list
RE: Where I do ask for a new feature
I still see no great reason for a new feature here and the namespace issue has often been discussed. You can always opt to create your own namespace of some sort and make many of your variables within it and always refer to the variables explicitly so the only collisions that can happen are your own carelessness. I do note that reusing a variable like "i" is not uncommon and especially when it is merely used as a looping variable. Generally anything else using the same variable does not need to refer to the other use and is in another scope. May I politely ask if you can point to other languages that have the feature you want and what it looks like. How does it know when the variable can safely go away? Does it allow you to create your alias in something like a loop and re-assign it or is it more like a constant once set and so on? If you have a good use case with no other easy way to provide it, you still need to show it is more important than oodles of other feature requests before anyone would consider seriously doing it in some future release. I am wondering if your concept of an alias is more typographical than actual. I mean in languages like C, there was often a preprocessor that went through your code and made changes like: #DEFINE filename "/usr/me/dir/subdir/file.c" This could allow some shorter typing but would not have anything in the namespace on the compiler level which would just see the longer substitutions. Could Python include something like this by keeping a table of symbols and replacements or running a pre-processor first? Maybe. But as stated, it does not seem to be a NEED that some feel is important. Assigning a variable to hold a pointer of sorts does indeed add to the namespace but the resource involved is not a big deal. Python is an interpreted language that makes one pass but there are languages that make multiple passes through the code and allow things like defining a function after it has been called. That is not pythonic. -Original Message- From: Python-list On Behalf Of Roel Schroeven via Python-list Sent: Friday, October 20, 2023 3:55 AM To: [email protected] Subject: Re: Where I do ask for a new feature Op 20/10/2023 om 5:16 schreef Bongo Ferno via Python-list: > On Thursday, October 19, 2023 at 11:26:52 PM UTC-3, [email protected] wrote: > > > There are many ways to make transient variables that disappear at some time > > and do we need yet another? Yes, you can create one of those ways but what > > is the big deal with deleting a variable when no longer used? > > Assigning a variable to something can be anything else than a temporal alias. > A with statement makes clear that the alias is an alias and is local, and it > automatically clears the variable after the block code is used. > > Python clutters the variable space with vars that are needed only on certain > places, and an alias doesn't has a scope. > Convenient alias are short names, and short names are limited in quantity. If > the space is cluttered with short alias, it opens risks for wrong utilization. > > Its like writing a "for i" in a list comprehension and having to worry if "i" > was already used in another place.. As long as functions are kept reasonably short, which is a good idea anyway, I don't really see any of that as a problem. -- "Experience is that marvelous thing that enables you to recognize a mistake when you make it again." -- Franklin P. Jones -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Where I do ask for a new feature
On 10/19/23 19:32, Bongo Ferno via Python-list wrote: > >> You can actually just do that with simple assignment! >> >> short_view = my_object.stuff.long_stuff.sub_object >> print(short_view.some_method()) > > but then have to delete the variable manually > > del short_view Why? It's just a name in the namespace that you can bind to a function object. You can ignore it or rebind it later to something else. There's no need to del it, although you can. I'm not sure why you want to del it. It's not like a memory leak or something like that. I suspect we might also have a misunderstanding of what python variables are and how they work, which is why I did not use the word, "reassign" but rather "bind" or "rebind." -- https://mail.python.org/mailman/listinfo/python-list
Re: Where I do ask for a new feature
On 21/10/2023 01.32, Thomas Passin via Python-list wrote: On 10/19/2023 11:16 PM, Bongo Ferno via Python-list wrote: On Thursday, October 19, 2023 at 11:26:52 PM UTC-3, [email protected] wrote: There are many ways to make transient variables that disappear at some time and do we need yet another? Yes, you can create one of those ways but what is the big deal with deleting a variable when no longer used? Assigning a variable to something can be anything else than a temporal alias. A with statement makes clear that the alias is an alias and is local, and it automatically clears the variable after the block code is used. Python clutters the variable space with vars that are needed only on certain places, and an alias doesn't has a scope. Convenient alias are short names, and short names are limited in quantity. If the space is cluttered with short alias, it opens risks for wrong utilization. Its like writing a "for i" in a list comprehension and having to worry if "i" was already used in another place.. If a name is temporarily needed in a certain place and in a certain scope then reusing the name shouldn't be a problem. Agree. Surely, the only time we use a name like "i" is in a throw-away context? Under many circumstances Python will let us use "_" in place of a named-identifier - which enables both us and Python to remember its short-lived value/local-only use. Using an alias MERELY for the convenience of a shorter-name suggests two things: 1 lack of a competent editor/IDE, 2 lack of imagination in choosing names (perhaps one of THE skills of programming!) Yes, there are other languages which enforce a limited-scope on data-items created within or as part of a code-structure - and it IS a handy feature! On the other hand, Python's apposite stance can be useful too, eg trivial toy-example: # list_of_stuff = ... for n, element in list_of_stuff: if element == target: break # now element == target, so "element" is probably not that useful # but "n" is the index of the target-element, which may be # (there are other ways to accomplish same) Please take a look at the ideas behind "Modular Programming". This encourages the breaking-up of monolithic code and its "cluttered" global namespace, into potentially-independent code-units. The outlined-problem is solved by the independent scope of those code-units (in Python: modules, classes, functions, and "if __name__ == "__main__":". (to say nothing of the coder's virtues of "re-use", the "Single Responsibility Principle", "do one thing, and do it well", Law of Demeter, ...) Personal comment: my habit is to break specs into many classes and functions - sometimes more-so than others might prefer. Cannot recall when last had that hard-to-locate bug of unwittingly re-using a name/alias. (apologies: not a boast - a recommendation for going modular) -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
