woooee 814 Nearly a Posting Maven

Your indentation is off. Look at a basic tutorial and classes. https://wiki.python.org/moin/BeginnersGuide

Encray commented: can u pls tell me how yo fix it +0
woooee 814 Nearly a Posting Maven

login() is declared uner the class, even though it is not a member of the class.

TickleMeElmo commented: Thanks very much for your help! +0
woooee 814 Nearly a Posting Maven

Please don't post twice. That is rude.

woooee 814 Nearly a Posting Maven

A simple split will do the trick

test =""" 
        [
        "this is a text and its supposed to contain every possible char."
        ], 
        [
        "like *.;#]§< and many more."
        ], 
        [
        "plus there are even
        newlines

        in it."
        ]"""

x=test.split('[\n')
for rec in x:
    print(rec)
    print("-"*20)
woooee 814 Nearly a Posting Maven

Using random.shuffle(), you can just then read them in order. http://www.tutorialspoint.com/python/number_shuffle.htm

woooee 814 Nearly a Posting Maven

Everything regarding the menu is usually in the same function

def displayMenu():
    print('Enter 1 to convert a string to uppercase:')
    print('Enter 2 to convert a string to lowercase:')
    print('Enter 3 to count the number of words in a string:')
    print('Enter 4 to count the number of vowels in a string:')
    print('Enter 5 to exit:')

    choice = ""
    while (choice != 5):
        ## what happens when someone enters a letter
        choice = int(input('Enter your choice:'))
        if choice in [1, 2, 3, 4]:
            string_input=get_sring()
        if(choice == 1):
            upper(string_input)
        elif(choice == 2):
            lower(string_input)
        elif(choice == 3):
            split(string_input)
        elif(choice == 4):
            vowels(string_input)
        elif(choice == 5):
            print('Thank you. Goodbye!')
            return  ## <----- exit function
        else:
            print('Incorrect entry, please try again.')

## same thing for a strint
def get string():
    #Allow user to enter string
    while True:  ## infinite loop
        user_string = input('Enter a string: ')
        if len(user_string):  ## not an empty string
            return user_string
woooee 814 Nearly a Posting Maven

Use partial to pass something to the function, and the function will do something based on the value. This example prints what was passed to the function. Note that the Python Style Guide suggests function names should be lower case letters and underscores https://www.python.org/dev/peps/pep-0008/

root = tkinter.Tk()
root.geometry("200x300")
##buttons=range(10)
button_list=[]

def get_next(button_num):
    print("button number =", button_num)
    ## change the color of the button pressed to show how the list works
    button_list[button_num].config(bg="lightblue")

for num in range(10):
    btn=tkinter.Button(root, text="Button %d" % (num),
                       command=partial(get_next, num))
    btn.pack(side=tkinter.TOP)
    ## save a reference to the button so it can be used in get_next
    ## the button number corresponds to the offset in the list
    button_list.append(btn)

root.mainloop()
woooee 814 Nearly a Posting Maven

if not read_file:This statement is executed when bytes1 is found at the beginning of the file, offset/read_file==0). Use instead

      with open("foundhex.txt", "a") as found1:
          while True:
              read_file = bytearray(binaryfile.read(1024))
              if len(read_file):
                  find_bytes1 = read_file.find(bytes1, 0)
                  if fine_bytes1 != -1:
                      found1.write("Found 41646F626520 at : " + str(find_bytes1) + "\n")
              else:
                  break

Also this statement find_bytes1 = read_file.find(bytes1, 0)
starts at the beginning every time, so you are finding only the first sting and not any subsequent strings. Finally, for this statement read_file = bytearray(binaryfile.read(1024))
what happens if half of bytes1 is in one read, and half is in the next read?

woooee 814 Nearly a Posting Maven

How do you determine boundaries? I would suggest that you post some stripped down code, i.e without all of the plotting, etc. as that has nothing to do with "outside boundaries". Include also an explanation of how you would like to determine what is outside the boundaries.

glez_b commented: I want to plot only the data that are inside the Multipolygon of the shapefile +1
woooee 814 Nearly a Posting Maven

split() on <doc> first and then process each item separately in the returned list.

woooee 814 Nearly a Posting Maven

They are all True on my computer as each pair points to the same address in memory (although I am on a 64 bit computer and it may be different on a 32 bit machine). Python keeps a list of objects for all "small" integers so they don't have several references to the same number in a program. When you create an int in that range you actually just get back a reference to the existing object. So each variable in the pair points to the same existing object. To get a False you would have to point to some calculated number i.e. it is not a reference to an existing object.

a = 256  ## lookup in existing list
b = 256
print a is b

c = 257
d = 257
print c is d

e = 258
f=258
print e is f

## create and put in unique memory location
## "256+1" not in list
g = 256+1
print "c is g", c is g, c, g

""" prints
True
True
True
c is g False 257 257
"""
woooee 814 Nearly a Posting Maven

Please post the code you have tried so far, to be used as a starting point. The question can not be answered until we know how "e, 2, 1" is similar

woooee 814 Nearly a Posting Maven

Frist you have to determine the length of the final list. Then append zeroes unless the list offset is in the dictionary passed to the function.

def convert_dictionary(dict_in):
    """ a dictionary's keys are not necessarily in entry order
    """
    print max(dict_in.keys())
    print dict_in.keys()

convert_dictionary({0: 1, 2: 1, 4: 2, 6: 1, 9: 1})
woooee 814 Nearly a Posting Maven

Note also that this statement will always be true

    elif guess == a1a or a2a or a3a or a4a or a5a or a6a or a7a or a8a or a9a or a10a or a11a or a12a or a13a or a14a or a15a or a16a or a17a

an "or" is the same as if/elif so your statement becomes

elif guess == a1a:
    elif a2a:
    elif a3a:  

etc. " elif a2a" will always be true as long as any of the a2a-a17a is not an empty string, zero, or None.

woooee 814 Nearly a Posting Maven

Use the codecs' encoding parameter when reading and writing, although you can do it manually yourself, I find that this method works without problems. Also, note that how it prints depends on the default encoding of your OS.

import codecs

s = b'B1=A\xF1adir+al+carrito\n'.decode('latin-1')
with codecs.open('lat.txt', mode="wb", encoding='latin-1') as fp:
    fp.write(s)

with codecs.open('lat.txt', "r", encoding='latin-1') as fp:
    r=fp.read()

print s
print r
woooee 814 Nearly a Posting Maven

You use rowconfigure and columnconfigure. If you comment one of them out in the following example, it will only expand in the direction of which ever was not commented.

try:
    import Tkinter as tk     ## Python 2.x
except ImportError:
    import tkinter as tk     ## Python 3.x

def column_row_expandable():
    """ the labels and button will not expand when the top frame expands
        without the rowconfigure and columnconfigure statements
    """
    top=tk.Tk()
    top.rowconfigure(0, weight=1)
    for col in range(5):
        top.columnconfigure(col, weight=1)
        tk.Label(top, text=str(col)).grid(row=0, column=col, sticky="nsew")

    top.rowconfigure(1, weight=1)
    tk.Button(top, text="button").grid(row=1, column=0, columnspan=10, sticky="nsew")
    top.mainloop()

column_row_expandable()
woooee 814 Nearly a Posting Maven

To further the foo_1 is not mutable (when it is changed it resides at a new memory address).

foo_1=3
print "at memory address", id(foo_1)

foo_1 += 2
print "not mutable so new value=new address"
print id(foo_1)

print "\n lists are mutable (same memory address)"
foo_1 = [3]
print id(foo_1)
foo_1[0] += 2
print id(foo_1)
woooee 814 Nearly a Posting Maven

When palaces are kept up
Fields are left to weeds
And granaries empty (economy trashed);
Wearing fine clothes,
Bearing sharp swords,
Glutting with food and drink,
Hoarding wealth and possessions -
These are the ways of theft,
And far from the Way.

Tao Dejing #53

woooee 814 Nearly a Posting Maven

Add some print statements to self.search_capture() to see where the append to the list is happening incorrectly, as obviously the length never equals zero. Note that in "right" and "left" either the row or the column should be the same, and you add/subtract from both. I would suggest that you make each move a separate function, that you pass a color to, and test each one individually.

woooee 814 Nearly a Posting Maven

I recently went into a Rite-Aid. They take your old "rewards" card and sign you up for a Plenti card, asking for your email because you have to confirm the card through email. That email account went from almost no spam to 5-10 spams per day. Almost all are some variation of the Nigerian scams. You want to have a throw away email account for just this reason. I am increasingly shopping at stores that do not require rewards cards.

woooee 814 Nearly a Posting Maven

In a recent infomercial type commercial all of the "satisfied users" had faces with way too much plastic surgery (oh no they aren't actors reading from a script). Perhaps the product only appeals to people who have had plastic surgery. Or they "ordered now" and got a second one free (just pay shipping and handling), saving enough money so they could get a face lift.

woooee 814 Nearly a Posting Maven

Today's compilers are optimal, meaning comments don't make it into the final code, so you can just comment those lines, i.e. the if statement and everything beneath it. It is almost a certainty that you will want them again. The input will change or the program will have to be changed and you will want to know what is happening at those check points, so you can then uncomment them.

BustACode commented: The reason I wrote it is that some of the programs were rendered unreadble, even by me later. So it gets rid of the detritus. +0
woooee 814 Nearly a Posting Maven

It takes between 2 million and 10 million bee trips to make a pound of honey, depending on who's counting. And about 50,000 miles.

woooee 814 Nearly a Posting Maven

I am assuming that your question was already answered here http://stackoverflow.com/questions/30137630/open-frame-from-button

Statements like this say that you are indeed confused by the inheritance.

    for F in (PageSTART,PageSELECT,PageZS,PageARH,PageSET,PageHLP):
        frame = F(container, self)
woooee 814 Nearly a Posting Maven

There is no way to tell which "position_start" to use in the following code, as there are two with the same name in the for() statement. As for the problem, print the list(s) on the line before the for() statement to see what it contains. Finally, you should check that all lists are the same length before executing the for() loop.

for position_start, position_top, program_width, program_height in zip(position_start, position_top, program_width, program_height):

    pos_start = int(float(position_start))
mark103 commented: ty this is the answer i'm looking for +2
woooee 814 Nearly a Posting Maven

First, try it with "shell=True" (see the link below). And post which version of Python and the OS you are using.

You can capture the output and write it to a file yourself so you know if you are getting that far or not. See the Python Module of the Week's "capturing output" http://pymotw.com/2/subprocess/index.html#capturing-output (and subprocess.call should work just fine for calling/running the program).

The code you posted has one error that I can see, although we can not run it because we don't have the perl script. There a missing slash for the directory at the beginning of the output file i.e. should be "> /Input/tokenization/Eng-hin.translation.tok.en"

woooee 814 Nearly a Posting Maven

Take a look at the following thread in Daniweb https://www.daniweb.com/software-development/python/threads/452441/tkinter-entry-value-problem There are more examples under the "Python GUI Programming" thread at the top of the python page.

woooee 814 Nearly a Posting Maven

Sping gets shorter every year by about 30 seconds to a minute, due to astronomical quirks, researchers say. Summer gets longer. Similarly winter gets shorter and autumn gets longer.

The main reason spring is getting shorter is that Earth's axis itself moves, much like a wobbling top, in a type of motion called precession. Spring ends at the summer solstice, and because of precession, the point along Earth's orbit where the planet reaches the summer solstice shifts slightly.

Spring will be shortest in about the year 8680, measuring about 88.5 days, or about four days shorter than this year's spring

http://www.nbcnews.com/science/space/why-spring-gets-about-30-seconds-shorter-every-year-n327286

RikTelner commented: "Leap half-minute" ? :D +0
woooee 814 Nearly a Posting Maven

Pi is the circumference of a circle whose diameter is 1, and is the first letter of the Greek word perimeter."

woooee 814 Nearly a Posting Maven

You ignore spaces in the encoded message and insert a space at the appropriate number, ie. is in "key".

def decode(message, key):
    output=[]
    for ctr, ltr in enumerate(message):
        if ctr in key:
            output.append(" ")
        if ltr != " ":
            output.append(ltr)
    print "".join(output)

decode("HELLO WORLDT HISIS SOC OOL", [5, 11, 16, 19, 21])
woooee 814 Nearly a Posting Maven

And obviously those 2 things are related.

woooee 814 Nearly a Posting Maven

It something like this happens to you, a credit freeze is better than credit monitoring, at least in the US. This stops any new attempts to access your credit report, so unless a lending institution issues credit cards or loans without checking, nothing can be obtained in your name.

From http://www.consumer.ftc.gov/articles/0497-credit-freeze-faqs

Contact each of the nationwide credit reporting companies:
Equifax — 1‑800‑525‑6285
Experian —1‑888‑397‑3742
TransUnion — 1‑800‑680‑7289

You'll need to supply your name, address, date of birth, Social Security number and other personal information. Fees vary based on where you live, but commonly range from $5 to $10.

After receiving your freeze request, each credit reporting company will send you a confirmation letter containing a unique PIN (personal identification number) or password. Keep the PIN or password in a safe place. You will need it if you choose to lift the freeze.

woooee 814 Nearly a Posting Maven

FreedomPop announced unlimited wifi for $5 per month with 25 million hotspots expected http://techcrunch.com/2015/01/21/freedompop-wifi/

Google is interested in entering the wireless phone and/or internet market http://www.pcmag.com/article2/0,2817,2475602,00.asp

Google provides internet service for Starbucks, one of the hotspot providers for FreedomPop. Both announcements come within days of each other. Coincidence...or is it?

woooee 814 Nearly a Posting Maven

Good point. Am assuming from "lastnight" that titles don't contain spaces. And if they do, the concept is still the same.

woooee 814 Nearly a Posting Maven

You split them and add a newline so they are on new lines. We don't know what type of variable favorite_movies is so there is no way to give an exact answer, but it is something along the same lines as

favorite_movies="spiderman lastnight matrix"
print favorite_movies
print "\n".join(favorite_movies.split())
woooee 814 Nearly a Posting Maven

Not without knowing what argv contains. Print it and see for yourself.

print argv
print len(argv)
woooee 814 Nearly a Posting Maven
for elem in self.programs_button:

That statement is not in the code you posted.

woooee 814 Nearly a Posting Maven

The second return statement in inputPlayerLetter() never executes because the function exits when the first return is called. It should be

return Player, Computer

And you then have to catch the return when you call the function. See "the return Statement" at this link for a tutorial http://www.tutorialspoint.com/python/python_functions.htm
and https://www.safaribooksonline.com/library/view/python-cookbook-3rd/9781449357337/ch07s04.html

woooee 814 Nearly a Posting Maven

You start with a list full of ? and replace each ? with a letter when guessed correctly.

## assumes both words are the same length

def display_matches(matches, test_word, sample_word):
    """     H?L?          HELP
            HEL?          HELP
            HELP          HELP
    """
    for ctr in range(len(test_word)):
        if test_word[ctr] == sample_word[ctr]:
            matches[ctr] = test_word[ctr]
    print "%s   %s  %s" % ("".join(matches), sample_word, test_word)
    return matches

test_word="HALE"
sample_word="HELP"
matches = ["?" for ctr in range(len(sample_word))]

matches=display_matches(matches, test_word, sample_word)
matches=display_matches(matches, "WXYZ", sample_word)
matches=display_matches(matches, "KEEN", sample_word)
matches=display_matches(matches, "HERO", sample_word)
matches=display_matches(matches, "STOP", sample_word)

""" results
H?L?   HELP  HALE
H?L?   HELP  WXYZ
HEL?   HELP  KEEN
HEL?   HELP  HERO
HELP   HELP  STOP
"""
woooee 814 Nearly a Posting Maven

second it does not give me messages for when a one is rolled or 2 is rolled

Do you mean one or two dice are rolled, or the dice rolled total one or two

nor does it go on to the next players turn like its suppose too

The function game() always assigns zero to player

I added one line as the previous roll was covering up the current roll

canvas.delete(ALL)  ## remove all items

and modified another as you were calling the function incorrectly

button1 = Button(master, text = "continue", command=game)

Complete code, modified, and if this does not do it, post back

from tkinter import*
from functools import partial

master=Tk()
canvas = Canvas(master, width = 300, height = 200);
canvas.pack();
from random import randint
#### Dice
def draw(rolled,rolled2):
    dice = [rolled,rolled2]
    for i in range(2):
        canvas.create_rectangle(5+195*i,50,105+195*i,150)
        if dice[i] == 1:
            canvas.create_oval(45+195*i,85,65+195*i,105, fill="black")
        elif dice[i] == 2:
            canvas.create_oval(12+195*i,52,32+195*i,72, fill="black")
            canvas.create_oval(82+195*i,122,102+195*i,142, fill="black")
        elif dice[i] == 3:
            canvas.create_oval(45+195*i,85,65+195*i,105, fill="black")
            canvas.create_oval(12+195*i,52,32+195*i,72, fill="black")
            canvas.create_oval(82+195*i,122,102+195*i,142, fill="black")
        elif dice[i] == 4:
            canvas.create_oval(12+195*i,52,32+195*i,72, fill="black")
            canvas.create_oval(82+195*i,122,102+195*i,142, fill="black")
            canvas.create_oval(12+195*i,122,32+195*i,142, fill="black")
            canvas.create_oval(82+195*i,52,102+195*i,72, fill="black")
        elif dice[i] == 5:
            canvas.create_oval(45+195*i,85,65+195*i,105, fill="black")
            canvas.create_oval(12+195*i,52,32+195*i,72, fill="black")
            canvas.create_oval(82+195*i,122,102+195*i,142, fill="black")
            canvas.create_oval(12+195*i,122,32+195*i,142, fill="black")
            canvas.create_oval(82+195*i,52,102+195*i,72, fill="black")
        elif dice[i] == 6:
            canvas.create_oval(12+195*i,52,32+195*i,72, fill="black")
            canvas.create_oval(82+195*i,122,102+195*i,142, fill="black")
            canvas.create_oval(12+195*i,122,32+195*i,142, fill="black")
            canvas.create_oval(82+195*i,52,102+195*i,72, fill="black")
            canvas.create_oval(47+195*i,52,67+195*i,72, fill="black")
            canvas.create_oval(47+195*i,122,67+195*i,142, fill="black")

    button1 = Button(master, text = "continue", command=game)
    button1.configure(width = 10, activebackground = "#33B5E5", relief = FLAT)
    button1_window = canvas.create_window(10, 180, anchor=SW, window=button1)


#####game    
def game():
    playercount = 2
    maxscore = 100
    safescore = [0] * playercount
    player …
woooee 814 Nearly a Posting Maven

Rumor has it he was quoting Mr Greenjeans

English proverb
"The soul is healed by being with children."

Reverend Jim commented: When you've been around children long enough you begin to realize why some animals eat their young. +0
woooee 814 Nearly a Posting Maven

From the kids: Where do you find a turkey with no legs. Right where you left it.

woooee 814 Nearly a Posting Maven

You would have to use multiprocessing for the timer since the program is doing two things,
1. getting the answer
2. moving on/killing the question's process after 30 seconds whether the question has or has not been answered. Multiprocessing takes a little fiddling to get the input in a thread since a process does not use the same input stream as the non-in-a-process code, and you might also want to communicate to/from the thread with a Manager which is another thing to be learned.`

You could also use Tkinter (probably a better choice), which has a built in "after" method. Tkinter would also enable the user to click a button when finished instead of waiting for the 30 seconds to expire.

""" multiprocessing example
"""

import time
from multiprocessing import Process
import os
import sys

class AskQuestions():
   def __init__(self):
      self.answer=None
      self.correct_answers = 0

   def test_q(self, question, fileno):
      self.answer=None
      ## necessary to get input to work
      sys.stdin = os.fdopen(fileno)  #open stdin in this process
      print "\n\n", question
      self.answer = input("What is your answer? ")
      if self.answer:
          print "     Correct", self.answer

if __name__ == '__main__':
   AQ=AskQuestions()

   for question in ["The First Thing", "Second", "Last and Least"]:
       fn = sys.stdin.fileno()
       p = Process(target=AQ.test_q, args=(question, fn))
       p.start()
       ## sleep for 10 seconds and terminate
       time.sleep(10.0)
       p.terminate()
woooee 814 Nearly a Posting Maven

Apparently Fluxbox uses xclipboard so xclip and xsel have to be installed if you want to use them. Unfortunately when doing cross-platform stuff, Linux is not one size fits all.

woooee 814 Nearly a Posting Maven

Are you sure you even read the post as the list is still declared under the same for() loop.

woooee 814 Nearly a Posting Maven

Greased pole climbing, rock throwing and mud fighting were part of the 2004 Summer Olympics in St. Louis USA.

Weren't the 2004 Olympics in Athens?

woooee 814 Nearly a Posting Maven

I would use a Manager dictionary which would contain
1. a counter or other method that can be easily compared to the original to show that there is a change
2. the configuration

See the Managing Shared State heading on Doug Hellmann's site Click Here

This simple example shows that changes made to the manager dictionary inside or outside of the process can be seen by all processes

from multiprocessing import Process, Manager

def test_f(test_d):
   """  frist process to run
        exit this process when dictionary's 'QUIT' == True
   """
   test_d['2'] = 2     ## add as a test
   while not test_d["QUIT"]:
      print "P1 test_f", test_d["QUIT"]
      test_d["ctr"] += 1
      time.sleep(1.0)

def test_f2(test_d):
    """ second process to run.  Runs until the for loop exits
   """
    for j in range(0, 10):
       ## print to show that changes made anywhere
       ## to the dictionary are seen by this process
       print "     P2", j, test_d
       time.sleep(0.5)

    print "second process finished"

if __name__ == '__main__':
   ##--- create a dictionary via Manager
   manager = Manager()
   test_d = manager.dict()
   test_d["ctr"] = 0
   test_d["QUIT"] = False

   ##---  start first process and send dictionary
   p = Process(target=test_f, args=(test_d,))
   p.start()

   ##--- start second process
   p2 = Process(target=test_f2, args=(test_d,))
   p2.start()

   ##--- sleep 2 seconds and then change dictionary
   ##     to exit first process
   time.sleep(2.0)
   print "\nterminate first process"
   test_d["QUIT"] = True
   print "test_d changed"
   print "data from first process", test_d

   ##---  may not be necessary, but I always terminate to be sure
   time.sleep(5.0)
   p.terminate()
   p2.terminate()
woooee 814 Nearly a Posting Maven

The United States secured the #1 ranking in wealth inequality. Note that wealth is not income Click Here

woooee 814 Nearly a Posting Maven

You can also eliminate some of the redundancy when printing the hangman

def print_hangman(turn):
    print("turn=%d" % (turn))
    if turn >= 1:
        print(' |')
    if turn >= 2:
        print(' O')
    if turn >= 3:
        print('/', end="")
    if turn >= 4:
        print('|', end="")
    if turn >= 5:
        print('\\')
    if turn >= 6:
        print('/', end="")
    if turn == 7:
        print(' \\')
    print(" ")

for ctr in range(1, 8):
    print_hangman(ctr)
    input()
woooee 814 Nearly a Posting Maven

You can pass an optional start location to .find() but that means iterating over the entire list several times. Another way

word="APPLE"
guess="P"
hint=["-" for ctr in range(len(word))]
print "initial =", hint
for index in range(len(word)):
    if word[index]==guess:
        hint[index]=guess

print "".join(hint)