15,185 Topics

Member Avatar for
Member Avatar for lewashby

[CODE]class FooBar: def __init__(self, value = 42): self.somevar = value[/CODE] f = FooBar('This is a constructor argument') f.somevar This is a constructor argument How can the parameter value know what kind of data it's going to be given? Int, float, string, etc? thanks.

Member Avatar for vegaseat
0
121
Member Avatar for koveras vehcna

Hello everyone, I'm working on a random text generator -without using Markov chains- and currently it works without too many problems -actually generates a good amount of random sentences by my criteria but I want to make it even more accurate to prevent as many sentence repeats as possible-. Firstly, …

Member Avatar for TrustyTony
0
134
Member Avatar for koveras vehcna

Hello everyone, I'm working on a random text generator -without using Markov chains- and currently it works without too many problems. Firstly, here is my code flow: 1-Enter a sentence as input -this is called trigger string, is assigned to a variable- 2-Get longest word in trigger string 3-Search all …

Member Avatar for koveras vehcna
0
171
Member Avatar for James0l9l

I'm brand new to coding and python. Could someone tell me what is wrong with my code? [CODE] def getlist(): lst=[] answer1 = raw_input ("Would you like to add a number to create your mean value? y/n") if (answer1 == "y"): x = input ("Your number:") lst = lst + …

Member Avatar for TrustyTony
0
121
Member Avatar for n.utiu

Few days ago I finished making my own (quite primitive) chat server with SocketServer. I haven't had any problems with it apart from the designing of the chat protocol: I made a very sketchy protocol for messaging. The client just sent unix-like commands to the server to do certain opperations: …

Member Avatar for n.utiu
0
113
Member Avatar for rexona

Hi, I am trying to generate a list of random numbers where each number in the list is a individual string. This is my code so far: [CODE]import random def make_secret(numdigits): a=[] secret = random.sample(range(0, 10), numdigits) for i in secret: a.append(str(secret)) return a[/CODE] An example of what i'm trying …

Member Avatar for snippsat
0
183
Member Avatar for Xzarik

Okay i'm really sorry to have basically bombarded this forum but this is my last cry for help on this project I swear! I guess many of you are intimately familiar with what's happening so far, and thank you all so much for putting up with me =) I've got …

Member Avatar for TrustyTony
0
134
Member Avatar for Xzarik

Yet another thread showing how awful I am at programming... I've got a list called week_pattern It contains a list of 52-character strings which represent whether something occurs in a certain week. The list is below: [CODE]['0000000000111111111100000000000000000000000000000000', '0000000001000000000000000000000000000000000000000000', '0000000000000000000000000011111111000011100000000000', '0000000000000101111100000000000000000000000000000000', '0000000001111111111100000000000000000000000000000000', '0000000000111111111100000000000000000000000000000000', '0000000000000000000000000001111111000001100000000000', '0000000000111000000000000000000000000000000000000000', '0000000001111111111100000000000000000000000000000000', '0000000000000000000000000011111111000011100000000000', '0000000000000000000000000011111111000011100000000000', '0000000000000111111100000000000000000000000000000000', '0000000000000000000000000000000000000000001000000000', '0000000000000000000000000001111111000001100000000000', …

Member Avatar for Xzarik
0
114
Member Avatar for dj343

Hello, I'm trying to install a python based program, the instructions call for this command. I have python 2.7 installed & have successfully installed virtualenv using easy_install CODE_DIR=`pwd`/program PYTHON_BIN=/opt/python-2.5/bin/python VIRTUALENV_BIN=`dirname $PYTHON_BIN`/virtualenv $VIRTUALENV_BIN $CODE_DIR cd $CODE_DIR source bin/activate I try to run just the first line and I get this: Traceback …

Member Avatar for snippsat
0
114
Member Avatar for student_

this error keeps plaguing me with the code: [code=python] option = input('What would you like to do? ') if option == 1: newExpence = addExpence(totalBudget) totalBudget = totalBudget - newExpence elif option == 2: removedExpence = removeExpence(totalBudget) totalBudget = totalBudget + removedExpence elif option == 3: newRevenue = getNewRevenue() totalBudget …

Member Avatar for snippsat
0
133
Member Avatar for personx1212

hi, i am trying to implement a proxy based on BaseHTTPServer built-in module. the GET & POST methods work fine, but i have some problems implementing the CONNECT (do_CONNECT) method, i understand how ssl tunneling works theoritically, i tried to implement it using httplib.HTTPSConnection, i write the headers and the …

Member Avatar for personx1212
0
72
Member Avatar for funfullson

Hi dears. I want to send a string as sms in gsm modem witch mixed from english and unicode word. for example: "hello in persian is 'سلام' in arabic is 'السلام'." now, how I can make a pdu format from this string and what change I have to make in …

Member Avatar for funfullson
-2
416
Member Avatar for acrocephalus

Hello! I am trying to edit a csv file. This is my original csv file [CODE]"TINAMIFORMES",,,, ,"Tinamidae",,, ,,"Tinamus",, ,,,"tao","Grey Tinamou" ,,,"solitarius","Solitary Tinamou" ,,,"osgoodi","Black Tinamou" ,,,"major","Great Tinamou" ,,,"guttatus","White-throated Tinamou" ,,"Nothocercus",, ,,,"bonapartei","Highland Tinamou" ,,,"julius","Tawny-breasted Tinamou" ,,,"nigrocapillus","Hooded Tinamou" ,,"Crypturellus",, ,,,"berlepschi","Berlepsch's Tinamou" ,,,"cinereus","Cinereous Tinamou" ,,,"soui","Little Tinamou" ,,,"ptaritepui","Tepui Tinamou" ,,,"obsoletus","Brown Tinamou" ,,,"undulatus","Undulated Tinamou" ,,,"transfasciatus","Pale-browed Tinamou" …

Member Avatar for acrocephalus
0
5K
Member Avatar for gh0st0

Hi Folks, Windows/Python3.1.2 I'm totally at a loss with this one... The code is supposed to open a file (postscript with UNIX LF-only EOL characters), look for and change a line, then write the lines back. It works fine, except for the fact that I can't dissuade Python from writing …

Member Avatar for gh0st0
0
158
Member Avatar for kuchi

We have implemented ConfigParser object to parse the log file and load tested the application, but it was failed after 50 records created due to memory error. we removed ConfigParser's code and re-tested then the transaction was completed successfully, finally we figured out that this object is creating more objects …

0
62
Member Avatar for Xzarik

This one might be a challenge... Okay some of you might have an inkling what i'm trying to do already from the last thread (thanks for helping!) but I figured I should start a new topic for a new problem so that people can search solutions easier. I've got multiple …

Member Avatar for Xzarik
0
8K
Member Avatar for linuxoidoz

Hello, What's the right way to open and close dialog windows multiple times? At the moment I instantiate a dialog window on a clicked button signal, then close it with self.close() but when I open it again Python crashes. So I can open the dialog only once. How can I …

Member Avatar for raptr_dflo
0
16K
Member Avatar for koveras vehcna

Hello everyone, I am trying to process various texts by regex and NLTK of python -which is at [url]http://www.nltk.org/book-[/url]. I am trying to create a random text generator and I am having a slight problem. Firstly, here is my code flow: Step-1)Enter a sentence as input -this is called trigger …

Member Avatar for koveras vehcna
0
184
Member Avatar for bpatt22

What are some alternatives to writing [CODE]len(mylist3 & mylist4)[/CODE] within this code? [CODE] mylist1 = [1,2,3] mylist2 = [4,5,6] mylist3 = set(mylist1) mylist4 = set(mylist2) lenresult = len(mylist3 & mylist4) [/CODE] A module i'm importing is unable to use the count() that gets called with the ' & ' operator.

Member Avatar for bpatt22
0
102
Member Avatar for Xzarik

Hey all, I've been having some problem with python - i'm pretty awful at programming but have been soldiering on with this for some time now! What I need to do is take one list and compare it to another. Both lists are presented in rows, and I need to …

Member Avatar for Xzarik
0
154
Member Avatar for ultimatebuster

Why do people say isinstance is bad? If I have my own class, named Test, and if I want to check an variable to see if it is an instance of Test or Test's child classes, is using instance() bad?

Member Avatar for TrustyTony
0
186
Member Avatar for frankinaround

Hi, im looking for any tips on how to make a program that can move the windows vista mouse icon to different spots + left and right click. So I can tell it to go to this spot and click. can anyone please help

Member Avatar for vegaseat
0
96
Member Avatar for sravan953

Hello all, I want to make a Python program which will go to a particular site, login with my credentials, and do a specific task, such as in this case: go to WordPress.com, login, navigate to the drafts section, and add a line to a draft. I believe most of …

Member Avatar for ultimatebuster
0
171
Member Avatar for KnifeDarky

Hi everyone, I'm making some kind of game in Python and i need to save random number to text file but i cant. Please help me out. Here is the code: [code]def lvl(): x = random.randint(100,1000) tfile = open("text.txt", 'w') tfile.write(x) input("")[/code] Without x everything is good, but i need …

Member Avatar for snippsat
0
114
Member Avatar for acrocephalus

Hello! As a part of a database project, I need to find a way to send a MySQL table to wxpython and then select some of its records (using a Select/Remove button) to store them in another class of the database. Is there any kind of widget to do this? …

0
59
Member Avatar for donnyv

Hi, I have a content type with a selection field whose value I would like to set programmatically (ie, for all items in a folder). I know this is a vague question but can anyone point me towards something that might help me figure this out? Thanks in advance! Cheers, …

Member Avatar for Beat_Slayer
0
61
Member Avatar for acrocephalus

Hello! I am trying to update a MySQL table using a Python code but I am having some problems. I define the connection and the cursor in the Ornithobase (wx.Frame)class in the OnLof function as [CODE]self.db= MySQLdb.connect(host='localhost', user=self.Username , passwd=self.pwd, db='Ornithobase') self.cursor = self.db.cursor()[/CODE] Then, in the same class but …

Member Avatar for TrustyTony
0
288
Member Avatar for ronparker

Hello all, To begin, I am working with a MySQL database using python. In the database, I am working with 3 columns: REF_ENTRY_TIME, REF_EXIT_TIME, REF_ENTRY_VALUE. My goal is to graph the net value position against time. For the time portion, both REF_ENTRY_TIME and REF_EXIT_TIME are random various times between 9:00 …

Member Avatar for TrustyTony
0
116
Member Avatar for n.utiu

Hi, all! I was wondering if there is any way to check from the server side whether the client has closed a socket connected to one on my side. client side [CODE]import socket s = socket.create_connection ((host, random_port)) s.close () [/CODE] server side [CODE] ... a = lstn.accept () [/CODE] …

Member Avatar for n.utiu
0
5K
Member Avatar for Stefano Mtangoo

When you think of Media player, you need beautiful look n feel. I know GIMP can do alot. But Skin in wxPthon? I don't think it is possible. So I thought and thought then I came with this Idea. Create panel with Image as background and then Load wxBitmaps and …

Member Avatar for Beat_Slayer
0
455

The End.