- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 2
- Posts with Upvotes
- 1
- Upvoting Members
- 2
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
21 Posted Topics
Re: Here is your problem: [CODE] choice = input("ENTER CHOICE: ") [/CODE] Changing 'input' to 'raw_input' will solve your problem. You must probably try this to know the difference: [CODE] >>> input( "Enter something: " ) 5 5 >>> input( "Enter something else: " ) britanicus Traceback (most recent call last): … | |
Re: You could use `QDesktopWidget` to get the 20% of the width of the screen. Use `QDockWidget::resize` to set the initial size. | |
Re: You could try `from LookUpPath import LookUpPathPrefix` instead of `from LookUpPath import *` making your text function like this def test(): # Open the demo and training library from LookUpPath import LookUpPathPrefix fullfilename= LookUpPathPrefix('LIBRARIES') fullfilename = fullfilename+"_Libraries\"Here would be the aboslute path" if window('untitled'): select_menu('File>>Import Library...') if window('Select a Library … | |
While I was trying to write a small program to preview DjVu files I encountered a peculiar problem. This is a small function that renders a page of a DjVu document into QImage class of PyQt4. import djvu.decode as DjVu from PyQt4.QtCore import QImage from PyQt4.QtGui import QPixmap, QApplication, QLabel … | |
Re: Both the above code cannot work properly. The reason is simple, the math is not done properly. Line 16:[ICODE]total_distance = miles + miles[/ICODE] and line 17: [ICODE]total_fuel = gallons + gallons[/ICODE] In both these cases you are just multiplying the no. of miles and no. of gallons the user has … | |
Re: Dear ozzyx123, I think you are on the right track. Just open your xls book before you start reading your email ( i.e before line 18. and add your headers ( line 119 to line 123 ). Initialize a counter before line 74 to 1 ( i.e. you have written … | |
Re: Please stop re-posting the same problem again and again!! Your older thread has an answer: http://www.daniweb.com/software-development/python/threads/416255 | |
Re: Shouldn't you open the file, read the data and send the data as the input to secondDecode? say you save the module as nvr2b.py, then to decompress a file you should, [CODE] import nvr2b # Open the Compressed File cf = open( <compressedfilename>, 'rb' ) extractedData = nvr2b.secondDecode( cf.read() ) … | |
Re: Printing a table should not be any problem at all... Say, [ICODE]table[/ICODE] is the name of your QTableWidget, then to print, just iterate over the rows and columns, pick each QTableWidgetItem to get the text. [CODE] table = QTableWidget( NO_OF_ROWS, NO_OF_COLS ) # Add/Edit the data in the table # … | |
Re: Your code does not work mainly for two reasons.. Firstly, line 21: [CODE] replpos == string1.find("a");[/CODE] You are not assigning any value for replpos, just comparing the values of replpos and string1.find("a"). "==" is for comparison and "=" is for assigning.. Secondly, the next line, line 22: [CODE] string1.replace(replpos+1, 1, … | |
Re: Are you sure you have run this program!! Just looking at the program I can point out at least 3 mistakes. Starting with line 12, entering 'encrypt' or 'decrypt' will raise NameError, unless im mistaken. Putting it in quotes will be of no avail, for that will end up raising … | |
Re: You just have an indentation error!! Just increase the indentation level by 1 from line 91 to 99. Also i think there is an extra '_' in line 131 - you have typed 'legal__moves' instead of 'legal_moves' | |
Re: [CODE] while True : # Accept an input from the user reply = raw_input( "Enter an integer between 33 and 126: " ) # Check if it is indeed a number if not reply.isdigit() : continue # Convert it to number number = int( reply ) # Check if the … | |
Re: use the inbuilt function [COLOR="Red"]bin[/COLOR] to convert decimal numbers to binary | |
Re: Use PIL for reading bmp images: [CODE] import Image img = Image.open( "bmpfile.bmp" ) pixels = list() for row in img.size()[ 0 ] : for col in img.size()[ 1 ] : pixels.append( img.getpixel( row, col ) ) [/CODE] As for saving the file as dicom try the [URL="http://code.google.com/p/pydicom/"]pydicom[/URL] module | |
Re: threadedRotation.py [CODE] class threadedRotation : .... .... .... [/CODE] optimizer.py [CODE] from threadedRotation import threadedRotation class Optimizer : .... .... .... tr = threadedRotation( ... ) [/CODE] | |
This is a part the extension module im writing for python using c++. ( The complete source is available as an attachment ) [CODE] #include <python2.6/Python.h> #include <iostream> #include <fstream> #include "structmember.h" using namespace std; typedef struct { PyObject_HEAD fstream file; } CppFileObject; static int CppFile_init( CppFileObject *self, PyObject *args … | |
Re: You cannot do that in python. But what you can do, is create a temporary file, read your original file, replace the bytes and write it into the temporary file, then copy it into the original location. This is more or less what you need. [CODE]from tempfile import mkstemp from … | |
Re: You could try this : [CODE] def histogram(string): hist = dict() for char in set(string) : hist[char] = string.count(char) return hist def print_hist(h): hist = histogram(h) for key in sorted(hist.keys()) : print '%s : %d' % (key, hist[key]) print histogram('this is a test string') print_hist('this is a test string') [/CODE] | |
Re: The syntax is str[from:to]. So typing string[10:] will return a string containing all characters beginning from the 10th character of your original string. To get the last 10 characters from a string you should type string[(len(string) - 10):]. A smarter way of doing it would be string[:-10]. The negative index … | |
Re: You dont necessarily put your cTurtle.py into any of the folders. Make sure python searches the right locations for import : [CODE]import sys sys.path.append('/folder/in/which/cTurtle.py/resides') import cTurtle [/CODE] |
The End.