Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 12:44 PM Avi Gross via Python-list wrote: > > Greg, > > My point was not to ASK what python does as much as to ask why it matters to > anyone which way it does it. Using less space at absolutely no real expense > is generally a plus. Having a compiler work too hard, or even

Re: Behaviour of pop() for dictionaries

2021-06-15 Thread dn via Python-list
On 15/06/2021 21.37, BlindAnagram wrote: > On 15/06/2021 00:11, dn wrote: >> On 15/06/2021 09.18, BlindAnagram wrote: >>> On 14/06/2021 20:43, Chris Angelico wrote: On Tue, Jun 15, 2021 at 5:41 AM BlindAnagram >> ... > I think the difference here is that I know I am going to have to look at >

RE: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Avi Gross via Python-list
Greg, My point was not to ASK what python does as much as to ask why it matters to anyone which way it does it. Using less space at absolutely no real expense is generally a plus. Having a compiler work too hard, or even ask the code to work too hard, is often a minus. If I initialized the tuple

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Greg Ewing
On 16/06/21 12:15 pm, Avi Gross wrote: May I ask if there are any PRACTICAL differences if multiple immutable tuples share the same address or not? Only if some piece of code relies on the identity of tuples by using 'is' or id() on them. There's rarely any need to write code like that, though

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 10:17 AM Avi Gross via Python-list wrote: > > May I ask if there are any PRACTICAL differences if multiple immutable > tuples share the same address or not? No, there aren't. It's nothing more than an (optional) optimization. This is true of every immutable type, including

RE: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Avi Gross via Python-list
May I ask if there are any PRACTICAL differences if multiple immutable tuples share the same address or not? I mean if I use a tuple in a set or as the key in a dictionary and a second one comes along, will it result in two entries one time and only one the other time? Some languages I use often

Re: Php vs Python gui (tkinter...) for small remote database app

2021-06-15 Thread Menno Holscher
Op 15-06-2021 om 19:14 schreef Grant Edwards: On 2021-06-15, Menno Holscher wrote: There is no difference regarding security concerns. I find that hard to believe given the long list of CVEs I've just had to sort through for even fairly recent versions of PHP. I just can't belive that Python

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Greg Ewing
On 15/06/21 7:32 pm, Jach Feng wrote: But usually the list creation is not in simple way:-) for example: a = [1,2] m = [a for i in range(3)] m [[1, 2], [1, 2], [1, 2]] id(m[0]) == id(m[1]) == id(m[2]) True The first line is only executed once, so you just get one list object [1, 2]. You the

Re: optimization of rule-based model on discrete variables

2021-06-15 Thread Greg Ewing
On 15/06/21 10:07 pm, Elena wrote: After the optimization, I will use f just to predict new Xi. So you're going to use f backwards? I don't see how that will work. Where are you going to find a new yi to feed into the inverse of f? I think I don't understand what role g plays in all of this.

Re: Help with Python circular error

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 3:17 AM MRAB wrote: > > On 2021-06-15 17:49, Chris Angelico wrote: > > On Wed, Jun 16, 2021 at 2:45 AM Arak Rachael > > wrote: > >> > >> Hi to everyone, > >> > >> I am having a problem with this error, I created a package and uploaded it > >> to Test PyPi, but I can not

Re: Php vs Python gui (tkinter...) for small remote database app

2021-06-15 Thread Grant Edwards
On 2021-06-15, Menno Holscher wrote: > There is no difference regarding security concerns. I find that hard to believe given the long list of CVEs I've just had to sort through for even fairly recent versions of PHP. I just can't belive that Python has anywhere close to that many secruity issues

Re: Help with Python circular error

2021-06-15 Thread MRAB
On 2021-06-15 17:49, Chris Angelico wrote: On Wed, Jun 16, 2021 at 2:45 AM Arak Rachael wrote: Hi to everyone, I am having a problem with this error, I created a package and uploaded it to Test PyPi, but I can not get it to work, can someone help me please? https://test.pypi.org/manage/proj

Re: Where did the message go?

2021-06-15 Thread dn via Python-list
On 16/06/2021 04.47, Chris Angelico wrote: > On Wed, Jun 16, 2021 at 2:41 AM Grimble wrote: >> Thanks for reminding me of the log files. I've worked out that the >> message on machine H (for haydn, which shows my preferred music genre) >> was bouncing because haydn.. was not a registered

Re: Help with Python circular error

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 2:45 AM Arak Rachael wrote: > > Hi to everyone, > > I am having a problem with this error, I created a package and uploaded it to > Test PyPi, but I can not get it to work, can someone help me please? > > https://test.pypi.org/manage/project/videotesting/releases/' > > The

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread MRAB
On 2021-06-15 17:18, Dieter Maurer wrote: Chris Angelico wrote at 2021-6-15 19:08 +1000: On Tue, Jun 15, 2021 at 6:32 PM Dieter Maurer wrote: Chris Angelico wrote at 2021-6-15 05:35 +1000: >On Tue, Jun 15, 2021 at 5:12 AM Jach Feng wrote: >> >> >>> n = [(1,2) for i in range(3)] >> >>> n >> [

Re: Where did the message go?

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 2:41 AM Grimble wrote: > Thanks for reminding me of the log files. I've worked out that the > message on machine H (for haydn, which shows my preferred music genre) > was bouncing because haydn.. was not a registered subdomain with > my ISP, whereas bach..

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Chris Angelico
On Wed, Jun 16, 2021 at 2:18 AM Dieter Maurer wrote: > > Chris Angelico wrote at 2021-6-15 19:08 +1000: > >On Tue, Jun 15, 2021 at 6:32 PM Dieter Maurer wrote: > >> > >> Chris Angelico wrote at 2021-6-15 05:35 +1000: > >> >On Tue, Jun 15, 2021 at 5:12 AM Jach Feng wrote: > >> >> > >> >> >>> n =

Help with Python circular error

2021-06-15 Thread Arak Rachael
Hi to everyone, I am having a problem with this error, I created a package and uploaded it to Test PyPi, but I can not get it to work, can someone help me please? https://test.pypi.org/manage/project/videotesting/releases/' The error: /home/user/anaconda3/envs/testing/bin/python /home/user/de

Re: Where did the message go?

2021-06-15 Thread Grimble
On 14/06/2021 20:58, dn wrote: On 15/06/2021 01.00, Grimble wrote: I have two machines running Mageia 8 and Python 2.8.9, They use the same Python script to maintain a list of changed packages from dnf update and dnf install. In addition the script sends a short email message to my main email ad

Re: optimization of rule-based model on discrete variables

2021-06-15 Thread Elena via Python-list
Il Tue, 15 Jun 2021 01:53:09 +, Martin Di Paola ha scritto: > From what I'm understanding it is an "optimization problem" like the > ones that you find in "linear programming". > > But in your case the variables are not Real (they are Integers) and the > function to minimize g() is not linear

Re: optimization of rule-based model on discrete variables

2021-06-15 Thread Elena via Python-list
Il Tue, 15 Jun 2021 10:40:05 +1200, Greg Ewing ha scritto: > On 15/06/21 12:51 am, Elena wrote: > Hmmm, so the problem breaks down into two parts: > (1) find a vector Y that minimises g (2) find a set of rules that will > allow you to predict each component of Y from its corresponding X values >

Re: Php vs Python gui (tkinter...) for small remote database app

2021-06-15 Thread Menno Holscher
Op 14-06-2021 om 21:17 schreef Pascal B via Python-list: Hi, I would like to know if for a small app for instance that requires a connection to a remote server database if php is more suitable than Python mainly regarding security. Php requires one port for http and one port for the connection

Re: Behaviour of pop() for dictionaries

2021-06-15 Thread BlindAnagram
On 15/06/2021 00:11, dn wrote: On 15/06/2021 09.18, BlindAnagram wrote: On 14/06/2021 20:43, Chris Angelico wrote: On Tue, Jun 15, 2021 at 5:41 AM BlindAnagram ... No it isn't hard to use popitem() but it evidently proved hard for me to remember that it was there. If that's a problem, you'

Re: Behaviour of pop() for dictionaries

2021-06-15 Thread BlindAnagram
On 15/06/2021 01:36, Terry Reedy wrote: On 6/14/2021 5:18 PM, BlindAnagram wrote: I believe that consistency in how methods common to different types work is useful since it adds to the coherence of the language as a whole and avoids the need to remember special cases. Each collection class

Re: Is there a way to get the following result in Python?

2021-06-15 Thread Jach Feng
Peter Otten 在 2021年6月15日 星期二下午2:48:07 [UTC+8] 的信中寫道: > On 12/06/2021 04:02, Jach Feng wrote: > > def foo(): > > ... # do something > > ... > a = [] > for i in range(3): > > ... a.append(foo()) > > ... > a > > [] > The most natural way to achieve something similar is to

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Jach Feng
Greg Ewing 在 2021年6月15日 星期二下午3:01:46 [UTC+8] 的信中寫道: > On 15/06/21 3:18 pm, Jach Feng wrote: > > From a user's point, I don't really care how Python creates thoseinstances, > > > either using an already exist one or create a new one, as > > long as each element (and its sub-element) are independen

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Jach Feng
Chris Angelico 在 2021年6月15日 星期二上午5:23:12 [UTC+8] 的信中寫道: > On Tue, Jun 15, 2021 at 7:11 AM Rob Cliffe via Python-list > wrote: > > > > This puzzled me, so I played around with it a bit (Python 3.8.3): > > > > n = [] > > for i in range(3): > > n.append((1,7,-3,None,"x")) > > for i in range(3

Re: Is there a way to get the following result in Python?

2021-06-15 Thread Christian Gollwitzer
Am 12.06.21 um 04:02 schrieb Jach Feng: def foo(): ... # do something ... a = [] for i in range(3): ... a.append(foo()) ... a [] How about having "foo" return a list of things? Then you can append that list and return an empty list if you want nothing added: In [1]: def foo():

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Dieter Maurer
Chris Angelico wrote at 2021-6-15 19:08 +1000: >On Tue, Jun 15, 2021 at 6:32 PM Dieter Maurer wrote: >> >> Chris Angelico wrote at 2021-6-15 05:35 +1000: >> >On Tue, Jun 15, 2021 at 5:12 AM Jach Feng wrote: >> >> >> >> >>> n = [(1,2) for i in range(3)] >> >> >>> n >> >> [(1, 2), (1, 2), (1, 2)] >

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Greg Ewing
On 15/06/21 3:18 pm, Jach Feng wrote: From a user's point, I don't really care how Python creates thoseinstances, > either using an already exist one or create a new one, as long as each element (and its sub-element) are independent from each other so a modification of one will not influence the

Re: Php vs Python gui (tkinter...) for small remote database app

2021-06-15 Thread Tomasz Rola
On Tue, Jun 15, 2021 at 08:39:51AM +1200, dn via Python-list wrote: > On 15/06/2021 07.17, Pascal B via Python-list wrote: > > Hi, > > I would like to know if for a small app for instance that requires a > > connection to a remote server database if php is more suitable than Python > > mainly reg

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Chris Angelico
On Tue, Jun 15, 2021 at 6:32 PM Dieter Maurer wrote: > > Chris Angelico wrote at 2021-6-15 05:35 +1000: > >On Tue, Jun 15, 2021 at 5:12 AM Jach Feng wrote: > >> > >> >>> n = [(1,2) for i in range(3)] > >> >>> n > >> [(1, 2), (1, 2), (1, 2)] > >> >>> id(n[0]) == id(n[1]) == id(n[2]) > >> True > >

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Dieter Maurer
Chris Angelico wrote at 2021-6-15 05:35 +1000: >On Tue, Jun 15, 2021 at 5:12 AM Jach Feng wrote: >> >> >>> n = [(1,2) for i in range(3)] >> >>> n >> [(1, 2), (1, 2), (1, 2)] >> >>> id(n[0]) == id(n[1]) == id(n[2]) >> True > >This is three tuples. Tuples are immutable and you get three >references

Re: Behaviour of pop() for dictionaries

2021-06-15 Thread Cameron Simpson
On 14Jun2021 09:39, BlindAnagram wrote: >However, d.pop(key, [default]) returns the value (or the default) and >consistency with other pops (a good thing in my view) would suggest >that d.pop() could return a random value, which would serve my purpose >when there is only one element. If you do