sneekula 969 Nearly a Posting Maven

The American News Media can only handle three major events at a time.

sneekula 969 Nearly a Posting Maven

"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones."
--- Albert Einstein

sneekula 969 Nearly a Posting Maven

"We are asleep until we fall in Love!"
--- Leo Tolstoy

sneekula 969 Nearly a Posting Maven

Here is a typical example:

def funk(arg1, arg2, arg3):
    pass

arg1 = 77
# call function with only one argument
funk(arg1)

''' error -->
Traceback (most recent call last):
  File "<module1>", line 5, in <module>
TypeError: funk() takes exactly 3 arguments (1 given)
'''
sneekula 969 Nearly a Posting Maven

... not fixed and running properly??

sneekula 969 Nearly a Posting Maven

I think you highlightthe code and press the Code button on the grey bar on top.

sneekula 969 Nearly a Posting Maven

At this time PyScripter will not work with Python34, too bad!

sneekula 969 Nearly a Posting Maven

Looks like I have to bring up IDLE or IDLEX for each version of Python.

sneekula 969 Nearly a Posting Maven

Ninja looks great, but again fails the input test, at least on a Windoze machine. The output console does not show the prompt or what you type in until Enter is pressed. Pretty bad!

sneekula 969 Nearly a Posting Maven

Since Python has this miserable version two-three mess right now, it would be nice to have an IDE that let's the user select the version to run.

Editra that comes in the wx folder allows you to easily do that, but it does not handle input() well at al.

sneekula 969 Nearly a Posting Maven

The newer Portable Python 2.7.6.1 package contains the following applications/libraries:

PyScripter v2.5.3
PyCharm Community Edition 3.1.2 (Thanks to cebik)
NymPy 1.8.1
SciPy 0.13.3
Matplotlib 1.3.1
PyWin32 218
Django 1.6.2
PIL 1.1.7
Py2Exe 0.6.9
wxPython 3.0.0.0
NetworkX 1.7
Lxml 3.3.4
PySerial 2.7
PyODBC 3.0.7
PyGame 1.9.1
PyGTK 2.24.2
PyQt 4.10.4
IPython 1.2.1
Pandas 0.11.0
Dateutil 2.2
PyParsing 2.0.1
Six 1.6.1
XLRD 0.9.2
XLWT 0.7.5
XLUtils 1.7.0
OpenPyXL 1.8.5

The best way to run Python on a Windoze machine! Since MS tries so hard to discourage Python users.

Now you have three IDEs available:
Pyscripter (PyScripter-Portable.exe)
Pycharm (PyCharm-Portable.exe)
IDLE (IDLE-Portable.exe)

There is also the old Pythonwin.exe in the site-packages folder.

sneekula 969 Nearly a Posting Maven

Old folks are just a drag on society. Putting up with them with about 25 years after retirement is generous enough. Making this 925 years would be insane. They are a major source of income for the medical profession now.

Reverend Jim commented: insensitive and insulting +0
sneekula 969 Nearly a Posting Maven

In my book the only thing that lives on is meaningful communication you made with people that survive you.

sneekula 969 Nearly a Posting Maven

Well, it is time to plan for Christmas 2014!

sneekula 969 Nearly a Posting Maven

The UK is starting to employ electric commuter buses that are charged at each route end station through an inductive connection in the ground they park on. Each charge takes about 10 minutes, allowing the buses to run all day long.

sneekula 969 Nearly a Posting Maven

I would use this approach, use whatever .gif file you have, sorry this is from my iPad and it does not work well with DaniWeb commands:

,,,
display an image using Tkinter
for Python2
'''
import Tkinter as tk

root = tk.Tk()

image_file = "Vacation2013.gif"
photo = tk.PhotoImage(file=image_file)
root.title(image_file)

label = tk.Label(root, image=photo)
label.pack(padx=5, pady=5)

root.mainloop()
sneekula 969 Nearly a Posting Maven

Majid, please do not hijack a thread with an unrelated question!

sneekula 969 Nearly a Posting Maven

The way it is coded it should work with Python2 or Python3.

sneekula 969 Nearly a Posting Maven

Which version of Python?

sneekula 969 Nearly a Posting Maven

Santa has no religious meaning. He is a jolly soul that represents gift giving, flying sleds and obesity. Let's name the whole thing Santaday.

sneekula 969 Nearly a Posting Maven

You might have set host initially to something that makes sense.

sneekula 969 Nearly a Posting Maven

Works nicely!

sneekula 969 Nearly a Posting Maven

Looks like you managed to put 2 spaces ahead of of line 6.
Python does not like that!

sneekula 969 Nearly a Posting Maven

Note that in Python3 the / division gives a float value, use integer division //

sneekula 969 Nearly a Posting Maven

This code snippet is pretty stupid.
If I could down vote it from my iPad, I would!

sneekula 969 Nearly a Posting Maven

If you have a PC, take the mouse and double click in the code. This will highlight the code. Now right click on the highlighted code and use copy from the pop up menu. If you have a touch pad like the iPad, you are plain out of luck!

sneekula 969 Nearly a Posting Maven

As an exercise you could create all those buttons in a loop.

sneekula 969 Nearly a Posting Maven

I wonder which beach you went to?

sneekula 969 Nearly a Posting Maven
sneekula 969 Nearly a Posting Maven

You may want to help the user in case of an invalid integer entry.

sneekula 969 Nearly a Posting Maven

There are a number of functions that need integer arguments.

sneekula 969 Nearly a Posting Maven

I think it's just style.

sneekula 969 Nearly a Posting Maven

Use
quantity = input()

sneekula 969 Nearly a Posting Maven

How do you run PyPy?

sneekula 969 Nearly a Posting Maven

Hint:

# assume this is your data file (CSV type)
# each line has last name, first name, grade
data = '''\
Miller,Jean,75
Paulson,Peter,47
Tanner,Abraham,88
Norton,Sheila,33
'''

filename = "grades123.txt"
# write a test file
with open(filename, "w") as fout:
    fout.write(data)

# now read your test file back in and process the data
with open(filename, "r") as fin:
    for line in fin:
        # remove trailing newline char
        line = line.rstrip()
        # split the line at the commas
        line_list = line.split(",")
        print(line, line_list)  # test
        # unpack the line
        last, first, grade = line_list
        # now check if int(grade) <= 50
        # and tell person (last first) if they failed

You will have to work with more than one grade in your data line.

sneekula 969 Nearly a Posting Maven

I though it was odd, but that 'bug' has been in there ever since Python26.

sneekula 969 Nearly a Posting Maven

Here would be one number of hints:

'''
file data1.txt looks like this:
A233;Apple;FOOD;1;5.00
A345;Blanck CD 10;DATA;10;0.25
B453;Pasta;FOOD;1;12.00
T545;USB-Memory 16GB;DATA;1;25

each line represents:
identity, name, category, quantity, price
'''

class Billing(object):
    def __init__(self, identity, name, category, quantity, price):
        self.identity = identity
        self.name = name
        self.category = category
        self.quantity = quantity
        self.price = price

# create a list of instances of class Billing
bill_list = []
for line in open("data1.txt"):
    #print(line)  # test
    #print(line.split(';'))  # test
    identity, name, category, quantity, price = line.split(';')
    quantity = int(quantity)
    # remove trailing new line char from price
    price = price.rstrip()
    price = float(price)
    #print(identity, name, category, quantity, price)  # test
    bill_list.append(Billing(identity, name, category, quantity, price))


print("------------------  F O O D  -------------------")
header = ('Product', 'Qty', 'Price/each', 'Price total')
print("%-18s %-5s %-6s %-10s" % (header))
total_food = 0
for bill in bill_list:
    if bill.category == "FOOD":
        totalprice = bill.quantity * bill.price
        sf = "%-18s %2d %10.2f %12.2f"
        print(sf % (bill.name, bill.quantity, bill.price, totalprice))
        total_food += totalprice

print("Total food = %0.2f" % total_food)

print('-'*48)

print("------------------  D A T A  -------------------")
header = ('Product', 'Qty', 'Price/each', 'Price total')
print("%-18s %-5s %-6s %-10s" % (header))
total_data = 0
for bill in bill_list:
    if bill.category == "DATA":
        totalprice = bill.quantity * bill.price
        sf = "%-18s %2d %10.2f %12.2f"
        print(sf % (bill.name, bill.quantity, bill.price, totalprice))
        total_data += totalprice

print("Total data = %0.2f" % total_data)

You still have to bring in your identity file and then search for bill.identity matches.

sneekula 969 Nearly a Posting Maven

You need to change your first data file format to something like this, where for instance the ';' character is the separator:
A233;Apple;FOOD;5.00
A345;Blanck CD 10;DATA;2.50
B453;Pasta;FOOD;12.00
T545;USB-Memory 16GB;DATA;25

sneekula 969 Nearly a Posting Maven

This might give you some hints:

'''
file gemstone.csv looks like this:
valid gemstone owing mark channels code
No Diamond 26.06 20 218 (KJQ:10E)2
Yes Diamond 15.43 25 36 (DRX:25H)7
No Sapphire 11.44 51 141 (XKL:31L)4
No Zircon 79.68 23 60 (BYA:26Ix8
No Moonstone 79.41 11 67 (BWC:79L)4
Yes Garnet 109.69 17 215 (ECO:67B)5
No Pearl 61.16 30 128 (GAZ:36A)6
Yes Opal 44.2 9 162 (ZPK:85T)8
No Emerald 103.13 70 181 (GYN:99F)3
No Ruby 59.09 3 48 (UKI:10I)6
No Amethyst 36.94 35 71 (IUQ:42Z)3
No Diamond 5.45 79 28 (EHX:17T)8
No Amethyst 102.26 11 224 (ZTG:03L)8
No Sapphire 13.01 7 62 (ZBY:68T)9
No Garnet 121.96 93 43 (KHP:59H)3
Yes Garnet 47.13 31 156 (LnQ:15E)1
No Emerald 119.71 30 219 (IWZ:72J)4
No Zircon 38.99 120 98 (VTK53Q)1
No Pearl 91.76 135 80 (STE:05N)8
No Garnet 26.18 13 154 (KTD:90A)1
'''

from collections import Counter
import pprint

with open("gemstone.csv") as fin:
    gem_list = []
    for row in fin:
        gem_list.append(row.split()[1])

# eliminate header/title row
gem_list = gem_list[1:]

gem_cntr = Counter(gem_list).most_common()
pprint.pprint(gem_cntr)

print('-'*24)

# last element
print(gem_cntr[-1:])

'''
[('Garnet', 4),
 ('Diamond', 3),
 ('Zircon', 2),
 ('Pearl', 2),
 ('Amethyst', 2),
 ('Sapphire', 2),
 ('Emerald', 2),
 ('Opal', 1),
 ('Moonstone', 1),
 ('Ruby', 1)]
------------------------
[('Ruby', 1)]
'''
sneekula 969 Nearly a Posting Maven

Looks like Pillow is not available for Python3

sneekula 969 Nearly a Posting Maven

You can use something like this:
myvar.set("Current Folder Selected is: {}".format(dirname))

sneekula 969 Nearly a Posting Maven

One way to do this:

def make_userid(user):
    first, last = user.split()
    user_id = first[0] + last
    return user_id

user = "John Doe"

user_id = make_userid(user)

print(user_id)  # JDoe
sneekula 969 Nearly a Posting Maven

The factorial function is part of the math module in later versions of Python:

''' math_factorial.py
tested with Python 2.7.3
'''

from math import factorial

for k in range(1, 101):
    print("factorial of {} = {}".format(k, factorial(k)))

print(type(factorial(10)))       # <type 'int'>
print(type(factorial(100)))      # <type 'long'>
print(len(str(factorial(100))))  # 158
print(len(str(factorial(69))))   # 99
sneekula 969 Nearly a Posting Maven

The standard gold bar held as gold reserves by central banks and traded among bullion dealers weighs 12.4 kg (438.9 ounces). Gold ingots/bars produced by pouring the molten metal into molds near the mining operation can be as heavy as 60 pounds.

sneekula 969 Nearly a Posting Maven

A banana and a cup of hot chocolate.

sneekula 969 Nearly a Posting Maven

A few hours every now and then in school.

sneekula 969 Nearly a Posting Maven

Another option is to make a DailyExpenses.pth text file that contains the directory name where you can find the DailyExpenses.py file. You can save the path file in Python's "site-packages" directory.

sneekula 969 Nearly a Posting Maven

Global Warming is also used for all sorts of bad legislation. Another Ice Age will solve this.

sneekula 969 Nearly a Posting Maven

Mutation to a real chicken would happen in the egg, so the egg comes first.

sneekula 969 Nearly a Posting Maven

Multigrain flax cereal with Banana slices and almond milk.