324 Posted Topics
Re: Do mean something like this: line = 14 word = 15 letters = 128 print "Number of lines,words,letters is : " ,line,word,letters # using the C type % specifier print "Number of lines,words,letters is : %d %d %d" % (line,word,letters) # include justification print "Number of lines,words,letters is : %5d … | |
Re: If rational people are involved, I don't mind getting into an argument. With irrational folks like politicians, religious extremists and bullies, I just walk away. | |
Just in the news: A Miami police officer fatally shot a naked man who refused to stop chewing on the face of another naked man — even after being shot once by the officer — on a busy downtown highway ramp. Have you read any other strange news lately? | |
Re: For instance use sys.setdefaultencoding('iso-8859-1') | |
Re: This may help you: http://stackoverflow.com/questions/4241036/how-do-i-center-a-frame-within-a-frame-in-tkinter There is additional info at: http://zetcode.com/gui/tkinter/introduction/ http://www.daniweb.com/software-development/python/threads/66181/center-a-tkinter-window | |
Re: This should help a little: import turtle as tu ''' turtle by default starts at (x=0, y=0) center of a (450x550) window to pick another center lift the pen up then move to the right x units and up y units or ... to the left -x units and down … | |
Re: In 2050, after smart and honest super-robots have been elected to run the country, replacing the usual slimy lot of human politicians. Also iPad300 just came out with unlimited battery life, 500 yotta bytes of memory containing every song ever written, every movie ever made and the explanation of every … | |
Re: Sounds like a fun project! You may also want to look at: http://packages.python.org/pyenchant/ and its tutorial http://packages.python.org/pyenchant//tutorial.html it mentions a custom dictionary The Python IDE Eric5 can use pyenchant for a spell checker. | |
Re: This might be faster: # create and word:index dictionary and a sorted list of index tuples def create_index_dict(data_list): index_dict = {} for ix, word in enumerate(data_list): index_dict.setdefault(word, []).append(ix) return index_dict data_list = ['the', 'house', ',', 'the', 'beer'] index_dict = create_index_dict(data_list) print(index_dict) ''' {'house': [1], 'the': [0, 3], 'beer': [4], ',': … | |
Re: In Python2 the input() function actually uses raw_input() and eval(). You can enter a string with input() if you put it in quotes. The function eval can turn evil if you enter a command to whipe out your hard disk for instance. With Python3 raw_input() turns into simply input() and … | |
Re: Everything is **big** in Texas, so a hailstorm leads to a **big** repair bill. | |
![]() | Re: def file_exists(filename): ''' a file exists if you can open and close it ''' try: f = open(filename) f.close() return True except: return False ![]() |
Re: Using `return (float(ftemp)-32) * 5 / 9` would also help you with the integer division problem with Python2 | |
Re: Here is a typical example using PyQT: '''pqt_tableview2.py use PyQT's QTableView and QAbstractTableModel to present tabular data a rather simplified experiment tested with PyQT 4.8 and Python 3.2 ''' from PyQt4.QtCore import * from PyQt4.QtGui import * class MyWindow(QWidget): def __init__(self, data_list, header, *args): QWidget.__init__(self, *args) # setGeometry(x_pos, y_pos, width, … | |
![]() | Re: If you use the Windows OS, you can use this approach: # display text on a Windows console # Windows XP with Python27 or Python32 from ctypes import windll # needed for Python2/Python3 diff try: input = raw_input except: pass STD_OUTPUT_HANDLE = -11 stdout_handle = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE) # look at the … |
Re: You specify usecols=(0,12,18) Do you have 18 columns in each data line? | |
Re: The c code line **int leap ( int int x)** will give error: two or more data types in declaration of `x' this is bad coding! | |
Re: flag = None should be okay Python object None is simply an empty object/value | |
Re: # the look of sets have changed with Python3 myset = set('abcd') print(myset) """ result with Python2 --> set(['a', 'c', 'b', 'd']) result with Python3 --> {'a', 'c', 'b', 'd'} """ print(len(myset)) # 4 print('c' in myset) # True | |
| |
Re: Here is a little more advanced code that checks your values you enter: # numeric input function with range check # works with Python25+ or Python3+ try: input = raw_input except: pass def get_num(low=0, high=100, ps="a number"): """ the function will loop until a number within the given low and … | |
Re: [QUOTE=vegaseat;1775083]Data-mining might be an awesome area to be in.[/QUOTE] With the ever increasing amount of data on the internet, data-mining/data-evaluation will be very important. | |
Re: There are a few posts on DaniWeb: [url]http://www.daniweb.com/software-development/legacy-and-other-languages/threads/371156/1596372#post1596372[/url] Particularly the ref to: [url]http://www.norvig.com/[/url] | |
Re: I downloaded the 32 bit version for Python 2.7 from: [url]http://qt-project.org/wiki/PySide_Binaries_Windows[/url] The Windows self installer is called: PySide-1.1.0qt474.win32-py2.7.exe It installs easily without problems. | |
Re: All you need to do is to expand the pseudo-code your teacher gave you. Here is a hint to get you started: [code]# Prompt your friend for how many drinkers will be present. prompt = 'How many drinkers will be present? ' drinkers = int(input(prompt)) # Prompt your friend to … | |
Re: There is a nice example in: [url]http://www.daniweb.com/software-development/python/threads/191210/954810#post954810[/url] | |
Re: You might want to do it this way: [code]STOPWORDS = ['a','able','about','across','after','all','almost','also','am','among', 'an','and','any','are','as','at','be','because','been','but','by','can', 'cannot','could','dear','did','do','does','either','else','ever','every', 'for','from','get','got','had','has','have','he','her','hers','him','his', 'how','however','i','if','in','into','is','it','its','just','least','let', 'like','likely','may','me','might','most','must','my','neither','no','nor', 'not','of','off','often','on','only','or','other','our','own','rather','said', 'say','says','she','should','since','so','some','than','that','the','their', 'them','then','there','these','they','this','tis','to','too','twas','us', 'wants','was','we','were','what','when','where','which','while','who', 'whom','why','will','with','would','yet','you','your'] def remove_stop_words(wordlist, stopwords=STOPWORDS): # ask for sentence if wordlist is empty if not wordlist: sentence = raw_input("type a sentence: ") wordlist = sentence.split() marked = [] for t in … | |
Re: I like the improved version of the IDLE editor that comes with Vpython. | |
Re: People that criticize a successful business like Google are generally losers that couldn't run a hamburger joint themselves. | |
![]() | Re: You can use the PyQT Designer if you don't develop commercial software. |
Re: You have to make sure your code blocks are indented properly. Here is an example showing the proper indentations: [code]#!/usr/bin/python # -*- coding: utf-8 -*- # PySide is the official LGPL-licensed version of PyQT # I downloaded and used the Windows self-extracting installer # PySide-1.0.0qt472.win32-py2.7.exe # from: http://developer.qt.nokia.com/wiki/PySide_Binaries_Windows # tested … | |
Re: His supporters were hoping he was drunk, but he was actually sober! | |
Re: Sounds like 'love' will always be for sale. | |
Re: Here is one way do accomplish this task: [code]import pprint # constants are pos in list FIRST = 0 LAST = 1 CREDIT = 3 def update_dict(myDict): updatedDict = myDict.copy() for key in myDict: #print key, myDict[key], myDict[key][3] # test # show full name print myDict[key][FIRST], myDict[key][LAST] credit2 = raw_input("Please … | |
Re: ... you can think of 20 words that rhyme with geek. | |
![]() | Re: The new Lithium and doped Iron Phosphate batteries will do it. |
Re: I think scripting was done by scribes (mostly monks), particularly in the really olden days. | |
| |
According to the Python 2.7 manual this construction of the with statement should work: [code]text = "aim low and reach it" fname = "test7.txt" with open(fname, 'w') as foutp, open(fname, 'r') as finp: # write text to file foutp.write(text) # read text from file mytext = finp.read() print("to file --> … | |
I was trying to create a simple Python GUI with a label on a frame. I can't get the label's position and size to work: [code]# a simple wxPython GUI program # showing a label with color text # however, label position and size do not work! import wx class … | |
Re: There are some pretty bad tutorials floating about, which one is this exactly? | |
Re: O. J. Simpson played for the AFL's Buffalo Bills, used to be the best, "The Juice". He would simply jump over any defender. | |
Re: There are lots of Unidentified Flying Objects. If you are high on something, there are even more. | |
Re: Another example that looks interesting: [url]http://eclecti.cc/computergraphics/evil-eye-microvision-showwx-as-a-face-tracking-eyeball[/url] |
The End.