Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #22250

RE: Advise of programming one of my first programs

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ramit.prasad@jpmorgan.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'python,': 0.02; 'else:': 0.04; 'elif': 0.05; 'completeness': 0.07; 'print': 0.15; 'to:name :python-list@python.org': 0.15; 'currencies': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'dose': 0.16; 'eval': 0.16; 'from:addr:jpmorgan.com': 0.16; 'quoted': 0.16; 'received:155.180': 0.16; 'received:159': 0.16; 'received:159.53': 0.16; 'received:159.53.110': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'subject:programming': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'val': 0.16; 'val,': 0.16; 'accuracy': 0.18; 'later': 0.18; 'changes': 0.19; 'def': 0.20; 'passed': 0.20; 'received:169.254': 0.20; 'function': 0.22; 'header:In-Reply-To:1': 0.22; 'chapter': 0.23; 'received:169': 0.27; 'somewhere': 0.27; 'second': 0.28; 'post': 0.28; 'arguments': 0.29; 'received:155': 0.29; 'code': 0.29; 'maybe': 0.31; 'phone:': 0.31; 'rest': 0.32; 'basic': 0.33; 'in.': 0.33; 'thanks': 0.34; 'url:python': 0.34; 'probably': 0.34; 'reading': 0.34; "skip:' 10": 0.35; 'version': 0.36; 'why': 0.36; 'done': 0.36; 'sure': 0.36; 'text': 0.36; 'but': 0.36; 'url:org': 0.36; 'thank': 0.37; 'list': 0.37; 'mind': 0.38; 'david': 0.39; 'being': 0.39; 'doing': 0.39; 'to:addr:python-list': 0.39; 'either': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'mail': 0.61; 'learning': 0.61; 'forward': 0.62; 'back': 0.63; 'more': 0.63; 'dont': 0.64; 'information,': 0.65; 'giving': 0.66; 'reply': 0.66; 'here': 0.66; 'url:5': 0.67; 'purchase': 0.67; 'subject': 0.70; 'investment': 0.71; 'legal': 0.73; 'saw': 0.74; 'bank': 0.74; 'sale': 0.75; 'below.': 0.78; 'loop': 0.79; '712': 0.84; 'don`t': 0.84; 'houston,': 0.84; 'received:169.254.8': 0.84; 'true:': 0.84; 'url:release': 0.84; 'from.': 0.91; 'edition': 0.97
X-DKIM OpenDKIM Filter v2.1.3 sj1.jpmchase.com q2RFWsdH013632
DKIM-Signature v=1; a=rsa-sha256; c=simple/simple; d=jpmorgan.com; s=smtpout; t=1332862374; bh=bGKuBkxdOUf9KPYSAZFvqAH5/gFI77vd17mLV5cVaPQ=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=Mn50N5N7+4/cY7XPTPLKJXdMv1CF+bkydOhdidLDa5ZHzxCMVpImzL9Hq0dN5nKkh DK/xTWWqtRvMrW1HkIR/R4TZWvgdBpjwli6+rzdjRvgM+YuklN8ul8GnANkmN+BVoi VPAZo34bsal1orKbJI8Vq1avVJlGD6nfhpEQ1leI=
From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
To "python-list@python.org" <python-list@python.org>
Subject RE: Advise of programming one of my first programs
Thread-Topic Advise of programming one of my first programs
Thread-Index AQHNC5r4MvUwEx1tfEGrnSkYZViDo5Z9Ix/AgAFcCQD//8DxYA==
Date Tue, 27 Mar 2012 15:32:39 +0000
References <CAKhY55OL1qvq+kqbyKT8gEuFOK4BkgYGZkkyUVb84_H9VVEQhA@mail.gmail.com> <5B80DD153D7D744689F57F4FB69AF4740928C365@SCACMX008.exchad.jpmchase.net> <CAKhY55O9zE_jxF5PvzOF0DGifRT2gZLbRHiuQ_a1vA-aGGDb9g@mail.gmail.com>
In-Reply-To <CAKhY55O9zE_jxF5PvzOF0DGifRT2gZLbRHiuQ_a1vA-aGGDb9g@mail.gmail.com>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.67.79.38]
Content-Transfer-Encoding base64
MIME-Version 1.0
X-DLP-FWD Yes
Content-Type text/plain; charset="utf-8"
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1045.1332862379.3037.python-list@python.org> (permalink)
Lines 47
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332862379 news.xs4all.nl 6865 [2001:888:2000:d::a6]:40150
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:22250

Show key headers only | View raw


It is considered polite to post your reply either after the quoted text
or interspersed as I have done below.

> By the way I dont know why your mail was in my junk I just saw it.

Probably because I only reply back to the list and let the list 
forward to you.

> And here is my last code I did for the phonebook:
> Thanks
> 
> ####### CODE #########
> fileread = open('myfile.txt','r')
> tbook = eval(fileread.read())
> fileread.close()

The use of eval is dangerous if you are not *completely* sure what is 
being passed in. Try using pickle instead: 
http://docs.python.org/release/2.5.2/lib/pickle-example.html 


> Thank you Ramit for your advice`s. I`m reading a book ( Learning Python,
> Second Edition ) by Mark Lutz and David Ascher and now I just finished the
> Basic Function lesson :) I will keep in mind what you have advised me, but
> will implement it later when I have more experience with the book, because
> I don`t understand exactly what you mean by doing all dose changes :)

Maybe I can help you more by giving you a somewhere to build from. Try
building the rest of the program given the new version of listpb below.
You will need to read the chapter on Function Arguments (chapter 18?).

 def listpb():
     tbook = load_book()
     print '_' *45, ' Phonebook ', '_' *45,'\n\n\n'
     print 'Nick\t\tF.Name\t\tL.Name\t\tCity\t\t\tRegion\t\tTel'
     print '_' * 105,'\n','\t' * 13
     for val in tbook.keys():
             print val, '\t\t', tbook[val][0], '\t', tbook[val][1], '\t',
 tbook[val][2], '\t\t', tbook[val][3], '\t\t', tbook[val][4],'\t\t\n'
     print '_'*105,'\n\n'
     while True:
          choice = get_menu_choice()
          if choice == 'e' or choice == 'E':
               book = get_book_to_edit()
               edit( tbook, book )
          elif choice == 'd' or choice == 'D':
               book = get_book_to_edit()
               details( tbook, book )
          elif choice =='Q' or choice == 'q':
               break # end loop to exit program
          else:
               print 'Selection {0} not understood.'.format( choice ) 

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: Advise of programming one of my first programs "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-27 15:32 +0000

csiph-web