15,175 Topics
| |
I am writing a script that solves a Quadratic equation. What I am doing wrong and why? The error I get is: [COLOR="Red"]Traceback (most recent call last): File "/home/matthew/Desktop/QuadraticSolver.py", line 5, in <module> c1 = (b * -1) + math.sqrt(((b*b) - 4*a*c) / 2*a) ValueError: math domain error[/COLOR] Here is … | |
How do you make Python delete a specific line of text from a file? For example, delete_input = input ('> ') file = open('blahblah.$','w') #delete the variable delete_input file.delete(delete_input from file) Any form of help would be appreciated. Thanks! | |
I have a very tough problem- how do you make an icon/character move across a console screen? For example, if I press W, +++++ ++E++ +++++ Then I press D +++++ +++E+ +++++ And I want it to be like the CHOICE command in CMD- Without requiring the user to … | |
Hi, I am trying to create a simple GUI which let user to populate a list box base on a click event in wxpython. Can you please point me into a simple tutorial or example which has a sample? For example I have a list of colors: Red, Green, Blue, … | |
| Is there any way to remove an imported library? `Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32` `Type "copyright", "credits" or "license()" for more information.` `>>> dir()` `['__builtins__', '__doc__', '__name__', '__package__']` (Currently imported packages) `>>> import time` `>>> dir()` `['__builtins__', '__doc__', '__name__', '__package__', 'time']` … |
Hi, I'm a newbie to Python and trying to write my first FTP script. Here's the code: from ftplib import FTP ftp = FTP("LoginServer.com") ftp.login("LoginID", "Password") # open the file to read it f = open("C:/Users/MyDocs/Documents/Python/test.txt", "r") # Open directory ftp.cwd("/") # save file ftp.storbinary("STOR test.txt", f) ftp.quit() f.close() I'm … | |
im following along in this nifty little book and one of the coding examples just sparked my interest. data = open('some_file.txt') for each_line in data: print(each_line) How does python know what i want it to do without really telling it? i figured i would have to tell it how i … | |
Hi guys. So, I'm trying to read data from a database and displaying in a GtkTreeview. I used glade to design the GUI when i click on the button (view movies) the list of movies should display as a list. def on_btnmovies_clicked(self,widget,data=None): store=self.builder.get_object('listmovies') connect=sqlite.connect('movies.db') db=connect.cursor() db.execute("SELECT * FROM movie") for … | |
Assume that a file containing a series of names ( as strings ) is named names.dat and exists on the computers disk. Design a program that displays the numbers of names that are stored in the file. ( Hint: Open the file and read every string stored on it. Each … | |
I started using Python a few weeks ago, something finally clicked and I started writing tools for my personal use. I started writing something with a GUI using GTK and the code lines started multiplying rapidly, so I thought to myself "Am I commenting my source to death? How many … | |
im trying to write a program that will read a line of text from a file and then print that text into whereever the cursor is in the browser. like into the address bar or something. is the possible with python? how would i go about doing it. i know … | |
Hi, I'm a beginner at python and I'm trying to extract specific columns from a text file, and then use those columns to make a line plot. The files contains the following few lines of data: # Raw SIFs at Crack Propagation Step: 0 # Vertex, X, Y, Z, K_I, … | |
I am currently working on an app to convert documents (specifically Open Document Text, at least for now) to epub format. The problem I'm running into right now is this, I am using etree ElementTree to parse the xml files extracted from the .odt file, right now I'm working on … | |
Hey guys, I'm new to parallel programming, so I was wondering if anyone could help me parallelize a bit of code. It is a code that goes into large h5 files (using h5py) and grabs some data out. After that the data has to be reformatted and printed into another … | |
How do you make Python delete a string or a number (in this case, .0) from a file? Example: #Error Fixing if '.0' in open('ship.$','r'): #Delete the '.0' | |
I am trying to write a python script to open file, read each line, and replace the 18th position of each line with a a user specified character (sysargv[3]) IF AND ONLY IF that 18th position is another user specified character (sysargv[2]). It should then save it as a file … | |
Hi :) i'm kind of new to this site and everytime I read a thread someone else makes i don't understand what anyone is saying.... :sad: well anyways, please help me python pros. I have been on my very first exercise of "Learn Pyhton the Hard Way" since two weeks … | |
Guys check out http://cx6-dev.blogspot.com/ for an awesome game coded in Python. It's new but still fun. HIGHLY RECOMMENDED! PS: You'll need to have Python 3.2 or above to install/play it. | |
Hello, I was seeking help in why my small program/script is not performing the way I would like. Here is the question. Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each … | |
I had been wanting to write an IRC bot with asynchronous IO for a while. My bot responds to pings, but can be extended by defining functions and registering them to get called when the bot receives certain commands. My bot uses the RFC 1459 USER command and parameters, but … | |
As in C++ was some question about speed of simple hard disk based lookup, here is a version of unscramble program completely HD based lookup, which gives all possible candidate words for multiword anagram. Program is not sensitive for case of words but does not ignore special characters like ' … | |
This is a script that was supposed to be very basic, just running a command with my scripts arguments attached. I didn't realize that if user 'cj' opens firefox, when user 'root' does '**firefox -new-tab**' it doesn't work. Firefox will just open a new window, and thats exactly what I … | |
Hi, I've started learning Python and want to find out how easy is creating GUI for a software. I used to use VB6 with Visual Studio and it was all about Drag and Drop items on a form. Do we have such thing or we just have to hand code … | |
I have a code for a game. money_file = open ('money.$','r').read() money_file = str(money_file) money = int(money_file) But everytime I run it, it returns an error: Traceback (most recent call last): File "C:\Users\eeo.j\Desktop\CX6 SDK\CX6 Normal\CX6.py", line 86, in <module> money = int(money_file) ValueError: invalid literal for int() with base 10: … | |
I've an web page which reads the data from (server side) database and write into csv file, but as per requirement I need to write the file in client side and asked user to save the file in their local machine with popup window to save the location (client side), … | |
Okay, my problem goes as follows. I've been writing a small program in python (an adventure game) which has hitherto run via the console. I'm now working on giving it a full interface, which is requiring a lot of changes to my rather simplistic/archaic structure and generally making things something … | |
OK, so when I use open(<filename>, 'w') the program either writes to the specified file or creates a new one if it doesn't exist, right? Is there a way to create a folder path or something? Like to create D:\My Documents\Folder and create a file in that folder? How would … | |
I've been working on Tkinter, and setting a message box. It worked fine, but I didn't really like the fact that the text displayed was in a small position in the window. Take a look at this code and you'll know what I mean. def About(self): text = Message(self, text=''' … | |
| Hi, all. I am trying to clear the console window without using the "os" library. This seems like the only way to do it: from os import system import time print "I will clear the screen in 2 seconds" time.sleep(2) system("cls") print "*Cleared Screen*" SystemExit() But the problem is, this … |
Hello, I am trying to read values from an excel spreadsheet but just for specific cells at a time; say Cell A1 and B1. Then I want to save the respective values into a variable and use the variable through out the rest of the code. Then loop at the … |
The End.