14,951 Topics

Member Avatar for
Member Avatar for minimee120

Problem 2. tttCheckMove() Write a function named tttCheckMove() that checks whether or not a TicTacMove is on an empty space on a TTT board. Input (two parameters): ยท Parameter 1: A string of 9 characters denoting the state of a TTT board. Each character in the string indicates the state …

Member Avatar for minimee120
0
179
Member Avatar for TrustyTony

Here slightly edited code from one of my earliest posts to DaniWeb. Limitted by recursion limit of Python as it uses recursion, but interesting for me.

Member Avatar for TrustyTony
0
1K
Member Avatar for NeoSyn

I'm not entirely sure how function work, and ive been trying different combos for a while.. Main: import pygame, motherWhale, scoreBoard pygame.init() def main(): global motherWhale global seaWorld global scoreBoard screen = pygame.display.set_mode((640, 480)) pygame.display.set_caption("Bubble Battle") background = pygame.Surface(screen.get_size()) background = background.convert() background.fill((255, 255, 255)) screen.blit(background, (0, 0)) motherwhale = …

Member Avatar for NeoSyn
0
736
Member Avatar for falek.marcin

I came across a problem that I can't solve and it's associated with multiprocessing and use it inside the decorator. When I'm calling the method **run_in_parallels** using multiprocessing I 'm getting the error: `Can't pickle <function run_testcase at 0x00000000027789C8>: it's not found as __main__.run_testcase` The call takes place inside the …

Member Avatar for falek.marcin
0
1K
Member Avatar for TrustyTony

Here is my take on [balanced ternary](http://en.wikipedia.org/wiki/Balanced_ternary) conversion (the base considered by [Donald Knuth](http://en.wikipedia.org/wiki/Donald_Knuth) "Maybe the prettiest")

1
947
Member Avatar for TrustyTony

I would like to take string argument for class BalancedTrinary intializer, but the string type of argument is processed before it enters the init function. I guess I must override any class method which deals with those for int/long? def val(number_sequence, base): """ produce integer value of number_sequence as base …

Member Avatar for Gribouillis
0
275
Member Avatar for lfmconsummates

I currently have this login form in my python program with a submit button: <input type="text" class="input-small" placeholder="Email"> <input type="password" class="input-small" placeholder="Password"> and I have an sql database that has emails/logins/etc. How do I make it so the after pushing the submit button, the email/password is verified with the database …

Member Avatar for lfmconsummates
0
121
Member Avatar for drichird

import os def a(): print("A") def b(): print("B") # I want to sometimes skip the main body if os.path.isdir("C:\\Blender\\mainbody"): print("main body of module_A") Is there a way to control whether or not the main body of a module gets executed by passing in arguments to the import command, such as …

Member Avatar for drichird
0
8K
Member Avatar for drichird

I am finding myself a little confused about how Python imports. Would the following be a correct statement: In any Python interactive shell, if the shell (since it was initiated or opened) has never before imported "myScript.py" then if the user types in "myScript" he will get an error like: …

Member Avatar for drichird
0
387
Member Avatar for Suffii

Hi I am trying to run a simple gui app using wxPython as follow to list pdf files in a listbox but I am getting this error" return _controls_.ListBox_Insert(*args, **kwargs) TypeError: String or Unicode type required import os import wx class ButtonFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, 'Button Example',size=(500, 500)) …

Member Avatar for Gribouillis
0
228
Member Avatar for TrustyTony

Here is base conversion function written to deal also with [negative bases](http://en.wikipedia.org/wiki/Negative_base). Not yet balanced ternary, where numbers themselves can be negative, maybe later I add it.. Based on the code in the wikipedia article, which has bug for converting 0.[**Edit: I fixed the bug in wikipedia**]

Member Avatar for TrustyTony
0
239
Member Avatar for heinlein_

Hi, I have a little problem. I want to replace words in a text, but only 'whole words'. That is, I'm looking for a method that changes "cat", but not "catfood". I know how to do it using re.sub, like this: re.sub(r'\bword\b', 'change', text) Only problem is, I'm using a …

Member Avatar for heinlein_
0
7K
Member Avatar for qaman88

""" # Tic Tac Toe Author: Tlamangile Ngobeni Lecture: Gary Stewart Department: University of Cape Town Website: www.uct.ac.za Last edited: March 2011 """ from random import* # to alternate who play first def move(position,matrix,symbol): #define the fuction to make a move by replacing to list #if statement to check user …

Member Avatar for TrustyTony
0
183
Member Avatar for Python4Psudo

# Here is a piece of code I wrote as to a homework assignment # # I would like the community's opinion on structure and style. This code gives the factorial of a user defined number(near as I could tell by the online math help.) print "This is a problem …

Member Avatar for Python4Psudo
0
190
Member Avatar for SgtMe

I have finally managed to make some progress on PyOpenGL textures. Now I have another problem. Here is my OpenGL init function (its in a script called gl2D.py: [CODE]def init(): glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) glEnable(GL_TEXTURE_2D) glShadeModel(GL_SMOOTH) glClearColor(0.0, 0.0, 0.0, 0.0) glDisable(GL_DEPTH_TEST) glEnable(GL_ALPHA_TEST) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) glAlphaFunc(GL_NOTEQUAL,0.0)[/CODE] And here is …

Member Avatar for SgtMe
0
818
Member Avatar for aprilcrash

Hi. Iยดm writing my first python program - a text adventure game. I want to have a list of possible things a dog could eat, whatยดs bad about them, how bad they are. So, I thought Iยดd do this: badfoods = [] keys = ['Food','Problem','Imminent death'] food1 = ['alcohol', 'alcohol …

Member Avatar for TrustyTony
0
288
Member Avatar for sofia85

Hi, I have a big text file (2 GB) with 4 columns looking like this: C START END A 1 10583 10583 0.14 1 10611 10611 0.02 1 13302 13302 0.11 I also have another file where I have extracted a string of information and if this string matches col1:col2:col3 …

Member Avatar for macanohost
0
182
Member Avatar for jdm3

Hello, I'm new with Python and running into an error trying to print data I have retrieved from a database. The code works but there are characters being printed with it that are not displayed in the database...here is my current code: con = mysql.connect(host="silo.soic.indiana.edu", port=3306, user="XXXXXXX", passwd="XXXXXX", db="XXXXXXXXX") cursor …

Member Avatar for TrustyTony
0
257
Member Avatar for neo_31591

(<type 'exceptions.NameError'>, NameError("global name 'MenuPage' is not defined",), <traceback object at 0x028BEC38>) The MenuPage contains buttons to All functions of the PDF shuffler software. This is one such function which retirieves Information about the PDF files. Problem is, It executes once, goes back to MenuPage , then again if i …

Member Avatar for TrustyTony
-1
303
Member Avatar for Yoink

Hi, I have a program that deals with stacks and queues in python. Part of the program compares items in 3 stacks that contain objects. The loop will run and compare all items in the top of the stacks and pop the item that has the highest value and appends …

Member Avatar for scudzilla
0
260
Member Avatar for how_too

Objectives: โ€ข Use an object with a list โ€ข Use a list of objects Write a class that encapsulates data for a sales person. Class SalesPerson has an ID number (int), a name (string), and a list of sales (float). It provides a constructor __init__ that initializes ID and name, …

Member Avatar for Lardmeister
0
236
Member Avatar for Kirielson

Hello, I am trying to implement a version of the cubic spline based on the artilce here: [Click Here](http://en.wikipedia.org/w/index.php?title=Spline_%28mathematics%29&oldid=288288033#Algorithm_for_computing_natural_cubic_splines) and while implementing it I find errors that my indices are out or range such as: ` h[i]=(n[i+1]-n[i]) IndexError: list index out of range ` Here's a part of the code: …

Member Avatar for Kirielson
0
325
Member Avatar for 4evrmrepylrning

A while ago I created a PHP application that looks at xml files. I have now been tasked with converting this to Python or Django or Turbo gears(anything as long as it's Python something). I am new at Python and while I have played with Django a bit I have …

0
148
Member Avatar for straylight

I am having some problems working with the tell method when working with a file. Basically what I am trying to do is use the tell method to find where I currently am within a paragraph and to only display the characters up to a certain tell count. For example: …

Member Avatar for TrustyTony
0
283
Member Avatar for jtaylor-bye

Hi all. I am a newcomer to python and I am teaching myself from books, videos and on-line tutorials. I currently have a basic script I am working on (can't post the code right now as I'm away from my laptop), and I cannot figure out how to do what …

Member Avatar for jtaylor-bye
0
99
Member Avatar for ckugblenu

We have learnt programming concepts with python and have now acquired the skill. What are the stuff we can go in and what areas are awesome to be in. Need help

Member Avatar for m1raEbrah1m
0
120
Member Avatar for jdm3

Hello, I'm currently working on a Python CGi program. This program takes a zipcode in a form and interacts with a website to obtain information on the Congress representative for that district. My question is, certain zipcodes have multiple representatives, and I want to make a page with radio buttons …

0
83
Member Avatar for memomk

hey i have this code when starting the Process to make database it freeze at all what should i do? # -*- coding: utf-8 -*- from PyQt4 import QtCore, QtGui import sys try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: _fromUtf8 = lambda s: s class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName(_fromUtf8("Dialog")) Dialog.resize(400, …

Member Avatar for memomk
0
2K
Member Avatar for imperialguy

Platforms: Windows 7/Mac OS X ActiveState Python 2.7.2 Installed docx on Windows 7 at D:\Program Files (x86)\Python27\Lib\site-packages. Installed docx on OS X at /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages Following is the sample script (named as docx_example.py), which runs absolutely fine on the python interpreter: #!/usr/bin/env python ''' This file makes an docx (Office 2007) …

Member Avatar for memomk
0
613
Member Avatar for strongguy12345

Hello to all, haven't been on here in a while but recently been having major problems with trying to finish this second problem set my teacher has given me and the other students for the gr. 12 ics college coarse, currently im gr. 11 but this coarse had to be …

Member Avatar for strongguy12345
0
326

The End.