Re: [Tutor] encrypt a file in Python3
On Sat, Nov 10, 2012 at 12:54 AM, wrote: > > I want to encrypt a file, then decrypt it. I prefer to do it without adding > any > packages. > > $ uname -a > Linux laptop 3.2.0-32-generic-pae #51-Ubuntu SMP You'll either need to install the package "python3-crypto" or compile it yourself. To build it locally, you'll need to setup your build environment. The packages build-essential, python3-dev, python3-setuptools, and libgmp-dev should suffice. Once everything is setup, simply run the following: sudo easy_install3 --verbose pycrypto On My Debian system it installs to /usr/local/lib/python3.2/dist-packages/. You can also run the self tests: >>> import sys >>> import Crypto.SelfTest >>> Crypto.SelfTest.run(verbosity=1, stream=sys.stdout) For me it ran 1078 tests (one dot per test). ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python books
On 10/11/12 01:18, Ed Owens wrote: Please start new threads with a fresh mail. On threaded readers this gets lost under a previous topic called "Question"... > Dawson, which is too plodding. Can you experts recommend a Python library? I would like to have: A command reference for the basic library. O'Reilly's Nutshell book or the Pocket Reference or Beasleys "Essential Reference". But mostly I just use the built in help() system... A comprehensive "How to" course for the basic library. There is a best practice Python 'Recipes' book, but there is a much bigger resource on ActiveState's site. Graphics in Python Depends on the tookit. For GUIs there are books on Tkinter, wxPython, PyQt and (I think) pyGTk. There are more general books on things like R and GNU plot. Theres also pygame and things like OpenGL. It all depends on what kind of graphics and your favoured toolkit. Too hard to recommend anything specific. Data Management in Python I don't know of anything specific although a lot of the general tutorials include a chapter on the Python DBI interface. But the biggest thing here is learning SQL... Using the internet with Python Python Network Programming by Goerzen. (maybe Real Time(ish) Python) Don't know of anything here. The (ish) is the killer, you can't really do too much hard real-time in Python... A comprehensive "Learn Python" course that puts all this together I would have recommended Python -How to Program by the Deitels but I don't know if its been updated so is now quite old. If you can pick up a cheap second hand copy its a good broad top level intro to all of the topics above. Its the only one I've seen that covers everything in your list except real-time. But it was very expensive. That's my list :-) Of course I cover most of it in my online tutorial too. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python books
The "Head First..." series of books (O'Reilly Press) adopts a wonderful, intuitive "work-along" format; of particular interest [to you] would be "Head First Python" by Paul Barry. From the virtual desk of Lowell Tackett From: Ed Owens To: tutor@python.org Sent: Friday, November 9, 2012 8:18 PM Subject: [Tutor] Python books I've been trying to learn Python, writing a Blackjack program. Seems that's a common problem for learning. I'm not in a class or school, just working on my own. I've been working in Python 2.7, and considering moving up to 3.x. My programming background is ancient, having done most of my programming in FORTRAN. I have been using free internet resources to learn, mostly Google searches on syntax, and their free courses. I have the basic game done: dealing from a shoe of multiple decks, splits, betting, etc. and started to work on the harder parts such as graphics of the table with cards, managing record keeping, and so on. There seem to be a plethora of packages and options, many of them outside of the "standard" Python installation. Plus, I'm still discovering how to do things with the standard library. I need more structure and organization! I have one book, "Python Programming for the Absolute Beginner" by Dawson, which is too plodding. Can you experts recommend a Python library? I would like to have: A command reference for the basic library. A comprehensive "How to" course for the basic library. Graphics in Python Data Management in Python Using the internet with Python (maybe Real Time(ish) Python) A comprehensive "Learn Python" course that puts all this together I realize that this is outside of the "help with this code" request, but I would value your advice. Ed O ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python books
Hi, On Nov 9, 2012, at 11:13 PM, wesley chun wrote: > there is no one single book that has all you're seeking, however you can > probably find one or two that may suit your fancy in these Python reading > lists that i made earlier this year: http://goo.gl/i4u0R > > note that the 3rd set of books are some of the references that you're seeking. > > best of luck! > --wesley > > > On Fri, Nov 9, 2012 at 5:18 PM, Ed Owens wrote: >> I've been trying to learn Python, writing a Blackjack program. Seems that's >> a common problem for learning. I'm not in a class or school, just working >> on my own. I've been working in Python 2.7, and considering moving up to >> 3.x. My programming background is ancient, having done most of my >> programming in FORTRAN. I have been using free internet resources to learn, >> mostly Google searches on syntax, and their free courses. >> >> I have the basic game done: dealing from a shoe of multiple decks, splits, >> betting, etc. and started to work on the harder parts such as graphics of >> the table with cards, managing record keeping, and so on. There seem to be >> a plethora of packages and options, many of them outside of the "standard" >> Python installation. Plus, I'm still discovering how to do things with the >> standard library. I need more structure and organization! >> >> I have one book, "Python Programming for the Absolute Beginner" by Dawson, >> which is too plodding. Can you experts recommend a Python library? I would >> like to have: >> >> A command reference for the basic library. >> A comprehensive "How to" course for the basic library. >> Graphics in Python >> Data Management in Python >> Using the internet with Python >> (maybe Real Time(ish) Python) >> A comprehensive "Learn Python" course that puts all this together >> >> I realize that this is outside of the "help with this code" request, but I >> would value your advice. >> >> Ed O First book I highly recommend Learn Python the Hard Way http://learnpythonthehardway.org/ It's a great book which will get you going with python. It also has video companion which could come handy since you are learning on your own. Next book I would look at is Core Python Programming http://www.amazon.com/Core-Python-Programming-2nd-Edition/dp/0132269937/ref=sr_1_1?ie=UTF8&qid=1352566105&sr=8-1&keywords=Core+python+programming I used the first edition and I liked how it covers a lot of areas of python and most of what's on your list. Good luck with your study and have fun doing it Laszlo >> >> >> ___ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> http://mail.python.org/mailman/listinfo/tutor > > > > -- > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > "A computer never does what you want... only what you tell it." > +wesley chun : wescpy at gmail : @wescpy > Python training & consulting : http://CyberwebConsulting.com > "Core Python" books : http://CorePython.com > Python blog: http://wescpy.blogspot.com > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] encrypt a file in Python3
Thank you Mark and eryksun! You've put me back on the road to success! I'll start saving up for your bill. :-) Ken ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] encrypt a file in Python3
On 10/11/2012 19:23, ke...@kendy.org wrote: Thank you Mark and eryksun! You've put me back on the road to success! I'll start saving up for your bill. :-) Ken ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor Please ensure that all funds are sent directly to me. Let's face it apart from ... what does erkysun know about Python? -- Cheers. Mark Lawrence. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python Project
Hello Tutor, My name is darren and I'm new to this python subject but I'm a quick and persistent learner. I'm trying to do a presentation with rst2Reveal using html5 and to tell you the truth it's not that simple. So far I wrote the rst file and there is a rst2Reveal webpage with all the needed docs. [https://bitbucket.org/adimascio/rst2reveal/src] My problem is that I don't know what to do first. I'm using python 2.7. I have my repo on bitbucket. I have the images I want to use. I have my rst file. I need to know the steps I need to do to get this presentation up and running. I even started my python script??? I think??? #!c:/Python27/python.exe def main(): print "Content-type: text/html" print print "" print "Scrum Presentation" print "" print "Hello World" print "" #?? if _name_=="_main_":.0 Any way, I think this is all that I have as now. I've search the web and got lots of info. But still there is the fact that I need to know the steps exactly for me to finish this . Or at leat get the web page up and running. Any andall help will be appreciated. Sincerely, Darren Swinson project.rst Description: Binary data ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Project
On 11/11/12 01:24, darren swinson wrote: My name is darren and I'm new to this python subject but I'm a quick and persistent learner. Wekcome to the list, however... I'm trying to do a presentation with rst2Reveal using html5 Ok, I have no idea what that means. Its not standard Python so you are probably going to have to give us a bit of a clue or ask questions on a forum aimed at rst2Reveal... My problem is that I don't know what to do first. Nor me. To write a Python program you write python code in a file. But how that fits with your rst files I have no idea. I need to know the steps I need to do to get this presentation up and running. I even started my python script??? I think??? #!c:/Python27/python.exe def main(): print "Content-type: text/html" print print "" print "Scrum Presentation" print "" print "Hello World" print "" #?? if _name_=="_main_":.0 The only bit of help I can offer is that there should be two underscores on each side of name and main: if __name__=="__main__":.0 What the . does I have no idea. If you are using something outside of standard Python you can't expect us to know about it, you need to explain what you are doing first. Or at leat get the web page up and running. Any andall help will be appreciated. I suspect you need help somewhere else before getting to the point where this list can help. Unless you get lucky and somebody on the list does actually use the same framework - or is prepared to do the research for you. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Parsing a multi-line/record text file
Hello, I am trying to parse a text file with a structure that looks like: [record: Some text about the record] Attribute 1 = Attribute 1 text Attribute 3 = Attribute 3 text Attribute 4 = Attribute 4 text Attribute 7 = Attribute 7 text [record: Some text about the record] Attribute 1 = Attribute 1 text Attribute 2 = Attribute 2 text Attribute 3 = Attribute 3 text Attribute 4 = Attribute 4 text Attribute 5 = Attribute 5 text Attribute 6 = Attribute 6 text [record: Some text about the record] Attribute 2 = Attribute 2 text Attribute 3 = Attribute 3 text Attribute 7 = Attribute 7 text Attribute 8 = Attribute 8 text Etc.for many hundreds of records I am looking to create output that looks like: Attribute 1 text | Attribute 3 text Attribute 1 text | Attribute 3 text Blank | Attribute 3 text Treating each record as a record with its associated lines is the holy grail for which I am searching, yet I seem to only be coming up with dead parrots. It should be simple, but the answer is eluding me and Google has not been helpful. Pathetic thing is that I do this with Python and XML all the time, but I can't seem to figure out a simple text file. I 'm missing something simple, I'm sure. Here's the most I have gotten to work (poorly) so far - it gets me the correct data, but not in the correct format because the file is being handled sequentially, not by record - it's not even close, but I thought I'd include it here: for line in infile: while line != '\n': Attribute1 = 'Blank' Attribute3 = 'Blank' line = line.lstrip('\t') line = line.rstrip('\n') LineElements = line.split('=') if LineElements[0] == 'Attribute1 ': Attribute1=LineElements[1] if LineElements[0] == 'Attribute3 ': Attribute3=LineElements[1] print("%s | %s\n" % (Attribute1, Attribute3)) Is there a library or example I could be looking at for this? I use lxml for xml, but I don't think it will work for this - at least the way I tried did not. Thank you, Marc ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Parsing a multi-line/record text file
On 11/11/2012 12:01 AM, Marc wrote: > Hello, > > I am trying to parse a text file with a structure that looks like: > > [record: Some text about the record] So the record delimiter starts with a left bracket, in first column? And all lines within the record are indented? Use this fact. > Attribute 1 = Attribute 1 text > Attribute 3 = Attribute 3 text > Attribute 4 = Attribute 4 text > Attribute 7 = Attribute 7 text > > [record: Some text about the record] > Attribute 1 = Attribute 1 text > Attribute 2 = Attribute 2 text > Attribute 3 = Attribute 3 text > Attribute 4 = Attribute 4 text > Attribute 5 = Attribute 5 text > Attribute 6 = Attribute 6 text > > [record: Some text about the record] > Attribute 2 = Attribute 2 text > Attribute 3 = Attribute 3 text > Attribute 7 = Attribute 7 text > Attribute 8 = Attribute 8 text > > Etc.for many hundreds of records > > I am looking to create output that looks like: > > Attribute 1 text | Attribute 3 text > Attribute 1 text | Attribute 3 text > Blank | Attribute 3 text > > Treating each record as a record with its associated lines is the holy grail > for which I am searching, yet I seem to only be coming up with dead parrots. > It should be simple, but the answer is eluding me and Google has not been > helpful. > > Pathetic thing is that I do this with Python and XML all the time, but I > can't seem to figure out a simple text file. I 'm missing something simple, > I'm sure. Here's the most I have gotten to work (poorly) so far - it gets > me the correct data, but not in the correct format because the file is being > handled sequentially, not by record - it's not even close, but I thought I'd > include it here: > > for line in infile: > while line != '\n': >Attribute1 = 'Blank' >Attribute3 = 'Blank' >line = line.lstrip('\t') >line = line.rstrip('\n') >LineElements = line.split('=') > if LineElements[0] == 'Attribute1 ': > Attribute1=LineElements[1] > if LineElements[0] == 'Attribute3 ': > Attribute3=LineElements[1] >print("%s | %s\n" % (Attribute1, Attribute3)) > > Is there a library or example I could be looking at for this? I use lxml > for xml, but I don't think it will work for this - at least the way I tried > did not. I don't think any existing library will fit your format, unless you happen to be very lucky. What you probably want is to write a generator function that gives you a record at a time. It'll take a file object (infile) and it'll yield a list of lines. Then your main loop would be something like: for record in records(infile): attrib1 = attrib2 = "" for line in record: line = strip(line) line_elements = line.split("=") etc. here you print out the attrib1/2 as appropriate I'll leave you to write the records() generator. But the next() method will probably play a part. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor