2,190 Posted Topics

Member Avatar for andrewtrench

The easiest way is to use a class and define the dictionary as self.some_name so you can access it inside or outside the class. A simple example: [CODE]class TestClass: def __init__(self): self.test_name = "test name from class" def print_object_variable(self): print "variable within class -->", self.test_name x = TestClass() print "outside …

Member Avatar for andrewtrench
0
2K
Member Avatar for kadvar

Store the "short" line and blank it after writing. If there isn't a short line, the store variable will be empty. [CODE]in_file = open('myhugetextfile.txt') out_file = open('mycleaneduptextfile.txt','w') #go through the file line by line repaired_line = "" for line in in_file: #split on ;; and check if the length is …

Member Avatar for kadvar
0
139
Member Avatar for AMW

If you are looking for the same English word in both files, use one set for each file and then you can get the difference or intersection of the sets. [url]http://en.wikibooks.org/wiki/Python_Programming/Sets[/url] To read two files, you open the first file, process it (add to the set or whatever), and then …

Member Avatar for woooee
0
108
Member Avatar for parijat24

I looked through all 10 of your previous posts and you haven't produced one line of code. It's about time you did or find another site to get free programming.

Member Avatar for parijat24
0
134
Member Avatar for danholding

If I understand the question, you want to print file dates that have not already been printed so you have to use some sort of container, a list for example, which contains the dates already printed, and print only if the date has not already been used.

Member Avatar for danholding
0
146
Member Avatar for acrocephalus

It sounds like either the screensaver or the wxPython time out (for certain types of widgets). I don't use timeout so am not familiar with it other than seeing it in the docs. Your program should allow the user a certain amount of time to choose a file, and if …

Member Avatar for acrocephalus
0
594
Member Avatar for pdini

QImage has a save function. See "Reading and Writing Image Files" [URL=http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qimage.html]here[/URL]

Member Avatar for pdini
0
2K
Member Avatar for pythonbegin

Python usually has ways of replacing a bunch of if/elif/else statements.[CODE] for field in infos: if field.startswith('AC'): f_out.write('%s\t' % field[3:]) elif field.startswith('ID'): f_out.write('%s\t' % field[3:]) elif field.startswith('FA'): f_out.write('%s\t' % field[3:]) elif field.startswith('OS'): f_out.write('%s\t' % field[3:]) elif field.startswith('SF'): f_out.write('%s\t' % field[3:]) elif field.startswith('BS'): f_out.write('%s\t' % field[3:]) elif field.startswith('GE'): f_out.write('%s\t\n' % field[3:]) …

Member Avatar for pythonbegin
0
1K
Member Avatar for sandhya1202

If I understand correctly, you would modify the RemovePunc() function to receive an individual record from the file, and then execute the rest of the code as is line = RemovePunc(file_record) line_stop_words = RemoveStopWords(line) line_stop_words = StemWords(line_stop_words) index = Indexing(line_stop_words) OutputIndex(index) See here [url]http://www.greenteapress.com/thinkpython/html/book010.html#wordlist[/url]

Member Avatar for Beat_Slayer
0
639
Member Avatar for reviloera

It's in the repository [url]https://admin.fedoraproject.org/pkgdb/acls/name/qscintilla?_csrf_token=ad09f71cc75d6c163204002663217b089dd6945c[/url] so you can install it like any other software. [QUOTE]I get an error message.........(bash: qmake command not found)[/QUOTE]On my Slackware machine, qmake is in /usr/lib/qt which is not in the path, so you would have to call it with /usr/lib/qt/qmake ...

Member Avatar for woooee
0
101
Member Avatar for koveras vehcna

Split on the period. Note that the following doesn't make sense/requires an example. [QUOTE]Also, if a sentence is long, does not end in the same paragraph, it should be printed as a whole too [/QUOTE]

Member Avatar for TrustyTony
0
1K
Member Avatar for andrewtrench

[QUOTE]The error is: TypeError: unsupported operand type(s) for +: 'int' and 'tuple' [/QUOTE]There isn't any "+" sign in the code you posted. How about posting the entire error message including the offending line of code,

Member Avatar for andrewtrench
0
250
Member Avatar for Ultralisk

You can use the code you have with a range from total rows to zero and a step of -1, or a counter for the number of stars to print. [CODE]total_rows = 5 num_stars = total_rows for row in range (total_rows): print '*' * num_stars num_stars -= 1 [/CODE]

Member Avatar for Ultralisk
0
117
Member Avatar for cnuzzo

Take a look at the first paragraph of the first hit [URL=http://www.google.com/search?client=opera&rls=en&q=pygtk+set+cursor&sourceid=opera&ie=utf-8&oe=utf-8]here[/URL]. You can just comment that line and keep the default cursor.

Member Avatar for woooee
0
248
Member Avatar for newyawk

[QUOTE]I need to read in the first 2 columns until line 12960. I then need to write the 12960 lines of 2 columns to a file.[/QUOTE]You can use enumerate to count the records as it appears that a file is shorter than you think or there are blank records. [CODE]import …

Member Avatar for woooee
0
178
Member Avatar for rahul8590

Personal preference here is to use a dictionary, with the key being the word, pointing to the number. Convert the first list to a dictionary, loop through the second list and if the word is found in the dictionary, add to the number [url]http://www.greenteapress.com/thinkpython/html/book012.html#toc120[/url] Post back with any code you …

Member Avatar for ultimatebuster
0
262
Member Avatar for jenzilla

Try greeting = Text(Point(300, 250), "Hello," + player + "and good night") Otherwise: print_str = "Hello," + player + "and good night" greeting = Text(Point(300, 250), print_str)

Member Avatar for rahul8590
0
100
Member Avatar for nuaris

printB is not part of the class unless you define as being a class member, like so[CODE] def printB(self): print "B"[/CODE]You then call it with self.printB() See this page from "How To Think Like A Computer Scientist" [url]http://www.greenteapress.com/thinkpython/html/book018.html[/url]

Member Avatar for yinchao
0
2K
Member Avatar for Kraln00b

[QUOTE]I essentially need to compare each Item in a list to every other item in the list.[/QUOTE]Generally speaking, to compare you start with the first item in the list and compare to item #2, #3, etc. Then the same for the second item through n-1, as there is nothing to …

Member Avatar for Kraln00b
0
162
Member Avatar for hisan

That comes from the OS and depends on what "graphic card details" means. If you just want to know what type of graphics card, use subprocess to run lspci and pipe the output to a file. You can then read the file and search for "graphic".

Member Avatar for Gribouillis
0
7K
Member Avatar for Peter_TARAS

You can use the id also since you only want a name that is unique. Perhaps a dictionary with name/id --> class + args as well. [CODE]class TestClass(object): def __init__(self): print "class instantiated" ins = TestClass() unique_name = str(id(ins)) print unique_name [/CODE]

Member Avatar for vegaseat
0
17K
Member Avatar for sanv

I don't see a problem on my machine using this simple example so it probably has nothing to do with time.sleep(). The queue perhaps? [CODE]import time from multiprocessing import Process class TestClass(): def test_f(self, name): ctr = 0 while True: ctr += 1 print name, ctr time.sleep(1.0) if __name__ == …

Member Avatar for woooee
0
131
Member Avatar for vulcano224

[QUOTE]Write a PYTHON function that takes the time as three integer arguments (for hours, minutes, and seconds)[/QUOTE] You are supposed to create a function, not a class, that takes three arguments/parameters. Your class doesn't take any arguments. You can take a look at functions [URL="http://hetland.org/writing/instant-python.html"]here[/URL] for a simple example.

Member Avatar for vegaseat
0
206
Member Avatar for Tommymac501

[CODE]L = 10 - len(answer) list.append(answer + ' ' * L)[/CODE]You can do this if you want but remember that Python has most things built in so you can also use: (look up string formatting) [CODE]print "%10s %10s" % (car, answer) ## ## and your original code should read print_list …

Member Avatar for woooee
0
4K
Member Avatar for hisan

You should be able to read the 100 bytes, split and write. The following code uses 25 bytes and splits from 10 through 20 (11 bytes) for simplicity. [CODE]alpha = "abcdefghijklmnopqrstuvwxy" print alpha print alpha[9:20][/CODE]

Member Avatar for hisan
0
89
Member Avatar for acrocephalus

Here is a link to simple on-line tutorial. See the explanation under "Functions". You should book mark this link for future reference [url]http://hetland.org/writing/instant-python.html[/url]

Member Avatar for acrocephalus
0
10K
Member Avatar for acrocephalus

You would have to use Tkinter or one of the other toolkits. An example [url]http://tkinter.unpythonic.net/wiki/AutocompleteEntry[/url]

Member Avatar for cronos4d
0
92
Member Avatar for bettersaid

Since you are running an app outside of the Python environment, via os.system, the mouse is controlled by the external app that you are running.

Member Avatar for bettersaid
0
111
Member Avatar for Gribouillis

Perhaps I am missing something, but the following code should work. But once you get past the precision of floating point numbers you will have to use the decimal module whichever way you do it. [CODE]import decimal x = decimal.Decimal("2.4999999999999999999999999") whole, remain = divmod(x, 1) if remain >= decimal.Decimal("0.5"): whole …

Member Avatar for Gribouillis
0
3K
Member Avatar for kumarantechie

You have to install pygtk, which is the python binding to GTK, for the 2.5 version. If you look in the /usr/lib/ directory for 2.6.4 you should see a directory for pygtk. I would first search the Fedora repositories as it should have both Python2.5 and PyGTK for 2.5.

Member Avatar for woooee
0
147
Member Avatar for murjam

I prefer to bind the button to a function that returns the desired variable, but it is somewhat personal preference. [CODE]from Tkinter import * class ChooseVideoFiles: def __init__(self, root): canv = Toplevel(root) canv.geometry("+150+250") title = Label(canv, text = "Select 3 videos with specified or a bit longer length", font = …

Member Avatar for TrustyTony
0
157
Member Avatar for timrichardson

Use root.withdraw [CODE]from tkinter import * ##from tkinter import ttk from tkinter import messagebox root = Tk() root.withdraw() answer = messagebox.askyesno(message="Are you thinking of the " + "data " + "?" ,icon='question' ,title="My guess") print(answer) [/CODE]

Member Avatar for vegaseat
0
1K
Member Avatar for Tommymac501

Can you just strip off the first and last parameter? [CODE]## path_file "".join(sys.argv[1:-1]) import os test1 = ["program_name.py", "one/path/", "two_paths/", "three", "second_arg"] path_file = "".join(test1[1:-1]) print path_file if os.path.isfile(path_file): ## etc [/CODE]

Member Avatar for Tommymac501
0
140
Member Avatar for wolfeater017

See this comment is tbone2sk's reply above. [QUOTE]Line 33 Python Syntax (Toggle Plain Text) return windowSurface return event A method can not have more than one return statement, both of these variables can be returned as a tuple though. [/QUOTE]The first culprit to check on is to see if "event" …

Member Avatar for wolfeater017
0
293
Member Avatar for dekepler

[QUOTE]These files are between 6 and 15 mb is size.[/QUOTE]That's not very large by today's standards so I doubt that "MemoryError message" means running out of memory. Try running the program with a try/except and maybe you will get error messages that show what and where the error is, as …

Member Avatar for Tommymac501
0
999
Member Avatar for pxalpine

The problem is more one of viewpoint, not coding. You want to get away from the word processing mentality. There is no such thing as lines in a document in a folder (unless the programmer first creates them). We have data (bytes) in two files that we can use or …

Member Avatar for woooee
0
111
Member Avatar for parijat24

You have to find some unique combination that you can split on. If SV= is always the final string then you can split on that. You could also split on finding X number of capital letters in a row. [CODE]## an easy way to create the string from the post …

Member Avatar for parijat24
0
141
Member Avatar for bettersaid

To get a matrix, you would have to split each record in the file. The file will be read in as a single dimension list if each record has a newline. You then have to split each record on the individual fields to get a matrix that you can access. …

Member Avatar for woooee
0
180
Member Avatar for G_S

Using EasyGUI [url]http://easygui.sourceforge.net/download/current_version/tutorial/[/url] is a simple solution and should solve the problem

Member Avatar for G_S
0
205
Member Avatar for pancakelove

Is self.storeli a list or a dictionary? I would suggest that you print self.counter and len(self.storeli) before the line in question. +1 on Beat_Slayer's suggestion.

Member Avatar for woooee
0
96
Member Avatar for doomas10

The following part of your code doesn't make sense. You should go back to where ever the code came from and double check that it was copied correctly, and that you copied all of the code supplied. Also, print the dictionary to see what it contains. [CODE]clist= {} for word …

Member Avatar for woooee
0
120
Member Avatar for PythonNewbie2

Python has a CSV reader/writer [url]http://docs.python.org/release/2.5.2/lib/csv-examples.html[/url]. I would suggest you start with reading the file and printing individual rows and columns so you discover how to access them individually. Google is your friend here.

Member Avatar for PythonNewbie2
0
141
Member Avatar for faby

You would have to use threading or multiprocessing. One thread/process would run festival, while another process would capture some input and send a notice (change a variable) in the first process. Obviously you would have to communicate between the two processes.

Member Avatar for woooee
0
164
Member Avatar for gsingh2011

Mechanize is an easier way IMHO to do this. This link explains how to log in with a user name and password to a remote site [url]http://stockrt.github.com/p/emulating-a-browser-in-python-with-mechanize/[/url]

Member Avatar for Beat_Slayer
0
251
Member Avatar for mastermoo420

The general way to create a dictionary is to split the text file records into a key and data, then [CODE]if key not in the_dictionary: the_dictionary[key] = [] ## this is a list but you can use whatever type you want the_dictionary[key].append(data) [/CODE] For additional help you should post some …

Member Avatar for TrustyTony
0
62
Member Avatar for kshw

This is trivial without regular expressions. Read one record, split into words, and test each word; read the next record, etc. Note that the following two lines probably don't do anything as Original_File_Content is one, long string. See Section 7.2.1 for clarification [URL]http://docs.python.org/release/2.5.2/tut/node9.html#SECTION009200000000000000000[/URL]. If it is a very large file, …

Member Avatar for woooee
1
211
Member Avatar for cableguy31

Gedit is going to use whatever locale the OS is set up for. I'm sure you can probably change the UTF for gedit alone, although I don't use it so don't know. You can also change the locale which would make the change system wide, but how you do this …

Member Avatar for woooee
0
133
Member Avatar for wiluo

Somebody should Google disk cache. This is the doc for flushing write commands. [QUOTE]file.flush() Flush the internal buffer, like stdio‘s fflush(). This may be a no-op on some file-like objects. Note: flush() does not necessarily write the file’s data to disk. Use flush() followed by os.fsync() to ensure this behavior. …

Member Avatar for jcao219
0
4K
Member Avatar for ITgirl2010

[QUOTE]there is no main[/QUOTE]Python does not require a "main" function. I would be better the say that no instance of the class has been called/created. This is a link to the instant python tutorial which includes classes [url]http://hetland.org/writing/instant-python.html[/url] If you copied this program and want to modify it, I would …

Member Avatar for TrustyTony
0
121
Member Avatar for aframe

Actually this is more a function of the desktop, each of which has wrappers to perform this function. KDocker for KDE is only one that comes to mind right now but there are sure to be more, perhaps one or two that are not desktop specific.

Member Avatar for woooee
0
2K

The End.