15,190 Topics

Member Avatar for
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
Member Avatar for TrustyTony

Here little debugged version of my calculator posted earlier in GUI calculator thread. I prepared it after listening that their teacher did more limited calculator in around 150 lines of code with their graphics module. This is 115 lines without empty lines and comment lines [CODE]>>> li=[i for i in …

Member Avatar for fonzali
1
2K
Member Avatar for glao

hello, I want to compare 2 strings.I want to find if a list with characters contains all the letters in a string. If **all** the letters in the string are in the list. For example: > mystring='abc' > mylist=['a','b','c'] must return True > > mystring='abc' > mylist=['a','c','b'] must return True …

Member Avatar for glao
0
504
Member Avatar for kayed.alsalim

ok guys I really need help with this homework assignment that my teacher sent I really dont know where to start a little help will be great. You are to write a program that will compute grades. Its input will be a file containing semester scores in TAB-separated format as …

Member Avatar for vmanes
0
218
Member Avatar for wolfraven004

# Heading Here #Hello ## I am reading a book that doesn't do a very good job of explaining things. It is talking about parallel arrays and gives an example of pseudo-code. I am trying to figure out how to access the parallel arrays using python and I wrote this …

Member Avatar for sneekula
0
170
Member Avatar for CodingCabbage

I'm programming a UI mock-up and need to make the window of fixed size and position. The lines of code for setting the size are as follows : widthOfScreen = mainGUI.winfo_screenwidth() #Get the width of the screen heightOfScreen = mainGUI.winfo_screenheight() #Get the height of the screen mainGUI.geometry("%dx%d+0+0" % (widthOfScreen, heightOfScreen)) …

0
94
Member Avatar for glao

Hello, my code works fine when I don't have white spaces but I can't make it work when the string has. I am trying sth like: def lengthR(mystring): count=0 if mystring=='': return 0 while (mystring!='') and (' ' not in mystring): mystring=mystring[0:-1] lengthR(mystring) count+=1 return count but it returns 0 …

Member Avatar for glao
0
191
Member Avatar for Prithiv_1

I have an openstack setup with ceilometer (polslter and notifier) installed. I am getting the required metrics like Storaeg_objects_incoming_bytes, storage_objects_size of swift in the metering tab. how ceilometer is getting these metrics.. what are the underlying components of swift which ceilometer api is communicating.. i am writing a python code …

Member Avatar for atul_3
0
243
Member Avatar for theUserMan

# Heading Here # Trying to add a webcam fee to a panel inside of my wxpython GUI. I have buttons on the left currently, and a black panel on the right. I'm confused as to how to add a webcam feed to that panel? here is the code being …

Member Avatar for ZZucker
0
475
Member Avatar for krystosan

It seems like the slotDirChanged is getting executed twice, becuase everything seems to be working fine, import datetime from PyQt4 import QtGui,QtCore from PyQt4.QtCore import pyqtSlot import sys import os class WatchFilesBin(QtGui.QMainWindow): def __init__(self, lookinpath=None): super(WatchFilesBin, self).__init__() self._filesBinPath = lookinpath createFilesBin(self._filesBinPath) self.filesList = os.listdir(self._filesBinPath) print self.filesList self.fileSysWatcher = QtCore.QFileSystemWatcher() def …

Member Avatar for krystosan
0
1K
Member Avatar for Josias_1

Hello everyone i have an issue with this problem, the problem is i need to reset the count after every line in the file, i put a comment so you can see where i want to reset the count. The program is suppose to cut each line after every specified …

Member Avatar for TrustyTony
0
333
Member Avatar for glao

Hello , I am trying to implement this function: def getGuessedWord(theword, wordlist): for letter in theword: if letter in wordlist: print letter, else: print '_', For example: theword = 'hi' wordlist = ['e', 'i', 'o', 's'] must return : _i but it returns : _iNone I tried : for letter …

Member Avatar for glao
0
147
Member Avatar for Rebecca_2

In the parent directory O, I have a series of directories Aa, where a varies from 0-1. In each of these I have a series of directories Bb, where b varies from 0-1. In each of these there are the input/output files AaBbCc.dat and AaBbCc.out for some calculations [c also …

Member Avatar for woooee
0
390
Member Avatar for kur3k

I create reports by means of RML(XML) and parse to PDF (use pyjon.reports). In output pdf polish char not display my xml file <?xml version="1.0" encoding="utf-8" standalone="no" ?> <!DOCTYPE document SYSTEM "rml.dtd"> <document filename="encoding-test-utf8.pdf"> <template> <pageTemplate id="main"> <frame id="first" x1="72" y1="72" width="451" height="698"/> </pageTemplate> </template> <stylesheet> </stylesheet> <story> <title>Test of …

Member Avatar for shadia.mohamed.9_1
0
837
Member Avatar for LucyLogic

Hey guys, I need assistance with my program need to write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 100. The application should let the user specify how many random numbers the file will hold. …

Member Avatar for LucyLogic
0
10K
Member Avatar for Remy the cook

I am trying to extract blogs related to economy using the RSS feeds in python. I have no idea how to get a specific number of blogs and how to get those blogs in a particular domain (like economy). My project requires analysing these blogs using NLP techniques, but I'm …

Member Avatar for Remy the cook
0
2K
Member Avatar for Con7e

Hello to all! I've made this script the other day, and I need some input from you telling me how could I improve the code / style. There aren't problems with the code (it does the job) but I want it more organized and "simple" so that in 1 week …

Member Avatar for Con7e
0
273
Member Avatar for Satya Prakash_1

I am writing a GUI flow using wxPython which has 4 pages (or more). They way I have approached is creating 4 (or more) classes with each class defining its own static (background) and dynamic images / content. In my application I would then programmatically create instances class required and …

0
240
Member Avatar for pythonnewbie16

Hey fellow programmers.Im a new python programmer.Only been learning for about 2 weeks.Below is a code I wrote this weekend.It is a simple text adventure.tell me what you think of it.Feel free to copy and paste it into python and run it yourselves.I'm open to suggestions. #Text adventure v 2.0 …

Member Avatar for snippsat
0
394
Member Avatar for stevewilliams02

I have already made a post on how to open a JPG file but I now plan to use GIF image files. Can someone show me a sample code example on how to open GIF image files whenever you click buttons on TKinter GUI in Python? Thanks.

Member Avatar for stevewilliams02
0
1K
Member Avatar for dark_falzar

So I decided to learn Python as my first programming language... So far I kinda like Python(when i say so far, I mean just now i started it just now), I'm using www.codeacademy.com as a tutorial(more on studying the basics first) and so I'm just wondering will I be able …

Member Avatar for ryantroop
0
329
Member Avatar for bryann

I was wondering if somebody could explain this to me. I am trying to find numbers that are NOT divisible by other numbers. Originally i wrote: if i%3!==0 however it came up with an error and said it was invalid syntax Instead my code now reads if i%3!=0 This works …

Member Avatar for Lardmeister
0
114
Member Avatar for bnn678

So my code to test a prime number is as follows: PrimeTest(): test = input ( "What number would you like to test? " ) test = int(test) true = 0 divisor = 0 for divisor in range (2, 10): if ( (isinstance( test/divisor, int )== True) & (test/divisor == …

Member Avatar for bnn678
0
372
Member Avatar for DoomCarnage

while(Truth): guesschar = input("Guess: ") if(guesschar == Word): break elif(len(guesschar) != 1): print("You can only guess one character at a time or the correct answer") else: Truth = False

Member Avatar for slate
0
118
Member Avatar for flebber

Having trouble getting pyhon to repeat things for me. What I wanted to test was python's random.sample. So say I have a list myList = range(1, 15) I can for a single time do this import random >>> myList = range(1,15) >>> random.sample(myList, 3) [10, 6, 11] >>> I would …

Member Avatar for flebber
0
221
Member Avatar for 12344321

Hi, I am new to writing code and am doing a programming assignment for a class that has to be separated into different functions. I figured most of it out, but can't seem to get the validation part to work at all. could someone with more experience than me please …

Member Avatar for 12344321
0
173

The End.