15,185 Topics

Member Avatar for
Member Avatar for Crazyscript77

Hi all, just wondering if someone could help me out with a small loop question. If I had an input field in a GUI which writes to variable "counter" (a numerical value), how would I be able to use this value to control the amount of times a loop is …

Member Avatar for Crazyscript77
0
183
Member Avatar for krystosan

I have a function in which i want to mock `os.listdir` that returns directory content to variable `dirContent` def setUp(self): self._filePaths = ["/test/file/path"] self.mox = mox.Mox() def imageFilePaths(paths): imagesWithPath = [] for _path in paths: try: dirContent = os.listdir(_path) except OSError: raise OSError("Provided path '%s' doesn't exists." % _path) for …

0
139
Member Avatar for Py New BB

Hello all, by using Python, i want to pickup the news titles on http://www.boston.com/yourtown/ and save them into a .txt file. i have 2 questions: 1. how can i have the codes run every 2 hours? 2. how can i have the outputs write into a .txt file? thanks. from …

Member Avatar for snippsat
0
162
Member Avatar for nouth

for example I don't know what this is called » `[('cat', 'meow'), ('dog', 'ruff')]` if I try `for l in [('cat', 'meow'), ('dog', 'ruff')]: print l` I am using l for lady luck lucy not I for I or the number 1 + maybe even | pipe for smoking it …

Member Avatar for vegaseat
0
246
Member Avatar for RAJESH.M

hello sir, my work is run version.sh file and collect the values of version and type in the output. i have around 500 servers,so i want to automate this process using pyhton. i had written sample code shown below, but it is not giving good results.will you please help me …

Member Avatar for rrashkin
0
170
Member Avatar for lewashby

#!/usr/bin/python3 import sys input1 = sys.argv[1] def print_params(*params): print(params) print_params(input1) #END# In the above code how can I call all the command line arguments with the prin_params function without having to code input1, input2, input3, etc... When I'm doing testing liket this I would like to be able to just …

Member Avatar for vegaseat
0
234
Member Avatar for johnny_disco

Hi All, I am trying to scrape a piece of HTML similar to the below where I want beautiful soup to return something like: List Price, £28,410 Body Style, Open Car etc etc. I thought if I did this: soup = BeautifulSoup(html_doc) tag = soup.find_all('tr') tag_td = tag[0].find('td') tag_b = …

Member Avatar for BearofNH
0
225
Member Avatar for Yarynka

I'm curious.. is it possible to extend the context of the word "monstrous" in concordance so we have: >>> text1.concordance("monstrous") Building index... Displaying 11 of 11 matches: ong the former , one was of a most monstrous size . ... This came towards us , ON OF THE PSALMS . …

Member Avatar for Yarynka
0
103
Member Avatar for Iceman10284

Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in an array and the display the following data: • The lowest number in the array • The highest number in the array • The total of the numbers in …

Member Avatar for booicu
-1
7K
Member Avatar for Waseemaburakia

I'm trying to modify a Bibblesort code I'm writing that will count the number of instances and print out a seperate line for each instance and how many occurances it had. def BubbleSortList(MyList): ComparisonCounter = 0 for j in range ( len(MyList)): for i in range ( len(MyList)-1-j ): if …

Member Avatar for Waseemaburakia
0
290
Member Avatar for sinnebril

Hi, I'm trying to teach myself the Python language with the Google Python class ([url]http://code.google.com/edu/languages/google-python-class/set-up.html[/url]). With the exercise 'wordcount' I get a Traceback error (with the main function and sys.exit(1) function). Even with the solution script (as displayed here). Does anyone recognize this problem and can some one tell me …

Member Avatar for vegaseat
0
987
Member Avatar for krystosan

How do I rotate image in this code every n seconds http://pastebin.com/SKDzuC15 lets say i want to change the image in pixmap after 5 seconds to next image, what is happening right now the last one gets displayed.

Member Avatar for krystosan
0
267
Member Avatar for Stefano Mtangoo

I started this for any information on new python modules apart from standard library. Many people (Including me), aren't willing to move into p3k due to lack of external/non-standard modules. So I started this to keep ourselves informed on New Python 3 Modules. No Limitation, ANY PYTHON 3 MODULE

Member Avatar for vegaseat
0
981
Member Avatar for stevewilliams02

I need help with the button action for this code. When you click on the button, a new window should open with the GIF image of the horoscope sign. The name of the GIF image files are "Pisces.gif", "Taurus.gif",etc. from Tkinter import * #Call all modules for TKinter in order …

Member Avatar for sneekula
0
190
Member Avatar for vegaseat
Member Avatar for robert99x

Programming Python 3rd Edition by Mark Lutz has example code (below) where a variable seems to be assigned with options ("or") but what the criteria for selecting the options is not clear. The explanation is almost non-existent but I think this is to do with feeding in a variable number …

Member Avatar for robert99x
0
289
Member Avatar for Pioggia254

Hello! I am a newbe to python and apologize in advance for this question, because I am sure it is an easy fix that I am oblivious too - I wrote this simple program for a guessing game- very basic, which is fine - but when you get to the …

Member Avatar for vegaseat
0
172
Member Avatar for vinodvinu

Hi there, I am a newbie in programming. Python is my choice. because it is easy to learn. But the Tkinter GUI making is horiible. I don't like to write code for GUI. I like the visual basic method. So i installed Qt Designer. But i don't know how to …

Member Avatar for vegaseat
0
438
Member Avatar for flebber

Maybe a list comprehsnion is not the right way to go here. I want to define a nested list that a user can tell how many lists and how many entries in each subllist. Then have random call a value for each entry in the sublist, working on unique entries …

Member Avatar for TrustyTony
0
234
Member Avatar for XodoX

I'm new to Python, but I can use a library to do this, right? Like this one: import pprint import scipy import scipy.linalg # SciPy Linear Algebra Library A = scipy.array([ [7, 3, -1, 2], [3, 8, 1, -4], [-1, 1, 4, -1], [2, -4, -1, 6] ]) P, L, …

Member Avatar for Gribouillis
0
2K
Member Avatar for flebber

Hi I am struggling with assigning values to a list of a list. This is my full code. import random #get user input as to size of range range_size = 0 if range_size == 0: try: range_size = int(input('Size of Range?: ')) except ValueError: print('That was not an integer!') range_size …

Member Avatar for flebber
0
541
Member Avatar for bryann

Can someone please help me with this because it is driving me crazy. I wrote a program which prompts the user to enter a number I convert the string to an integer when i print the value it sometimes comes out as a decimal e.g. 3.0 I thought an integer …

Member Avatar for bryann
0
319
Member Avatar for gmill198

# This is my code for a space invaders-like game in pygame. How do I add a second enemy? # from pygame import * import random class Sprite: def __init__(self, xpos, ypos, filename): self.x = xpos self.y = ypos self.bitmap = image.load(filename) self.bitmap.set_colorkey((0,0,0)) def set_position(self, xpos, ypos): self.x = xpos …

0
73
Member Avatar for Remy the cook

I have been trying to find the frequency distribution of nouns in a given sentence. If I do this: text = "This ball is blue, small and extraordinary. Like no other ball." token_text= nltk.word_tokenize(text) tagged_sent = nltk.pos_tag(token_text) nouns= [] for word,pos in tagged_sent: if pos in ['NN',"NNP"]: nouns.append(word) freq_nouns=nltk.FreqDist(nouns) print …

Member Avatar for Remy the cook
0
1K
Member Avatar for Tcll

Note: this isn't a questional thread. I need help in building an accurate and efficient Vector class which supports 1D to 4D vectors with their various manipulation/transformation methods. in the end, I want the result to be a reference for other users to copy from. this class is not meant …

0
86
Member Avatar for Remy the cook

I have to append first 3 sentences of this sample text to a file(data.txt). So far I've done this: import nltk text="""First patented in 1876 by Alexander Graham Bell and further developed by many others, the telephone was the first device in history that enabled people to talk directly with …

Member Avatar for vegaseat
0
268
Member Avatar for Ismatus3

Hello, When i try to insert some datas with python to MySQL database where the fourth column is a variable , (it depends on the variable "e0") , i get a message error here is the query syntax : `cur.execute('insert into suiviactuelms (modelsa,date,heure,%s) values (%s,%s,%s,%s);',(e0, modelidvar, cur_date, t, quantitevar))` and …

Member Avatar for woooee
0
581
Member Avatar for laura301019

I'm pretty new to coding with Python and I am trying to save a users username in a session variable which should be a new entry in the session dictionary. The code I have is from bottle import route, request, debug, run, template session={'logins':0} def checkLogin(name,password): if name==password: return True …

Member Avatar for slate
0
368
Member Avatar for renierdbruyn

Hi, I am new to Python and am looking into web development frameworks i.e. Pyramid. Is there anyone here who is familiar with this Framework using MongoDB? I am using pymongo and Ming I follwed a tutorial [here](http://pieceofpy.com/2012/01/10/working-with-pyramid-and-ming/). I am getting an `AttributeError: 'str' object has no attribute '_auto_ensure_indexes'` in …

Member Avatar for renierdbruyn
0
530
Member Avatar for CodingCabbage
Member Avatar for vegaseat
0
263

The End.