snippsat 661 Master Poster

You dont define x,so then it will of course not have an value.

>>> x

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    x
NameError: name 'x' is not defined
>>>

def file2Function():
    x = 5
    print x
    
file2Function()  #5
#file1.py
def file2Function():
    x = 5
    return 5


>>> import file1
>>> dir(file1)
['__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 'file2Function']
>>> print file1.file2Function()
5
>>>
snippsat 661 Master Poster
>>> xdate = 5
>>> print 'value of xdate is %d' % xdata
value of xdate is 5

String formatting operations has been in python since day one.
http://docs.python.org/library/stdtypes.html#string-formatting-operations

A new and more powerful string formatting operations,from python 2.6-->
http://docs.python.org/library/string.html#format-examples
http://www.daniweb.com/code/snippet232375.html

snippsat 661 Master Poster

Drop all eval,where have you learn this very ugly way to convert string to integer?

>>> loan_str = raw_input ("Amount of loan:")
Amount of loan:20000
>>> #make integer
>>> loan = int(loan_str)
>>> loan
20000
>>> type(loan)
<type 'int'>

>>> #Or make input return an integer
>>> loan_str = int(raw_input ("Amount of loan:"))
Amount of loan:500000
>>> type(laoan_str)
<type 'int'>
>>>

On this site vega done a lot work over many year.
So here is a some help you can look at.
http://www.daniweb.com/code/snippet216739.html

snippsat 661 Master Poster

With ironpython you can write in python with full acess to the .NET Framework.
For a python programmers this is very fine,dont have to learn a more verbose and static types language as C#.

You have BOO that use a python like way to write code.
But are statically typed and do not have the true dynamic typed power of python,that you use with ironpython.

combine c# with python or vice-versa

Combing i dont know how smart that is or if it possible,with ironpython you can dropp C#.
C# has off course better and more documation for working against .NET.
And maybe framework like XNA(game), silverlight are eaiser to develop in C#,because of documation.

snippsat 661 Master Poster
@classmethod
    def from_points(cls, P1, P2):
        return Vector2(P2[0] - P1[0], P2[1] - P1[1])

http://docs.python.org/library/functions.html?highlight=classmethod#classmethod

could someone please explain the __add__ constructor to me? Thanks.

>>> x = 5
>>> y = 6
>>> x + y
11
>>> dir(x)
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'imag', 'numerator', 'real']

So a simple explanation is to say that everything in Python is an object.
So x is an object and has method,and has a special method called __add__.
When + is used __add__ get called.
We can write it like this.

>>> x = 5
>>> y = 6
>>> x.__add__(y)
11
>>> 
>>> x.__add__.__doc__
'x.__add__(y) <==> x+y'
>>>

So we can say that special methods two underscore __something__ work in the background an get call when we as an example use * - + /.

snippsat 661 Master Poster

Some hint
You will not get finish code or so much help if you dont show some effort.

>>> a = 3
>>> if a <=5 and a >= 1:
...     print 'Number are between 1 and 5'
...     
Number are between 1 and 5
>>> a = 7
>>> if a <=5 and a >= 1:
...     print 'Number are between 1 and 5'


>>> b = int(raw_input('Enter a number: '))
Enter a number: a

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    b = int(raw_input('Enter a number: '))
ValueError: invalid literal for int() with base 10: 'a'

>>> try:
	b = int(raw_input('Enter a number: '))
except ValueError:
	print 'Please number only'

	
Enter a number: a
Please number only
snippsat 661 Master Poster
for line in open('my.txt'):
    print line,

This is memory efficient and fast way,it reads line by line.
Not the hole file into memory.
Am not sure(dont think so)it`s a way to get one line,without reading something into memory.

snippsat 661 Master Poster

Write takes string as argument,if x is a string is shall be ok.
If not ''.join() as tony used be an option.
Remeber to close() the file,if not it will not write anything.
with open() close the file auto,as tony use over.

if x[0:4]=="ATOM":
   print type(x) #Check the type

>>> help(f.write)
Help on built-in function write:

write(...)
    write(str) -> None.  Write string str to file.
    
    Note that due to buffering, flush() or close() may be needed before
    the file on disk reflects the data written.
snippsat 661 Master Poster

Can't I just access the specific line without loading the file to memory?

Yes use linecache from standard library.

'''--> l.txt
line 1.
line 2.
line 3.
'''

from linecache import getline
#Notice  linecache count from 1
print getline('l.txt', 2).strip()
#--> line 2.
snippsat 661 Master Poster

@doffing81 i will give som advice about code design.
This can be very important as code grow,to much code in global space can be a real pain.
when you work with function code is local to that function(you have to call it)
Learn to work with function first,of course class is also an option later.
But is important to get comfortable with function.

So some code to show you what i mean.
Look how this work,and a make some documation(called dok_string)

from random import shuffle

def make_deck():
    '''This function retur a sorted deck'''
    rank = 'A23456789TJQK'
    suit = 'CDHS'
    deck = []
    for r in list(rank):
        for s in list(suit):
            card = r + s
            deck.append(card)
    return deck

def shuffle_deck(deck, number=None):
    '''Shuffle deck and return card number(5) return five card'''
    shuffle(deck)
    return [deck.pop() for k in range(number)]

def foo():
    '''Not finsih yet'''
    pass

def main():
    #Here we put it all together
    #Make a note that no code is in global space,this make it eaiser to add remove code
    #We can just add remove function.
    deck = make_deck()
    five_card = shuffle_deck(deck, 5)
    print 'A test give player five card: %s' % five_card
    #-->A test give player five card: ['AH', '5S', '9H', '2S', '9S']

if __name__ == '__main__':
    main()
snippsat 661 Master Poster

For log in use mechanize.
for parsing are beautifulSoup or lxml good choice.

import mechanize
browser = mechanize.Browser()
browser.open(your_url)
browser.select_form(nr=0) #Check form name nr=0 work for many
browser['username'] = "xxxxx"
browser['password'] = "xxxxx"
response = browser.submit()
html = response.read()
print html
snippsat 661 Master Poster

One way to make a deck,that is ok to understand.
@askrabal remember that import statement shall never be inside a class or function.
Import statement shall alway be on top.

rank = 'A23456789TJQK'
suit = 'CDHS'

deck = []
for r in list(rank):
    for s in list(suit):
        card = r + s
        deck.append(card)

print deck

One with list comprehension.

deck = [rank + suit for rank in "A23456789TJQK" for suit in "CDHS"]
print deck

Shuffle deck and deal some card.

>>> from random import shuffle
>>> #Shuffle deck
>>> shuffle(deck)
>>> #Deal out 5 card
>>> [deck.pop() for k in range(5)]
['7S', 'TC', 'TD', '8C', 'QS']
snippsat 661 Master Poster

Look into dictionary.
Example Banana is the key and price is the value.
So if you call key you get price.

Here is a code example you can look.
This code will run in a loop given bye argument number given to function.
And save result to a dictionary,that you can use later.

def question(times=None):
    '''Dok string some info about code'''
    grocery_ditch = {}
    print 'Enter grocery item and price'
    for i in range(times):
        key = raw_input('item %d' % int(i+1))
        value = int(raw_input('price'))
        grocery_ditch[key] = value
    print grocery_ditch  #Or use return to get result out of function

question(3)
snippsat 661 Master Poster

griswolf soultion is ok.
You should not get error whit code i fixed over.

Testrun.

>>> 
enter 1 for sin, 2 for cos, 3 for tan1
Type in angle value: 35
0.573576436351
 
enter 1 for sin, 2 for cos, 3 for tan3
Type in angle value: 45
1.0
>>>
snippsat 661 Master Poster

You can do that in IDLE(python shell),you most du that in cmd(windows) or terminal(linux)
If you shall run code in IDLE you have to import it.

Or when in IDLE file->new window(write code) or open code(..py)
Save and run it with F5.
Or as most off do use and editor when running code pyscripter is good for windows or SPE(for linux)

Example.

#save as hello.py,just save it in python27 folder
def foo(your_name=None):
    return 'Hello world from %s' % your_name

my_name = 'Mical'
print foo(my_name)

Run it from cmd
C:\python27>python hello.py
Hello world from Mical

You can import hello.py py in IDLE and use it as an module.

>>> import hello
Hello world from Mical
>>> dir(hello)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'foo', 'my_name']

>>> hello.foo
<function foo at 0x02A950F0>  #Just show an memory adress
>>> hello.foo()               #Use it with no argument
'Hello world from None'
>>> my_name = 'Tom'
>>> hello.foo(my_name)        #Give it and argument
'Hello world from Tom'
>>>
snippsat 661 Master Poster

1. I need to convert string to integer

>>> a = '5'
>>> type(a)
<type 'str'>
>>> a
'5'
>>> b = int(a)
>>> type(b)
<type 'int'>
>>> b
5

>>> a = raw_input()
5
>>> type(a)
<type 'str'>
>>> a = int(raw_input())
5
>>> type(a)
<type 'int'>
>>>

I was planning on doing sin instead of 1, cos instead of 2, etc. Possible?

a = raw_input("Enter sin,cos for calulate ")
if a == 'sin':
    #do something
    #and you should have a else statement
else:
    print 'Input not correct'

3. Why does the print lines result in a syntax error?

Do you use python 2.7(advisable)
If python 3.x print has become a function so use print (tan)

snippsat 661 Master Poster
from __future__ import division
from math import sin
from math import cos
from math import tan
from math import radians
a = raw_input("enter 1 for sin, 2 for cos, 3 for tan")
if a == '1':  #most be string when compare(raw_input return string)
    degree1 = int(raw_input("Type in angle value: "))  #missing )
    radian_1 = radians(degree1)  #degree1
    sin = sin(radian_1)
    print sin
elif a == '2':
    degree2 = int(raw_input("Type in angle value: "))  #missing )
    radian_2 = radians(degree2)
    cos = cos(radian_2)
    print cos
elif a == '3':
    degree3 = int(raw_input("Type in angle value: "))  #missing )
    radian_3 = radians(degree3)
    tan = tan(radian_3)
    print tan
snippsat 661 Master Poster

Byte of python has also a python 3.x.
The best advice is to stay with 2.7 for now,and later switch to python 3.
Most pepole stay with python 2.x,because off many famous 3.party moduls has to be rewritten.
There are many books tutorials that are really good for beginner and the are most in python 2.x.
Dont worry when you learn python 2.x you also learn python 3.x
That you will understad later,and python 3.x is the future(but not quite yet)

snippsat 661 Master Poster
>>> 1.0 - 2.718281828**(-(23.0**2)/730)
0.5155095380022271
>>> #Or import division from future
>>> from __future__ import division
>>> 1.0 - 2.718281828**(-(23**2)/730)
0.5155095380022271
>>>

http://www.ferg.org/projects/python_gotchas.html

snippsat 661 Master Poster

Bent slayer_Slayer you are missing number combination in your code.
Here a test with range(10, 20) and number 60.
range(10, 75) will but my code down.
Example off one miss.

>>> sum([12, 14, 16, 18])
60
>>>
def subsets_i(s):
    subsets = []
    n_elems = len(s)
    n_subsets = 2**len(s)
    for i in range(0,n_subsets):
        sub = []
        for j in range(0,n_elems):
            if (i >> j & 1):
                sub.append(s[j])
        subsets.append(sub)
    return subsets

def compare_sum(n ,l):
    '''
    Take argument integer(n) and list(l)
    Compare if sum off any number in list(l)
    Are equal to integer(n)
    '''
    count = 0
    for i in l:
        if sum(i) == n:
            count += 1
            print i
    print 'There are %s number combination in my_list that sums upp to %d' % (count, n)

if __name__ == '__main__':   
    my_list = range(10, 20)
    my_number = 60

    sub_l = subsets_i(my_list)
    compare_sum(my_number, sub_l)

'''Out-->
[10, 11, 12, 13, 14]
[13, 14, 16, 17]
[12, 15, 16, 17]
[13, 14, 15, 18]
[12, 14, 16, 18]
[11, 15, 16, 18]
[12, 13, 17, 18]
[11, 14, 17, 18]
[10, 15, 17, 18]
[12, 14, 15, 19]
[12, 13, 16, 19]
[11, 14, 16, 19]
[10, 15, 16, 19]
[11, 13, 17, 19]
[10, 14, 17, 19]
[11, 12, 18, 19]
[10, 13, 18, 19]
There are 17 number combination in my_list that sums upp to 60
'''
#list1 = [1, 5, 3, 9, 4, 2, 7, 8]

list1 = range(10, 20)
int1 = 60

print 'List:', ', '.join([str(i) for …
snippsat 661 Master Poster

Well, it's not meant to be passed a list, it's meant to be passed an array which is converted to a list using tolist.

When we take about array in python we mean list.
my_array = [1,2,3]
my_list = [1,2,3]
Is both ok.
Make a list or in other languages is called array.
There are and not so much used array module in python(import array)

Something like this,not quite finish need off couse else clause if no match found.

def subsets_i(s):
    subsets = []
    n_elems = len(s)
    n_subsets = 2**len(s)
    for i in range(0,n_subsets):
        sub = []
        for j in range(0,n_elems):
            if (i >> j & 1):
                sub.append(s[j])
        subsets.append(sub)
    return subsets

def compare_sum(n ,l):
    '''
    Take argument integer(n) and subset_list(l)
    Compare if sum off any number in list(l)
    Are equal to integer(n)
    '''
    count = 0
    for i in l:
        if sum(i) == n:
            count += 1
    print 'There are %s number combination in my_list that sums upp to %d' % (count, n)

if __name__ == '__main__':
    my_list = [1, 5, 3, 9, 4]
    my_number = 8
    sub_l = subsets_i(my_list)
    compare_sum(my_number, sub_l)

'''Out-->
There are 2 number combination in my_list that sums upp to 8
'''
snippsat 661 Master Poster

The problem is - in "gui"window of gui2exe the locations for python modules does not accept the given modules separated by commas
i.e.(tkinter,zipfile,fnmatch...)
Is this the right technique ?

You dont use comma in gui2exe,if you want to include/exclude moduls push add button and write the name.
Then it will be put in a list in the setup script.
So if you want to add tkinter push add button and write name.
Then push add button and new name...and so on.

snippsat 661 Master Poster

NewbieXcellence import statement shall never be inside a function always on top.
And the script dont work,where come tolist() from your_array.tolist()

Get this errormessage.
This is when you give function a number and a list one_way(5, [1,5,4])
exceptions.AttributeError: 'list' object has no attribute 'tolist'

*can't find the delete post button*

You can not delete post,think off it all question can help other pepole to learn.
It you delete it,you delete answer you got to.
That had been no good.

list(set(my_list))

>>> l = ['my', 'car', 'is', 'black', 'black', 'black']
>>> set(l)
set(['black', 'car', 'is', 'my'])
>>> #set remove equal elements in a list
>>> list(set(l))
['car', 'is', 'my', 'black']
>>> #This take set back to a list again,set and dictionary dont keep order off elements
snippsat 661 Master Poster

What is the general usage area of python? Maybe I can change my question.

Python are useful in many areas,read pytohn quotes
Whatever you want to do python has some excellent soltions in moste areas.

snippsat 661 Master Poster

is there fucntion like goto on C++

No,and i hope we never see goto it in python.
http://xkcd.com/292/

Edsger W.Dijkstra wrote this in 1968.
A Case against the GO TO Statement

snippsat 661 Master Poster

But once i try and use sample again it takes the string of the entire list

import random

def make_secret(numdigits):
    return map(str,(random.sample(xrange(10),numdigits)))

print make_secret(4)
#-->['4', '7', '0', '1'] #output elements will alway be unique
snippsat 661 Master Poster

It depends on whether or not rexona wants the elements of the list to be unique or if each number should be chosen randomly over the whole range.

Yes you are right,i think maybe randrange is more correct.
I dont see rexona mention unique elements,so maybe he ment to use randrange in first script.
Just some fun with a one liner.

>>> map(str,[randrange(0,10) for i in range(4)])
['9', '0', '1', '1']
>>>
snippsat 661 Master Poster

I havent tryed virtualenv,look like program much point to folder that you have to make.
Something like this.

mkvirtualenv PROJECTNAME

#Make a folder
mkdir -p program

add2virtualenv $(pwd)/program
snippsat 661 Master Poster

Like this is it can be done without exception handling.
Here it will loop until user enter a valid choice or quit.
User can type in everthing and it will not break out in a error.
Remeber raw_input() return a string for everthing that user input.

print 'Enter a choice | Q to quit'
while True:
    option = raw_input('What would you like to do?  ').lower()
    if option == '1':
        print '1 is you choice'
    elif option == '2':
        print '2 is you choice'
    elif option == 'q':
        break
    else:
        print 'Not a correct choose: %s,try again' % option

One to show exception handling,use int(raw_input()) is always better than input() for python 2.x
Python 3.x has only input(),that work in the same was as raw_input() in python 2.x
Try type in a letter here an it will not break out out in a error,we catch the error and give user a message.

try:
    option = int(raw_input('What would you like to do?  '))
except ValueError:
    print 'Please only numbers,try again'
snippsat 661 Master Poster

There are possible to use sample,can write something compact like this.

>>> from random import sample
>>> map(str,(sample(xrange(10),4)))
['1', '6', '2', '9']
>>>
snippsat 661 Master Poster
>>> tfile = open("text.txt", 'w')
>>> help(tfile)  

 |  write(...)
 |      write(str) -> None.  Write string str to file.
 |      
 |      Note that due to buffering, flush() or close() may be needed before
 |      the file on disk reflects the data written.

As you see write takes string as an argument,so if you try to put in an integer you get an error.
That error message is pretty clear first part TypeError: must be string,should be a good hint.
Beat_Slayer has the easy soultion to this.

snippsat 661 Master Poster

if the ID always is a number without -
If not change the regex.

import re

text = '''\
xxxxx(xxxxx);xxx=xxxx,ID=1234-xxxxxxx
(ID=4321),xxxxxxx/xxxxxxx-xxxxxxxxxxx
(ID=3802))(xxxxxx=(xxxxxx=xxx)(xxxxx=xxxxxxx)(ID=3802)))
'''

out_match = re.findall(r'ID=\d+', text)
print out_match
#-->['ID=1234', 'ID=4321', 'ID=3802', 'ID=3802']
snippsat 661 Master Poster

Look into Pygame Package Builder
In the link over there is link to gui2exe and cx_freeze you can try.

snippsat 661 Master Poster

self has an important role in a class,it like a transporter off data in a class.
You use self.discountinput in onAction() method.
Then off course it will not find anything if you not using self on what it`s looking for.
Here is a fix so wx.TextCtrl return data in to method onAction()

import wx

class CashTransaction(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self, None, title = "Cash Transaction",
                                                  size = (450, 470))

            mainpanel = wx.Panel(self)

            font = wx.Font(20, wx.SWISS, wx.NORMAL, wx.NORMAL, False, "Mangal")
            title = wx.StaticText(mainpanel, label = "Cash Transaction", style = wx.ALIGN_CENTRE)
            title.SetFont(font)

            titleholder = wx.BoxSizer()
            titleholder.Add(title, 1 , wx.EXPAND)
            mainpanel.SetSizer(titleholder)

            calcpanel = wx.Panel(self)


            self.btn_list = [
                
            "7", "8", "9",
            "4", "5", "6",
            "1", "2", "3",
            "0", ".", "BackSpace"
                            ]

            gsizer = wx.GridSizer(4, 3, 0, 0)

            self.btn = range(len(self.btn_list))
            for ix, b_label in enumerate(self.btn_list):
            
                id = 10 + ix
                self.btn[ix] = wx.Button(calcpanel, id, label=b_label, size=(-1, -1))
                
                gsizer.Add(self.btn[ix], 0, wx.ALL|wx.EXPAND)
                calcpanel.SetSizer(gsizer)


            infoandinputpanel = wx.Panel(self, style = wx.SUNKEN_BORDER)


            totalamount = 0.00


            font2 = wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False, "Mangal")

            totallabel = wx.StaticText(infoandinputpanel,
                            label = "Transaction Total\n""%s" %(totalamount))
            totallabel.SetFont(font2)

            discountlabel = wx.StaticText(infoandinputpanel, label = "Discount\n")
            discountlabel.SetFont(font2)
            
            
            self.discountinput = wx.TextCtrl(infoandinputpanel)  #**
            self.discountinput.Bind(wx.EVT_TEXT_ENTER, self.onAction) #**


            discspacer1 = wx.BoxSizer()
            discspacer2 = wx.BoxSizer()

            discsizer = wx.BoxSizer(wx.VERTICAL)
            discsizer.Add(discountlabel, 1)
            discsizer.Add(discspacer1, 1)
            discsizer.Add(self.discountinput, 1)  #**
            discsizer.Add(discspacer2, 1)

            paidlabel = wx.StaticText(infoandinputpanel,
                                      label = "Amount Recieved")
            paidlabel.SetFont(font2)
            
            paidinput = wx.TextCtrl(infoandinputpanel)          
            paidspacer1 = wx.BoxSizer()
            paidspacer2 = wx.BoxSizer()

            paidsizer = wx.BoxSizer(wx.VERTICAL)
            paidsizer.Add(paidlabel, 1)
            paidsizer.Add(paidspacer1, 1)
            paidsizer.Add(paidinput, 1)
            paidsizer.Add(paidspacer2, 1)

            changefigure = 1.29

            changelabel = wx.StaticText(infoandinputpanel, label = ("Change to give\n""%s" % (changefigure))) …
snippsat 661 Master Poster

Just some tips,you have to do something yourself.

This regex [A-Z]\w will match Hi and My.
---
Hi this is a test.
My car is red.
---

import string
>>> string.ascii_uppercase
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

#-------#
>>> for num in range(65, 91):
...     capLetter = chr(num)
...     print capLetter
...     
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
snippsat 661 Master Poster

Working for me with gui2exe,just remove tk from excludes.
Tkinter is is set to be excludes in gui2exe,because most off use wxpython or other gui toolkit.
For cx_freeze look at this post.
http://www.daniweb.com/forums/thread20774-25.html

Here is the exe i got out.
http://www.esnips.com/doc/8db198e1-5442-48b7-a810-79e7adbfa773/zip_e

snippsat 661 Master Poster

Now one will will code differential backups for you,and that is no point either
Because you learn little from it.

Start by moving and copying some files/folders around,like backup soultion most do.
Look into os module and shutil module
Some examples.

import shutil

#Copy a file from test folder temp folder
#shutil.move dos what name says
shutil.copy('c:\\test\my_file.txt', 'c:\\temp')

#-----------------#
import shutil

#Will copy content in folder test and make a new folder temp that have the same content
shutil.copytree('c:\\test', 'c:\\temp')
snippsat 661 Master Poster

Something like this.

def foo(num):
    ''' Return an exponential notation'''
    return '%e' % num

print foo(3000000000000000000000000)
#-->3.000000e+24
snippsat 661 Master Poster

Your first code was a big mess.

def triangle():
    totalRows = int(input("Please enter a number: "))
    for totalRow in range(1, totalRows):
        print '*' * (totalRow)
    for totalRow in range(totalRows, 0, -1):
        print '*' * (totalRow)

triangle()
snippsat 661 Master Poster

You have to install wxpython to get gui2exe to work.
http://www.wxpython.org/download.php#binaries

My script you run,you alone only change my_file.py to the name off your py file that you want to make exe off.
windows = [{"script": 'my_file.py'}])
Or
console = [{"script": 'my_file.py'}])

snippsat 661 Master Poster
from distutils.core import setup
import py2exe
import sys

if len(sys.argv) == 1:
    sys.argv.append("py2exe")

setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 3}},
       zipfile = None,
       
       ##data_files = ['apple.jpg', 'cheese.jpg'],
       
       #Can use windows or console,replace my_file.py with py file you want to make exe off.
       #If not run in same folder give path /mydir/my_file.py
       windows = [{"script": 'my_file.py'}])

Or use gui2exe

snippsat 661 Master Poster

Use Gui2exe
I talk a little of what tool i use her.
http://www.daniweb.com/forums/thread303665.html

snippsat 661 Master Poster

redyugi now you have 2 "int(raw_input" lines that do the same.

To simplify it.
The first function we dont give an argument,just retun value out.
Remember run this code as a script and not in python shell(IDLE)

def get_celsius():
    celsius = int(raw_input("Type in the Celsius temperature:" ))
    return celsius

def main(get_celsius):
    celsius = get_celsius()
    farenheit=(9.0/5.0)*celsius+32
    print "It is %s degrees outside.", farenheit

main(get_celsius)
snippsat 661 Master Poster

If you change Bent Slayer code,to this.
It will give you a list.

initial_date = '9/14/1990'
initial_month, initial_day, initial_year = initial_date.split('/')
final_date = '9/17/1990'
final_month, final_day, final_year = final_date.split('/')

f_in = open('test.csv').readlines()
#f_out = open('filtered_stations_temp.csv', 'w')

my_list = []
for i in range(1, len(f_in)):
    station, date, max_temp, min_temp = f_in[i].split(',')
    month, day, year = date.split('/')
    if initial_month <= month <= final_month and \
    initial_day <= day <= final_day and \
    initial_year <= year <= final_year:
        my_list.append(f_in[i].strip())

#f_out.close()
print my_list

Another way.

start_date = '9/14/1990'
end_date = '9/18/1990'

flag = 1
my_list = []
linelist = open('test.csv')
for line in linelist:
    if start_date in line: # or line.startswith('STATION') ## to get first line
        flag = 0
    if end_date in line:
        flag = 1
    if not flag and not end_date in line:
       #print line,
       my_list.append(line.strip())

print my_list
snippsat 661 Master Poster

indentations 4 space,is important in python.
If you have a good python editor it will auto indent.

import wx

class bucky(wx.Frame):

    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'Frame aka window', size=(400,300))
        panel=wx.Panel(self)

        status=self.CreateStatusBar()
        menubar=wx.MenuBar()
        first=wx.Menu()
        second=wx.Menu()
        first.Append(wx.NewId(),"new window")
        first.Append(wx.NewId(),"Open...")
        menubar.Append(first,"File")
        menubar.Append(second,"edit")
        self.SetMenuBar(menubar)

if __name__=='__main__':
    app=wx.PySimpleApp()
    Frame=bucky(parent=None, id=-1)
    Frame.Show()
    app.MainLoop()
vegaseat commented: excellent observation +12
snippsat 661 Master Poster

Does Python offer any way of extracting just the data between my two dates??

Yes more than one way depends how data are organized.

post an short example off that cvs file.
Mark where 'initialDay' and 'finalDay' are.

snippsat 661 Master Poster

I don't know how to package up BeautifulSoap so that my users don't have to download it...If you could tell me how to do that,

I have told you,it`s one file beautifulSoup.py
Put that file in the folder with xml files or python path.

#xml_parser.py
from bs import BeautifulSoup

xml = open('test.xml').read()
soup = BeautifulSoup(xml)
matches = soup.findAll('label')
for i,match in enumerate(matches):
    print i, match.text

'''Out-->
0 Hello!
1 Find me ok?
2 HI I'M RED-Y.
'''

Then you can call it whatevere you want,just as a test i called it bs.py
Now bs.py, test.xml, xml_parser.py are in same folder.
Then off course it use the renamed bs.py and not the orginal beautifulSoup in my python path.

>>> import bs
>>> dir(bs)
['BeautifulSOAP', 'BeautifulSoup', 'BeautifulStoneSoup', 'CData', 'Comment', 'DEFAULT_OUTPUT_ENCODING', 'Declaration', 'ICantBelieveItsBeautifulSoup', 'MinimalSoup', 'NavigableString', 'PageElement', 'ProcessingInstruction', 'ResultSet', 'RobustHTMLParser', 'RobustInsanelyWackAssHTMLParser', 'RobustWackAssHTMLParser', 'RobustXMLParser', 'SGMLParseError', 'SGMLParser', 'SimplifyingSOAPParser', 'SoupStrainer', 'StopParsing', 'Tag', 'UnicodeDammit', '__author__', '__builtins__', '__copyright__', '__doc__', '__file__', '__license__', '__name__', '__package__', '__version__', '_match_css_class', 'buildTagMap', 'chardet', 'codecs', 'generators', 'markupbase', 'name2codepoint', 're', 'sgmllib', 'types']
>>> bs.__version__
'3.0.8'
snippsat 661 Master Poster

You have typing error.
Special methods name always have to underscore __init__
special-method-names
Now it should work.

#!usr/bin/python
# Filename: objvar.py

class Robot:
    '''Represents a robot with a name.'''

    # A class variable, counting the number of robots
    population = 0

    def __init__(self, name):   #_init_ wrong __init__ correct
        '''Initializes the data.'''
        self.name = name
        print('(Initialzing {0})'. format(self.name))

        # When this person is created, the robot
        # adds to the population
        Robot.population += 1
    def __del__(self):  #_del_
        '''I am dying.'''
        print('{0} is being destroy!'. format(self.name))

        Robot.population -= 1

        if Robot.population == 0:
            print('{0} was the last one.'. format(self.name))
        else:
            print('There are still {0:d} robots working. '. format(Robot.population))

    def sayHi(self):
        '''Greeting by the robot.


        Yeah, they can do that.'''
        print('Greetings, my master call me {0}'. format(self.name))

    def howMany():
        '''Prints the current population.'''
        print('We have {0:d} robots.'. format(Robot.population))
    howMany = staticmethod(howMany)

droid1 = Robot('R2-D2')
droid1.sayHi()
Robot.howMany()

droid2 = Robot('C-3PO')
droid2.sayHi()  #Typing error
Robot.howMany()


print('\nRobots can do some work here.\n')

print('Robots have finished their work. So lets destroy them.')
del droid1
del droid2

Robot.howMany()
snippsat 661 Master Poster

Why not not try BeautifulSoup?

xml = '''
<Label> Hello!</Label>
<!-- The above label says Hello.
  -- It is clear, no?  Let's try spicing it up a bit.
  -- Add some color to it.
-->

#Test
<!--
--Test
-->
<---->
--
<Label>Find me ok?</Label>
<-->
>--<
<-->
------
<Label color="#FF0000">HI I'M RED-Y.</Label>
'''

from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(xml)
matches = soup.findAll('label')
for i,match in enumerate(matches):
    print i, match.text

'''Out-->
0 Hello!
1 Find me ok?
2 HI I'M RED-Y.
'''
snippsat 661 Master Poster

It`s about same size,i guess you are talking about packed so it can run as an standalone application.
PyQt is 3-4 mb larger for standalone application.

I have got size down on wxpython quite a lot.
Gui2exe(compressed: 2, optimize: 2 bundle_files: 3)
Delete unnecessary files,so run UPX
Last run Inno setup
For my translate program py-trans(using api off google translate)
Size of setup.exe(one file for windows install) was 3.8mb.
Unpack litte over 5mb.

This is better than uncompressed/unoptimize wxpython that can be 15-20 mb large.