Nallo's Profile User Rating: -----

Reputation: 165 Stalwart
Group:
Contributors
Active Posts:
261 (0.12 per day)
Joined:
19-July 09
Profile Views:
9,433
Last Active:
User is offline Jun 27 2015 07:57 AM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
50
Icon   Nallo has not set their status

Posts I've Made

  1. In Topic: User Input Test

    Posted 23 Jun 2015

    Your program reads from stdin. So what you need is another program that writes to stdout and connect stdout with stdin through a pipe.

    From the command line on a unix system (maybe python2 or python3 instead of python):
    cat input.txt | python your_prog.py
    
    


    Windows equivalent (if I remember correctly been years since I last used windows):
    type input.txt | python your_prog.py
    
    
  2. In Topic: remeber previous iteration!

    Posted 3 May 2015

    Your problem is that you used a mutable object as a default argument.

    Run this to see what happens:
    def foo(n, bar = []):
        bar.append(n)
        return bar
    
    baz = foo(1)
    print(baz)
    baz = foo(2)
    print(baz)
    
    


    To avoid that:
    def foo(n, bar = None):
        if bar is None:
            bar = []
        bar.append(n)
        return bar
    
    baz = foo(1)
    print(baz)
    baz = foo(2)
    print(baz)
    
    
  3. In Topic: tkinter drawing rectangles

    Posted 2 Feb 2015

    create_rectangle takes four arguments plus some optional arguments. Those four arguments denote the position of the upper left and lower right corner: create_rectangle(x1, y1, x2, y2).
    What you did with the comented out self.canvas.create_rectangle(self.lst[i], 10, self.lst[i], 10) is create a rectangle for which the upper left and lower right corner are the same (no wonder you see no rectangle).

    An example:
    from Tkinter import *
    
    master = Tk()
    
    w = Canvas(master, width=200, height=100)
    w.pack()
    
    x, y = 10, 10
    width = 25
    width2 = 50
    height = 5
    dist = 10
    w.create_rectangle(x, y, x + width, y + height, outline='blue', fill="red")
    w.create_rectangle(x, y + height + dist, x + 50, y + height + dist + height) 
    
    mainloop()
    
    
  4. In Topic: Learning Python

    Posted 4 Jun 2014

    when you are writing
    x = Set([1, 3, 5, 7])
    print(x.union(Set([1, 4, 7])))
    
    

    other is Set([1, 4, 7]), so in the union fuction call in line
    for x in other:
    ...
    
    

    python tries to get an iterator over other ...
    ...python: thinking
    ...python: no __iter__ method defined
    ...python: oops, use some fallback
    ...not sure here, but python "does something" with __getitem__

    in other words:
    python needs an iterator to execute
    for x in other:
    
    

    but has some fallback if __iter__ is not provided for the other instance (again I am not sure about that fallback)
  5. In Topic: Help keeping track of attendees

    Posted 28 May 2014

    Edit: removed as was wrong

My Information

Member Title:
D.I.C Regular
Age:
102 years old
Birthday:
January 1, 1913
Gender:
Programming Languages:
who cares

Contact Information

E-mail:
Private
Website URL:
Website URL  http://