Beat_Slayer 17

Beat_Slayer 17

The from_points function pass the values to the init by the cls variable, and not the other way around.

When you call 'AB = Vector2.from_points(A, B)' it will pass the 'A' and 'B' tuples to the 'from_points' function that will calculate and pass then the result to the class init function.

Cheers and Happy coding

Beat_Slayer 17

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

doffing81 commented: Perfect +1

Beat_Slayer 17

As NOT wizards, we don't guess code solutions.

Cheers and Happy coding

Beat_Slayer 17

Like this mate.

[CODE]import time
import subprocess

ip = '127.0.0.1'

def ping(ip):
pinging = subprocess.Popen('ping -w 200 -n 1 ' + ip, stdout=subprocess.PIPE)
if "0% loss" in pinging.stdout.read():
return True

while 1:
if ping(ip):
subprocess.Popen('cmd')
time.sleep(0.3)
else:
time.sleep(0.3)[/CODE]

Be aware, if you run it like this it will open a shell every 300 milisecs.

Cheers and Happy coding

s0ur commented: Really nice guy! :-) +0

Beat_Slayer 17

[QUOTE]Popen.terminate()¶

Stop the child. On Posix OSs the method sends SIGTERM to the child. On Windows the Win32 API function TerminateProcess() is called to stop the child.

New in version 2.6.

Popen.kill()¶

Kills the child. On Posix OSs the function sends SIGKILL to the child. On Windows kill() is an alias for terminate().[/QUOTE] [URL="http://docs.python.org/library/subprocess.html"]Source[/URL]

If you paste the code it will be more easy to help.

Cheers and Happy coding

Beat_Slayer 17

Your code is very messy, very distorted, but if you copy your line 18 to line 25 it will work.

Anyway I recommend some clean up.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Two litle functions to help on text slice and spliting.

The code comments say it all.

[CODE]# Slicer takes as arguments a tuple containing the string before,

the string after and the string to truncate. It returns the string
between the two given strings

Slicer = lambda((b, a, t)): t.partition(b)[2].partition(a)[0][/CODE]

[CODE]# Spliter takes as arguments a tuple containing the string before,

the string after and the string to truncate. It returns a tuple
containing the string before, the string between and the string
after the given strings

Spliter = lambda((b, a, t)): ((t.partition(b)[0]),) + t.partition(b)[2].partition(a)[0::2][/CODE]

Cheers and Happy coding

Beat_Slayer 17

[CODE]list1 = []

for y in range(50):
for x in range(50):
list1.append((x, y))

print list1[/CODE]

Cheers and Happy coding

Beat_Slayer 17

[QUOTE]An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages.[/QUOTE] [URL="http://docs.python.org/tutorial/controlflow.html"]Source[/URL]

Cheers and Happy coding

Beat_Slayer 17

[CODE]relevant_weeks = [['[11', " '05/10/2009'", " '06/10/2009'", " '07/10/2009'", " '08/10/2009'", " '09/10/2009']", ''],
['[10', " '28/09/2009'", " '29/09/2009'", " '30/09/2009'", " '01/10/2009'", " '02/10/2009']", ''],
['[27', " '25/01/2010'", " '26/01/2010'", " '27/01/2010'", " '28/01/2010'", " '29/01/2010']", '']]

relevant_days = ['TUES', 'TUES', 'THURS', 'WED', 'THURS', 'MON', 'WED', 'THURS', 'WED', 'TUES', 'MON', 'WED', 'MON', 'WED', 'THURS', 'FRI', 'THURS']

days_reference = [['0', ' MON', ' TUES', ' WED', ' THURS', ' FRI']]

days_reference = [item.strip() for item in days_reference[0]] # cleaning the list

for i in range(len(relevant_weeks)):
print relevant_weeks[i][days_reference.index(relevant_days[i])][/CODE]

Cheers and Happy coding

Beat_Slayer 17

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 + ":" + server_port
print "Level Name: %s" % level_name
print "Public IP: %s" % public_ip
print "-------------------------------------------"

os.system("pause")[/CODE]

Cheers and Happy coding

Beat_Slayer 17

That means that you have a typo, or your reference list is somenthing like:
[CODE]reference_list = '1, 2, 3, 4'[/CODE]
and for that:
[CODE]reference_list = [int(item.strip()) for item in reference_list.split(',')][/CODE]

Cheers and Happy coding

Beat_Slayer 17

Hint:

[CODE]list1 = [4, 3, 1, 3, 2, 1]

list2 = [[0, '0800', 'MON'],
[1, '0830', 'MON'],
[2, '0900', 'MON'],
[3, '0930', 'MON'],
[4, '1000', 'MON']]

for i in range(len(list1)):
for item in list2:
if item[0] == list1[i]:
print item[/CODE]

Cheers and Happy coding

Beat_Slayer 17

One hint.

[CODE]import time

date = 19980224
print time.strptime(date, '%Y%m%d')

date = 19982402
print time.strptime(date, '%Y%m%d')[/CODE]

Cheers and Happy coding

Beat_Slayer 17

Going from the root as as folder python, [CODE]python\Objects\intobject.c[/CODE]

Cheers and Happy coding

Beat_Slayer 17

Some code to see what you have done so far so we can guide you?

Cheers and Happy coding.

Beat_Slayer 17

A example:

[CODE]print item.lower()[/CODE]

Cheers and Happy coding

Beat_Slayer 17

This simple solution will work for all files on the current dir.

[CODE]import os

filelist = os.listdir('')

for files in filelist:
basename, ext = os.path.splitext(files)
if ext == '.kml':
f_output = open('%s-errors.txt' % basename, 'w')
f_output.write('whatever you want')
f_output.close()[/CODE]

Cheers and Happy coding

Beat_Slayer 17

I think that definatelly it's a bad version installed.

Try to redownload and install the proper ones.

Cheers and Happy coding

Beat_Slayer 17

The 'blit' loads a image object to the window surface.

In your example 'blit' loads the 'background' image to the window starting at cordinates 0 in x and 0 in y.
[CODE]screen.blit(background, (0, 0))[/CODE]
The second 'blit' loads the 'sprite' image to the screen, with a fixed cordinate of 100 in 'y', and uses a variable 'x' to define the cordinate on x, that is incremented by 10 every cycle.
[CODE]screen.blit(sprite, (x, 100))
x += 10[/CODE]

Hope it helps,

Cheers and Happy coding

Beat_Slayer 17

Beat_Slayer 17

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('') != -1:
before_html, tag_before, rest_html = str(item).partition('')
title, tag_after, after_html = rest_html.partition('')
print 'Title:', title

def find_episodes(temp="temp2.txt"):
f = open(temp)
site = f.readlines()
f.close()
for item in site:
if item.find('''onmouseover="showToolTip2(event,'View Trailer');return false;" onmouseout="hideToolTip2();" > <a href='/Warehouse_13/episodes/''') != -1:
before_html, tag_before, rest_html = str(item).partition('''onmouseover="showToolTip2(event,'View Trailer');return false;" onmouseout="hideToolTip2();" > <a href='/Warehouse_13/episodes/''')
title, tag_after, after_html = rest_html.partition(' ')
print 'Episodes:', title[12:]

save_page()
find_title()
find_episodes()[/CODE]

Happy coding.

stam0283 commented: this is very nice. it helps you avoid regexes, which is awesome. +0

Beat_Slayer 17

You must return the value from the recursive function.

[CODE]def function(depth):
if depth > 0:
return function(depth - 1)
else:
return 10

function(5)[/CODE]

EDIT: Sorry, was testing it while it was answered.

Beat_Slayer 17

You need to start [URL="http://collada.in4lines.com/"]here[/URL], so you can load those collada files and work with them.

Beat_Slayer 17

How about you post some file and some code, so we can toy with also. ;)

Happy coding!

Gribouillis commented: well said ! +4

Beat_Slayer 17

[CODE]f = open('filename.rc')
old_rc = f.readlines()
f.close()

host = 'PARTYHOST'
new_ip = '127.0.0.1'
f = open('filename.rc', 'w')
for i in range(len(old_rc)):
if old_rc[i].find(host) != -1:
f.write('%s %s\n' % (host, new_ip)) #You should check the newline
else:
f.write(old_rc[i])
f.close()[/CODE]

Beat_Slayer 17

[CODE]if(!strcmp($row['dtFirstContactSt'], '0000-00-00') AND !strcmp($row['dtMarketingSt'], '0000-00-00')) {
echo "" . "&nbsp ";
} else {
echo "" .$row['dtFirstContactSt']. "";
}[/CODE]

Beat_Slayer 17

I guess it is
[CODE]windowSurface.blit(pi, 25, 25)

or

windowSurface.blit(pi, (25, 25))[/CODE]

but i never used pygame.

Beat_Slayer 17

The working file, is the file wich you are processing.

The one that you create or open, and read or write to it.