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

2021-06-14 Thread Peter Otten
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 replace append() with extend(): >>> def foo(): return () >>> a = [] >>> for i in range(3):

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

2021-06-14 Thread Cameron Simpson
On 11Jun2021 19:02, Jach Fong wrote: def foo(): >... # do something >... a = [] for i in range(3): >... a.append(foo()) >... a >[] Chris has explained that what you've written will never do it. But if instead you wanted to filter out None results, getting an empt

Re: Cant find sorcecode

2021-06-14 Thread Dan Stromberg
I don't know where your source code is specifically, but here's an example of looking up where a file lives: $ python3 below cmd output started 2021 Mon Jun 14 09:05:54 PM PDT Python 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for mo

Re: curses apps on MS Windows?

2021-06-14 Thread Eryk Sun
On 6/13/21, Grant Edwards wrote: > > Are there examples of popular curses applications for Windows? I don't think are any popular examples. The port of the "nano" editor uses ncurses. https://github.com/lhmouse/nano-win IIRC, PDCurses has better support -- e.g. 256 colors and blinking under Win

Re: optimization of rule-based model on discrete variables

2021-06-14 Thread Martin Di Paola
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. You could try/explore CVXPY (https://www.cvxpy.org/) which it's a so

Re: curses apps on MS Windows?

2021-06-14 Thread Michael Torrie
On 6/13/21 11:44 AM, Grant Edwards wrote: > There's been a surprising amount of discussion lately about using > curses libraries on Windows OS. I'm surprised by this, because I don't > think I've ever even seen a Windows curses application. > > Are there examples of popular curses applications for

Re: Behaviour of pop() for dictionaries

2021-06-14 Thread Terry Reedy
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 *is* a special case, and pop has to be ad

Re: curses apps on MS Windows?

2021-06-14 Thread jak
Il 13/06/2021 19:44, Grant Edwards ha scritto: There's been a surprising amount of discussion lately about using curses libraries on Windows OS. I'm surprised by this, because I don't think I've ever even seen a Windows curses application. Are there examples of popular curses applications for Wi

Re: curses apps on MS Windows?

2021-06-14 Thread Terry Reedy
On 6/13/2021 1:44 PM, Grant Edwards wrote: Does windows have a terminfo/termcap subsystem to deal with different terminal types? No. AFAIK Or do the apps only work with the built-in terminal windows implemented by command.com/cmd.exe? The windows console is implemented by separate code.

Re: optimization of rule-based model on discrete variables

2021-06-14 Thread Greg Ewing
On 15/06/21 12:51 am, Elena wrote: I see what you mean, so I try to explain it better: Y is a vector say [y1, y2, ... yn], with large (n>>10), where yi = f(Xi) with Xi = [x1i, x2i, ... x10i] 1<=i<=n. All yi and xji assume discrete values. I already have a dataset of X={Xi} and would like to find

Re: optimization of rule-based model on discrete variables

2021-06-14 Thread Richard Damon
On 6/13/21 12:15 PM, Elena via Python-list wrote: > Hi, I have, say 10 variables (x1 ... x10) which can assume discrete finite > values, for instance [0,1 or 2]. > I need to build a set of rules, such as: > > 1) if x1==0 and x2==1 and x10==2 then y = 1 > 2) if x2==1 and x3==1 and x4==2 and x6==0 t

Re: Behaviour of pop() for dictionaries

2021-06-14 Thread dn via Python-list
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 going to love using deques

Re: Behaviour of pop() for dictionaries

2021-06-14 Thread BlindAnagram
On 14/06/2021 20:43, Chris Angelico wrote: On Tue, Jun 15, 2021 at 5:41 AM 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

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-14 Thread Chris Angelico
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): > n.append((1,7,-3,None,"x")) > print([id(x) for x in n]) > > a = 4 >

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-14 Thread Rob Cliffe via Python-list
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):     n.append((1,7,-3,None,"x")) print([id(x) for x in n]) a = 4 n = [] for i in range(3):     n.append((1,7,-3,a,None,"x")) for i in range(3):     n.appe

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

2021-06-14 Thread dn via Python-list
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 regarding security. > Php requires one port for http and one port for the connect

Re: Where did the message go?

2021-06-14 Thread dn via Python-list
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 address. The problem is: the

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

2021-06-14 Thread 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 to the database open. If using Python with a tkinter gui,

Re: Behaviour of pop() for dictionaries

2021-06-14 Thread Chris Angelico
On Tue, Jun 15, 2021 at 5:41 AM 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 elemen

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

2021-06-14 Thread Chris Angelico
On Tue, Jun 15, 2021 at 5:23 AM Jach Feng wrote: > > >>> def foo(): > ... # do something > ... > >>> a = [] > >>> for i in range(3): > ... a.append(foo()) > ... > >>> a > [] > >>> > Barring shenanigans like messing with globals, no, there is no way for a function to return a lack of value

Re: optimization of rule-based model on discrete variables

2021-06-14 Thread Elena via Python-list
Il Mon, 14 Jun 2021 19:39:17 +1200, Greg Ewing ha scritto: > On 14/06/21 4:15 am, Elena wrote: >> Given a dataset of X={(x1... x10)} I can calculate Y=f(X) where f is >> this rule-based function. >> >> I know an operator g that can calculate a real value from Y: e = g(Y) >> g is too complex to be

Re: Behaviour of pop() for dictionaries

2021-06-14 Thread BlindAnagram
On 14/06/2021 08:29, Greg Ewing wrote: On 14/06/21 4:19 am, BlindAnagram wrote: Am I missing the obvious way to obtain the value (or the key) from a dictionary that is known to hold only one item? v = d.popitem()[1] Thanks, Greg, I missed that. More importantly, is there a good reason why

Behaviour of pop() for dictionaries

2021-06-14 Thread BlindAnagram
The pop() method exists for five mainstream data items and shows a range of different behaviours for each of them. But, of the five, pop for dictionaries is the only one for which the first parameter is required and this makes d.pop() for dictionaries an error rather than doing something usefu

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-14 Thread Chris Angelico
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 to the same thing. > >>> m = [[1,2] for i in range(3)]

optimization of rule-based model on discrete variables

2021-06-14 Thread Elena via Python-list
Hi, I have, say 10 variables (x1 ... x10) which can assume discrete finite values, for instance [0,1 or 2]. I need to build a set of rules, such as: 1) if x1==0 and x2==1 and x10==2 then y = 1 2) if x2==1 and x3==1 and x4==2 and x6==0 then y = 0 3) if x2==0 and x3==1 then y = 2 4) if x6==0 and x7

Tree library that allows conditions on nodes and will return the node

2021-06-14 Thread Veek M
LibreOffice has a huge class tree and I need to familiarize myself with it - trouble is, it won't fit on A4 because it has a flat hierarchy with loads of leaf nodes. I wanted to shove all the leaf nodes > x into a subgraph and style that differently using Graphviz. I tried treelib but while i can

Fwd: Unable to uninstall Python 3.8.7

2021-06-14 Thread Rudraksh Nanavaty
I previously uninstalled to python install directory which was: “C:\Users\{username}\Python\Python 3.8.4” Then I went to programs and features in the control panel and clicked uninstall. Wizard said uninstall successful, but it didn’t remove python from the programs list. I left it as is. Ignore

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

2021-06-14 Thread Jach Feng
>>> def foo(): ... # do something ... >>> a = [] >>> for i in range(3): ... a.append(foo()) ... >>> a [] >>> --Jach -- https://mail.python.org/mailman/listinfo/python-list

Re: Behaviour of pop() for dictionaries

2021-06-14 Thread Stestagg
You can do the following: _,v = d.popitem() Or: key, value = d.popitem() Steve On Mon, 14 Jun 2021 at 20:10, Greg Ewing wrote: > On 14/06/21 4:19 am, BlindAnagram wrote: > > Am I missing the obvious way to obtain the value (or the key) from a > > dictionary that is known to hold only one ite

Re: Terminology: EU language skills, and Master to Main (or ...)

2021-06-14 Thread Alan Gauld via Python-list
On 13/06/2021 04:21, dn via Python-list wrote: > What do you think a professionally-recognisable series of skill-levels > for programmers? This has been done or attempted many times, with perhaps the most complete scheme being the British Computer Society's "Industry Standard Model" which breaks

Where did the message go?

2021-06-14 Thread Grimble
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 address. The problem is: the message from machine B arrives, the mes

Re: Terminology: EU language skills, and Master to Main (or ...)

2021-06-14 Thread Greg Ewing
On 13/06/21 3:21 pm, dn wrote: Will referring to skilled professionals as 'masters (of their profession/craft)' transgress (international or at least US-instigated) 'Political Correctness'? And what about all the university degrees with the word "master" in their names? Worst of all, will epis

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-14 Thread Jach Feng
>>> 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 >>> m = [[1,2] for i in range(3)] >>> m [[1, 2], [1, 2], [1, 2]] >>> id(m[0]) == id(m[1]) == id(m[2]) False >>> --Jach -- https://mail.python.org/mailman/listinfo/python-list

Re: optimization of rule-based model on discrete variables

2021-06-14 Thread Greg Ewing
On 14/06/21 4:15 am, Elena wrote: Given a dataset of X={(x1... x10)} I can calculate Y=f(X) where f is this rule-based function. I know an operator g that can calculate a real value from Y: e = g(Y) g is too complex to be written analytically. I would like to find a set of rules f able to minim

Python

2021-06-14 Thread Adarsh Kumar
How to run python file in normal laptop actually when i run python it is showing error pls tell me how to add python extension in xammp -- https://mail.python.org/mailman/listinfo/python-list

Re: Behaviour of pop() for dictionaries

2021-06-14 Thread Greg Ewing
On 14/06/21 4:19 am, BlindAnagram wrote: Am I missing the obvious way to obtain the value (or the key) from a dictionary that is known to hold only one item? v = d.popitem()[1] More importantly, is there a good reason why we don't have d.pop() for dictionaries? My guess is because it's not

Cant find sorcecode

2021-06-14 Thread Madden
Hi so I've been trying to find my sorcecode files so I can 7zip them to get to the ovl_tool_gui so I can add mods but I haven't been able to find them could you help? Sent from [1]Mail for Windows 10 References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=5

curses apps on MS Windows?

2021-06-14 Thread Grant Edwards
There's been a surprising amount of discussion lately about using curses libraries on Windows OS. I'm surprised by this, because I don't think I've ever even seen a Windows curses application. Are there examples of popular curses applications for Windows? Does windows have a terminfo/termcap subs

Re: Python

2021-06-14 Thread Michael F. Stemper
On 12/06/2021 01.25, Adarsh Kumar wrote: How to run python file in normal laptop actually when i run python it is showing error pls tell me how to add python extension in xammp Are you trying to run a python program, as the first line suggests, or are you trying to run python itself, as the

Re: Tkinter8.6: date picker

2021-06-14 Thread Alan Gauld via Python-list
On 11/06/2021 22:20, Rich Shepard wrote: > I need a date picker +1 -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/ma

Re: Has anone seen or know of a CFFI wrapper for PDCurses?

2021-06-14 Thread Dan Stromberg
On Sun, Jun 13, 2021 at 10:42 PM wrote: > > From: Dan Stromberg > > Sent: Monday, June 14, 2021 12:36 AM > > To: pjfarl...@earthlink.net > > Cc: Python List > > Subject: Re: Has anone seen or know of a CFFI wrapper for PDCurses? > > > > > On Sun, Jun 13, 2021 at 12:50 AM