15,190 Topics
![]() | |
I've followed a tutorial where a Person class was used to illustrate the difference between class and instance variables. Something like: [CODE] class Person(object): population=0 def __init__(self, name): self.name=name Person.population += 1 print 'current population', Person.population Sally=Person('sally') Joe=Person('joe') [/CODE] This example really illustrated the difference between class and instance variables … | |
hi friends . i have a sqlite program. i need get stuff data from QLineEdit and add to model & tableView . but i dont know what should I do :( plz help me | |
Sometimes, before optimizing your code, you may end up to have very slow running code in list comprehension statement. Because you have not yet tested the code fully, it easy to loose patience and just interrupt the code. If you are making function, you can insert print statements for verification. … | |
The objective is to have the user guess the letters of a word which has to be the name of an object that can be seen. The user is presented with an array of 26 buttons corresponding to the 26 letters of the alphabet. Additionally the user is presented with … | |
Hi friends, I want create a image Button by hovering mouse event as a pushbutton,how i to do? | |
I am trying to make a python that can remove any occurences of any word in stopwords from the wordlist, but I don't know what is exactly wrong with this program. Any suggestions? [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): wordlist … | |
Hello, I and doing a ball bounce project for Vpython and I am trying run the program I wrote. I keep getting an invalid syntax error, but I am unable to find any. Please help. [CODE]from visual import* wallA = box(pos=vector(0,6,0), size=vector(12.1,0.2,12.1), color=color.red) wallB = box(pos=vector(0,-6,0), size=vector(12.1,0.2,12.1), color=color.green) wallC = … | |
I have selected several files with the open multiple files dialog: [CODE][[u'C:\\Documents and Settings\\Administrator\\My Documents\\My Pictures\\chord.jpg'], [u'C:\\Documents and Settings\\Administrator\\My Documents\\My Pictures\\toad1.jpeg', u'C:\\Documents and Settings\\Administrator\\My Documents\\My Pictures\\21369.jpg', u'C:\\Documents and Settings\\Administrator\\My Documents\\My Pictures\\g2.jpg']][/CODE] I want to display the selected files in a nice user-friendly way. Just the filenames, each on a separate … | |
hi everyone i am very new to programming and really need some advice. i am currently building a program and one of the things i need is to be able to count the number of pages in pdf files in a directory. i found a script online which is suppose … | |
Hi, I work for NGO. I am the only software developer here. I want to develop few simple softwares for them as charity work. 1. Devnagri Font Software -They have ANSI Devnagri fonts. I need to create one Font Engine for them, so that they can do feeding or editing … | |
Hi, I have two list of any datatype supported by python. I want to check whether the any of the element of first list is present in second list or not. Example: I have a = [4,5,6] b = [1,3,8,6,7,9] I want to check whether any element of a is … | |
Hello Sorry if this is confusing I'm really new to python and have been stuck trying to figure this out for hours now. I'm trying to write a function for a text based battlship game. I need the function to do this is_occupied: (int, int, int, int, list of list … | |
Make a program that reads some text and produces as output the distribution of words that start with dierent letters. I recently wrote a program that would count how many times a certain letter would show up, but I am not sure how to look to see at the first … | |
I want to loop through directory and process the files in them. I do this with the following code. for (root, subdirectories, files) in os.walk(dirDialoog.GetPath()): for file in files: My problem is that the files processed 2 times. I tried the next code, but in that way the files weren't … | |
I need a program which counts the pages of all the pdf files in a directory. i found this scrpit which is supposet to do exactly that, but when i try to run it it just doesnt work for me it outputs nothing. i dont really know what to change … | |
Hi! I'm working on program with a lot of buttons and I would like to use For loop to make all of them instead of writing every each one of them. so, can anybody help me? here is example of code [CODE] import tkinter as tk def klik_1(): button1.config(image=s1) def … | |
Okay, so I am creating a battleship game, I posted a thread here earlier to figure out how to place the ships, but know I'm back, because I am curious as to how I should program the AI for it. Here's my base code now, and I'll explain how the … | |
[CODE] startup = 0 r = rock p = paper s = scissors if startup == 0: weapon = str(input("Please enter your weapon: Rock, Paper, or Scicors") while weapon =! r: print("Incorrect choice, please choose again")[/CODE] Im running python 3.2.2. Im trying to make rock paper scissors. I am trying … | |
i got a working highlight code example that works in python 2.7.2 [CODE] import Tkinter """ Edit a file and save the text. """ textFont1 = ("Courier New", 16, "normal") class ScrollbarX(Tkinter.Scrollbar): def set(self, low, high): if float(low) <= 0.0 and float(high) >= 1.0: self.grid_remove() else: self.grid() Tkinter.Scrollbar.set(self, low, high) … | |
Title says it all. I am looking for a way to find the values of a column within a row. I am unsuccessful at being about to create a for loop that searches each value in the row and inputs a value if it is x. For example: [CODE] there … | |
Here is the problem: a function that takes two strings and removes from the first string any character that appears in the second string. eg. if the first string is “[B]IamLearningPython[/B]” and the second string is “[B]aeiou[/B]” the result is “[B]mLrnngPythn[/B]”. I've written the code for this, but I can … | |
Hi, I have the a situation here . My motive : Hiding one panel and showing another. Whats Working :Layout wise , my app is behaving like i want it to . The Problem : After the I hide one panel and show another , the button in this panel … | |
Hi, I'm trying to find a way to solve this equation with two unknowns using Python: [QUOTE](a * b) = (x * c) + (y * d) + e [/QUOTE] Where a, b, c, d and e are all floating numbers provided by the user and x and y are … | |
Hey all I need some help with Jython. In Python I'm given the easy option to read a file with [CODE]file = open('/dev/input/js0')[/CODE] Then I can put it into a non blocking mode with something similar to [CODE] import os, fcntl file = os.open('/dev/input/js0', os.O_NONBLOCK) [/CODE] But in Jython I'm … | |
Okay, so for some practice problems from a friend, he asked me to take some previous code, and define a function called parseName? I'm not familiar at all with what it is/does. The objective he gave me was to use this parseName function and to return the firstname, middlename, and … | |
![]() | apparently my data is too big to be split at every newline.. any idea how to split every 4th newlien? |
Hello, I need your help to get my Python program running please. Thank you so much. This is the assignment: Highway Robbery! Use skills learned in Units 1 - 4 and include: • input functions, calculation functions and output functions • passing variables between functions • elif statement (if/else for … | |
Hi, I have several tkinter entries created within a loop, where users input numbers. I wish to create a reset button to set all entries to zero. On the following code the reset button will just reset the last entry. How is possible to call each of the entry and … | |
I'm doing some research to determine the most efficient way to copy files. I've got 3 candidate functions: #1 [CODE=python] # uses generator to load segments to memory def copy(src, dst, iteration=1000): for x in xrange(iteration): def _write(filesrc, filedst): filegen = iter(lambda: filesrc.read(16384),"") try: while True: filedst.write(filegen.next()) except StopIteration: pass … | |
I'd like to ask the user if he/she wants to rerun a script. I've thought of doing that with a while. My problem is that both [CODE] import sys rerun = "y" while rerun == "n": sys.exit() else: print("do some stuff") rerun = str(input("Would you like to start again? [y/n]: … |
The End.