324 Posted Topics

Member Avatar for zaphoenix

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 …

Member Avatar for HiHe
0
154
Member Avatar for jakizak

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.

Member Avatar for Ancient Dragon
0
221
Member Avatar for HiHe

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?

Member Avatar for vegaseat
0
229
Member Avatar for giancan
Member Avatar for neojiphre

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

Member Avatar for HiHe
0
11K
Member Avatar for unigrad101

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 …

Member Avatar for HiHe
0
121
Member Avatar for jkon

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 …

Member Avatar for Dani
0
280
Member Avatar for utkarshsahu

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.

Member Avatar for ihatehippies
0
237
Member Avatar for Darek6

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], ',': …

Member Avatar for Gribouillis
0
235
Member Avatar for sunfutbol

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 …

Member Avatar for sunfutbol
0
202
Member Avatar for Ancient Dragon

Everything is **big** in Texas, so a hailstorm leads to a **big** repair bill.

Member Avatar for Ancient Dragon
0
98
Member Avatar for HTMLperson5

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

Member Avatar for HTMLperson5
0
2K
Member Avatar for arunpawar

Using `return (float(ftemp)-32) * 5 / 9` would also help you with the integer division problem with Python2

Member Avatar for arunpawar
0
252
Member Avatar for iraj.jelo

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, …

Member Avatar for HiHe
0
2K
Member Avatar for HTMLperson5

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 …

Member Avatar for HiHe
0
191
Member Avatar for sidestrand
Member Avatar for sidestrand
0
2K
Member Avatar for srk619

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!

Member Avatar for HiHe
0
657
Member Avatar for 4evrmrepylrning
Member Avatar for 4evrmrepylrning
0
218
Member Avatar for adam93

# 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

Member Avatar for HiHe
0
90
Member Avatar for thanadaray
Member Avatar for thanadaray

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 …

Member Avatar for HiHe
0
201
Member Avatar for ckugblenu

[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.

Member Avatar for m1raEbrah1m
0
122
Member Avatar for mlhuff12

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]

Member Avatar for Rashakil Fol
0
239
Member Avatar for xopenex

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.

Member Avatar for HiHe
0
2K
Member Avatar for puddlejumper406

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 …

Member Avatar for puddlejumper406
0
119
Member Avatar for moroccanplaya

There is a nice example in: [url]http://www.daniweb.com/software-development/python/threads/191210/954810#post954810[/url]

Member Avatar for HiHe
0
93
Member Avatar for boiishuvo

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 …

Member Avatar for HiHe
0
833
Member Avatar for 909kidd
Member Avatar for HiHe
0
178
Member Avatar for webecedarian

People that criticize a successful business like Google are generally losers that couldn't run a hamburger joint themselves.

Member Avatar for Netcode
0
230
Member Avatar for draven07
Member Avatar for vegaseat
0
2K
Member Avatar for pwolf

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 …

Member Avatar for snippsat
0
305
Member Avatar for pseudorandom21
Member Avatar for HiHe
0
42
Member Avatar for pseudorandom21
Member Avatar for vegaseat
0
98
Member Avatar for happygeek
Member Avatar for bigredaltoid

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 …

Member Avatar for bigredaltoid
0
135
Member Avatar for mrnutty
Member Avatar for royng
Member Avatar for sneekula
Member Avatar for Falcon25
Member Avatar for blackcathacker
2
403
Member Avatar for mariko

I think scripting was done by scribes (mostly monks), particularly in the really olden days.

Member Avatar for vegaseat
0
165
Member Avatar for Ancient Dragon
Member Avatar for jonhylever
Member Avatar for Ene Uran
-2
359
Member Avatar for HiHe

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 --> …

Member Avatar for vegaseat
1
170
Member Avatar for HiHe

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 …

Member Avatar for vegaseat
0
311
Member Avatar for WolfShield

There are some pretty bad tutorials floating about, which one is this exactly?

Member Avatar for HiHe
0
183
Member Avatar for Pendukeni

O. J. Simpson played for the AFL's Buffalo Bills, used to be the best, "The Juice". He would simply jump over any defender.

Member Avatar for jingda
0
163
Member Avatar for jingda
Re: UFO?

There are lots of Unidentified Flying Objects. If you are high on something, there are even more.

Member Avatar for Lardmeister
0
410
Member Avatar for installer
Member Avatar for jingda
Member Avatar for hoangtuepchai

Another example that looks interesting: [url]http://eclecti.cc/computergraphics/evil-eye-microvision-showwx-as-a-face-tracking-eyeball[/url]

Member Avatar for HiHe
0
84

The End.