- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 38
- Posts with Upvotes
- 38
- Upvoting Members
- 20
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
225 Posted Topics
Re: Dont forget to select your code and press (CODE) next time. And do you have a sample file, becasue this normally works. import csv for row in csv.reader(open('mesaure.csv')): print row | |
Re: Can't you do like this: [CODE]d['key']['fieldname'][/CODE] | |
Re: Like this? [CODE]#!/usr/bin/env python import urllib def save_page(site="http://www.tvrage.com/Warehouse_13/episode_list"): mypath = site f = open('temp2.txt', 'w') for item in urllib.urlopen(mypath).readlines(): f.write(item) f.close() def find_title(temp="temp2.txt"): f = open(temp) site = f.readlines() f.close() for item in site: if item.find('<title>') != -1: before_html, tag_before, rest_html = str(item).partition('<title>') title, tag_after, after_html = rest_html.partition('</title>') print 'Title:', … | |
Re: A twin brother??? http://code.activestate.com/recipes/496778-binary-converter10/ | |
Re: ??? Does yours outputs like this mate? [CODE]>>> import unittest >>> dir (unittest) ['FunctionTestCase', 'TestCase', 'TestLoader', 'TestProgram', 'TestResult', 'TestSuite', 'TextTestRunner', '_CmpToKey', '_TextTestResult', '_WritelnDecorator', '__all__', '__author__', '__builtins__', '__doc__', '__email__', '__file__', '__metaclass__', '__name__', '__package__', '__unittest', '__version__', '_makeLoader', '_strclass', 'defaultTestLoader', 'findTestCases', 'getTestCaseNames', 'main', 'makeSuite', 'os', 'sys', 'time', 'traceback', 'types'] >>> print unittest.TestCase <class … | |
Re: Can you provide a sample xml and itl, it's a pretty easy task to achieve. Cheers and Happy coding... | |
Re: So you can't read C++, and want to convert some C++ files to Python? How about leaking the C++ files so we can help you? Meanwhile, i'll google for tools. ;) | |
Well, it bothers me to build menus for every shell application that needs one. So, I've written a module to handle that, like in the good old turbo pascal times. :) Here it is, the module comments are pretty explainatory, I think, and the sample usage if run as script … | |
Simple script for image transparency. Someone asked one some time ago, and i had other but for a different system, and decided to write a Python/PIL version. The value of the color used as transparent is the value of the pixel at position (0, 0). You can adjust tolerance value. … | |
Re: You don't have questions, nowone cared about this, so just let it sink, till someone finds it attractive. Cheers and Happy coding | |
Re: [URL="http://docs.python.org/tutorial/index.html"]One of my favorites, it just explains you everything, has a lot of examples.[/URL] | |
| |
Re: Going from the root as as folder python, [CODE]python\Objects\intobject.c[/CODE] Cheers and Happy coding | |
Re: Have you tried [URL="http://www.pygame.org/docs/ref/joystick.html"]pygame.joystick[/URL]. Wheres the code? Cheers and Happy coding | |
Re: doffing81, theres no need to hardcode the 5 deals. [CODE]def deal(): """this function deals the cards individually to each hand""" for i in range(5): self.append(deck.pop(0)) #pop(0) grabs the first card/item in list p2.append(deck.pop(0)) #pop() would grab last...I believe p3.append(deck.pop(0)) p4.append(deck.pop(0))[/CODE] Cheers and Happy coding | |
Re: You want all the output in text file, or only the error output? Wich OS? Are you using GUI? Cheers and Happy coding | |
Re: You can run the listening function on an asynchronized thread. [CODE]from functools import wraps from threading import Thread def async(func): @wraps(func) def async_func(*args, **kwargs): func_handler = Thread(target=func, args=args, kwargs=kwargs) func_handler.start() return func_handler return async_func @async def listener(): print "Initializing Listener..." Listener.Listen(server_ip, int(server_port)) os.system("cls") print "Server IP: %s" % server_ip + … | |
Re: This should be faster. [CODE]lines = [line for line in tx.readlines(2000000)][/CODE] Cheers and Happy coding | |
Re: What you mean? Like clipboard access? Or a internal function? Copy to variable and write the variable to the widget maybe? Cheers and Happy coding | |
Re: Something like... [CODE]self.transport.getDestination()[/CODE] Cheers and Happy coding | |
![]() | Re: I can't see the problem, and it's working good. Maybe IDLE? Maybe version of the pygame you use? Cheers and Happy coding |
Re: You don't need to display them, if you maintain a list of the image objects open, you can easilly save them all in a nice loop. Show a example of what you mean, I'll help you. Cheers and Happy coding | |
Re: [CODE]class SpeciesGrid(wx.Frame): self.EnglishNameList = ['Great Tit','Marsh Tit','Coal Tot','Crested Tit'][/CODE] Your code defines EnglishNameList as a attribute of the SpeciesGrid class, so you must change the [CODE]self.EnglishNameList[/CODE] on the SearchDlg class by something like [CODE]SpeciesGrid.EnglishNameList[/CODE]. Cheers and Happy coding | |
Re: The usage is [CODE]SetGridCursor(self, row, col)[/CODE], so why collumn -1 on your code mate? [CODE]self.SpeciesGrid.SetGridCursor(ind, -1)[/CODE] Cheers and Happy coding | |
Re: Add '\n' in each write. Cheers and Happy coding | |
Re: Only the print implementation. You can do [CODE]from __future__ import print_function[/CODE] and keep the 3.x print style. Cheers and Happy coding | |
Re: It seems to work here... [CODE]import re print re.findall('[0-9][0-9][0-9]\.', '1234_.txt') print print re.findall('[0-9][0-9][0-9]\.', '1234.txt')[/CODE] Can you explain what's not working. Cheers and Happy coding | |
Re: The distance between vectors, presuming you have vector A and B with two coordinates x and y, is: [CODE]sqrt(((Ax - Bx) ** 2) + ((Ay - By) ** 2))[/CODE] | |
Re: @staticmethod returns a static method for function. @classmethod returns a class method for function. The classmethod is called with the 'cls' argument as first argument and it represents the class. It's called when you create a class object and will serve as constructor for the class. At line 13 it … | |
Re: You have [URL="http://docs.python.org/library/urllib2.html"]urllib2[/URL] also, or you can try with the Beautiful Soup. Cheers and happy coding | |
Re: Something like this... [CODE]f_in = open('file.csv') lines = f_in.readlines()[1:] fields = [item for item in lines.split(',')] selected = [] for field in fields: selected.append((field[4], field[6]))[/CODE] It will need adjusting... Cheers and Happy coding | |
Re: Like this I believe... [CODE]#!/usr/bin/python import socket import subprocess sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) host = socket.gethostname() port = 1234 sock.bind((host,port)) while True: command, addr = sock.recvfrom(1024) if len(command) > 0: print("Received ", command, " command from ", addr) exec_command = subprocess.Popen(command, stdout=subprocess.PIPE) print(exec_command.stdout.read()) sock.close()[/CODE] Cheers and Happy coding | |
Re: [URL="http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html"]Here.[/URL] Cheers and Happy codings | |
Re: Here it is. Now it works. [CODE]class Rectangle: def __init__(self, length = 1, width = 1): self.set_length(length) self.set_width(width) ##Setters to float def set_length(self, length): length = float(length) try: if 0.0 < length < 20.0: print "Value is in range. You may continute." self._length = length else: raise ValueError except ValueError: … | |
Re: The error message, and not the error type, were of great help. And a code usage sample also And wheres line 95? Cheers and Happy coding | |
Re: Wheres the checksum? Cheers and Happy coding EDIT: How about this? [CODE]data = '\x02' + '1T025.0F00R1000000000000000' + '\x8B' + '\x03'[/CODE] | |
Re: The print, one place is enough. Cheers and Happy coding | |
Re: Or [CODE]Hands.hasFlush()[/CODE] for outside the class Hands, or [CODE]self.hasFlush()[/CODE] if it's inside the class that defines hasFlush(). Cheers and Happy coding | |
Re: what are you trying to do? A folder creation? [CODE]os.makedirs('c:\\foo\\bar')[/CODE] [URL="http://docs.python.org/library/os.html"]Look here.[/URL] Cheers and Happy coding | |
Re: ask grade exam a ask grade exam b ask homework 90 = (needed*0.35) - (a*0.25) - (b*0.25) - (homework*0.15) Cheers and Happy coding | |
Re: Yeah, you need do read a litle bit before jumping into it, trying is good, but research also. [URL="http://effbot.org/zone/tkinter-menubar.htm"]Some help[/URL] Cheers and Happy coding | |
Re: You can use [URL="http://www.pythonware.com/library/tkinter/introduction/whats-tkinter.htm"]tkinter[/URL] or [URL="http://easygui.sourceforge.net/"]Easygui[/URL], or downgrade do 2.x and use [URL="http://www.wxpython.org/"]wxPython[/URL]. Cheers and Happy coding | |
Re: I think it's simple as this: [CODE]list1 = [1, 5, 3, 9, 4] int1 = 8 list2 = [item + item for item in list1] if int1 in list2: print int1, 'is the sum of', int1/2 else: print int1, 'is not the sum of any of the numbers in the … | |
Re: The if statements are no repeated, theres one if for each sprite. The if of line 42 moves the second sprite (x2) every 5 frames, or being said every 5 movements of the first sprite (x1) The frame counter is incremented on line 52. Cheers and Happy coding | |
Re: Your router may be cofigured to only allow connections through ethernet cable and not wireless connections to the settings. Apart that, this is the python forum, for python related questions. Cheers and Happy coding. | |
Re: For that function you use pyhton 3.x, or you do: [CODE]from __future__ import print_function def main(): f = open('lines.txt') for line in f: print(line, end = '') if __name__ == "__main__": main()[/CODE] Cheers and Happy coding | |
Re: And your code is? Cheers and Happy coding | |
Re: Functions to add, remove and view entries to the address book, values stored in a pickled dictionary. I'm eager to help, but I want to see some code effort from you. Cheers and Happy coding | |
Re: Some code??? Cheers and Happy coding | |
Re: You must use the 'SetCellValue(self, row, col, s)' attrivute of the grid. Make a loop, read row, iterate trough items, and insert the data on the cells. Cheers and Happy coding |
The End.