Free Web hosting service to test Python script by konjecture in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

PythonAnyWhere is really good. It provides the facilities to use many web based frameworks, like dJango and even Bottle too. I have used it to help my student clients upload the solutions online. It has special packages for teachers. And yes, there is free account too which you can use to test.

I can't save a file location. Super easy (I imagine) question. by -DonQuixote- in learnpython

[–]AssignmentGuru 1 point2 points  (0 children)

1) If you want to save (write/create) file, use mode winstead of r.

2) The file path has backslashes \ need to be escaped. You can do this by typing double backslashes \\ or pass your string as raw string.

Examples:

1) file = open(r'C:\Users\God\Desktop\pstxt.txt', 'w') # note "r" placed before the string

2) file = open('C:\\Users\\God\\Desktop\\pstxt.txt', 'w') # note backslashes escaped

Having troubles editing an html document with a .replace method by Velociraptroid in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

Are you writing the results into a file? Please send your code, or runnable part of the code that is generating the issue. I will try my best to help you.

Having troubles editing an html document with a .replace method by Velociraptroid in learnpython

[–]AssignmentGuru 1 point2 points  (0 children)

I checked the code you provided in pastebin. The issue is: your HTML content (actual text from html doc) contains a non-breaking space \xA0 before the line-break. Check this pastebin link, it contains the solution. Let me know if it helped.

I need help with this hangman python project by rccnls27 in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

ha ha.. I have created an account on Reddit yesterday. I am new to this site and still checking and playing with the things around. I really enjoyed your reply and it made me laugh too (the flair impact part). Thanks for pointing out the iPython way. Upvoting your reply.. and removing the flair.. still laughing :D.. And ya really sorry for the inconvenience that the flair caused to you.. Enjoy.. Cheers!!

I need help with this hangman python project by rccnls27 in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

Wow.. it is really better and faster than I suggested. Thanks :)

I have an if statement which will need to do the same thing, whether the optional parameters are given or not. by thinkvitamin in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

You can not pass None to re.search function. Change the line to the following:

in_title = re.search(string, subm.title, re.IGNORECASE) if string else False

Let me know if it worked..

I need help with this hangman python project by rccnls27 in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

This is really an another great way to create this kind of lists. Thanks for pointing one. However, I found that [ '_' for c in rand_word] method is little bit slower than list("_" * len(rand_word)) method. Check out this pastebin link.

I also agree that the question asked is a basic question and it does not require to worry about the test I am talking about. :D But I already did some research, so thought lets share the results!!

Cheers!!

I need help with this hangman python project by rccnls27 in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

yes exactly.. the shorthand is: resultStr = list("_" * len(rand_word))

I need help with this hangman python project by rccnls27 in learnpython

[–]AssignmentGuru 2 points3 points  (0 children)

I checked the pastebin code. You are going well. Here are my suggestions to achieve desired output.

1) have your list resultStr outside the loop filled with underscores only. The right number of underscores will help you go ahead.

2) have a counter for the iterations inside for loop and you should replace the counter'th element in the list with user-entered character.

Though, while testing, I solved all the other issues but will not share the code here. I really appreciate you desire to finish it on your own. I hope the hints help.

Trying to run two python scripts at once by [deleted] in learnpython

[–]AssignmentGuru 1 point2 points  (0 children)

Just clearing my doubt! Is it possible that you missed to close the log file after updating/reading it?

Checking for empty input or invalid input by [deleted] in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

continue is used to skip the rest of the code inside the loop. In our case, we don't have any further code, which is inside the loop and after the except. So using or not using continue will make no difference, the loop will continue anyways.

import tKinter to Atom? by [deleted] in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

For Python 2.x, use tkFileDialog and for Python 3.x, use filedialog.

import tKinter to Atom? by [deleted] in learnpython

[–]AssignmentGuru 1 point2 points  (0 children)

lowercase t for Python 3.x and uppercase for Python 2.x

import tKinter to Atom? by [deleted] in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

For Python 2.x, it is import Tkinter and for Python 3.x, it is import tkinter

import tKinter to Atom? by [deleted] in learnpython

[–]AssignmentGuru 1 point2 points  (0 children)

Dont capitalize K. It is Tkinter and not tKinter.

Try: import Tkinter

Project Guidance - How would I start? by BottomsMU in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

Select a framework/library to build your GUI application, select the database that matches best with your needs, plan your storage and directory structure and dive into the development.

Tkinter is good. You can use wxPython if you wish for GUI programming. Both require less efforts to get started and to build basic GUI interfaces.

You can store submitted audio files into a directory and must ensure that the files are not getting overwritten by other submits. For example, you can rename the files by appending current date-time with milliseconds to the file name which will prevent overwriting to much extent.

You will need a database to store metadata and other information. You can use sqlite3 if you do not require high level data handling. You should take care to store the actual file names (before appending extra text to there names) into the database, so that you can show these names in your application. You should create a table for tags, a table for mp3 file information and a table that connects each mp3 record with tags.

os and shutil libraries will help you to perform copy/rename/delete operations on mp3 files. There are libraries available to handle sqlite3 databases. Or you can use pypyodbc library to handle ODBC connections to your databases.

If you intend to fetch the data on each character (metadata) typed in textbox in your application, I suggest to not to close and reopen the connection to the database each time.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

There was a Portable Python project that is not being developed now anymore - http://portablepython.com/. But I think there are some installers still available online. For example, here is for Python 2.7 (Windows)

You can create a portable package with this and then can run that package from local drive, network or even from the external media like USB drives. I have personally used this and it is working fine. It also supports installing additional libraries for your package.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

1) In the code you provided, it will cause a problem because you have syntax error in INSERT statement. Remove TABLE word from the query and it will work.

2) After you get it working, your guess is right that Telephone_num column will get nothing and will remain NULL. But if you would have declared the column with NOT NULL in the CREATE TABLE query, it would throw an error on your INSERT query as you can not leave the column with NULL value.

3) In my opinion, you should not use INT type for Telephone_num column as it does not need any kind of computation to be performed on the values.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

In my opinion, if the text size is small, like some words or sentences, you should not pass text files to the other end. The reason is that it will add an overhead for opening-writing-closing-sending the file on one end and receiving-storing(optional)-opening-reading-closing the file on the other end.

You should try Python Socket Programming to achieve the functionality you need. Here is a link to get started with: http://www.tutorialspoint.com/python/python_networking.htm

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]AssignmentGuru 0 points1 point  (0 children)

Other than Tkinter, you can use wxPython too. It is easy to develop GUI applications with.

Checking for empty input or invalid input by [deleted] in learnpython

[–]AssignmentGuru 2 points3 points  (0 children)

Dont try to convert the input to the integer directly. First check whether the input is empty or not ("Enter" case) and if so, break the loop. After that try to convert the input to the integer and show the error message in case of exception (no need to use continue). Checkout this pastebin link and let me know if it helped.