Beat_Slayer 17 Posting Pro in Training
Beat_Slayer 17 Posting Pro in Training

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 Posting Pro in Training

doffing81, theres no need to hardcode the 5 deals.

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))

Cheers and Happy coding

doffing81 commented: Perfect +1
Beat_Slayer 17 Posting Pro in Training

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


Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Like this mate.

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)

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 Posting Pro in Training

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().

Source

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

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

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.

# 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]
# 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]

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training
list1 = []

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

print list1

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages.

Source

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training
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])]

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

You can run the listening function on an asynchronized thread.

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")

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

That means that you have a typo, or your reference list is somenthing like:

reference_list = '1, 2, 3, 4'

and for that:

reference_list = [int(item.strip()) for item in reference_list.split(',')]

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Hint:

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

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

One hint.

import time

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

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

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Going from the root as as folder python,

python\Objects\intobject.c

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

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

Cheers and Happy coding.

Beat_Slayer 17 Posting Pro in Training

A example:

print item.lower()

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

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

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()

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

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 Posting Pro in Training

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.

screen.blit(background, (0, 0))

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.

screen.blit(sprite, (x, 100))
x += 10

Hope it helps,

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training
Beat_Slayer 17 Posting Pro in Training

Like this?

#!/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:', 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> <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> <a href='/Warehouse_13/episodes/''')
            title, tag_after, after_html = rest_html.partition('</a> </td>')
            print 'Episodes:', title[12:]

save_page()
find_title()
find_episodes()

Happy coding.

stam0283 commented: this is very nice. it helps you avoid regexes, which is awesome. +0
Beat_Slayer 17 Posting Pro in Training

You must return the value from the recursive function.

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

function(5)

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

Beat_Slayer 17 Posting Pro in Training

You need to start here, so you can load those collada files and work with them.

Beat_Slayer 17 Posting Pro in Training

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 Posting Pro in Training
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()
Beat_Slayer 17 Posting Pro in Training
if(!strcmp($row['dtFirstContactSt'], '0000-00-00') AND !strcmp($row['dtMarketingSt'], '0000-00-00')) {
echo "<td width='156'>" . "&nbsp </td>";
} else {
echo "<td bgcolor=FF0000 width='156'>" .$row['dtFirstContactSt']. "</td>";
}
Beat_Slayer 17 Posting Pro in Training

I guess it is

windowSurface.blit(pi, 25, 25)

or

windowSurface.blit(pi, (25, 25))

but i never used pygame.

Beat_Slayer 17 Posting Pro in Training

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

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

Beat_Slayer 17 Posting Pro in Training
Beat_Slayer 17 Posting Pro in Training

Come on guys you are arsh with each others.

I said that as info vegaseat, nothing more.

I said that because he had made like that and succeded, so he already have done mantining proportions, I said that so it was easier for him to see that this is without.

I don't understand, why the people here is so difficult with each others, I really like this forum, but i think that the people should keep their minds on sharing knowledge and trying to help.

And I'm not arguing against you vegaseat, I hope you understand me.

I'm just a coder wanting to share some knowledge, and to learn a lot with the great coders that go on this forums.

Happy coding!!!

EDIT: And sorry it this is off-topic or something like that.

Beat_Slayer 17 Posting Pro in Training

list of int

list3 = [[int(x) for x in y] for y in list2]
Beat_Slayer 17 Posting Pro in Training

Oups... :)

I was sleeping.

def unrar():

    try:
        os.chdir(fileDir)
        
        print "\n-------------"
        print "Installing..."
        print "-------------\n"

        found = None
		
        for file in Unrar2.RarFile(filename).infoiter():
			
	    basename, ext = os.path.splitext(file)
			
            if ext == ".package":
                print "Found %s. Extracting to \\Packages." % file
                archive.extract(file, modDir + "\\Packages", False)
                found == True
				
            elif ext == ".dbc":
                print "Found %s. Extracting to \\DCCache." % file
                archive.extract(file, modDir + "\\DCCache", False)
                found == True
				
        if found:
            print "\nInstallation successful!"
	    os.system("pause")
        else:
            print "No valid files found."
            os.system("pause")
            os.system("cls")
            checkExtension()
Beat_Slayer 17 Posting Pro in Training
def unrar():

    try:
        os.chdir(fileDir)
        
        print "\n-------------"
        print "Installing..."
        print "-------------\n"

        found = None
		
        for filename in Unrar2.RarFile(filename).infoiter():
			
	    basename, ext = os.path.splitext(filename)
			
            if ext == ".package":
                print "Found %s. Extracting to \\Packages." % filename
                archive.extract(filename, modDir + "\\Packages", False)
                found == True
				
            elif ext == ".dbc":
                print "Found %s. Extracting to \\DCCache." % filename
                archive.extract(filename, modDir + "\\DCCache", False)
                found == True
				
        if found:
            print "\nInstallation successful!"
	    os.system("pause")
        else:
            print "No valid files found."
            os.system("pause")
            os.system("cls")
            checkExtension()
Beat_Slayer 17 Posting Pro in Training

If you replace the read from the url with the html code you gave, it works just fine.

Could it be something related to the talking with the server?

We can test it.

matchstr = urlopen('http://192.168.0.1/stlui/user/allowance_request.html%20target=%22allowance%22').read()
matchstr = '''
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="refresh" Content="60;url=/stlui/user/allowance_request.html">
<title>Download Allowance Status</title></head><body><h3 style="font-size: 150%; color:blue; text-align:center; font-weight:bold">DOWNLOAD ALLOWANCE STATUS</h3><TABLE width='100%' cellpadding='10'><tr><td style="text-align:center;"><h3>Usage within allowance - no download restrictions</h3></td><td><span style="display:block;text-align:center">100%</span><table style="font-size:1; background-color:white; border:1px solid black;" width='15%' cellspacing='0' cellpadding='0' align='center'><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr><tr style="background-color:green"><td>&nbsp;</td></tr></table><span style="display:block;text-align:center">0%</span></td></tr><tr><td>&nbsp;</td><td><table style="font-size:18; border-width:0px;" width=90% cellspacing=0 cellpadding=0 ALIGN=CENTER><tr><td>&nbsp;</td><td style="border-width:0px;">Plan Allowance (MB)</td><td style="border-width:0px;"> 625</td></tr><tr><td>&nbsp;</td><td style="border-width:0px;">Allowance Remaining (MB)</td><td style="border-width:0px;"> 625</td></tr><tr><td><span style="background-color: green;">&nbsp;&nbsp;&nbsp;</span>&nbsp;</td><td style="border-width:0px;">Allowance Remaining (%)</td><td style="border-width:0px;"> 100</td></tr><tr><td>&nbsp;</td><td style="border-width:0px;">Time Until Allowance Refill</td><td style="border-width:0px;"> 22:18:01</td></tr></table></td></tr></TABLE>
</body>
</html>
'''
Beat_Slayer 17 Posting Pro in Training

test_UnRAR2.py

If you take a look at this, it will get easier.

I can tested but i think something likethis maybe. :)

for rarinfo in archive.infoiter():
    if rarinfo.filename == "*.txt":
        # your code