Re: WANT: bad code in python (for refactoring example)
There are some nice changes in here. You can mention to the students that I really appreciated the work done on the menu loop. You took an example of code that had grown piecemeal and become reasonably unmaintainable, and refactored it to be very maintainable in the future. Good luck to all class participants! On Fri, Feb 17, 2017 at 3:47 PM, Makoto Kuwata wrote: > On Thu, Feb 16, 2017 at 6:34 AM, Dotan Cohen wrote: > >> I think that we can help each other! This is my own code, back when I >> was writing Python like PHP: >> https://github.com/dotancohen/burton > > > Year, this is a good example code for me to do refactoring. > > I created a pull request. This will be shown to my students. > > https://github.com/dotancohen/burton/pull/20/files > > I hope you favor this PR. > > -- > regards, > makoto kuwata > -- > https://mail.python.org/mailman/listinfo/python-list -- Dotan Cohen http://gibberish.co.il http://what-is-what.com -- https://mail.python.org/mailman/listinfo/python-list
Python application launcher (for Python code)
I could probably write this myself, but I'm wondering if this hasn't already been done many times. Anyone have some git links or other places to download from? -- https://mail.python.org/mailman/listinfo/python-list
Re: print odd numbers of lines from tekst WITHOUT space between lines
On Saturday, February 18, 2017 at 6:03:37 PM UTC, Wildman wrote: > On Sat, 18 Feb 2017 09:38:32 -0800, TTaglo wrote: > > > i = 1 > > f = open ('rosalind_ini5(1).txt') > > for line in f.readlines(): > > if i % 2 == 0: > > print line > > i += 1 > > > > > > How do i get output without breaks between the lines? > > > > Result: > > > > Other things just make you swear and curse > > > > When you're chewing on life's gristle, don't grumble give a whistle > > > > This will help things turn out for the best > > > > Always look on the bright side of life > > In Python 3 you can do this: > > print(line, end="") > > For Python 2 use this: > > import sys > . > . > . > sys.stdout.write(line) > > Don' forget... > f.close() > > -- > GNU/Linux user #557453 > The cow died so I don't need your bull! For Python 2, strictly from memory:- from __future__ import print_function print(line, end="") Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
Noob confused by ConfigParser defaults
I am trying to use ConfigParser for the first time (while also writing my first quasi-serious Python program). Assume that I want to parse a a configuration file of the following form: [section-1] option-1 = value1 option-2 = value2 [section-2] option-1 = value3 option-2 = value4 How do a set a default for option-1 *only* in section-1? -- Ian Pilcher arequip...@gmail.com "I grew up before Mark Zuckerberg invented friendship" -- https://mail.python.org/mailman/listinfo/python-list
Re: Python application launcher (for Python code)
"Deborah Swanson" writes: > I could probably write this myself, but I'm wondering if this hasn't > already been done many times. Can you describe what you are looking for, in enough detail that we can know whether it's already been done as you want it? -- \ “God forbid that any book should be banned. The practice is as | `\ indefensible as infanticide.” —Dame Rebecca West | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Noob confused by ConfigParser defaults
Ian Pilcher writes: > How do a set a default for option-1 *only* in section-1? I think you misinderstand the semantics of what ‘configparser’ expects https://docs.python.org/3/library/configparser.html#configparser-objects>: Default values […] are used in interpolation if an option used is not defined elsewhere. When default_section is given, it specifies the name for the special section holding default values for other sections and interpolation purposes (normally named "DEFAULT"). The default values are a special pseudo-section that holds defaults for the named options *anywhere else* in the configuration. It's not done per-section, it's done for the entire configuration input. This is IIUC because of the long-standing semantics of the format that inspired the ConfigParser behaviour. -- \ “Software patents provide one more means of controlling access | `\ to information. They are the tool of choice for the internet | _o__) highwayman.” —Anthony Taylor | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list