Re: Reduce waiting queue at supermarket from Corona with Python-Webapp

2020-03-18 Thread Orges Leka
Thanks Christian for your suggestion.

I made the start here
https://github.com/orgesleka/supermarket-waiting-queue-alarm
The incomplete Flask/Jquery app is hosted here:
http://www.orges-leka.de/limburg.html
If someone can contribute by hosting this app for his city/community and
spreading the link to his friends, that would be a great thing to help.
If someone with better knowledge in Flask/Jquery can contribute code to
this, that would also be great.

Kind regards,
Orges

Am Di., 17. März 2020 um 23:02 Uhr schrieb Christian Gollwitzer <
[email protected]>:

> Am 17.03.20 um 11:16 schrieb Orges Leka:
> > The web-app could be a simple as one button:
> >
> > If users are before supermarket and there is a long queue, they click on
> > the web-app button and warn other users of the queue.
>
> It might be possible to make a Facebook "app" out of it. Facebook
> already provides a "login" feature, where it autodetects if you are near
> som point of interest and you only need to confirm that you want to be
> there. Also, the Facebook user base is extensive.
>
> > The same principle works for anti-traffi-jam apps, with user generated
> > content.
> >
> > If someone would like to work on this project, please let me know.
> >
>
> There is one obvious candidate who could work on this project. It's you.
>
> Best regards,
>
> Christian
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Mit freundlichen Grüßen
Herr Dipl. Math. Orges Leka

Mobil: 015751078391
Email: [email protected]
Holzheimerstraße 25
65549 Limburg
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reduce waiting queue at supermarket from Corona with Python-Webapp

2020-03-18 Thread joseph pareti
all right, I have informed my contact person at Facebook. I'll let you know
if anything positive comes out of it

Am Mi., 18. März 2020 um 08:09 Uhr schrieb Orges Leka :

> Thanks Christian for your suggestion.
>
> I made the start here
> https://github.com/orgesleka/supermarket-waiting-queue-alarm
> The incomplete Flask/Jquery app is hosted here:
> http://www.orges-leka.de/limburg.html
> If someone can contribute by hosting this app for his city/community and
> spreading the link to his friends, that would be a great thing to help.
> If someone with better knowledge in Flask/Jquery can contribute code to
> this, that would also be great.
>
> Kind regards,
> Orges
>
> Am Di., 17. März 2020 um 23:02 Uhr schrieb Christian Gollwitzer <
> [email protected]>:
>
> > Am 17.03.20 um 11:16 schrieb Orges Leka:
> > > The web-app could be a simple as one button:
> > >
> > > If users are before supermarket and there is a long queue, they click
> on
> > > the web-app button and warn other users of the queue.
> >
> > It might be possible to make a Facebook "app" out of it. Facebook
> > already provides a "login" feature, where it autodetects if you are near
> > som point of interest and you only need to confirm that you want to be
> > there. Also, the Facebook user base is extensive.
> >
> > > The same principle works for anti-traffi-jam apps, with user generated
> > > content.
> > >
> > > If someone would like to work on this project, please let me know.
> > >
> >
> > There is one obvious candidate who could work on this project. It's you.
> >
> > Best regards,
> >
> > Christian
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
>
>
> --
> Mit freundlichen Grüßen
> Herr Dipl. Math. Orges Leka
>
> Mobil: 015751078391
> Email: [email protected]
> Holzheimerstraße 25
> 65549 Limburg
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


How to fit & predict in Cat-boost Algorithm

2020-03-18 Thread princit
I am new in python. I am trying to predict the "time_to_failure" for given 
"acoustic_data" in the test CSV file using catboost algorithm.


def catbostregtest(X_train, y_train):  
# submission format
submission = pd.read_csv('sample_submission.csv', index_col='seg_id')
X_test = pd.DataFrame()
# prepare test data
for seg_id in submission.index:
seg = pd.read_csv('test/' + seg_id + '.csv')
ch = gen_features(seg['acoustic_data'])
X_test = X_test.append(ch, ignore_index=True)
# model of choice here
model = CatBoostRegressor(iterations=1, loss_function='MAE', 
boosting_type='Ordered')
model.fit(X_train, y_train)  #error line
y_hat = model.predict(X_test)#error line
# write submission file LSTM
submission['time_to_failure'] = y_hat
submission.to_csv('submissionCAT.csv')
print(model.best_score_)



This function "catbostregtest" is giving me error with the errorlog
 
Traceback (most recent call last):
File "E:\dir\question.py", line 68, in main()
File "E:\dir\question.py", line 65, in main catbostregtest(X_train, y_train)
File "E:\dir\question.py", line 50, in catbostregtest model.fit(X_train, 
y_train)
File 
"C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py",
 line 4330, in fit save_snapshot, snapshot_file, snapshot_interval, init_model)
File 
"C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py",
 line 1690, in _fit train_params["init_model"]
File 
"C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py",
 line 1225, in _train self._object._train(train_pool, test_pool, params, 
allow_clear_pool, init_model._object if init_model else None)
File "_catboost.pyx", line 3870, in _catboost._CatBoost._train
File "_catboost.pyx", line 3916, in _catboost._CatBoost._train
CatBoostError: 
c:/goagent/pipelines/buildmaster/catboost.git/catboost/libs/data/quantization.cpp:2424:
 All features are either constant or ignored.
This is gen_features function

def gen_features(X):
  
strain = []

strain.append(X.mean())

strain.append(X.std())

strain.append(X.min())

strain.append(X.max())

strain.append(X.kurtosis())

strain.append(X.skew())

strain.append(np.quantile(X,0.01))

strain.append(np.quantile(X,0.05))

strain.append(np.quantile(X,0.95))

strain.append(np.quantile(X,0.99))

strain.append(np.abs(X).max())

strain.append(np.abs(X).mean())

strain.append(np.abs(X).std())

return pd.Series(strain)


This function is called from the main function

def main():
train1 = pd.read_csv('train.csv', iterator=True, chunksize=150_000, 
dtype={'acoustic_data': np.int16, 'time_to_failure': np.float64})
X_train = pd.DataFrame()
y_train = pd.Series() 
for df in train1: 
ch = gen_features(df['acoustic_data']) 
X_train = X_train.append(ch, ignore_index=True)
y_train = y_train.append(pd.Series(df['time_to_failure'].values[-1])) 
catbostregtest(X_train, y_train)

How I can remove the error that occur during making predict from catboost 
model? How I can remove this error please help. You can download and run the 
project in spyder ide from this link 
https://drive.google.com/file/d/1JFsNfE22ef82e-dS0zsZHDE3zGJxnJ_J/view?usp=sharing
 or https://github.com/princit/catboostAlgorithm

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to fit & predict in Cat-boost Algorithm

2020-03-18 Thread Barry Scott



> On 18 Mar 2020, at 08:59, princit  wrote:
> 
> I am new in python. I am trying to predict the "time_to_failure" for given 
> "acoustic_data" in the test CSV file using catboost algorithm.
> 
> 
> def catbostregtest(X_train, y_train):  
># submission format
>submission = pd.read_csv('sample_submission.csv', index_col='seg_id')
>X_test = pd.DataFrame()
># prepare test data
>for seg_id in submission.index:
>seg = pd.read_csv('test/' + seg_id + '.csv')
>ch = gen_features(seg['acoustic_data'])
>X_test = X_test.append(ch, ignore_index=True)
># model of choice here
>model = CatBoostRegressor(iterations=1, loss_function='MAE', 
> boosting_type='Ordered')
>model.fit(X_train, y_train)  #error line
>y_hat = model.predict(X_test)#error line
># write submission file LSTM
>submission['time_to_failure'] = y_hat
>submission.to_csv('submissionCAT.csv')
>print(model.best_score_)
> 
> 
> 
> This function "catbostregtest" is giving me error with the errorlog

Have you checked the documentation for the library you are using?
Its clear that the author knows something is wrong, hence the error:

> CatBoostError: 
> c:/goagent/pipelines/buildmaster/catboost.git/catboost/libs/data/quantization.cpp:2424:
>  All features are either constant or ignored.

Hopeful the author documented the error to guide you.

Barry


> 
> Traceback (most recent call last):
> File "E:\dir\question.py", line 68, in main()
> File "E:\dir\question.py", line 65, in main catbostregtest(X_train, y_train)
> File "E:\dir\question.py", line 50, in catbostregtest model.fit(X_train, 
> y_train)
> File 
> "C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py",
>  line 4330, in fit save_snapshot, snapshot_file, snapshot_interval, 
> init_model)
> File 
> "C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py",
>  line 1690, in _fit train_params["init_model"]
> File 
> "C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py",
>  line 1225, in _train self._object._train(train_pool, test_pool, params, 
> allow_clear_pool, init_model._object if init_model else None)
> File "_catboost.pyx", line 3870, in _catboost._CatBoost._train
> File "_catboost.pyx", line 3916, in _catboost._CatBoost._train
> CatBoostError: 
> c:/goagent/pipelines/buildmaster/catboost.git/catboost/libs/data/quantization.cpp:2424:
>  All features are either constant or ignored.
> This is gen_features function
> 
> def gen_features(X):
> 
>strain = []
> 
>strain.append(X.mean())
> 
>strain.append(X.std())
> 
>strain.append(X.min())
> 
>strain.append(X.max())
> 
>strain.append(X.kurtosis())
> 
>strain.append(X.skew())
> 
>strain.append(np.quantile(X,0.01))
> 
>strain.append(np.quantile(X,0.05))
> 
>strain.append(np.quantile(X,0.95))
> 
>strain.append(np.quantile(X,0.99))
> 
>strain.append(np.abs(X).max())
> 
>strain.append(np.abs(X).mean())
> 
>strain.append(np.abs(X).std())
> 
>return pd.Series(strain)
> 
> 
> This function is called from the main function
> 
> def main():
>train1 = pd.read_csv('train.csv', iterator=True, chunksize=150_000, 
> dtype={'acoustic_data': np.int16, 'time_to_failure': np.float64})
>X_train = pd.DataFrame()
>y_train = pd.Series() 
>for df in train1: 
>ch = gen_features(df['acoustic_data']) 
>X_train = X_train.append(ch, ignore_index=True)
>y_train = y_train.append(pd.Series(df['time_to_failure'].values[-1])) 
>catbostregtest(X_train, y_train)
> 
> How I can remove the error that occur during making predict from catboost 
> model? How I can remove this error please help. You can download and run the 
> project in spyder ide from this link 
> https://drive.google.com/file/d/1JFsNfE22ef82e-dS0zsZHDE3zGJxnJ_J/view?usp=sharing
>  or https://github.com/princit/catboostAlgorithm
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


ZipFile and timestamps

2020-03-18 Thread Manfred Lotz
I unzip a zip file like follows which works fine.   

 with ZipFile(zip_file, 'r') as zip:
zip.extractall(tmp_dir)

The only caveat is that the unpacked files and dirs do have a current
timestamp i.e. the timestamps of the files are not preserved.

Is there a way to tell ZipFile to preserve timestamps when unpacking a
zip archive?


-- 
Manfred

-- 
https://mail.python.org/mailman/listinfo/python-list


Tkinter: which ttk widget for database table primary key?

2020-03-18 Thread Rich Shepard

Subject might be confusing so I'll expand it here.

My application uses a database backend in which each table has a unique and
database-generated sequential numeric key. I want to display that key in the
GUI for that class but it's not entered by the user or altered. It seems to
me that the ttk.Entry and ttk.Spinbox widgets are inappropriate. As a
newcomer to Tkinter I ask for advice on which widget to use.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: which ttk widget for database table primary key?

2020-03-18 Thread Christian Gollwitzer

Am 18.03.20 um 21:39 schrieb Rich Shepard:

Subject might be confusing so I'll expand it here.

My application uses a database backend in which each table has a unique and
database-generated sequential numeric key. I want to display that key in 
the

GUI for that class but it's not entered by the user or altered. It seems to
me that the ttk.Entry and ttk.Spinbox widgets are inappropriate. As a
newcomer to Tkinter I ask for advice on which widget to use.


You can use an Entry and set it to readonly state. Or you can use a 
Label. The advantage of the readonly Entry is, that the user can still 
copy/paste the content, and that it can scroll if the string is very long.


Christian
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: which ttk widget for database table primary key?

2020-03-18 Thread MRAB

On 2020-03-18 20:39, Rich Shepard wrote:

Subject might be confusing so I'll expand it here.

My application uses a database backend in which each table has a unique and
database-generated sequential numeric key. I want to display that key in the
GUI for that class but it's not entered by the user or altered. It seems to
me that the ttk.Entry and ttk.Spinbox widgets are inappropriate. As a
newcomer to Tkinter I ask for advice on which widget to use.


You can make the Entry widget read-only:

entry_widget['state'] = 'readonly'

The user will still be able to copy from it.

Alternatively, you can disable it:

entry_widget['state'] = 'disabled'

The user won't be able to copy from it.

When updating the GUI, you'll need to make it writeable if you have it 
currently read-only or disabled:


entry_widget['state'] = 'normal'
:
# Change the contents here.
:
entry_widget['state'] = 'readonly'
--
https://mail.python.org/mailman/listinfo/python-list


Re: ZipFile and timestamps

2020-03-18 Thread MRAB

On 2020-03-18 20:38, Manfred Lotz wrote:

I unzip a zip file like follows which works fine.

  with ZipFile(zip_file, 'r') as zip:
 zip.extractall(tmp_dir)

The only caveat is that the unpacked files and dirs do have a current
timestamp i.e. the timestamps of the files are not preserved.

Is there a way to tell ZipFile to preserve timestamps when unpacking a
zip archive?

You might have to iterate over the contents yourself and set the 
modification times.

--
https://mail.python.org/mailman/listinfo/python-list


[ANN] PyYAML-5.3.1: YAML parser and emitter for Python

2020-03-18 Thread Tina Müller

===
Announcing PyYAML-5.3.1
===

A new release of PyYAML is now available:
https://pypi.org/project/PyYAML/

This release contains a security fix for CVE-2020-1747. FullLoader was still
exploitable for arbitrary command execution.
https://bugzilla.redhat.com/show_bug.cgi?id=1807367

Thanks to Riccardo Schirone (https://github.com/ret2libc) for both reporting
this and providing the fixes to resolve it.

Changes
===

* https://github.com/yaml/pyyaml/pull/386 -- Prevents arbitrary code execution 
during python/object/new constructor


Resources
=

PyYAML IRC Channel: #pyyaml on irc.freenode.net
PyYAML homepage: https://github.com/yaml/pyyaml
PyYAML documentation: http://pyyaml.org/wiki/PyYAMLDocumentation
Source and binary installers: https://pypi.org/project/PyYAML/
GitHub repository: https://github.com/yaml/pyyaml/
Bug tracking: https://github.com/yaml/pyyaml/issues

YAML homepage: http://yaml.org/
YAML-core mailing list: http://lists.sourceforge.net/lists/listinfo/yaml-core


About PyYAML


YAML is a data serialization format designed for human readability and
interaction with scripting languages. PyYAML is a YAML parser and emitter for
Python.

PyYAML features a complete YAML 1.1 parser, Unicode support, pickle support,
capable extension API, and sensible error messages. PyYAML supports standard
YAML tags and provides Python-specific tags that allow to represent an
arbitrary Python object.

PyYAML is applicable for a broad range of tasks from complex configuration
files to object serialization and persistence.


Example
===


import yaml



yaml.full_load("""

... name: PyYAML
... description: YAML parser and emitter for Python
... homepage: https://github.com/yaml/pyyaml
... keywords: [YAML, serialization, configuration, persistence, pickle]
... """)
{'keywords': ['YAML', 'serialization', 'configuration', 'persistence',
'pickle'], 'homepage': 'https://github.com/yaml/pyyaml', 'description':
'YAML parser and emitter for Python', 'name': 'PyYAML'}


print(yaml.dump(_))

name: PyYAML
homepage: https://github.com/yaml/pyyaml
description: YAML parser and emitter for Python
keywords: [YAML, serialization, configuration, persistence, pickle]


Maintainers
===

The following people are currently responsible for maintaining PyYAML:

* Tina Mueller
* Ingy döt Net
* Matt Davis

and many thanks to all who have contribributed!
See: https://github.com/yaml/pyyaml/pulls


Copyright
=

Copyright (c) 2017-2020 Ingy döt Net 
Copyright (c) 2006-2016 Kirill Simonov 

The PyYAML module was written by Kirill Simonov .
It is currently maintained by the YAML and Python communities.

PyYAML is released under the MIT license.
See the file LICENSE for more details.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: which ttk widget for database table primary key?

2020-03-18 Thread Rich Shepard

On Wed, 18 Mar 2020, Christian Gollwitzer wrote:


You can use an Entry and set it to readonly state. Or you can use a Label.
The advantage of the readonly Entry is, that the user can still copy/paste
the content, and that it can scroll if the string is very long.


Christian,

Thank you. I did not find all options for the Entry widget in my quick look
for them. I like this because users will sometimes want to find all data
from that location and being able to copy that number and paste it in a
query will be helpful.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: which ttk widget for database table primary key?

2020-03-18 Thread Rich Shepard

On Wed, 18 Mar 2020, MRAB wrote:


You can make the Entry widget read-only:
   entry_widget['state'] = 'readonly'
The user will still be able to copy from it.

Alternatively, you can disable it:

   entry_widget['state'] = 'disabled'

The user won't be able to copy from it.

When updating the GUI, you'll need to make it writeable if you have it 
currently read-only or disabled:


   entry_widget['state'] = 'normal'
   :
   # Change the contents here.
   :
   entry_widget['state'] = 'readonly'


MRAB,

Thanks very much for expanding on Christian's response. This is the widget
I'll use and set it to 'readonly'.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Please Help! Absolute Novice - New Job, have this task.

2020-03-18 Thread mjnash194
Absolute beginner here, have no idea what I am doing wrong. All I want to do 
here is have the pushButton in PyQt5 to change to "Working..." and Red when 
clicked... which it currently does. Thing is I need it to also change back to 
the default "SCAN" and Green color when done running that method the button is 
linked to...

I know this is a super simple problem, and forgive any Novice errors in this 
code. I know very very little but if you guys can help me I would highly 
appreciate it!!! :)

from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import pyautogui



class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.showMaximized()
MainWindow.setMinimumSize(QtCore.QSize(0, 0))
MainWindow.setMaximumSize(QtCore.QSize(3840, 2160))
font = QtGui.QFont()
font.setFamily("Arial Black")
MainWindow.setFont(font)
MainWindow.setStyleSheet("background-color: rgba(0, 85, 127, 100);")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(250, 250, 400, 150))
font = QtGui.QFont()
font.setFamily("Tahoma")
font.setPointSize(24)
font.setBold(True)
font.setWeight(75)
self.pushButton.setFont(font)
self.pushButton.setStyleSheet("background-color: rgb(0, 170, 0);\n"
"color: rgb(255, 255, 255);")
self.pushButton.setObjectName("pushButton")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(730, 300, 701, 111))
font = QtGui.QFont()
font.setPointSize(18)
font.setBold(True)
font.setItalic(False)
font.setWeight(75)
self.label.setFont(font)
self.label.setLayoutDirection(QtCore.Qt.LeftToRight)
self.label.setObjectName("label")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1920, 18))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)

self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)

def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label.setStyleSheet("background-color: rgba(0, 85, 127, 0);\n"
"color: rgb(255, 255, 255);")
self.pushButton.setText(_translate("MainWindow", "SCAN"))
self.label.setText(_translate("MainWindow", "WELCOME"))

self.pushButton.clicked.connect(self.copy)

def copy(self, MainWindow):
self.pushButton.setText('WORKING...')
self.pushButton.setStyleSheet("background-color: rgb(250, 0, 0);\n"
"color: rgb(255, 255, 255);")
testprompt=storeid=pyautogui.prompt(text='test', title='test')



class Application():
def run():
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())

Application.run()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please Help! Absolute Novice - New Job, have this task.

2020-03-18 Thread bob gailer
Request for future: give us a specific subject e.g. how do I restore a 
button's text/color ?


On 3/18/2020 6:05 PM, [email protected] wrote:

Absolute beginner here, have no idea what I am doing wrong. All I want to do here is have 
the pushButton in PyQt5 to change to "Working..." and Red when clicked... which 
it currently does.

That's amazing since your code sets the text to WORKING...

Thing is I need it to also change back to the default "SCAN" and Green color 
when done running that method the button is linked to...

I know this is a super simple problem, and forgive any Novice errors in this 
code. I know very very little but if you guys can help me I would highly 
appreciate it!!! :)

from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import pyautogui



class Ui_MainWindow(object):
 def setupUi(self, MainWindow):
 MainWindow.setObjectName("MainWindow")
 MainWindow.showMaximized()
 MainWindow.setMinimumSize(QtCore.QSize(0, 0))
 MainWindow.setMaximumSize(QtCore.QSize(3840, 2160))
 font = QtGui.QFont()
 font.setFamily("Arial Black")
 MainWindow.setFont(font)
 MainWindow.setStyleSheet("background-color: rgba(0, 85, 127, 100);")
 self.centralwidget = QtWidgets.QWidget(MainWindow)
 self.centralwidget.setObjectName("centralwidget")
 self.pushButton = QtWidgets.QPushButton(self.centralwidget)
 self.pushButton.setGeometry(QtCore.QRect(250, 250, 400, 150))
 font = QtGui.QFont()
 font.setFamily("Tahoma")
 font.setPointSize(24)
 font.setBold(True)
 font.setWeight(75)
 self.pushButton.setFont(font)
 self.pushButton.setStyleSheet("background-color: rgb(0, 170, 0);\n"
"color: rgb(255, 255, 255);")
 self.pushButton.setObjectName("pushButton")
 self.label = QtWidgets.QLabel(self.centralwidget)
 self.label.setGeometry(QtCore.QRect(730, 300, 701, 111))
 font = QtGui.QFont()
 font.setPointSize(18)
 font.setBold(True)
 font.setItalic(False)
 font.setWeight(75)
 self.label.setFont(font)
 self.label.setLayoutDirection(QtCore.Qt.LeftToRight)
 self.label.setObjectName("label")
 MainWindow.setCentralWidget(self.centralwidget)
 self.menubar = QtWidgets.QMenuBar(MainWindow)
 self.menubar.setGeometry(QtCore.QRect(0, 0, 1920, 18))
 self.menubar.setObjectName("menubar")
 MainWindow.setMenuBar(self.menubar)
 self.statusbar = QtWidgets.QStatusBar(MainWindow)
 self.statusbar.setObjectName("statusbar")
 MainWindow.setStatusBar(self.statusbar)

 self.retranslateUi(MainWindow)
 QtCore.QMetaObject.connectSlotsByName(MainWindow)

 def retranslateUi(self, MainWindow):
 _translate = QtCore.QCoreApplication.translate
 MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
 self.label.setStyleSheet("background-color: rgba(0, 85, 127, 0);\n"
"color: rgb(255, 255, 255);")
 self.pushButton.setText(_translate("MainWindow", "SCAN"))
 self.label.setText(_translate("MainWindow", "WELCOME"))

 self.pushButton.clicked.connect(self.copy)

When user clicks button self.copy is invoked. True?

 def copy(self, MainWindow):
 self.pushButton.setText('WORKING...')

Why do you sometimes use _translate and not other times?

 self.pushButton.setStyleSheet("background-color: rgb(250, 0, 0);\n"
"color: rgb(255, 255, 255);")
 testprompt=storeid=pyautogui.prompt(text='test', title='test')


This method does no actual work! If you add

self.pushButton.setText(_translate("MainWindow", "SCAN"))
self.pushButton.setStyleSheet # whatever it was originally

it will reset the button. Of course it will so really fast, as there is 
no actual work being done.


So you should first address the issue of actually doing something that 
will take a little time. Also it is not a good idea to duplicate code, 
so I would put those 2 lines in a function and call that function from 2 
places.


Am I going in the right direction? Am I missing something?


class Application():
 def run():
 import sys
 app = QtWidgets.QApplication(sys.argv)
 MainWindow = QtWidgets.QMainWindow()
 ui = Ui_MainWindow()
 ui.setupUi(MainWindow)
 MainWindow.show()
 sys.exit(app.exec_())

Application.run()

Bob Gailer
--
https://mail.python.org/mailman/listinfo/python-list


How to build python binaries including external modules

2020-03-18 Thread James via Python-list
When you build python binaries from source, how to add external modules?
For example, to install cython, conventional method is building python first, 
then running setup.py for cython.
I'd like to combine the 2-step into one.

Thanks
James
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to build python binaries including external modules

2020-03-18 Thread Michael Torrie
On 2020-03-18 5:06 p.m., James via Python-list wrote:
> When you build python binaries from source, how to add external modules?
> For example, to install cython, conventional method is building python first, 
> then running setup.py for cython.
> I'd like to combine the 2-step into one.

Cython requires a working Python interpreter to run the setup.py.  How
would that work when building python itself?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to build python binaries including external modules

2020-03-18 Thread Dan Stromberg
I'm not completely sure I understand what the question is.

You can 'python3 -m pip install cython'.

You can use a shell/powershell wrapper that invokes the two things in
series.

Does that help?

On Wed, Mar 18, 2020 at 4:10 PM James via Python-list <
[email protected]> wrote:

> When you build python binaries from source, how to add external modules?
> For example, to install cython, conventional method is building python
> first, then running setup.py for cython.
> I'd like to combine the 2-step into one.
>
> Thanks
> James
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to build python binaries including external modules

2020-03-18 Thread Dan Stromberg
For a rather involved example of using a shell wrapper to build a bunch of
python-related stuff, feel free to raid
http://stromberg.dnsalias.org/svn/cpythons/trunk/ for ideas.  Or even just
use it.

It builds python 1.0 - 3.9, and installs some dependencies like cython,
pygobject and numpy.


On Wed, Mar 18, 2020 at 4:50 PM Dan Stromberg  wrote:

>
> I'm not completely sure I understand what the question is.
>
> You can 'python3 -m pip install cython'.
>
> You can use a shell/powershell wrapper that invokes the two things in
> series.
>
> Does that help?
>
> On Wed, Mar 18, 2020 at 4:10 PM James via Python-list <
> [email protected]> wrote:
>
>> When you build python binaries from source, how to add external modules?
>> For example, to install cython, conventional method is building python
>> first, then running setup.py for cython.
>> I'd like to combine the 2-step into one.
>>
>> Thanks
>> James
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to build python binaries including external modules

2020-03-18 Thread James via Python-list
On Wednesday, March 18, 2020 at 4:44:46 PM UTC-7, Michael Torrie wrote:

> Cython requires a working Python interpreter to run the setup.py.  How
> would that work when building python itself?

Python binary is built with a host of default modules. My question was how to 
promote external module(s) to a list of default modules. Or is it possible?
The goal was to build python for cross-platforms with external modules.

James
-- 
https://mail.python.org/mailman/listinfo/python-list


Why is the program not printing three lines?

2020-03-18 Thread Souvik Dutta
Hi,
I wrote a purposeless code today.

class first():
print("From first")
def second():
print("From second")
first()
first.second()


Now the output I get is
>From first
>From second

But when I comment the call of first that is the comment the second last
line of the code (#first()).
I get the same output. This is confusing because first() when called alone
prints from first. And first.second() when called alone prints from first
from second. But when both of them are called together, the output is from
first from second. Should not first.second() print only from second. Or
when I call both should I not get three line
from first
from first
from second
Why do I get that output?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why is the program not printing three lines?

2020-03-18 Thread Chris Angelico
On Thu, Mar 19, 2020 at 12:30 PM Souvik Dutta  wrote:
>
> Hi,
> I wrote a purposeless code today.
> 
> class first():
> print("From first")
> def second():
> print("From second")
> first()
> first.second()
> 
>
> Now the output I get is
> From first
> From second
>
> But when I comment the call of first that is the comment the second last
> line of the code (#first()).
> I get the same output. This is confusing because first() when called alone
> prints from first. And first.second() when called alone prints from first
> from second. But when both of them are called together, the output is from
> first from second. Should not first.second() print only from second. Or
> when I call both should I not get three line
> from first
> from first
> from second
> Why do I get that output?

Creating the class runs all the code in the class block, including
function definitions, assignments, and in this case, a print call.

Classes are not declarations. They are executable code.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in NumPy)

2020-03-18 Thread Santiago Basulto
Hello community. I have an idea to share with the list to see what you all
think about it.

I happen to use both Python for Data Science (with our regular friends
NumPy and Pandas) as well as for scripting and backend development. Every
time I'm working in server-side Python (not the PyData stack), I find
myself missing A LOT features from NumPy, like fancy indexing or boolean
arrays.

So, has it ever been considered to bake into Python's builtin list and
dictionary types functionality inspired by NumPy? I think multi indexing
alone would be huge addition. A few examples:

For lists and tuples:
>>> l = ['a', 'b', 'c']
>>> l[[0, -1]]
['a', 'c']

For dictionaries it'd even be more useful:
d = {
'first_name': 'Frances',
'last_name': 'Allen',
'email': '[email protected]'
}
fname, lname = d[['first_name', 'last_name']]

I really like the syntax of boolean arrays too, but considering we have
list comprehensions, seems a little more difficult to sell.

I'd love to see if this is something people would support, and see if
there's room to submit a PEP.

-- 
Santiago Basulto.-
Up!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ZipFile and timestamps

2020-03-18 Thread Manfred Lotz
On Wed, 18 Mar 2020 21:41:10 +
MRAB  wrote:

> On 2020-03-18 20:38, Manfred Lotz wrote:
> > I unzip a zip file like follows which works fine.
> > 
> >   with ZipFile(zip_file, 'r') as zip:
> >  zip.extractall(tmp_dir)
> > 
> > The only caveat is that the unpacked files and dirs do have a
> > current timestamp i.e. the timestamps of the files are not
> > preserved.
> > 
> > Is there a way to tell ZipFile to preserve timestamps when
> > unpacking a zip archive?
> >   
> You might have to iterate over the contents yourself and set the 
> modification times.

Oops, if this is required then I better change my code to invoke unzip.

Thanks,
Manfred

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in NumPy)

2020-03-18 Thread DL Neil via Python-list

On 19/03/20 3:28 PM, Santiago Basulto wrote:
...> myself missing A LOT features from NumPy, like fancy indexing or 
boolean

arrays.
So, has it ever been considered to bake into Python's builtin list and
dictionary types functionality inspired by NumPy? I think multi indexing
alone would be huge addition. A few examples:
For lists and tuples:
 >>> l = ['a', 'b', 'c']
 >>> l[[0, -1]]
 ['a', 'c']
For dictionaries it'd even be more useful:
 d = {
 'first_name': 'Frances',
 'last_name': 'Allen',
 'email': '[email protected]'
 }
 fname, lname = d[['first_name', 'last_name']]



I fear that I'm missing your point.

How is
l[[0, -1]] or fname, lname = d[['first_name', 'last_name']]
any better than
l[ 0 ], l[ -1 ] or
fname = d[ 'first_name' ]
lname = d[ 'last_name' ]

Are you aware, that whilst there is more coverage of "tuple unpacking" 
(at least to my eye), there is also a "list unpacking" feature?


>>> t = ( 1, 2, 3 )
>>> a, b, c = t
>>> print( a, b, c )
1 2 3

>>> l = [ 1, 2, 3 ]
>>> a, b, c = l
>>> print( a, b, c )
1 2 3

and somewhat similarly for dictionaries:

>>> fname, lname = d[ "first_name" ], d[ "last_name" ]
>>> fname, lname
('Frances', 'Allen')


That said, I've often wished to be allowed to write:

d.first_name

for a dict (cf a class/object).

Hmm, I feel a 'utility' coming-on - but first I'll look to see where/how 
such might be used in 'live' code (and be any better than the current 
mechanisms)...


Simple collections are one thing. How would you handle the structure if 
one or more elements contains a second dimension? eg a list within a 
list/a 2D matrix (or if you must, an 'array')?

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list