15,406 Topics
![]() | |
this is my first attempt to implement OOP. IS this class ok?(in terms of structure) AND another Question: there are some folders in message application in Symbian phones and sometimes there are up to 1000 messages in each folders. I do itterate over all messages for gathering their info about … | |
This snippet allows one to implement an equivalent of a `__getattr__()` function in a python module. The module can then define its own way to lazily import abitrary symbols. For example the module can contain infinitely many names or load values from other modules on demand. There are many implementations … | |
Well, I'm making a tic-tac-toe game in Python **2.7**, and I need a code snippet to "make" the AI want to get a Tic-Tac-Toe, and make the game end if there's a **draw**. What can I do? This is the code as it is: # Python Tic Tac Toe import … | |
hi i've recently been learning about python on cssciencecircles.com. After a while i decided to download it so i can save some of my programmes. When i make a programme in the IDLE shell and save it, even the most simple instructions, eg. print('hello world') , when i try to … | |
Having a hard time getting this to work. options = [ 'option 1', 'option 2', 'option 3' ] for x in range(len(options)): Opt = str(x + 1) print('(' + Opt + ')', options[x]) while True: try: playerOpt = int(input('input ')) check = 'fail' for x in range(len(options)): Opt = x … | |
Hi, I am writing some code for android using python. I want to control the visibility of bluetooth ( i.e on or off of the bluetooth visibility) using some python script. Can you please help me ? | |
Hi! I have a beginners problem I really need some help with. First of all, here is my current program: def texten(): filehandle=open ( 'savetonight.txt', 'r' ) text=filehandle.read() return text def smabokstavertext(): texten() print text.lower() I basically want my function smabokstavertext() to call the first function texten() and then print … | |
hi guys .. Im here again ! I dont know how to explain this .. Here's my example : [url]http://desmond.imageshack.us/Himg228/scaled.php?server=228&filename=screenshotzjj.jpg&res=landing[/url] i want to know how to make a code like my example .. An icons and a cursor ! Im using s60v2 os8.1 .. Thanks ! | |
Hello everyone .. Im new in python and i have a question ! How to compile myfile.py to myfile.pyo ? Can you give me an example script coz i dont know were to put python -0 to compile it into pyo ! Thanks a lot .. | |
it is possible to start a python apps when you start your phone ? Im using s60v2 N70-1 .. Is there a python code autostart for my phone ? Please help .. | |
Can anyone HELP me for my problem .. Im a newbie in python ! I want to create a script to rename files in a dir. that dir has 400 files .png .. startswith 001.png , 002.png to 400.png ! I want to rename them startswith 000.png to 399.png .. … | |
movies = ["The Holy Grail", 1975, "Terry Jones & Terry Gilliam", 91, ["Graham Chapman", ["Michael Palin", "John Cleese", "Terry Gilliam", "Eric Idle", "Terry Jones"]]] print(movies[4][1][3]) In the above code, how does [4][1][3] result in "Eric Idle"? It looks to me like the 4 selects Eric Idle becaue it's the 4th … | |
I'm trying to figure out how to use '%s'. I looked it up in the python docs but it never actually shows how to use it. This is the line I'm working on right now just to figure it out. It is the first one of different variations where the … | |
I've playing with pygame a little and reading about it and i tried to make a simple rock paper scrissors game. I can't seem to get fullscreen working. Everything i've tried or read didnt work. Can u please help me? thanks | |
hello! I'd like to rank a numpy array without getting the number positions changed. I was able to do it using the numpy function below but it keeps ranking the 'NaN' values as well, how can I get it to ignore them and just rank the real number values instead. … | |
I'm trying to do something simple like get calc.exe to start minimized, but it's not happening. import subprocess import win32gui import win32con info = subprocess.STARTUPINFO() info.dwFlags |= subprocess.STARTF_USESHOWWINDOW info.wShowWindow = win32con.SW_SHOWMINIMIZED x = subprocess.Popen("calc.exe", startupinfo = info) It pops up the same as always, no matter what I provide for … | |
I've got an application that I call several times in a for loop using subprocess.call. Every time I call it, it starts minimized. I want it to be in a restored window. So what I've tried to do is get a handle on the window using win32gui.FindWindow. But in my … | |
Ok Guys, got a question on a nested list and how to return the values from it. Writing a scout script for a game I play. The return is this: [[278,278,-1,[25076,u'name',3,6,u'',0,0,1,[0,0,None,5]]]] [[278,279,-1,[25076,u'name',3,6,u'',0,0,1,[0,0,None,5]]]] I'm wanting to place the coordinates i.e. 278 and 279 along with the 3rd value in this case … | |
data = open('sketch.txt') for each_line in data: try: (role, line_spoken) = each_line.split(':', 1) print(role, end='') print(' said: ', end='') print(line_spoken, end='') except: pass data.close() I'M gettin the following error when I run this code but it looks exactly like what I'M seeing in my Head First book. File "sketch.py", line … | |
I'M trying to find the python3 file that would be the counterpart to the python3.exe in Windows. I want to point Geany to pyton3 rather that 2.7 which it's pointing to now. I don't even know if I found the right directory or not but I've attached a screenshot from … | |
I have a small Python program that should react to pushing the up button by running an appropriate method. But instead of doing this, it gives me a confusing error... from tkinter import * class App: def __init__(self, master): self.left = 0 self.right = 0 widget = Label(master, text='Hello bind … | |
I've been strugglin with this all day. I'm trying to use python to walk through a registry key and delete all the values it finds. I've succeeded in getting it to find all the nested values, but as soon as I try to delete one, I'm met with "WindowsError: [Error … | |
how would you add a scroll bar to this code [CODE] import site # for exemaker import tkMessageBox from Tkinter import * import os, sys TITLE = "Pydit" class RoomEditor(Text, object): def __init__(self, master, **options): Text.__init__(self, master, **options) self.config( borderwidth=0, #font="{Lucida Sans Typewriter} 14", #font="{OCR A Std} 14", font="{Terminal} 14", … | |
My name is Danielle Jacob and I am a Masters (through) Research student at Bangor University, North Wales. *[email removed]* I have been using Python now for about 3 months (but only once a fortnight for a few hours at a time...so I am still very new) My supervisor extracted … | |
Hi!! :) Can someone help me to write a code that with sort through a list of strings which are peoples names without using the python sort function. So the rules are : We start with an initial pile containing only the first name in the list. Go through all … | |
Hi All, I have a list of hex values that originated from a text string that was downloaded having now created a list of thes values approx 804 of them, when i run the list items through a loop to conert hex into dec had an error looking at this … | |
How to run shell commands from python. eg. How to use 'echo $a' commands? where a is any variable. | |
Hello, I am trying to create a program that will allow me to find a certain phrase, (always between brackets and always with a "'0" in it) and replace it. Basically I have something like [ k '0 ir e ] and what I need to do is use regular … | |
We are moving from an Informix DB/Stored Procedures to a Vertica DB/Python environment. I am not sure how to even start since the Vertica DB is new and we have NO training in Python. Here is a basic scenario: I have two tables and one table will update the other … | |
File "/usr/local/lib/python3.2/distutils/archive_util.py", line 52, in make_tarball tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress]) File "/usr/local/lib/python3.2/tarfile.py", line 1769, in open stream = _Stream(name, filemode, comptype, fileobj, bufsize) File "/usr/local/lib/python3.2/tarfile.py", line 421, in __init__ raise CompressionError("zlib module is not available") tarfile.CompressionError: zlib module is not available garrett@toshiba-laptop ~/Desktop/nester $ I'M getting the above … | |
Hello, new to python a bit. I get an indentation error at line 10, "m -= 1". Sorry if this is a repeated post, I've tried searching but found no solution. # calculates sum of squares of natural numbers print "Enter number of terms." n = raw.input("Terms? ") first_term = … | |
ihave a file containing data in the form of table with 5 columns and 10 rows the columns are separated by spaces . i have a to read the file line by line without reading the first line which is the header line.Please suggest me the code using python technology | |
The Tkinter library folder \lib-tk contains a module called turtle. You can import this module and experiment with turtle graphics. Tell the turtle to move and draw circles, lines, rectangles and more, and watch it, as it performs on a Tkinter canvas. In typical turtle fashion it moves at its … | |
Hello, I'm new and I was wondering how to do these things in python using turtle graphics... but don't know how to do it: 1.Write a program that draws a red line connecting two points (-39,48) and (50, -50) and displays the coordinates of the two points. 2. How to … | |
I have to make my own turtle class without using the "from turtle import *" line. This is the code i have so far: from graphics import * class Turtle: '''The turtle''' def __init__(self, win, defstep, defwidth, defangle, startpt, startangle): '''initialize the turtle - win: window to draw - defstep: … | |
This script is suppost to autorun from the flash drive once it is inserted into the pc it needs to auto download files to a paticular folder called (MEDIA) And it is supposed to over write whatever is in the (MEDIA) folder and add the new content from the flash … | |
I have two files, "ranked.txt" and "sorted.txt". Sorted.txt is a smaller subset from ranked.txt that is sorted in alpha order. However ranked.txt preserves the ranking of words I would like to keep. How do I check the rank of every word in sorted.txt when matched to the original ranked.txt? I … | |
Hello, I am trying to make a variable (name) so it only accepts alphabet characters (eg. DaNiEl) not $@@4234. Below is an example of the code i'm trying to use. I have tried a few functions, to no avail. Can someone please post the answer (in code form). Much Appreciated. … | |
Because of [the course](https://www.edx.org/courses/BerkeleyX/CS169.1x/2012_Fall/about) I think to take to improve employment changes by SaaS, Ruby and Rails and basic agile techniques, I looked little the Ruby forum. Unfortunately it seemed in quite a sorry state some months old questions unanswered. Even there was a related article from one of them … | |
To print on the same line Python2 uses print item, Python3 uses print(item, end=' ') Is there a way to make it work in both versions? | |
![]() | I am completely new at Python and I am not sure where to start with this task. Basically, I want to search for a word in each line; if the word is there, output the entire line to another file (Excel or Text). The lines look like this: PA,IAV protein,AC0T9,DHP … |
I need a little bit of help here with comparing data sets. file1 = open("filename1.txt", "r") file2 = open("filename2.txt", "r") fileone = file1.readlines() filetwo = file2.readlines() file1 = close() file2 = close() exfile = open("results.txt", "w") for line1 in fileone: s1, v1, p1 = line[:-1].split(":") for line2 in filetwo: s2, … | |
Hi, I'm having some difficulty reading in boolean values from a file, particularly false values. Python can understand false values as empty strings, as well as a few other ways. For example: In [43]: bool(0) Out[43]: False In [44]: bool(False) Out[44]: False In [45]: bool('') Out[45]: False The problem is, … | |
This is a simple hangman game that I wrote using my beginner python skills. Though this game is playable, there must be lots of things I must've been doing wrong or the methods I'm using here may be not so pythonic. So I want some suggestions on how to improve … | |
Hello all, this is my first post here. I seem to have a problem dealing with data, csvs and dictionaries. Here is a snippet of contents of file 1 (Node,x,y,z): 1,19.0,18.2,22.4 2,8.4,9.4,10.2 4,22.2,2.5,3.1 7,3.2,6.1,4.3 10,3.1,4.2,33.7 11,3.7,23.8,23.4 Here is a snippet contents of file 2 (Node,x,y,z): 1,4.2,7.3,9.5 2,4.1,8.4,9.2 4,2.3,4.6,3.2 11,2.5,2.7,32.6 File … | |
Hello. I am new to python and am making a text-based game. If you want to be a code editor supply your email in the comments. You will get your share of revenue*. *Provided there is revenue | |
can anyone give simple example of storing data in datastore in google apps engine using python . thnx | |
Hi, I am trying to create the most general function possible to test if an object passed into it has mutability or not. With some prior help from pytony, it seemed that the best way to do this is to try to set and attribute. If the attribute can be … | |
This is probably going to be beyond my knowledge/experience but I thought I'd ask... I work on a radio station in the UK. I have a friend in Canada who wants to listen but he is 5 hours behind us. I'd like to be able to capture our shoutcast stream, … |
The End.