Re: Pickling issue.
On Mon, Dec 21, 2020, 3:03 PM Vincent Vande Vyvre < vincent.vande.vy...@telenet.be> wrote: > Hi, > > I've an object that I want to serialise with pickle. > When I reload the object the attributes of this object are correctly > fixed except one of these. > > This attribute (value) define a simple string. > > Example: > - > tag = XmpTag('Xmp.dc.form'image/jpeg') I am not familiar with XmpTag. Where might I get the containing module? tag.key > 'Xmp.dc.format' > tag.type > 'MIMEType' > tag.value > 'image/jpeg' > > s = pickle.dumps(tag) > t = pickle.loads(s) > t.key > 'Xmp.dc.format' # Correct > t.type > 'MIMEType' # Correct > t.value > ('image', 'jpeg') # Not correct > - > > Tested with Python-3.8 > > An idea ? > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Library for text substitutions with calculations?
On Tue, Dec 15, 2020, 10:42 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > On 2020-12-15 at 16:04:55 +0100, > Jan Erik Moström wrote: > > > I want to do some text substitutions but a bit more advanced than what > > string.Template class can do. I addition to plain text substitution I > would > > like to be able to do some calculations: > > > > $value+1 - If value is 16 this would insert 17 in the text. I would also > > like to subtract. > > val = 2 print(f'{val+3}') 5 Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Unable to download
On Wed, Dec 9, 2020, 11:46 AM Siddarth Adiga wrote: > Hello. I wanted to download the Python Version 3.9.1 but it said there was > already another version of Python already installed. But I have deleted the > program from the ADD OR REMOVE PROGRAMS option. But still I am unable to > download it. Please help. What OS are you using? Exactly what did you do to download? Exactly what did the error.message say? Bob Gailer > -- https://mail.python.org/mailman/listinfo/python-list
Re: try/except in loop
On Fri, Nov 27, 2020, 6:06 PM Jason Friedman wrote: > I'm using the Box API ( > https://developer.box.com/guides/tooling/sdks/python/). > I can get an access token, though it expires after a certain amount of > time. My plan is to store the access token on the filesystem and use it > until it expires, then fetch a new one. In the example below assume I have > an expired access token. > > > # This next line does not throw an error: > > client.folder('0').get_items() > > > # But iteration does (maybe this is a lazy fetch?) > > for _ in client.folder('0').get_items(): > > logger.debug("Using existing access token.") > > return access_token > > > # So I use try/except > > try: > > for _ in client.folder('0').get_items(): > > logger.debug("Using existing access token.") > > return access_token > > except boxsdk.exception.BoxAPIException: > > pass # access token invalid, let's get one > > else: > > pass # access token invalid, let's get one > > > # When running the debugger the except clause seems to catch the first > throw, but the loop I think continues, throws the error again, and that > second throw is not caught. > It would appear that get items is a generator which uses the token exactly once when it is first started; subsequent calls to the generator all use the same token. You need to test the token; if it fails, obtain a new one, then start the loop. Bob Gailer > -- https://mail.python.org/mailman/listinfo/python-list
Re: How to start using python
I am not feeling well these days. It is sometimes difficult for me to respond to others the way I would like to. This is a long reply; in my humble opinion is important to read all of it 1-whenever you respond to an email from one of us please include the help list what you can do by reply-all since there are others on this list who also help. 2 - you did not provide the information I had requested. It's really hard to help without that information. 3 - problems like you are facing are usually due to some unusual installation method. 4 - I suspect when you run the Visual Basic icon you enter an interactive development environment. True? Python also comes with an interactive development environment its name is IDLE. Idle is normally installed in a subdirectory how's the one that contains python.exe. once you locate that director you'll be able to run idle and you will be in an environment that will look somewhat familiar to you. There are tutorials specifically written to help you use IDLE. Others on this list can tell you how to locate that tutorial. 5 - I am sorry you are having such difficulty. It is relatively unusual for newcomers to experience that. 6 - suggestion: uninstall the thing you installed. go to python.Org. find, download and run the correct installer paying attention to any information it gives you on where it is installing python. then try running py again. On Nov 12, 2020 10:41 PM, "Anthony Steventon" wrote: > I am new to Python and have downloaded the software onto my pc. There is > no shortcut on my desktop. How the heck do I access it to start learning > how to program with it? > Anthony Steventon. > > -- > This email has been checked for viruses by AVG. > https://www.avg.com > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: How to start using python
On Nov 12, 2020 10:41 PM, "Anthony Steventon" wrote: > > I am new to Python and have downloaded the software onto my pc. There is no shortcut on my desktop. How the heck do I access it to start learning how to program with it? Visit www.Python.Org there should be some links to tutorials that should cover the topics of how to install python and how to start using it. If that does not help come back to us with more information including your operating system, the website from which you downloaded the installer, the name of the installer file, and what you did to install python. You also might try from a terminal or command prompt typing py, which should start up a python Interactive session. You should see>>> type 2 + 3 hit enter you should see a new line displaying five. Let us know how it goes and we'll give you a hand from there. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: How can I make this more complex?
On Nov 9, 2020 5:59 PM, "Quentin Bock" wrote: > > grade = input("Enter your grade: ") > if grade >= 90: > print("You got an A ") > if grade >= 80: > print("You got a B ") > if grade >= 70: > print("You got a C") > if grade >= 60: > print("You got a D ") > if grade >= 50: > print("You failed") > > > > > How can I make this to say if your grade is 90 or higher BUT less than 100 > you got an A if 100 > grade <= 90: Additional suggestions: change all but the first if to elif -- https://mail.python.org/mailman/listinfo/python-list
Re: Module import question
On Aug 9, 2020 11:41 AM, "Mats Wichmann" wrote: > > On 8/9/20 12:51 AM, Gabor Urban wrote: > > Hi guys, > > > > I have a quite simple question but I could not find the correct answer. > > > > I have twoo modules A and B. A imports B. If I import A in a script, Will > > be B imported automatically? I guess not, but fő not know exactly. > > > > Thanks for your answer ín advance, > > Think of import as meaning "make available in namespace". Well it's actually a little more involved than that. When python import a module it executes the module code. This is why you often see at the bottom of a module: if __name__ == '__main__': # code to execute when running the module as opposed to importing it. When importing a module __name__ is the module's name rather than '__main__'. What happens when module A Imports module B depends on whether or not the import B statement is actually executed. -- https://mail.python.org/mailman/listinfo/python-list
Re: python installation help
On Jul 10, 2020 1:04 PM, "Deepak Didmania" <6073sum...@gmail.com> wrote: > > please help me in installing python Visit this page: https://www.python.org/about/gettingstarted/ If you get stuck, reply-all and tell us: Your computer's operating system, Version of python you're trying to install, What you tried, Results you got that you weren't expecting. Don't attach screenshots as they probably won't come through. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Curses Programming HowTo -reviewers?
> If anyone feels keen please reply and I'll forward a copy. I'm interested please forward me a copy. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Can't run program
On May 19, 2020 9:02 PM, "Ryan Harrington" < ryan.harring...@whitesourcesoftware.com> wrote: > > Hi - I'm not the least bit technical. Trying to learn through YouTube. I've > gotten exit code 1, 2, 106. Tried setting up the project interpreter and > can't figure it out. Tried uninstalling and reinstalling everything and > still having problems. Any feedback appreciated. We need a lot more information in order to help you. Operating system? Where did you get the installation file? what does "everything" mean? Show us the steps you took and whatever error messages you got, or whatever "still having problems" means. I'm pretty sure this list does not take attachments, so you either need to copy and paste what you might have typed and any results from that, or put images in a place like pastebin and give us the link. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Not able use installed modules
On May 8, 2020 2:15 PM, "boB Stepp" wrote: [snip] > This may be a naive question on my part, but, as far as I can tell, most > instructions that I have encountered for installing Python packages state the > installation instructions as "pip install ...", which seems to repeatedly > lead to these type of OP questions. Has there ever been given thought to > changing these "standard" installation instructions to something less error > fraught for the newcomer/novice? > -- > Wishing you only the best, > > boB Stepp I agree. I've been using python for many many years and have been repeatedly frustrated with pip. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Error 0x80070643
On Apr 29, 2020 5:17 PM, "Antonis13XD" wrote: > > On Wed, Apr 29, 2020, 1:59 PM Antonis13XD > > > Hello python team! > > > > My name is antonis and I am a new fella who wants to be a programmer in > > python language. However, my thirst for learning I faced with an issue. > > More specifically, when I try to install 3.8.2 version of python, it > > shows me a message like this one in the first photo. This list does not accept attachments. Please copy and paste the text you want to share with us. Remember to reply all so that everyone on the list gets to see your response. Also let us know where you got the installer from and exactly what you did to try to install from it. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Getting the dependencies of a function from a library
For me the question is a little vague. What do you mean by Library? Could you give us a simple example of the input and the output? It's possible to interpret your question as an assessment of your skill level. We know nothing about your skill level. It's possible to interpret your question as to whether or not this is a turing complete problem. If you succeed in coming up with a sample input and output then how about trying to write a program to process that input to get that output. Post those results to this list and we'll see what we can do to help you. Bob gailer On Apr 20, 2020 6:18 PM, "elisha hollander" wrote: > I have a python library with a function. > This function call some other functions, classes and variable from the > library (and those functions and classes call other ones, etc)... > Can I automatically create a file with all of the dependencies (and nothing > else)? > (Already posted on stack overflow with no answer) > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Issues regarding the download
On Apr 18, 2020 2:29 PM, "MRIDULA GUPTA" <500067...@stu.upes.ac.in> wrote: > > Hi, > I am a new user and I am facing difficulty using the app. everytime I click > on the app the windows open which tell me either to modify the app or > repair it or uninstall it. I did my level best but still I am facing > problems installing it. please look into it as soon as possible. The program you downloaded is an installer. You run an installer one time, then you find the program that was installed ( python.exe in this case) and run that program. Exactly how you run the program depends on the operating system and where you chose to install the program. See the documentation at python.org for operating system specifics. Try this out then get back to us for more help. When responding please reply all and tell us what operating system you are using. This list does not accept attachments so you will have to copy and paste any text you want to share with us. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Troubling running my Python
On 4/8/2020 3:35 PM, Michael Torrie wrote: Assuming Windows here. The Python interpreter does nothing without a python program to run (to interpret). Thus if you simply double click on python.exe it will do nothing. That does not match my experience. I get the interactive prompt: Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Troubling running my Python
On 4/8/2020 3:12 PM, Lorraine Healy wrote: -- Forwarded message - From: Lorraine Healy Date: Wed, Apr 8, 2020 at 12:11 PM Subject: Troubling running my Python To: Hi, I have downloaded the 3.8 64 bit python program to my PC but the interpreter will not run. It seems to have 'repaired' itself when I ran the setup again but the interpreter still won't run. Is there a reason for this? Do you require a screenshot? Which operating system are you using? Exactly what do you do to "run the intepreter"? Copy and paste your actions and any messages. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Please Help! Absolute Novice - New Job, have this task.
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, mjnash...@gmail.com 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
Re: Python download for windows
:> You talk only about downloading - and the link you gave leads to the download page as a whole, so we can't guess the OS you - or your daughter - use. the subject line explicitly states "download for Windows" Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Python download for windows
On Mar 9, 2020 5:22 AM, "Hilary Ilsley" wrote: > > Hello > > We have been asked to download python so our daughter can complete her homework, only once we have down loaded it keeps going to "set up" and even after completing "modify" or "repair" it goes back to set up. You're getting that response because you are re-running the installer rather than running python. Take a look at https://docs.python.org/3/tutorial/interpreter.html#invoking-the-interpreter There is a section explicitly for Windows. Whoever asked you to download python has made the incorrect assumption that you could figure out what to do. That's not your fault. You might want to tell them about your experience and ask them for guidance. regarding email list etiquette: note that I have trimmed all the excess from your post and have responded in line rather than what we call Top posting. Please feel free to post here telling us what you've done and what that's gotten you. We are here to help and we are also volunteers which means we help as we can. -- https://mail.python.org/mailman/listinfo/python-list
Re: Need Help Urgently
On Feb 26, 2020 10:56 AM, "Prakash Samal" wrote: > > [ABCD client error]: Connection to broker at 126.0.0.1: lost! > "timestamp":"Wed Feb 19 11:48:41 > > [XYZ]: Connection to broker at 126.0.0.1: lost! > "timestamp":"Wed Feb 19 11:48:40 > > Note: I want to read the error code i.e ABCD Client error from the line and also wrt timestamp value. First a couple of pointers to help you get the results you want in future communications. Use a meaningful subject rather than help. Why? Because we keep track of a communication thread by the subject. It also helps us decide whether or not we can even tackle that particular problem. Send such requests to tu...@python.org. Understand that urgency on your part does not translate to urgency on our part. We are volunteers who donate some of our time to giving help. You can accomplish your objective by using various string processing functions or by using regular expressions. I will assume that you want to extract everything between square brackets as the error and everything following the 2nd quote as the timestamp. Let's use the string find method. With that you can get the index of a particular character and use string slicing with those indexes to get the actual strings. If you have a basic understanding of python that should be enough to get you started. Otherwise I suggest you start with a tutorial that will get you those basics. if you just want someone to write the program for you then one of us will be glad to act as a paid consultant and do that for you. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: no explanation towards not installing my application//
On Feb 3, 2020 8:18 AM, "the python app i had downloaded is not opening!" < mbharathi1...@gmail.com> wrote: I'm assuming you're using Windows 10. Correct? You're telling us you downloaded the program installer. Did you run the installer? Where did it tell you it was putting the program? Exactly what did you do to try to open python? Exactly what results did you get? Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re:
On Jan 17, 2020 5:37 AM, "kiran chawan" wrote: > > Hi, Sir my self kiran chawan studying in engineering and I have HP PC and > windows edition is window 10, system type 64-bit operating system. So tell > me which python version software is suitable for my PC okay and send me > that software direct link Try this link: Windows x86-64 executable installer <https://www.python.org/ftp/python/3.8.1/python-3.8.1-amd64.exe> Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Implementing CURL command using libcurl in C/C++
This list is for Python, not C/C++. On Dec 13, 2019 3:50 AM, "Karthik Sharma" wrote: > The `CURL` command that I am using is shown below. > > curl -F 'file=@/home/karthik/Workspace/downloadfile.out' > http://127.0.0.1:5000/file-upload --verbose > > The response from the server is shown below. > > * Trying 127.0.0.1... > * Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0) > > POST /file-upload HTTP/1.1 > > Host: 127.0.0.1:5000 > > User-Agent: curl/7.47.0 > > Accept: */* > > Content-Length: 663876790 > > Expect: 100-continue > > Content-Type: multipart/form-data; boundary=- > ---4e96ef0714498bd7 > > > < HTTP/1.1 100 Continue > * HTTP 1.0, assume close after body > < HTTP/1.0 201 CREATED > < Content-Type: application/json > < Content-Length: 46 > < Server: Werkzeug/0.16.0 Python/3.5.2 > < Date: Sat, 14 Dec 2019 07:05:15 GMT > < > { > "message": "File successfully uploaded" > } > * Closing connection 0 > > I want to implement the same command in C/C++ using libcurl. I am using > the following function. > > int FileUploadDownload::upload(const std::string &filename, const > std::string &url) { > > CURL *curl; > CURLcode res; > struct stat file_info; > curl_off_t speed_upload, total_time; > FILE *fd; > > fd = fopen(filename.c_str(), "rb"); > if(!fd) { > m_logger->errorf("unable to open file: %s\n",strerror(errno)); > return 1; > } > if(fstat(fileno(fd), &file_info) != 0) { > m_logger->errorf("unable to get file stats: > %s\n",strerror(errno)); > return 2; > } > > std::cout << "filename : "<< filename << std::endl; > std::cout << "url : " << url << std::endl; > > curl = curl_easy_init(); > if(curl) { > > curl_easy_setopt(curl, CURLOPT_URL, > url.c_str()); > > curl_easy_setopt(curl, CURLOPT_POSTFIELDS, filename.c_str()); > curl_easy_setopt(curl, CURLOPT_POST, 1L); > curl_easy_setopt(curl, CURLOPT_READDATA, fd); > curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, > (curl_off_t) file_info.st_size); > curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); > > res = curl_easy_perform(curl); > if (res != CURLE_OK) { > m_logger->errorf("curl_easy_perform() failed: > %s\n",curl_easy_strerror(res)); > } else { > curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, > &speed_upload); > curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total_time); > m_logger->infof("Speed: %" CURL_FORMAT_CURL_OFF_T " > bytes/sec during %" > CURL_FORMAT_CURL_OFF_T ".%06ld seconds\n", > speed_upload, > (total_time / 100), (long) (total_time > % 100)); > } > } > return 0; > } > The below is the result that I get from the server. > > The result that I get is shown below. >* Trying 127.0.0.1... > * Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0) > > POST /file-upload HTTP/1.1 > > Host: 127.0.0.1:5000 > > User-Agent: curl/7.47.0 > > Accept: */* > > Content-Length: 550 > > Expect: 100-continue > > Content-Type: multipart/form-data; boundary=- > ---c8ef4837136fca99 > > > < HTTP/1.1 100 Continue > * HTTP 1.0, assume close after body > < HTTP/1.0 201 CREATED > < Content-Type: application/json > < Content-Length: 46 > < Server: Werkzeug/0.16.0 Python/3.5.2 > < Date: Sat, 14 Dec 2019 07:09:47 GMT > < > { > "message": "File successfully uploaded" > } > * Closing connection 0 > > > My aim is to mimic the curl command above in the C/C++ code below. What am > I doing wrong ? > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Looking for python pentest scripts
Try Googling python pentesting. That will give you some relevant links. On Nov 10, 2019 6:40 AM, "nixuser" wrote: > Hello, > > can someone tell about good resource for python related pentesting > scripts? > any extensive list? > > Thanks > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: How execute at least two python files at once when imported?
On Nov 5, 2019 1:35 PM, "Spencer Du" wrote: > > Hi > > I want to execute at least two python files at once when imported but I dont know how to do this. Currently I can only import each file one after another but what i want is each file to be imported at the same time. Can you help me write the code for this? Please explain what you mean by "imported at the same time". As far as I know that is physically impossible. -- https://mail.python.org/mailman/listinfo/python-list
Re: List comprehension strangeness
The length of the list produced by the comprehension also give you good information. -- https://mail.python.org/mailman/listinfo/python-list
Re: List comprehension strangeness
The function IMHO must be returning a generator. I would look for a problem in the generator code. -- https://mail.python.org/mailman/listinfo/python-list
Re: Do I need a parser?
I might be able to help. I'd need to understand a bit more about the configuration and scripting languages. Do you have any reference material? Or some way to look up the titration device on the internet? -- Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Python running issues
please copy everything from the command you entered through the end of the error message. Then paste that into a reply email. Also let us know what your operating system is. Be sure to reply all so a copy goes to the list. Bob Gailer On Apr 19, 2019 6:56 PM, "Kiranpreet Kaur" wrote: Hello, I am trying to run python from command prompt. However, cannot get past the error: “ImportError: no module named site”, whenever I try to run Python from the terminal. Can you help me fix that? I spent a couple hours on searching a fix for this issue on Google and nothing seems to work. I even deleted and re-installed Python, updated the Environment variables in the System Settings, but nothing seems to work. Also, I am not able to install the library needed to run the pip command. I would really appreciate if you could help me. Best Regards, Kiranpreet Kaur kayk...@ucdavis.edu -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to store scores of a race's players
Please do not use a mangled return email address. It causes us a lot of pain when we fail to read your address to fix it and get the message bounced back. The only reason I'm even bothering to resend it is because I put a lot of work into it.: > On > Mar 26, 2019 6:55 AM, "^Bart" wrote: > > > > Hello! > > > > I need to store scores of three players for more than a race, after every race the user will read "Is the competition finished?", if the competition if finished the user will see the winner who got higest score: > > > Thank you for reaching out to us for help as You Learn Python. A good mailing list to use instead of the main python list is tu...@python.org. I'm including that list in the reply addresses; please use that address in the future and always reply all so a copy goes to that list. > > This looks like a homework assignment. Be advised we won't write code for you but we will help you when you get stuck and provide some guidance. I'm personally curious as to who wrote that specification, since it is not well written. One of the questions that fails to address is what if two or more players have the same high score? > > It's also a little hard to guide you since we don't know what you've already learned. One of the fundamental concepts in computer programming is that of a loop. Since the requirements indicate there will be more than one race that requires a loop. The simplest python construction for a loop is a while. Within that Loop you write the code once rather than rewriting it as you have done. I hope that is enough to get you started. Please apply that advice as best you can and come back with a revised program. > > > p1 = int (input ("Insert score of the first player: ")) > > p2 = int (input ("Insert score of the second player: ")) > > p3 = int (input ("Insert score of the third player: ")) > > > > race = str (input ("Is the competition finished?")) > > > > totalp1 = 0 > > totalp2 = 0 > > totalp3 = 0 > > > > winner = 0 > > > > if p1 > p2 and p1 > p3: > > winner = c1 > > elif p2 > p1 and p2 > p3: > > winner = p2 > > else: > > winner = p3 > > > > if "yes" in race: > > print("The winner is:",winner) > > else: > > p1 = int (input ("Insert score of the first player: ")) > > p2 = int (input ("Insert score of the second player: ")) > > p3 = int (input ("Insert score of the third player: ")) > > > > race = str (input ("Is the competition finished?")) > > > > You read above just my toughts, is there someone who could help me to understand how to solve it? > > > > Regards. > > ^Bart > > -- > > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to store scores of a race's players
On Mar 26, 2019 6:55 AM, "^Bart" wrote: > > Hello! > > I need to store scores of three players for more than a race, after every race the user will read "Is the competition finished?", if the competition if finished the user will see the winner who got higest score: > Thank you for reaching out to us for help as You Learn Python. A good mailing list to use instead of the main python list is tu...@python.org. I'm including that list in the reply addresses; please use that address in the future and always reply all so a copy goes to that list. This looks like a homework assignment. Be advised we won't write code for you but we will help you when you get stuck and provide some guidance. I'm personally curious as to who wrote that specification, since it is not well written. One of the questions that fails to address is what if two or more players have the same high score? It's also a little hard to guide you since we don't know what you've already learned. One of the fundamental concepts in computer programming is that of a loop. Since the requirements indicate there will be more than one race that requires a loop. The simplest python construction for a loop is a while. Within that Loop you write the code once rather than rewriting it as you have done. I hope that is enough to get you started. Please apply that advice as best you can and come back with a revised program. > p1 = int (input ("Insert score of the first player: ")) > p2 = int (input ("Insert score of the second player: ")) > p3 = int (input ("Insert score of the third player: ")) > > race = str (input ("Is the competition finished?")) > > totalp1 = 0 > totalp2 = 0 > totalp3 = 0 > > winner = 0 > > if p1 > p2 and p1 > p3: > winner = c1 > elif p2 > p1 and p2 > p3: > winner = p2 > else: > winner = p3 > > if "yes" in race: > print("The winner is:",winner) > else: > p1 = int (input ("Insert score of the first player: ")) > p2 = int (input ("Insert score of the second player: ")) > p3 = int (input ("Insert score of the third player: ")) > > race = str (input ("Is the competition finished?")) > > You read above just my toughts, is there someone who could help me to understand how to solve it? > > Regards. > ^Bart > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: ajax with pyside webview
I assume you are referring to QT webview. "ajax via jquery does not work." Can you be more specific? what is the evidence that it's not working? It sounds like you've got a server running on your Local Host. What does the server tell you about its side of that Ajax request? -- https://mail.python.org/mailman/listinfo/python-list
Re: Im trying to replicate the youtube video Creating my own customized celebrities with AI.
On Feb 10, 2019 11:40 AM, wrote: > > The video I don't see any video here. If you attached one the attachment did not come through. > gives the source code and the necessary things to download with it. But I'm new to python and don't understand how to install any of the files. The files include: Python 3 Which you can download from python.org - just follow the link to downloads. > pip is automatically installed when you install python > tenserflow, pygame, scipy, and numby All of these are probably installable using pip. By the way did you mean numpy? At a command prompt type pip install packagename. I suggest you switch from l...@python.org to h...@python.org. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: OT - need help with PHP
Thank you. I will get back to you on that shortly. Bob -- https://mail.python.org/mailman/listinfo/python-list
Re: OT - need help with PHP
Thank you for your various responses. All helpful and encouraging. RE mailing list: I followed the instructions at http://php.net/manual/en/faq.mailinglist.php. I have had no response. Shouldn't I get something either welcoming me to the list or requesting a confirmation? Here are the instructions from the api vendor: (somewhat lengthy) HOW TO CALL A FUNCTION USING VOIP.MS REST/JSON API The following samples show how to get all Servers Information from our database and how to select a specific Server for your display purposes. Please Note: - When using our REST/JSON API you need to send the Method to be used and the Required Parameters as part of the URL. - By default the output Content-Type is "text/html". - If you want the output Content-Type to be "application/json", add the following to your URL: &content_type=json PHP - Using cURL GET - Sample Code |$ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt($ch, CURLOPT_URL, "https://voip.ms/api/v1/rest.php?api_username=j...@domain.com&api_password=password&method=getServersInfo&server_pop=1";); $result1 = curl_exec($ch); curl_close($ch); $data1=json_decode($result1,true); print_r($data1);| PHP - Using cURL POST - Sample Code |$postfields = array( 'api_username'=>'j...@domain.com', 'api_password'=>'password', 'method'=>'getServersInfo', 'server_pop'=>'1'); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt($ch, CURLOPT_POST, true ); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt($ch, CURLOPT_URL, "https://voip.ms/api/v1/rest.php";); $result = curl_exec($ch); curl_close($ch); $data=json_decode($result,true); print_r($data); | Note: I have edited these examples by removing unnecessary stuff, to make their size reasonable. On the Python side, I can make the GET version work using urllib.request. I will try requests soon. When I try to run the post example using php -r "path-to-php-progran"; It just prints the program. Any attempt at converting that to POST get me a Bad Request response. One of my needs is to upload a .wav file. The vendor requires the file to be encoded into base64 and the result string included in the POST data, which can lead to enormously long POST data. I can successfully use GET to send very short .wav files, but the url length limit is quickly reached for a reasonable length recording. Trying to use the POST ability that allows me to specify the file by path fails at the vendor side. Apology for long post, but I don't know what to omit. Again any help is welcome. -- Bob Gailer --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- https://mail.python.org/mailman/listinfo/python-list
OT - need help with PHP
Trying to setup PHP on Windows 10 using the curl extension to run standalone. Why? I am trying to use an API where the only coding examples are written in PHP. My goal is to use python, and the place where I'm stuck is: the examples use Curl to post requests; my attempts to translate this to urllib. request have failed. I can't even figure out how to sign up for a PHP email list. Help with either of the above would be welcome. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I get a python program to work on my phone?
kivy has a very steep learning curve. The easy way to use kivy is to install the kivy launcher app which then lets you run a Python program and access the kivy widgets. If you really want to dive into kivy I will send you a presentation I gave on kivy. After a lot of work I did manage to create an install an app. An interesting alternatives to create a simple web page to run in the phone's browser. If you don't already have a server on the web you can rent one from secure dragon for as low as $12 a year. Install websocketd and python. Websocketd lets you do all sorts of interesting things such as serve static pages, CGI programs, and use websockets. Websockets requires a little bit of JavaScript but makes the interaction between a browser page and a Python program on the server ridiculously easy. Much easier than Ajax. Feel free to ask for more information. I posted a Python program on the websocketd website that shows how to do the server side of websockets communication. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Exercize to understand from three numbers which is more high
On Jan 25, 2019 7:00 AM, "^Bart" wrote: > > number1 = int( input("Insert the first number: ")) > > number2 = int( input("Insert the second number: ")) > > number3 = int( input("Insert the third number: ")) > > if number1 > number2 and number1 > number3: > print("Max number is: ",number1) > > if number2 > number1 and number2 > number3: > print("Max number is: ",number2) > > else: > print("Max number is: ",number3) > > Try to insert numbers 3, 2 and 1 and the result will be number 3 and 1, can you help me to fix it?! :\ Suggestion: Pretend that you are the computer. Mentally execute each statement, providing input as required, and write down the results. Something like: Statement Input Result 13 number1 = 3 22 number2 = 2 31 number3 = 1 4 Max number is 3 5 False 6 Max number is 1 Do not guess or assume anything. Just do exactly what each statement says. As an alternative use some kind of debugger that will let you step through the program statement by statement. Most interactive development environments such as IDLE let you do this. You might as well learn to do this now as you will be needing it more and more as you go on. Personally I would not have given any answer to the problem until you had an opportunity to research it more thoroughly. We don't learn by being given answers. Also in the future use tu...@python.org as that's the proper place for this kind of question. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re:
On Dec 11, 2018 3:05 PM, "Alperen Eroğlu" <33alperen200...@gmail.com> wrote: > > I subscribed to python list and now I want to state my requeat.I downloaded > Python because I wanted to learn how to code.I also downloaded a text > editor specially designed for coding Python(which iscalled Pycharm) > .both of the softwares and my Windows 10 software was he latest.I got into > Python We will need more information in order to help you. What did you do to get into python? and it asked me which text file I was going to use to edit files I'm sorry but that does not make sense to me. Could you show us exactly what this request looks like? > the app(which is Python)couldn't find where the files were located. Again please show us the messages you got. It is best if possible to copy and paste this information into your reply Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP 572 -- Assignment Expressions
On 11/27/2018 5:48 AM, Ivo Shipkaliev wrote: Hello. Maybe it's too late for a discussion, but I just couldn't resist. I just found out about this new ":=" operator. I need to ask: What is the need for this additional ":" to the "="? Did you read the PEP? It answers the question. Why: if (match := pattern.search(data)) is not None: # Do something with match What is wrong with: if match = pattern.search(data) is not None: # Do something with match match = pattern.search(data) is not None returns True or False, which is then assigned to match. On the other hand, in (match := pattern.search(data)) is not None match is assigned the result of the search; then that is compared to None. I am glad to see this added to python. I first encountered embedded assignment in 1969 in the fortran iv compiler for the GE 415 computer. Love at first sight. -- Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: help me in a program in python to implement Railway Reservation System using file handling technique.
On Nov 24, 2018 1:35 AM, wrote: > > hello all, > please hepl me in the above program. What do you mean by "the above program"? I don't see any. python to implement Railway Reservation System using file handling technique. > > System should perform below operations. > a. Reserve a ticket for a passenger. > b. List information all reservations done for today’s trains. > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Intitalize values for a class
On Nov 23, 2018 8:42 AM, "Ganesh Pal" wrote: > > Hello team, > > I am a python 2.7 user on Linux. I will need feedback on the below program > as I'm new to oops . My feedback is: Firstly there's a blank line between every line of program text which makes it hard to read. Also some statements are spread out over more than one line which also makes it hard to read. Secondly this sounds like a homework assignment. Is that true? If so be aware that we will be glad to help if you tell us where you are stuck but we won't write the code for you. Please learn how to write effective questions. You can Google that and find several good resources. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Intitalize values for a class
On Nov 23, 2018 8:42 AM, "Ganesh Pal" wrote: > > Hello team, > > I am a python 2.7 user on Linux. I will need feedback on the below program > as I'm new to oops . What kind of feedback do you want? > > #!/usr/bin/python > > > class System(object): > > '''Doc - Inside Class ''' > > def __init__(self, params=None): > >if params is None: > > self.params = {'id': '1', > > 'name': 's-1'} > > print self.params > >if type(params) is dict and params.get('id') == '0': > > raise ValueError('ERROR: id 0 is reserved !! ') > >#print self.params > >else: > > self.params = params > > print self.params > > # Test all conditions > > #case 0 - Default should create {'id': '1','name': 's-1'} > #s0 = System() > > #Case 1 (id has value '0') > #test1_params = {'id': '0', 'name': 's-0'} > #s1 = System(params=test1_params) > > > #Case 2 (id has some other values) > #test2_params = {'id': '10', 'name': 's-10'} > #s2 = System(params=test2_params) > > > Question: > > I have to initialize the values the below class such that > > 1. Intitalize default values if nothing is supplied by the username i.e > self.params = {'id': '1', 'name': 's-1'} > > 2. I need to raise an Exception if the value for the key params[id] is '0'. > > 3. It should work if params[I'd] has values other than (1) and (2) > > Regards, > Ganesh > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Install
OK. On Nov 23, 2018 8:08 AM, "Salomon Chavarin" wrote: > > > Sent from Mail for Windows 10 > > > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: can you please help me in opening the python programming.
We would be glad to help. I can't tell from your question what kind of help you need so please give us more information. Have you tried to install python? If so has the installation succeeded? What do you mean by "open the programming"? What have you tried? What do you expect to see? -- https://mail.python.org/mailman/listinfo/python-list
Re: Python-remove duplicate output
On Nov 22, 2018 8:50 AM, wrote: > > On Thursday, November 22, 2018 at 12:10:28 AM UTC+1, drvuc...@gmail.com wrote: > > How to remove duplicate lines and store output into one ine > > > >reservations = ec.describe_instances().get('Reservations', []) > > > >for reservation in reservations: > > for instance in reservation['Instances']: > > tags = {} > > for tag in instance['Tags']: > > tags[tag['Key']] = tag['Value'] > > if tag['Key'] == 'Name': > > name=tag['Value'] > > > > if not 'Owner' in tags or tags['Owner']=='unknown' or tags['Owner']=='Unknown': > > print name > > > > Current Output: > > > > aws-opsworks > > > > aws-opsworks Ansible > > > > Desired output: > > > > aws-opsworks Ansible > > You can use a set to do the job. Remember that members in the set are unique, > duplicate members are ignored. > > Before you start the for loop, create a set: > > names = set() > > Instead of `print name`, you add the name to the set: > > names.add(name) > > Note that if name already exists, because members of a set are unique, > the name is (at least conceptually) ignored. > > Once the for loop is completed, you print the remaining names. > > print names (Python 2) > or > print(names) (Python 3) It is actually sufficient to just say print)names) since that works equally well in 2 or 3. Bob -- https://mail.python.org/mailman/listinfo/python-list
Re: int.to_bytes() for a single byte
On 11/6/2018 9:30 PM, jlada...@itu.edu wrote: I'm using Python 3.6. I have a need to convert several small integers into single bytes. As far as I can tell from reading through the Python docs, the correct way to accomplish this task is: b = i.to_bytes(1, "big") This seems to work, but I find it cumbersome. I have to supply the byteorder argument to prevent a TypeError. However, byte order doesn't matter if I'm only generating a single byte. Whether I choose "big" or "little" I should get the same result. Is there another function which provides a more logical interface to this straightforward task? Take a look at the struct module. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: zenity substitution
On Oct 28, 2018 10:17 PM, "listo factor via Python-list" < python-list@python.org> wrote: > > Hi all, > I'm new to Python, but not to programming. > > As a teaching exercise, I am converting a bunch of bash shell > scripts to Python, so that they can be run on all three OS-es > (Linux, Windows, MacOS). > > The scripts in questions make extensive use of Linux "zenity" > dialogs. > > Is there an equivalent facility in Python 3? If so, what is it? Look up zenity in Wikipeda. Scroll down to cross-platform script. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Accessing clipboard through software built on Python
On Oct 27, 2018 9:20 AM, "Musatov" wrote: > > I am wondering if Python could be used to write a program that allows: > > 1. Highlight some text > 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1 > 3. Highlight another string of text > 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2 > > THEN > > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 > What operating system are you using? If it is Windows I recommend you take a look at a program called autohotkey. > I found "pyperclip" and "Tkinter" but I don't know where to start. > > Thanks, > > Musatov > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Enhancement Proposal for List methods
Many of the features of python were added not out of need but rather for convenience. If need were the only criteria we could immediately get rid of comprehensions, since they can be written as a series of for loops, the same can be said for many other newer features. Python is all about making the programming experience easier and more productive. Expanding replace from just strings to other sequences such as as lists makes sense. The cost in time and effort to add this to python is trivial. I say go for it. -- https://mail.python.org/mailman/listinfo/python-list
Re: snakify issues
5:50 AM Dec 8, 2016 a post was made to this list - subject "Snakify - free introductory Python online course with exercises" Recently I was engaged by a student seeking help with some of the exercises. I found a number of issues at the snakify web site. Thus began a conversation between me and the Site Maintainer Here is the latest: On 9/28/2018 1:02 PM, Vitaly Pavlenko wrote: Hi Bob, Thanks for your email. I’d be very happy if you could describe what sort of issues were you running into. I drafted a rather lengthy reply which I sent to you on October 1. I have not received any response. Did you get it? Was it helpful? I don't see any changes of the website. Please let me know. As I continue to assist my student I run into more and more issues. I will be glad to send them after I hear from you. Examples: - misspelled words - unclear statements - information missing from tracebacks - no way to interrupt an infinite loop. My worst fear is that the list was overwhelming or seen as trivia or nit-pickingl. I have had other publishers refuse to talk to me after I had pointed out legitimate concerns. I don't understand that, but it happens. Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST
# your program is quite complicated. classes are overkill. A simpler solution is: import random for i in range(5): roll = random.randint(1,6) if roll not in (1,5): print('you can roll again') break else: print("you have all 1's and 5's in your result'") # comments on using classes: class Dice: ... # no need for die1...die5 - use list comprehension: alldice = [Dice(6) for i in range(5)] # object is a bult-in type. it is inadvisable to assign to names of built-ins # as this makes the built-in unavailable. Look up builtins (module) in help for # a complete list. # use list comprehension roll and report: print([d.roll_dice() for d in alldice]) -- https://mail.python.org/mailman/listinfo/python-list
Re: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1.
On Oct 2, 2018 4:59 PM, "Musatov" wrote: > > Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1. > DATA > > 31, 71, 73, 137, 211, 311, 419, 421, 647, 877, 1117, 1487, 1979, 2447, 3079, 3547, 4027, 7307, 7309, 12211, 14243, 18911, 18913, 23557, 25439, 28729, 36683, 37831, 46853, 50411, 53129, 55457, 57367, 60251, 67339, 70489, 74797, 89669, 98909, 98911 > > EXAMPLE > > 7*5 - 3 - 1 = 31 > > 11*7 - 5 - 1 = 71 > > 11*7 - 5 + 1 = 73 > > 13*11 - 7 + 1 = 137 > > Can someone put this in a Python program and post? It is our policy to not write code at others requests. We are glad to help if you've started writing a program and are stuck. Out of curiosity where does this request come from? If you want to hire one of us to write the program, in other words pay us for our time and expertise, that's a different matter. We would be happy to comply. > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Experiences with a programming exercise
On Sep 15, 2018 1:50 PM, "Alister via Python-list" wrote: > > On Sat, 15 Sep 2018 17:08:57 +, Stefan Ram wrote: > > > I gave two different functions: > > > > def triangle(): > > for i in range( 3 ): > > forward( 99 ); left( 360/3 ) > > > > def rectangle() > > for i in range( 4 ): > > forward( 99 ); left( 360/4 ) > > > > , and the exercise was to write a single definition for a function > > »angle( n )« that can be called with »3« to paint a triangle and with > > »4« to paint a rectangle. Nearly all participants wrote something like > > this: > > > > def angle( n ): > > if n == 3: > > for i in range( 3 ): > > forward( 99 ); left( 360/3 ) > > if n == 4: > > for i in range( 4 ): > > forward( 99 ); left( 360/4 ) > > > > Now I have added the requirement that the solution should be as short > > as possible! My candidate for shortest expression: [( forward( 99 ), left( 360/n)) for x in 'a'*n] > > seems a good exercise & you are breaking the students in step by stem > which is also good > get something that works, then make it better > > i would suggest instead of the new requirement to be make it a short as > possible make it work with ANY number of sides. > > > > > -- > Max told his friend that he'd just as soon not go hiking in the > hills. > Said he, "I'm an anti-climb Max." > [So is that punchline.] > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Python in endless loop
On Sep 17, 2018 9:31 AM, "YnIk" wrote: > > Dear Python, > Hello. This is an email concerning about my Python program(3.7.0). It keeps printing out stuff that’s too fast to read. If I try to write code, it just keeps on going. I have tried Ctrl+C, but even that’s not working. I searched through all my flies and can’t find one error that would cause this. I tried uninstalling and reinstalling the program multiple times, and that doesn’t work. What should I do? What did you do to install python? What action(s) do you take after installation that lead to the problem? Where does the output appear? Normally output appears in a window. Does this window have a title; if so what is it? You try yo write code. That presumes some kind of editor or command window. How do you get this window; what is it's title? I assume you mean "files". Do you literally search the thousands of files that are a part of a Windows installation? If not, which files? What are you looking for (when you say "error")? Please be as explicit as possible. We don't have ESP or crystal balls. > Thanks, Ed > > Sent from Mail for Windows 10 > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Python MySQL Guide
Thank you for this offer. My reaction is I don't like having to scroll through one very long page to find what I'm looking for. Might you consider breaking it up into a number of smaller pages and giving an index as the main page? On Aug 9, 2018 5:18 PM, wrote: > Refer this complete guide on working with Python and MySQL > > https://pynative.com/python-mysql-tutorial/ > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: your mail
On Jun 10, 2018 12:44 PM, "Karsten Hilbert" wrote: > > On Sun, Jun 10, 2018 at 06:58:17PM +0530, sagar daya wrote: > > > Couldn't install any module from pip > > Plz help??? The only help I can give at this point is to suggest that you tell us what you tried and how it failed. Please copy and paste any relevant terminal entries and error messages. No screenshots no attempts to rephrase just the facts. Once we have those we can take the next step. Just out of curiosity did you think there could be any other answer to your question? In the future please think about what you're asking otherwise it cost us time to have to ask you for the information we need got > > https://duckduckgo.com > > kh > -- > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: add me
On Jun 3, 2018 10:12 AM, wrote: > > i am saran. i want to learn python programming. Welcome. In future please use the python tutor email list - it is there to provide guidance. Go to the python. Org website - look for tutorials. That's the best place to start. -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I list only the methods I define in a class?
On 5/31/2018 3:49 PM, bruceg113...@gmail.com wrote: > How do I list only the methods I define in a class? Here's a class with some method, defined in various ways: >>> class x(): ... a=3 ... def f():pass ... g = lambda: None ... >>> l=[v for v in x.__dict__.items()]; print(l) [('a', 3), ('f', ), ('__module__', '__main__'), ('__dict__', ), ('__doc__', None), ('__weakref__', objects>)] >>> import inspect >>> [(key, value) for key, value in l if inspect.isfunction(i[1])] [('f', ), ('g', at 0x01DEDD693620>)] HTH -- https://mail.python.org/mailman/listinfo/python-list
Re: number of loops
On Mar 15, 2018 9:30 AM, wrote: > > I would like to have this offer 6 guesses, but instead it gives one guess and prints the if statement/output 6 timesany ideas where I went wrong? I suggest you conduct a walk-through. That means pointing using a pencil or a mouse pointer at each statement and noticing what it does. pay attention to what happens when the loop repeats. This will do more for you than if I just tell you the answer. > > import random > > number_of_guesses = 0 > > print ('Hello! what is your name?') > my_name=input() > print (my_name + " " + 'sounds like the name of my next opponent') > print ('Shall we play?') > > yes_or_no = input() > > if yes_or_no == 'yes': > print ('ok! guess my number') > else: > print ('log off and go home') > > my_number=random.randint(1,100) > > your_guess=input() > your_guess=int(your_guess) > > for number in range(6): > if your_guess > my_number: > print ('nope, too high') > if your_guess < my_number: > print ('nope, too low') > if your_guess == my_number: > break > > if your_guess == my_number: > number_of_guesses=str(number_of_guesses) > print ('good job, you guessed correctly') > else: > print('nope, you lose') > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: psychocomputational analysis toolkit in Python?
On Mar 8, 2018 10:08 AM, "Etienne Robillard" wrote: > > Thanks for sharing this link. MNE looks pretty cool. :-) > > I'm mostly interested in mapping specific cortical pathways to brain-to-brain interfaces implicated in the ultrasonic neuromodulation of behavior. > > Would it be possible to emulate a minimally functional brain-to-brain coupling system entirely in Python? Since python is a general purpose programming language, I'd say yes. I would add the use of a database management system, since you need some way of storing the data. sqlite is an excellent database management system with an excellent python interface. Unlike other database systems, sqlite is single-user system. You can always migrate later to a multi-user system. The sqlite3 module is included in the python distribution. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Syntax error
On 2/3/2018 2:40 PM, Terry Reedy wrote: On 2/3/2018 2:10 PM, Kevin Doney wrote: Hi. *pip3 install --upgrade tensorflow-gpu* When I try the above command I get SyntaxError: invalid syntax Please help. This group helps those who help the group -- by asking questions with sufficient information to answer. Post the ENTIRE trackback. It also helps us to know: operating system (e.g., windows 10) what does "when I try" mean? (e.g. at a windows command prompt I entered ...) What the *'s are for best is to copy the entire session and paste it into your email. Example Microsoft Windows [Version 10.0.16299.192] (c) 2017 Microsoft Corporation. All rights reserved. C:\Users\bgailer>pip install foo Collecting foo Could not find a version that satisfies the requirement foo (from versions: ) No matching distribution found for foo We could presume in your case that you tried to enter your pip command in a python interactive session. For example: C:\Users\bgailer>python Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:35:05) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> pip install foo File "", line 1 pip install foo ^ SyntaxError: invalid syntax >>> Why did you get that response? Because pip is not a python statement (python does not have commands); it is an executable program. So you need to use a command prompt or terminal. -- https://mail.python.org/mailman/listinfo/python-list
adding elif to for
Has any thought been given to adding elif to the for statement? for x in foo: if y: break elif a==b: something else: something else as a shortcut to: for x in foo: if y: break else: if a==b: something else: something else bob gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: General Purpose Pipeline library?
On Nov 20, 2017 10:50 AM, "Jason" wrote: > > a pipeline can be described as a sequence of functions that are applied to an input with each subsequent function getting the output of the preceding function: > > out = f6(f5(f4(f3(f2(f1(in)) > > However this isn't very readable and does not support conditionals. > > Tensorflow has tensor-focused pipepines: > fc1 = layers.fully_connected(x, 256, activation_fn=tf.nn.relu, scope='fc1') > fc2 = layers.fully_connected(fc1, 256, activation_fn=tf.nn.relu, scope='fc2') > out = layers.fully_connected(fc2, 10, activation_fn=None, scope='out') > > I have some code which allows me to mimic this, but with an implied parameter. > > def executePipeline(steps, collection_funcs = [map, filter, reduce]): > results = None > for step in steps: > func = step[0] > params = step[1] > if func in collection_funcs: > print func, params[0] > results = func(functools.partial(params[0], *params[1:]), results) > else: > print func > if results is None: > results = func(*params) > else: > results = func(*(params+(results,))) > return results > > executePipeline( [ > (read_rows, (in_file,)), > (map, (lower_row, field)), > (stash_rows, ('stashed_file', )), > (map, (lemmatize_row, field)), > (vectorize_rows, (field, min_count,)), > (evaluate_rows, (weights, None)), > (recombine_rows, ('stashed_file', )), > (write_rows, (out_file,)) > ] > ) > > Which gets me close, but I can't control where rows gets passed in. In the above code, it is always the last parameter. > > I feel like I'm reinventing a wheel here. I was wondering if there's already something that exists? IBM has had for a very long time a program called Pipelines which runs on IBM mainframes. It does what you want. A number of attempts have been made to create cross-platform versions of this marvelous program. A long time ago I started but never completed an open source python version. If you are interested in taking a look at this let me know. -- https://mail.python.org/mailman/listinfo/python-list
Re: "comprehend" into a single value
On 10/7/2017 11:17 PM, Nathan Hilterbrand wrote: dict= {10: ['a',1,'c'], 20: ['d',2,'f']} p = sum([dict[i][1] for i in dict]) Something like that? Ah, but that's 2 lines. sum(val[1] for val in {10: ['a',1,'c'], 20: ['d',2,'f']}.values()) On Sat, Oct 7, 2017 at 11:07 PM, Andrew Z wrote: Hello, i wonder how can i accomplish the following as a one liner: dict= {10: ['a',1,'c'], 20: ['d',2,'f']} p = 0 for i in dict: p += dict[i][1] Thank you -- https://mail.python.org/mailman/listinfo/python-list -- Image and video hosting by TinyPic -- https://mail.python.org/mailman/listinfo/python-list
Re: detaching comprehensions
I don't know whether you wanted a reply, since you did not ask for one. I am not even sure what your point is. See other comments below. On 9/8/2017 4:24 PM, Stefan Ram wrote: Maybe you all know this, but to me this is something new. I learnt it by trial and error in the Python 3.6.0 console. Most will know list comprehensions: |>>> [ i for i in range( 3, 5 )] |[3, 4] I found out that the comprehension can be detached from the list: |>>> k =( i for i in range( 3, 5 )) but one must use an extra pair of parentheses around it in the assignment. Now I can insert the "generator" »k« into a function call, but a spread operator should cannot be used there. |>>> sum( k ) |7 »sum« expects exactly two arguments, and this is what »k« provides. Where did you get that idea. If you look at the docs you will see: "sum(iterable[, start]) Sums start and the items of an iterable from left to right and returns the total. start defaults to 0." sum expects 1 or 2 arguments; when you write sum(k) you are providing 1 argument. But to insert it again into the place where it was "taken from", a spread operator is required! |>>> k =( i for i in range( 3, 5 )) |>>> [ *k ] |[3, 4] "taken from"?? k is a generator object. Clear? Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: Reading the documentation
On 8/24/2017 3:24 PM, Stefan Ram wrote: This is a transcript: from math import floor floor( "2.3" ) Traceback (most recent call last): File "", line 1, in TypeError: must be real number, not str help(floor) Help on built-in function floor in module math: floor(...) floor(x) Return the floor of x as an Integral. This is the largest integer <= x. Is the output of »help(floor)« supposed to be a kind of normative documentation, i.e., /the/ authoritative documentation of »floor«? Is there any hint in the documentation about the type expected of arguments in a call? Is a parameter name »x« (as used above) described somewhere to express the requirement of a real number? It seems, »real« means »int or float«. Is this meaning of »real« documented somewhere? in the Python Language Reference 3.2. The standard type hierarchy numbers.Real (float) These represent machine-level double precision floating point numbers. This is not the meaning of "real" in mathematics! I was surprised by the use of "integral". A dictionary search does not (IMHO) support this usage! Thanks in advance! -- Image and video hosting by TinyPic -- https://mail.python.org/mailman/listinfo/python-list
Re: Reading the documentation
On 8/24/2017 3:54 PM, Nathan Ernst wrote: You passed a string to "math.floor", not anything resembling a numeric type. Try using an actual float, int or Decimal: It would seem you did not understand the OP's question. It was not "why did I get this traceback." He showed the traceback as leading him to use the help builtin. He was questioning what help() returned. Python 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. from math import floor from decimal import Decimal floor("2.3") Traceback (most recent call last): File "", line 1, in TypeError: a float is required floor(2.3) 2 floor(Decimal("2.3")) 2 floor(2) 2 Remember that Python is strongly typed; you do not get automatic type conversions from strings to numeric types such as in Perl. Regards, Nathan On Thu, Aug 24, 2017 at 2:24 PM, Stefan Ram wrote: This is a transcript: from math import floor floor( "2.3" ) Traceback (most recent call last): File "", line 1, in TypeError: must be real number, not str help(floor) Help on built-in function floor in module math: floor(...) floor(x) Return the floor of x as an Integral. This is the largest integer <= x. Is the output of »help(floor)« supposed to be a kind of normative documentation, i.e., /the/ authoritative documentation of »floor«? Is there any hint in the documentation about the type expected of arguments in a call? Is a parameter name »x« (as used above) described somewhere to express the requirement of a real number? It seems, »real« means »int or float«. Is this meaning of »real« documented somewhere? Thanks in advance! -- https://mail.python.org/mailman/listinfo/python-list -- Image and video hosting by TinyPic -- https://mail.python.org/mailman/listinfo/python-list
Re:
Unfortunately the images did not come through, since this is a text-only email list. I suggest you put your images on an online resource such as Photobucket and post the links in your email. Unfortunately your description of the problem is not very precise. Obviously the images would help. Terms like installing the launcher and open the file don't help. Please get the images online send us the links and be more verbose in your explanation. On Aug 19, 2017 1:52 PM, "Owen Berry" wrote: > I'm new to python and having trouble with the most basic step. I have tried > to install python (Web-based installer) on my home pc to mess around and > attempt to develop a program. when I install the launcher it is fine but > when I try and open the file it launches a modify setup window. I have no > clue how to fix this issue and start using the actual program. how do I go > about fixing this issue? any information would be greatly valued. > > Thank you > > > > > [image: Inline image 2] > > Modify > [image: Inline image 3] > > Next > [image: Inline image 4] > > Install > [image: Inline image 5] > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Application Error
On Aug 15, 2017 9:50 AM, "Alhassan Tom Alfa" wrote: > > Dear Sir, > > I just downloaded Python Exactly what did you download? Where did you download it from? There are 32 bit versions and 64-bit versions. Did you download the one corresponding to your computer? Normally when you download python You are downloading an installer. Did you run the installer? on my PH What is pH? Windows 10 PC but any time I tried to > start the application When you say application are you referring to python or some Python program? Exactly what are you doing to run the application? Be as specific as possible. it always give the following error message; > > Python.exe - Application Error > The application was unable to start correctly (0xc07b). Click Ok to > close the application. Personally I have never heard of this error. Have you tried to Google it? The comments above are my own comments they reflect my own experience there may be others on this list who will give you a better answer. > > How this error be corrected? I really need to use this application We are all volunteers who choose to help others with questions. Expressions of urgency usually don't motivate us. So in the future just ask a question. > > Thank you in anticipation for a quick response > > Best Regards, > > Tom > > < https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon > > Virus-free. > www.avast.com > < https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link > > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: instructor solution manual for MODERN OPERATING SYSTEMS 2nd ed A.S.TANENBAUM
On Aug 10, 2017 7:15 AM, wrote: > > > > solutions manual to MODERN OPERATING SYSTEMS 3rd ed A.S.TANENBAUM > > > can you plz provide it for me.. This mailing list is for the Python programming language, not for operating systems. It is possible that someone else on this list might be able to help you anyway. Did you try Googling? > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Planning a Python Course for Beginners
On Aug 8, 2017 10:20 AM, "Stefan Ram" wrote: > > I am planning a Python course. > > I started by writing the course akin to courses I gave > in other languages, that means, the course starts roughly > with these topics: > > - number and string literals > - types of number and string literals > (just giving the names »int«, »float«, and »string«) > - using simple predefined operators (+, -, *, /) > (including 2*"a" and "a"+"b") > - calling simple predefined functions (len, type, ...) > > . This is a little bit boring however and might not > show off Python's strength early in the course. > > So, I now think that maybe I should start to also > include list (like > > [1,2,3] > > ) right from the start. A list conceptually is not > much more difficult than a string since a string > "abc" resembles a list ["a","b","c"]. I.e., the > course then would start as follows: > > - number, string, and list literals > - types of number, string and list literals > (just giving the names »int«, »float«, »string«, > and »list«) > - using simple predefined operators (+, -, *, /) > (including 2*"a", "a"+"b", 2*["a"], and [1]+[2]) > - calling simple predefined functions (len, type, ...) > > However, once the box has been opened, what else > to let out? What about tuples (like > > (1,2,3) > > ). Should I also teach tuples right from the start? > > But then how to explain to beginners why two > different types (lists AND tuples) are needed for > the concept of a linear arrangement of things? > > Are there any other very simple things that > I have missed and that should be covered very > early in a Python course? IMHO its a good idea to introduce conversational programming early. Start with input() and print() then int(), if, while, break . Add one item at a time. This will be more interesting and useful than a bunch of data types and operators, and answer a lot of questions that otherwise show up on the help and tutor lists. Also explain tracebacks. None of the above in great detail; just let students know there is more detail to come later > > (Especially things that can show off fantastic > Python features that are missing from other > programming languages, but still only using > literals, operators and function calls.) I think program flow is more important than fantastic or unique > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Code for addition
On Aug 4, 2017 5:27 PM, "Ode Idoko via Python-list" wrote: > > Can anyone help with the python code that can add 101, 102, 103...2033 please? We are here to help but we don't have crystal balls to interpret your request. The best thing you can do is show us what attempts you have made to write code for this problem and the difficulties you have encountered. We always assume when given a problem like this that it's a homework assignment. So it's a good idea to state that upfront. Have you had any success in writing and running any python programs? Assuming that you are in a class, what aspects of python have you already learned? Can you apply any of that to this problem? The more you give us the easier it is for us to help. > As I said before, I'm new to python and need assistance in this regard. > Thanks for always assisting. > > Sent from my iPhone > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Bug or intended behavior?
Sending this to docs in hopes of improving documentation of % formatting and operator precedence. Perhaps add "see 6:16 Operator precedence." On 6/3/2017 5:59 PM, Sean DiZazzo wrote: On Friday, June 2, 2017 at 10:46:03 AM UTC-7, bob gailer wrote: On 6/2/2017 1:28 PM, Jussi Piitulainen wrote: sean.diza...@gmail.com writes: Can someone please explain this to me? Thanks in advance! ~Sean Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. print "foo %s" % 1-2 Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for -: 'str' and 'int' The per cent operator has precedence over minus. Spacing is not relevant. Use parentheses. In other words "foo %s" % 1 is executed, giving "1". Then "1"-2 is attempted giving the error. Also: If there is more than one conversion specifier the right argument to % must be a tuple. I usually write a tuple even if there is only one conversion specifier - that avoids the problem you encountered and makes it easy to add more values when you add more conversion specifiers. print "foo %s" % (1-2,) Bob Gailer I get what it's doing, it just doesn't make much sense to me. Looking at operator precedence, I only see the % operator in regards to modulus. Nothing in regards to string formatting. Is it just a side effect of the % being overloaded in strings? Or is it intentional that it's higher precedence...and why? The documentation is unfortunately flawed. If you look at the .chm file in the docs folder under the python installation (c:\python35\docs\python351.chm as an example, and enter % in the index, you will see: % operator % formatting % interpolation note that modulo is missing! double-click operator to see the numeric operator double-click % formatting to see the string "unique built-in operation" aka interpolation. See under section 6:16 Operator precedence: "[5] The % operator is also used for string formatting; the same precedence applies." Maybe I'm making too big a deal of it. It just doesn't 'feel' right to me. Unfortunately "feel" is not a good guide to understanding programming languages. COBOL and Assembler use MOVE when it is actually COPY! Slight OT digression: The language that is best for me is APL in which there is no operator precedence to worry about. Execution is strictly right-to-left. () are used when the order of evaluation needs to be altered. I recall one person telling me that "right-to-left" was not natural. He preferred "left-to-right" as in FORTRAN. So I considered the FORTRAN statement A = B + C * D. Turns out that A * B happens first, then C + then A =. Sure looks right-to-left to me! -- https://mail.python.org/mailman/listinfo/python-list
Re: python certification
On Jun 8, 2017 7:58 AM, "Gonzalo V" wrote: > > hi, > good day. > where can i get a python certification? I'm not sure there is such a thing. Try Googling. > thanks! > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Bug or intended behavior?
On 6/2/2017 1:28 PM, Jussi Piitulainen wrote: sean.diza...@gmail.com writes: Can someone please explain this to me? Thanks in advance! ~Sean Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. print "foo %s" % 1-2 Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for -: 'str' and 'int' The per cent operator has precedence over minus. Spacing is not relevant. Use parentheses. In other words "foo %s" % 1 is executed, giving "1". Then "1"-2 is attempted giving the error. Also: If there is more than one conversion specifier the right argument to % must be a tuple. I usually write a tuple even if there is only one conversion specifier - that avoids the problem you encountered and makes it easy to add more values when you add more conversion specifiers. print "foo %s" % (1-2,) Bob Gailer -- https://mail.python.org/mailman/listinfo/python-list
Re: syntax error in first-time user script
On Mar 24, 2017 4:53 AM, "john polo" wrote: > > Greetings, > I am attempting to learn Python. I have no programming background. I'm on a computer with Windows 7. I checked the PATH in System Variables and Python and Python\Scripts are in the path. I have a book, Python for Biologists and it supplies example scripts, one is called comment.py. The output from comment.py is > > Comments are very useful! > > I use cd to get to the directory with the example scripts We can assume you are at a Windows command prompt. It' a good idea too tell us that, so we don't have to assume! and open a command prompt with "python" and get the prompt. Assumptions / terminology again! Typing "python" normally invokes the python interpreter. Since you did not pass any arguments you get a window displaying the python interpreter prompt (>>>). I type > > "python comment.py" > > and get > > "File "", line 1 > python comment.py > ^ > SyntaxError: invalid syntax It is great (as John said) that you provided the traceback. It would have been even greater if you had given us the rest e.g, Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved. C:\Users\bgailer>cd /examples C:\examples>python Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:35:05) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> python comment.py File "", line 1 python comment.py ^ SyntaxError: invalid syntax >>> Which brings up one other important matter: when writing us also tell us which python version you are using. In my example it is 3.3.5. > > Sorry, I realize this may not all line up like it does when I'm typing this in the email. The caret/error pointer is under the t in comment. I am not sure what is causing this error. > > If I type > > "import comment.py" > > the output is > > "Comments are very useful! > Traceback (most recent call last): > File "", line 1, in > ModuleNotFoundError: No module named 'comment.py'; 'comment' > " > > If I use IDLE shell: > > "python comment.py" > > "SyntaxError: invalid syntax" > > I know I can open the file in the editor and use F5, but shouldn't I be able to use a command from shell? How do I run comment.py from a command line without error? Or is that not possible? > > cheers, > John > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Who are the "spacists"?
On Mar 17, 2017 9:23 PM, "Mikhail V" wrote: > > So Python supports both spaces and tabs for indentation. > > I just wonder, why not forbid spaces in the beginning of lines? > How would one come to the idea to use spaces for indentation at all? One problem for me with tabs: there is no standard visual representation (1 tab = ? Spaces) > > Space is not even a control/format character, but a word separator. Huh? The character sets I'm familiar with don't have "word separators". Space is just another no -control character. > And when editors will be proportional font based Editors allow your choice of font. Some are proportional, some monospaced. I fail to see any benefit from making a proportional-only font based editor. , indenting with > spaces will not make *any* sense so they are just annoyance. Only in the eye of the beholder. > Neither makes it sense in general case of text editing. > I think it would be a salvation to forbid spaces for indentation, > did such attemps take place? > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Need reviews for my book on introductory python
On 1/25/2017 9:25 PM, Sandeep Nagar wrote: Hi, A few month ago I wrote a book on introductory python based on my experinces while teaching python to Bachelor students of engineering. It is now available in e-book and paperback format at Amazon. https://www.amazon.com/dp/1520153686 The book is written for beginners of python programming language and written in learn-by-doing manner. If some group members can review the same, it will be useful for myself to come up with an improved version. Who is the publisher of this book? I just took a look at the pages that can be viewed on Amazon. Many reactions. it is hard for me to write this, as it seems it would sound harsh, judgemental, unappreciative. But you did ask for a review, and this is my honest reaction. I find it hard to read a book written by a non-native speaker of English. I an constantly having to overlook what to me are spelling, grammatical and vocabulary errors. I HIGHLY recommend you find an editor who can fix these errors. When I pick up an "Introduction to ." book I expect to get right into the language. History, interpreted vs compiled, examples in C, if included at all should go in an appendix. I think you should be teaching Python 3 rather than 2. I disagree with your reasons for sticking with ver 2. I, as a developer using Python for over 10 years, welcomed ver 3 and now use it exclusively. Last sentence of 2.2 is confusing. Section 2.3 you need to tell reader how to obtain a python prompt. The example is also confusing, since to most python users it looks like: >>> 2+4 6 The result of 2+4. does not appear. sudo apt-get won't work on Windows. Tell the reader that this is how to do it in Unix, and show the Windows equivalent. I would avoid showing from xxx import * as it is likely to cause confusion when a module so imported overwrites a built-in. Bottom of p 23 (sys.sizeof(). How would a python newbie know to import sys? I will stop here - there are many other issues. I am, by degree, an engineer. If this were my introduction to python I probably would walk away from python, discouraged by how hard it is to learn. -- https://mail.python.org/mailman/listinfo/python-list
Re: Need reviews for my book on introductory python
On 1/26/2017 8:05 PM, Sandeep Nagar wrote: Hi As I mentioned, a scaled down version is available for free at bookmuft.Com which can be used to judge in this case. Maybe I am blind, but I don't see any mention of bookmuft.Co. Regards On Jan 27, 2017 05:02, "bob gailer" <mailto:bgai...@gmail.com>> wrote: On 1/25/2017 9:25 PM, Sandeep Nagar wrote: Hi, A few month ago I wrote a book on introductory python based on my experinces while teaching python to Bachelor students of engineering. It is now available in e-book and paperback format at Amazon. https://www.amazon.com/dp/1520153686 <https://www.amazon.com/dp/1520153686> The book is written for beginners of python programming language and written in learn-by-doing manner. If some group members can review the same, it will be useful for myself to come up with an improved version. I'd like to review it, but am reluctant to put out money for a copy! How about offering a review copy at no charge? Other similar books of mine are based on Octave and Scilab with following links: https://www.amazon.com/dp/152015111X <https://www.amazon.com/dp/152015111X> (Scilab) https://www.amazon.com/dp/1520158106 <https://www.amazon.com/dp/1520158106> (Octave) If you are interested in open source computing, please have a look. Also please do share the link for print books with your colleagues at other universities and recommend them for libraries and researchers, if you feel that they can be helpful to them. Regards Sandeep -- Image and video hosting by TinyPic -- Image and video hosting by TinyPic -- https://mail.python.org/mailman/listinfo/python-list
Re: Need reviews for my book on introductory python
On 1/25/2017 9:25 PM, Sandeep Nagar wrote: Hi, A few month ago I wrote a book on introductory python based on my experinces while teaching python to Bachelor students of engineering. It is now available in e-book and paperback format at Amazon. https://www.amazon.com/dp/1520153686 The book is written for beginners of python programming language and written in learn-by-doing manner. If some group members can review the same, it will be useful for myself to come up with an improved version. I'd like to review it, but am reluctant to put out money for a copy! How about offering a review copy at no charge? Other similar books of mine are based on Octave and Scilab with following links: https://www.amazon.com/dp/152015111X (Scilab) https://www.amazon.com/dp/1520158106 (Octave) If you are interested in open source computing, please have a look. Also please do share the link for print books with your colleagues at other universities and recommend them for libraries and researchers, if you feel that they can be helpful to them. Regards Sandeep -- Image and video hosting by TinyPic -- https://mail.python.org/mailman/listinfo/python-list
Re: Doubt with matrix
Always Post the entire traceback. That will show us the line of code that raised the error, as well as the sequence of function calls involved. On Jan 12, 2017 11:10 AM, "José Manuel Suárez Sierra" < josemsuarezsie...@gmail.com> wrote: > Hello, I want to go over matrix indexs with this code: > def comparador2(a, b): > c3 = ["0"] # variables > x = -1 # contador de letras aniadidas a c3 > i = 0 # contador bucle secuencia a > j = 0 # contador bucle secuencia b > l1 = len(a) > l2 = len(b) > cont = [] # contador de ciclos poner primer termino a 0 > k = -1 # contador de 0 y 1 aniadidos a cont > > if l1 > l2: # metodo de la burbuja que elige la secuencia mas larga > REVISAR puede ser alreves > aux = a > a = b > b = aux > > for a[i] in a: # en la secuencia1 recorro los elementos > > for b[j] in b : > > if a[i] == b[j] and i <= l1 and j <= l2: # Si el elemento > i de la seq1 es igual que el elemento j de la seq2, y el numero de > elementos en i y j es menor o igual que la longitud de las secuencias 1 y 2 > c3.append(a[i]) # se aniade el elemento comun a la > lista c3 > x = x + 1 > k = k + 1 > j = j + 1 # se pasa el elemento siguiente de la seq2 > i = i + 1 # se pasa el elemento siguiente de la seq1 > cont.append(1) > > > > elif a[i] != b[ > j] and i <= l1 and j <= l2: # si no coinciden estos > elementos se pasa al siguiente elemento de la lista 2 > j = j + 1 > k = k + 1 > cont.append(0) > if cont[k] == 0 and cont[k - 1] == 1 and cont[k - 2] > == 0 and k >= 2: > i = i - 1 > j = j - 1 > else: > k = k + 1 > cont.append(0) > if i == l2: > i = i + 1 > j = 0 > > > return c3 > > and this issue is prompted: > IndexError: list assignment index out of range > > How could I fix it? > > Thank you for your assistance > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: SIP install error on windows
On Dec 12, 2016 2:30 PM, "Xristos Xristoou" wrote: > > > hello i want to install sip on windows bit using python > 32 bit. > i download sip from this link https://www.riverbankcomputing.com > i try to install from cmd line : > > C:\WINDOWS\system32>cd C:\Users\username\Desktop\sip-4.17 > > C:\Users\username\Desktop\sip-4.17>python configure.py install > and take that error any idea ? The instructions at Riverbank for installing sip tell me to use pip3 install. I suggest you try that. > > This is SIP 4.17 for Python 2.7.11 on win32. > Error: Unsupported macro name specified. Use the --show-build-macros flag to > see a list of supported macros. > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: calling a program from Python batch file
On Dec 7, 2016 11:40 AM, "Karim Farokhnia" wrote: > > Hi there, > > I am writing a batch file in Python. The batch file, in part, calls a program named "oq-console.bat" to run. Then once the program comes up (it looks like windows CMD), I need the batch file to type some commands to make it run (just like I would do it by myself). > > I need the batch file does the whole things automatically, I mean calls the program, types in commands and press enter! Try using the stdin argument of subprocess. > > So far, I have used the below Python codes in my batch file to do that; > > > import subprocess > > subprocess.call(["C:\Program Files (x86)\OpenQuake Engine\oq-console.bat", "oq --run", "job.ini"]) > > > Note that the first string is the program, and the last two are the commands which needs to be typed in. > > It pulls up the program well, but doesn't type in the commands to make it to run. > > > Any ideas on how I can get the program to run the commands as well? > > Thank you! > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: data interpolation
On Nov 3, 2016 6:10 AM, "Heli" wrote: > > Hi, > > I have a question about data interpolation using python. I have a big ascii file containg data in the following format and around 200M points. > > id, xcoordinate, ycoordinate, zcoordinate > > then I have a second file containing data in the following format, ( 2M values) > > id, xcoordinate, ycoordinate, zcoordinate, value1, value2, value3,..., valueN > > I would need to get values for x,y,z coordinates of file 1 from values of file2. > Apologies but I have no idea what you're asking. Can you give us some examples? > I don´t know whether my data in file1 and 2 is from structured or unstructured grid source. I was wondering which interpolation module either from scipy or scikit-learn you recommend me to use? > > I would also appreciate if you could recommend me some sample example/reference. > > Thanks in Advance for your help, > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Dice Game/Need help with my script/looping!
On Nov 3, 2016 11:30 AM, "Constantin Sorin" wrote: > > Hello,I recently started to make a dice game in python.Everything was nice and beautiful,until now.My problem is that when I try to play and I win or lost or it's equal next time it will continue only with that. > Exemple: > Enter name >> Sorin > Money = 2 > Bet >> 2 > You won! > Money 4 > Bet >> 2 > You won! > and it loops like this :/ > What are the rules of the game? > Here is the code: > > import time > import os > import random > os = os.system > os("clear") > > print "What is your name?" > name = raw_input(">>") > > def lost(): > print "Yoy lost the game!Wanna Play again?Y/N" > ch = raw_input(">>") > if ch == "Y": > game() When you call a function from within that function you are using recursion. This is not what recursion is intended for. If you play long enough you will run out of memory. The proper way to handle this is to put the entire body of game() in a while loop. > elif ch == "N": > exit() > > > > def game(): > os("clear") > a = random.randint(1,6) > b = random.randint(1,6) > c = random.randint(1,6) > d = random.randint(1,6) > e = a + b > f = c + d > money = 2 > while money > 0: > print "Welcome to FireDice %s!" %name > print "Your money: %s$" %money > print "How much do you bet?" > bet = input(">>") > if e > f: > print "you won!" > money = money + bet > elif e < f: > print "you lost" > money = money - bet > else: > print "?" > > print money > lost() Since the values of e and f are not changed in the loop he will continue to get the same thing. > > game() > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Obtain javascript result
On Oct 22, 2016 12:45 AM, wrote: > > Many Thanks to everybody. You're welcome. It's fun to help in a challenging problem. Please let us know what solution(s), if any, you have adopted, what problems, if any, you've encountered, what Python version and operating system. -- https://mail.python.org/mailman/listinfo/python-list
Re: Obtain javascript result
On 10/21/2016 11:07 AM, epro...@gmail.com wrote: Yes, the page is http://www.betexplorer.com/next/soccer/ and You have to open any match You want. This pop-up new windows with match detail and odds (if present). I try to extract home team, away team, results, and bet365's bookmaker odds. I can't continue in my fun analyses because the odds are returned through that javascript code and I don't know how manage it in python to take that results. What version of Python are you using, and what operating system? I would use splinter (https://pypi.python.org/pypi/splinter) From a command prompt: pip install splinter The Python program (this is not tested; your mileage may vary): from splinter import Browser browser = Browser(browser) page = browser.visit('http://www.betexplorer.com/soccer/russia/youth-league/matchdetails.php?matchid=rLu2Xsdi') div = browser.find_by_id('be') text = div.text text looks like " Soccer » Russia » Youth League 2016/201720.10.2016 Cruzeiro-Corinthians 4:2 (1:1, 3:1) 14.Abila Ramon (penalty kick) 59.Abila Ramon 63.Rodrigo Bruno 83.De Arrascaeta Giorgian 35.Rodriguinho 86.Rildo 1X2 Odds (25) O/U (100) AH (33) DNB (11) DC (20) BTS (14) Bookmakers: 251X2 10Bet1.573.555.05 12BET1.753.554.40 188BET1.723.654.40 888sport1.683.704.80 bet-at-home1.673.404.42 bet3651.733.604.75 Betclic1.653.404.60 Betfair1.663.404.40 Betsafe1.683.504.25 Betsson1.683.504.25 BetVictor1.703.605.00 Betway1.703.404.75 bwin1.673.704.40 ComeOn1.573.555.05 Expekt1.653.404.60 Interwetten1.703.454.50 Ladbrokes1.733.605.00 mybet1.753.504.00 Pinnacle1.753.815.25 SBOBET1.723.504.70 Sportingbet1.673.604.60 Tipico1.653.504.70 Unibet1.683.704.80 William Hill1.733.404.40 youwin1.673.604.60 Average odds 1.693.544.63 close window $(document).ready(function() { matchdetails_init('rLu2Xsdi', '1x2'); }); " I hope you know enough to extract the data you want. There are probably better ways to drill down to the relevant table rows, but I can't do that right now as I am having my own problem with splinter. splinter is the only tool I know that will do this. There may be others. -- https://mail.python.org/mailman/listinfo/python-list
Re: Obtain javascript result
On Oct 21, 2016 9:30 AM, wrote: > > Hello NG. > > I'm new in Python for fun. > > I have a html page (I load it by BeautifulSoap) that contain > also this javascript code: > ... > > $(document).ready(function() { > matchdetails_init('rLu2Xsdi', '1x2'); > }); > > ... > Please, can You me to aim on the right way > to obtain into a Python data structure > everything that JS code give back to browser. Not without seeing the code for matchdetails_init. Likely we'd also need to see the page source. What do you expect to get? -- https://mail.python.org/mailman/listinfo/python-list
Re: Generator comprehension - list None
On Oct 18, 2016 7:45 AM, "Sayth Renshaw" wrote: > > I was solving a problem to create a generator comprehension with 'Got ' and a number for each in range 10. > > This I did however I also get a list of None. I don't understand where none comes from. Can you please clarify? > > a = (print("Got {0}".format(num[0])) for num in enumerate(range(10))) > The comprehension collects the values of the 10 calls to print(). print() always returns None. > # for item in a: > # print(item) > > b = list(a) > print(b) > > Output > Got 0 > Got 1 > Got 2 > Got 3 > Got 4 > Got 5 > Got 6 > Got 7 > Got 8 > Got 9 > [None, None, None, None, None, None, None, None, None, None] > => None > > Thanks > > Sayth > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Just starting to learn Python, and encounter a problem
On Jul 22, 2016 10:00 AM, "Zagyen Leo" wrote: > > yeah, it may be quite simple to you experts, but hard to me. > > In one of exercises from the Tutorial it said: "Write a program that asks the user their name, if they enter your name say "That is a nice name", if they enter "John Cleese" or "Michael Palin", tell them how you feel about them ;), otherwise tell them "You have a nice name." > > And i write so: > > name = input("Enter your name here: ") > if name == "John Cleese" or "Michael Palin": > print("Sounds like a gentleman.") > else: > print("You have a nice name.") > > But strangely whatever I type in (e.g. Santa Claus), it always say "Sounds like a gentleman.", not the result I want. Even without knowing the operator precedence, this will be evaluated either as: (name == "John Cleese") or "Michael Palin") or: name == ("John Cleese" or "Michael Palin"). Case 1: (name == "John Cleese") evaluates to either True or False. False or "Michael Palin" evaluates to ( believe it or not) " Michael Palin"! Which, as far as if is concerned, is True. True or "Michael Palin" evaluates to True. Case 2: "John Cleese" or "Michael Palin" evaluates to False; name== False evaluates to False. One way to get the results you want: if name in ("John Cleese" or "Michael Palin"): -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with subclasses and classes
On Jul 2, 2016 9:00 PM, wrote: > > When i run the code I get this error : > Traceback (most recent call last): > File "C:/Python25/chapter2", line 18, in > bank=InterestAccount(5,1000,0.5) > NameError: name 'InterestAccount' is not defined > > I can't find the issue, any help? Following is voice dictated therefore not actually correct but you'll get the point . interest account is a nested class inside of class bank account you're trying to refer to it outside of class > > > class BankAccount: > def __init__(self,numb,bal): > self.numb = numb > self.bal = bal > def showbal(self): > print "Your balance is", self.bal > def withdraw(self,wa): > self.bal-=wa > print("Your balance is now", self.bal) > def deposit(self,da): > bal+=da > print("Your balance is now", self.bal) > class InterestAccount(): > def BankAccount__init__(self,numb,bal,intrate): > self.intrate=intrate > def addintrest(self): > self.bal = self.bal * self.intrate > bank=InterestAccount(5,1000,0.5) > bank.addintrest() > bank.showbal() > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help in python program
On Jul 1, 2016 6:30 AM, "Archana Sonavane" wrote: > > Hello Everyone, > > I am doing python code by using API. > > My first API giving fields - Itemid, clock and value > second API giving fields - Itemid, key, units and delay > > using for loops for both API. > > Could you please tell me how to compare both id by using equal operator. > > My output should be : > > Itemid, clock, value, key, units and delay Please provide some sample input and the corresponding output. What do you mean by API? -- https://mail.python.org/mailman/listinfo/python-list
Re: Assignment Versus Equality
On Jun 26, 2016 5:29 PM, "Michael Torrie" wrote: > > On 06/26/2016 12:47 PM, Christopher Reimer wrote: > Sounds like fun. Every aspiring programmer should write an interpreter > for some language at least once in his life! In the mid 1970' s I helped maintain an installation of IBM' s APL interpreter at Boeing Computer Services. APL uses its own special character set, making code unambiguous and terse. It used a left-arrow for assignment, which was treated as just another operator. I will always miss "embedded assignment". A year later I worked on a project that ran on a CDC 6600? where only FORTRAN was available. The program's job was to apply user's commands to manage a file system. FORTRAN was not the best language for that task, so I designed my own language, and wrote an interpreter for it in FORTRAN. In retrospect a very good decision. That program was in use for 10 years! -- https://mail.python.org/mailman/listinfo/python-list
Re: Fw: Question about issue with opening Python
On May 13, 2016 9:22 AM, "christopher.amor...@mail.citytech.cuny.edu" < christopher.amor...@mail.citytech.cuny.edu> wrote: > > > > > > > From: christopher.amor...@mail.citytech.cuny.edu > Sent: Thursday, May 12, 2016 7:35 PM > To: python-list@python.org > Subject: Fw: Question about issue with opening Python > > > > I downloaded an older version of Python and for about an hour it was working, but started to get the same error message I received when using the latest version of Python. This mailing list does not take attachments. Please copy and paste the error into a reply. -- https://mail.python.org/mailman/listinfo/python-list
Re: Conditionals And Control Flows
On May 4, 2016 10:45 AM, "Cai Gengyang" wrote: > > I am trying to understand the boolean operator "and" in Python. It is supposed to return "True" when the expression on both sides of "and" are true > > For instance, > > 1 < 3 and 10 < 20 is True --- (because both statements are true) > 1 < 5 and 5 > 12 is False --- (because both statements are false) > > bool_one = False and False --- This should give False because none of the statements are False > bool_two = True and False --- This should give False because only 1 statement is True > bool_three = False and True --- This should give False because only 1 statement is True > bool_five = True and True --- This should give True because only 1 statement is True > > Am I correct ? Yes. Caveat : python Boolean operators return the value of the last argument necessary to determine the outcome. Example : 2 or 3 results in 2 2 and 3 results in 3. 0 and 3 results in 0. HTH. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python3 html scraper that supports javascript
On May 1, 2016 10:20 AM, wrote: > > Hi, > > can you please recommend to me a python3 library that I can use for scrapping JS I'm not sure what you mean by that. The tool I use is Splinter. Install it using pip. that works on windows as well as linux? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to fill in abbreviation in one column based on state name in another column?
1) Your code seems to be missing a lot. 2) it's better to post a small sample of the dictionary rather than the whole thing. 3) remove the comments that don't seem to say anything useful. 4) tell us what problems you are having -- https://mail.python.org/mailman/listinfo/python-list
Re: help install numpy and scipy in window 7 and 3.5.0 shell
On Apr 15, 2016 10:40 AM, wrote: > > Hi all, > > I have downloaded the numpy-1.11.01 and scipy-0.17.0 but after running setup files over IDLE in numpy and scipy, it still can not get through. Can someone give me a hand? or you can provide the installation instruction for both. Can you be more specific? "Can not get through" is not very informative. What opeting system are you using? What version of python? What messages or symptoms do you get? The more you help us the easier it is for us to help you. We do welcome your questions thank you -- https://mail.python.org/mailman/listinfo/python-list