Re: connect four (game)

2017-11-25 Thread Christopher Reimer
On Nov 25, 2017, at 9:16 AM, Ian Kelly wrote: > >> On Sat, Nov 25, 2017 at 10:02 AM, Chris Angelico wrote: >>> On Sun, Nov 26, 2017 at 3:36 AM, Ian Kelly wrote: On Sat, Nov 25, 2017 at 6:00 AM, bartc wrote:

Re: How to Generate dynamic HTML Report using Python

2017-11-21 Thread Christopher Reimer
On Nov 21, 2017, at 5:36 AM, Rustom Mody wrote: > >> On Tuesday, November 21, 2017 at 5:27:42 PM UTC+5:30, Ned Batchelder wrote: >>> On 11/20/17 9:50 AM, Stefan Ram wrote: >>> Ned Batchelder writes: Also, why set headers that prevent the Python-List mailing list from

Re: converting numbers into words (Posting On Python-List Prohibited)

2017-11-09 Thread Christopher Reimer
On Nov 9, 2017, at 3:45 AM, John Ladasky wrote: > >> On Wednesday, November 8, 2017 at 11:40:18 PM UTC-8, Lawrence D’Oliveiro >> wrote: >>> On Thursday, November 9, 2017 at 7:51:35 PM UTC+13, r16...@rguktrkv.ac.in >>> wrote: >>> >>> How can I covert numbers into

Keep or drop index.html from Django?

2017-10-28 Thread Christopher Reimer
Greetings, When I set up my static website using Pelican several years ago, many URLs ended with index.html. Now that I'm looking at Django, I got a small set of URLs working with and without index.html to point to the correct pages. I read somewhere that the Django philosophy was to keep the

Re: Python noob having a little trouble with strings

2017-10-27 Thread Christopher Reimer
On Oct 27, 2017, at 1:49 AM, Peter J. Holzer wrote: > > BTW, I find it hard to believe that PyCharm for the Mac "comes with" > Python 2.6. Python 2.6 is quite old. The Linux version isn't bundled > with a python interpreter and just uses whatever is already installed on > the

Re: Application and package of the same name

2017-10-21 Thread Christopher Reimer
On Oct 21, 2017, at 6:08 AM, David Stanek wrote: > This is actually a common pattern I see when teaching the language. For > example, when a student wants to test out a package like requests many > seem to initially want to create a requests.py module. Then they become >

Can't find latest version of 3.4.x on download page

2017-10-18 Thread Christopher Reimer
Greetings, I'm setting up different test environments for tox. I can't find Windows installer for the latest version of Python 3.4 on the download page. Versions 3.4.5 to 3.4.7 only have the source files available. Version 3.4.4 is the last version with Windows installers. Testing on Python

Re: Best practise for passing time as arguments

2017-10-14 Thread Christopher Reimer
On Oct 14, 2017, at 10:44 AM, Thomas Jollans wrote: > >> On 14/10/17 19:34, Stefan Ram wrote: >> r...@zedat.fu-berlin.de (Stefan Ram) writes: >>> a post. Use whatever is appropriate in the special case >>> given, or - to write a general library -, learn the design >>> of a good

Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread Christopher Reimer
On Oct 11, 2017, at 9:07 AM, Bill wrote: > > Grant Edwards wrote: >> On 2017-10-11, Bill wrote: >> >> >>> [...] I'm not here to "cast stones", I like Python. I just think >>> that you shouldn't cast stones at C/C++. >> Not while PHP exists.

Re: How to determine lowest version of Python 3 to run?

2017-10-06 Thread Christopher Reimer
On Oct 6, 2017, at 12:58 PM, Stephan Houben <stephan...@gmail.com.invalid> wrote: > > Op 2017-10-06, Christopher Reimer schreef <christopher_rei...@icloud.com>: > >> So I got tox and tox-docker installed. When I went to install Docker >> for Windows, it wou

Re: How to determine lowest version of Python 3 to run?

2017-10-06 Thread Christopher Reimer
On Oct 5, 2017, at 3:34 PM, Christopher Reimer <christopher_rei...@icloud.com> wrote: > >> On Oct 5, 2017, at 1:11 PM, Irmen de Jong <irmen.nos...@xs4all.nl> wrote: >> >>> On 10/05/2017 04:23 AM, Christopher Reimer wrote: >>> >>> I'm leani

Re: How to determine lowest version of Python 3 to run?

2017-10-05 Thread Christopher Reimer
On Oct 5, 2017, at 1:11 PM, Irmen de Jong <irmen.nos...@xs4all.nl> wrote: > >> On 10/05/2017 04:23 AM, Christopher Reimer wrote: >> >> I'm leaning towards installing the latest minor version of each available >> major version, running tox to run the unit tests

Re: Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread Christopher Reimer
On Oct 4, 2017, at 3:49 AM, Leam Hall wrote: > > Folks on IRC have suggested using virtualenv to test code under different > python versions. Sadly, I've not found a virtualenv tutorial I understand. > Anyone have a link to a good one? > > The next step will be to figure

How to determine lowest version of Python 3 to run?

2017-10-04 Thread Christopher Reimer
Greetings, I've always installed the latest and greatest version of Python 3 to develop my own programs. I'm planning to release a program to the public. I could toss in a note that the program runs on the latest version of Python 3.6 but I haven't tested on earlier versions (i.e., 3.4 and

Re: How best to initialize in unit tests?

2017-10-04 Thread Christopher Reimer
On Oct 4, 2017, at 6:07 AM, Skip Montanaro wrote: > > Suppose you want to test a package (in the general sense of the word, > not necessarily a Python package). You probably have specific unit > tests, maybe some doctests scattered around in doc strings. Further, >

Re: Spacing conventions

2017-09-27 Thread Christopher Reimer
On Sep 27, 2017, at 12:50 AM, Bill wrote: > > Ever since I download the MyCharm IDE a few days ago, I've been noticing all > sort of "spacing conventions (from PEP) that are suggested. How do folks > regard these in general? > > For instance, the conventions

Re: errors with json.loads

2017-09-20 Thread Christopher Reimer
I got the same results, but did not post them. > > Someone has posted programs with \xA0 (NBSP IIRC) > at the start of lines of the soure here before, in: > > From: Christopher Reimer <christopher_rei...@yahoo.com> > Newsgroups: comp.lang.python > Subject: Sett

Re: Even Older Man Yells At Whippersnappers

2017-09-19 Thread Christopher Reimer
> On Sep 19, 2017, at 9:09 AM, justin walters > wrote: > > On Tue, Sep 19, 2017 at 8:59 AM, Grant Edwards > wrote: > >>> On 2017-09-19, Rhodri James wrote: On 19/09/17 16:00, Stefan Ram wrote: D'Arcy Cain

Re: Old Man Yells At Cloud

2017-09-17 Thread Christopher Reimer
> On Sep 17, 2017, at 2:19 PM, Ned Batchelder wrote: > >> On 9/16/17 1:38 AM, Steve D'Aprano wrote: >> /rant on >> >> So apparently everyone who disagrees that Python should be more like >> Javascript >> is an old greybeard fuddy-duddy yelling "Get off my lawn!" to the

Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-14 Thread Christopher Reimer
> On Sep 13, 2017, at 10:12 PM, Paul Rubin wrote: > > Ben Finney writes: >>> I've never seen one. >> who has told you... they are working on a Python 3 code base. > > Just because they've told me about it doesn't mean I saw it personally. >

Re: Merge pdf files using information from two files

2017-09-08 Thread Christopher Reimer
> On Sep 8, 2017, at 1:21 PM, accessnew...@gmail.com wrote: > Ideas as to how to accomplish this? Export your spreadsheets as Comma Separated Values (CSV) files and use the CSV module to read/write those files. https://docs.python.org/3/library/csv.html Chris R. --

Re: Setting property for current class from property in an different class...

2017-09-07 Thread Christopher Reimer via Python-list
On 9/6/2017 9:26 PM, Christopher Reimer wrote: On Sep 6, 2017, at 9:14 PM, Stefan Ram <r...@zedat.fu-berlin.de> wrote: I can run this (your code) without an error here (Python 3.6.0), from a file named "Scraper1.py": I'll check tomorrow. I recently switched fro

Re: Setting property for current class from property in an different class...

2017-09-06 Thread Christopher Reimer
> On Sep 6, 2017, at 9:14 PM, Stefan Ram wrote: > > I can run this (your code) without an error here (Python 3.6.0), > from a file named "Scraper1.py": I'll check tomorrow. I recently switched from 3.5.x to 3.6.1 in the PyCharm IDE. It's probably FUBAR in some

Re: Have do_nothing as default action for dictionary?

2017-09-04 Thread Christopher Reimer via Python-list
Greetings, After reading everyone's comments and doing a little more research, I re-implemented my function as a callable class.     def __call__(self, key, value):     if key not in self._methods:     return value     return self._methods[key](value) This behaves like my

Have do_nothing as default action for dictionary?

2017-09-03 Thread Christopher Reimer via Python-list
Greetings, I was playing around this piece of example code (written from memory). def filter_text(key, value):     def do_nothing(text): return text     return {'this': call_this,   'that': call_that,   'what': do_nothing }[key](value) Is

Re: BeautifulSoup doesn't work with a threaded input queue?

2017-08-27 Thread Christopher Reimer via Python-list
Ah, shoot me. I had a .join() statement on the output queue but not on in the input queue. So the threads for the input queue got terminated before BeautifulSoup could get started. I went down that same rabbit hole with CSVWriter the other day. *sigh* Thanks for everyone's help. Chris R. --

Re: BeautifulSoup doesn't work with a threaded input queue?

2017-08-27 Thread Christopher Reimer via Python-list
On 8/27/2017 1:50 PM, MRAB wrote: What if you don't sort the list? I ask because it sounds like you're changing 2 variables (i.e. list->queue, sorted->unsorted) at the same time, so you can't be sure that it's the queue that's the problem. If I'm using a list, I'm using a for loop to input

Re: BeautifulSoup doesn't work with a threaded input queue?

2017-08-27 Thread Christopher Reimer via Python-list
On 8/27/2017 1:31 PM, Peter Otten wrote: Here's a simple example that extracts titles from generated html. It seems to work. Does it resemble what you do? Your example is similar to my code when I'm using a list for the input to the parser. You have soup_threads and write_threads, but no

Re: BeautifulSoup doesn't work with a threaded input queue?

2017-08-27 Thread Christopher Reimer via Python-list
On 8/27/2017 1:12 PM, MRAB wrote: What do you mean by "queue (random order)"? A queue is sequential order, first-in-first-out. With 20 threads requesting 20 different pages, they're not going into the queue in sequential order (i.e., 0, 1, 2, ..., 17, 18, 19) and coming in at different

Re: BeautifulSoup doesn't work with a threaded input queue?

2017-08-27 Thread Christopher Reimer via Python-list
On 8/27/2017 11:54 AM, Peter Otten wrote: The documentation https://www.crummy.com/software/BeautifulSoup/bs4/doc/#making-the-soup says you can make the BeautifulSoup object from a string or file. Can you give a few more details where the queue comes into play? A small code sample would be

BeautifulSoup doesn't work with a threaded input queue?

2017-08-27 Thread Christopher Reimer via Python-list
Greetings, I have Python 3.6 script on Windows to scrape comment history from a website. It's currently set up this way: Requestor (threads) -> list -> Parser (threads) -> queue -> CVSWriter (single thread) It takes 15 minutes to process ~11,000 comments. When I replaced the list with a

Re: School Management System in Python

2017-07-05 Thread Christopher Reimer
On Jul 5, 2017, at 6:34 AM, Sam Chats wrote: > Just curious, is it better, performance wise, to read from a text file (css > or tsv) compared to reading from a binary pickle file? I prefer CSV because I can load the file into Microsoft Excel and do a quick

Re: Reciprocal data structures

2017-06-19 Thread Christopher Reimer
> On Jun 18, 2017, at 11:02 PM, Chris Angelico wrote: > > On Mon, Jun 19, 2017 at 3:54 PM, Steven D'Aprano wrote: >>> With a list? No, I would say it's a bad idea. >> >> >> Why a bad idea? >> >> As opposed to "can't be done", or "too hard and slow". >

Re: Developers Who Use Spaces Make More Money!

2017-06-15 Thread Christopher Reimer
> On Jun 15, 2017, at 3:24 PM, jlada...@itu.edu wrote: > > This is hilarious, I have to share: > > https://stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/ > > Thanks to Guido for making us all richer! One commentator on a tech website admonished programmers for wasting

Re: openpyxl reads cell with format

2017-06-05 Thread Christopher Reimer
On 6/5/2017 4:55 PM, Gregory Ewing wrote: Mahmood Naderan wrote: from a button on a web page, I chose "export as excel" to download the data. Do you get an option to export in any other format? CSV would be best, since you can trivially read that with Python's csv module. If Excel is the

Passing yield as a function argument...

2017-05-23 Thread Christopher Reimer
Greetings, I have two functions that I generalized to be nearly identical except for one line. One function has a yield statement, the other function appends to a queue. If I rewrite the one line to be a function passed in as an argument -- i.e., func(data) -- queue.append works fine. If I

Re: Finding sentinel text when using a thread pool...

2017-05-20 Thread Christopher Reimer via Python-list
On 5/20/2017 1:19 AM, dieter wrote: If your (590) pages are linked together (such that you must fetch a page to get the following one) and page fetching is the limiting factor, then this would limit the parallelizability. The pages are not linked together. The URL requires a page number. If I

Finding sentinel text when using a thread pool...

2017-05-19 Thread Christopher Reimer
Greetings, I'm developing a web scraper script. It takes 25 minutes to process 590 pages and ~9,000 comments. I've been told that the script is taking too long. The way the script currently works is that the page requester is a generator function that requests a page, checks if the page

Re: Python inner function parameter shadowed

2016-09-14 Thread Christopher Reimer
> On Sep 13, 2016, at 8:58 PM, Lawrence D’Oliveiro > wrote: > >> On Wednesday, September 14, 2016 at 4:34:34 AM UTC+12, Daiyue Weng wrote: >> PyCharm warns about "Shadows name 'func' from outer scope" > > Typical piece of software trying to be too helpful and just

Re: [OT] Altair

2016-08-30 Thread Christopher Reimer
> On Aug 30, 2016, at 11:51 AM, Joe wrote: > >> Am 30.08.2016 um 17:52 schrieb D'Arcy J.M. Cain: >> On Tue, 30 Aug 2016 15:56:07 +0200 >> Joe wrote: >>> Am 30.08.2016 um 13:01 schrieb D'Arcy J.M. Cain: On Mon, 29 Aug 2016 21:21:05 -0700 Larry

Re: Creating a calculator

2016-07-01 Thread Christopher Reimer
> On Jul 1, 2016, at 6:52 AM, Steven D'Aprano <st...@pearwood.info> wrote: > >> On Fri, 1 Jul 2016 10:25 pm, Christopher Reimer wrote: >> >> For my BASIC interpreter, each line of BASIC is broken this way into >> tokens. > [...] >> By using * t

Re: Creating a calculator

2016-07-01 Thread Christopher Reimer
> On Jul 1, 2016, at 5:46 AM, Jussi Piitulainen <jussi.piitulai...@helsinki.fi> > wrote: > > Christopher Reimer writes: > >> For my BASIC interpreter, each line of BASIC is broken this way into >> tokens. >> >> line_number, keyword, *expression =

Re: Creating a calculator

2016-07-01 Thread Christopher Reimer
> On Jun 30, 2016, at 11:42 PM, Jussi Piitulainen > wrote: > > DFS writes: > >> Here's a related program that doesn't require you to tell it what type >> of operation to perform. Just enter 'num1 operator num2' and hit >> Enter, and it will parse the entry and

Re: Empty List

2016-06-26 Thread Christopher Reimer
On 6/26/2016 8:13 PM, Elizabeth Weiss wrote: Hi There, What is the point of this code?: word=[] print(word) The result is [] When would I need to use something like this? Thank you! Sometimes you need to assign an empty list to a variable prior to using it in a looping structure.

Re: Assignment Versus Equality

2016-06-26 Thread Christopher Reimer
On 6/26/2016 8:41 AM, MRAB wrote: On 2016-06-26 11:48, BartC wrote: On 26/06/2016 08:36, Lawrence D’Oliveiro wrote: One of Python’s few mistakes was that it copied the C convention of using “=” for assignment and “==” for equality comparison. One of C's many mistakes. Unfortunately C has

Re: Assignment Versus Equality

2016-06-26 Thread Christopher Reimer
On 6/26/2016 6:21 AM, Steven D'Aprano wrote: On Sun, 26 Jun 2016 08:48 pm, BartC wrote: On 26/06/2016 08:36, Lawrence D’Oliveiro wrote: One of Python’s few mistakes was that it copied the C convention of using “=” for assignment and “==” for equality comparison. One of C's many mistakes.

Re: Is signed zero always available?

2016-06-22 Thread Christopher Reimer
> On Jun 22, 2016, at 7:59 AM, Grant Edwards wrote: > >> On 2016-06-22, Random832 wrote: >>> On Wed, Jun 22, 2016, at 10:19, Grant Edwards wrote: >>> >>> Is that guaranteed by Python, or just a side-effect of the >>> implementation? Back in

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-10 Thread Christopher Reimer
Sent from my iPhone > On Jun 10, 2016, at 3:52 PM, mad scientist jr > wrote: > . > Now that it's done, I am wondering what kind of things I could do better. This is Python, not BASIC. Lay off on the CAP LOCK key and delete all the comments and separation blocks.

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Christopher Reimer
On 6/3/2016 7:31 PM, Steven D'Aprano wrote: On Sat, 4 Jun 2016 09:06 am, Sayth Renshaw wrote: I cant create a list with an append method pf.append(thing) in one go . Correct. You cannot append to a list until the list exists. Nor can you uppercase a string until the string exists: s =

Re: for / while else doesn't make sense

2016-05-25 Thread Christopher Reimer
> On May 25, 2016, at 3:47 AM, Marko Rauhamaa <ma...@pacujo.net> wrote: > > Christopher Reimer <christopher_rei...@icloud.com>: > >> Back in the early 1980's, I grew up on 8-bit processors and latin-1 was >> all we had for ASCII. > > You real

Re: for / while else doesn't make sense

2016-05-25 Thread Christopher Reimer
> On May 24, 2016, at 11:38 PM, Gregory Ewing <greg.ew...@canterbury.ac.nz> > wrote: > > Christopher Reimer wrote: >> Nope. I meant 8-bit ASCII (0-255). >> http://www.ascii-code.com > > That page is talking about latin-1, which is just one of many > po

Re: for / while else doesn't make sense

2016-05-24 Thread Christopher Reimer
On May 24, 2016, at 7:23 AM, Grant Edwards <grant.b.edwa...@gmail.com> wrote: > >> On 2016-05-24, Steven D'Aprano <st...@pearwood.info> wrote: >>> On Tue, 24 May 2016 08:36 am, Christopher Reimer wrote: >>> >>> Those symbols are blowing my 8-

Re: for / while else doesn't make sense

2016-05-23 Thread Christopher Reimer
> On May 23, 2016, at 1:22 PM, Grant Edwards wrote: > >> On 2016-05-23, Ian Kelly wrote: >>> On Mon, May 23, 2016 at 9:53 AM, Ian Kelly wrote: >>> I'm not sure where ℝ comes into this in the first place. Existing >>>

Re: Education [was Re: for / while else doesn't make sense]

2016-05-21 Thread Christopher Reimer
On 5/21/2016 3:05 AM, Steven D'Aprano wrote: On Sat, 21 May 2016 03:18 pm, Rustom Mody wrote: Given that for the most part, most of us are horribly uneducated [ http://www.creativitypost.com/education/9_elephants_in_the_classroom_that_should_unsettle_us ] how do we go about correcting our

Re: How do I subclass the @property setter method?

2016-05-21 Thread Christopher Reimer
On 5/21/2016 1:52 AM, Dirk Bächle wrote: Hi Christopher, On 20.05.2016 20:50, Christopher Reimer wrote: Greetings, My chess engine has a Piece class with the following methods that use the @property decorator to read and write the position value. slightly off topic: is your chess engine

Re: for / while else doesn't make sense

2016-05-20 Thread Christopher Reimer
On 5/20/2016 7:31 PM, Chris Angelico wrote: On Sat, May 21, 2016 at 11:23 AM, Christopher Reimer <christopher_rei...@icloud.com> wrote: On 5/20/2016 3:43 PM, Steven D'Aprano wrote: But the idea that you should avoid a Python feature while programming in Python because Javascript doesn'

Re: for / while else doesn't make sense

2016-05-20 Thread Christopher Reimer
On 5/20/2016 3:43 PM, Steven D'Aprano wrote: But the idea that you should avoid a Python feature while programming in Python because Javascript doesn't have it, or Ruby, or C, is surely the height of muddleheaded thinking. You're not programming Javascript, Ruby or C, you're programming in

Re: for / while else doesn't make sense

2016-05-20 Thread Christopher Reimer
On 5/20/2016 8:59 AM, Zachary Ware wrote: On Fri, May 20, 2016 at 3:09 AM, Erik wrote: On 20/05/16 00:51, Gregory Ewing wrote: It's not so bad with "else" because you need to look back to find out what condition the "else" refers to anyway. With my tongue only

Re: How do I subclass the @property setter method?

2016-05-20 Thread Christopher Reimer
On 5/20/2016 11:50 AM, Christopher Reimer wrote: This code does work, blows up the unit test, and keeps PyCharm happy. @property def position(self): return super().position @position.setter def position(self, position): pass Re-declaring @property and calling

How do I subclass the @property setter method?

2016-05-20 Thread Christopher Reimer
Greetings, My chess engine has a Piece class with the following methods that use the @property decorator to read and write the position value. @property def position(self): return self._position @position.setter def position(self, position): if

Re: Python PygLatin

2016-05-08 Thread Christopher Reimer
On 5/8/2016 10:53 AM, alister wrote: On Mon, 09 May 2016 03:12:14 +1000, Steven D'Aprano wrote: On Sun, 8 May 2016 08:21 pm, Cai Gengyang wrote: If one looks at the Forbes List, you will see that there are 4 programmers amongst the top ten richest people in the world (Bill Gates, Mark

Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Christopher Reimer
On 5/8/2016 9:27 AM, Steven D'Aprano wrote: On Sun, 8 May 2016 08:22 pm, beliav...@aol.com wrote: There are far more female than male teachers. I don't attribute it to anti-male suppression but to greater female interest in working with children. Of course there is suppression of male

Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Christopher Reimer
On 5/8/2016 8:09 AM, Rustom Mody wrote: See: https://www.washingtonpost.com/news/rampage/wp/2016/05/07/ivy-league-economist-interrogated-for-doing-math-on-american-airlines-flight/ Closing line: "In America today, the only thing more terrifying than foreigners is...math." Wonder how close to

Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Christopher Reimer
On 5/7/2016 11:58 PM, Marko Rauhamaa wrote: Chris Angelico : So the question is: Do we care about country equality or individual equality? You can't have both. That's why there's been a long-standing initiative to split California into multiple states:

Re: Pylint prefers list comprehension over filter...

2016-05-08 Thread Christopher Reimer
On 5/8/2016 5:02 AM, Steven D'Aprano wrote: On Sun, 8 May 2016 08:01 am, Christopher Reimer wrote: On 5/7/2016 2:22 PM, Chris Angelico wrote: Also, be sure you read this part of PEP 8: https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds

Re: Pylint prefers list comprehension over filter...

2016-05-07 Thread Christopher Reimer
On 5/7/2016 6:40 PM, Terry Reedy wrote: On 5/7/2016 3:17 PM, Christopher Reimer wrote: For my purposes, I'm using the list comprehension over filter to keep pylint happy. How sad. The pylint developers arrogantly take it on themselves to revise Python, against the wishes of Guido

Re: Pylint prefers list comprehension over filter...

2016-05-07 Thread Christopher Reimer
On 5/7/2016 1:31 PM, Marko Rauhamaa wrote: Christopher Reimer <christopher_rei...@icloud.com>: Never know when an asshat hiring manager would reject my resume out of hand because my code fell short with pylint. Remember that it's not only the company checking you out but also you ch

Re: Pylint prefers list comprehension over filter...

2016-05-07 Thread Christopher Reimer
On 5/7/2016 2:22 PM, Chris Angelico wrote: On Sun, May 8, 2016 at 5:17 AM, Christopher Reimer <christopher_rei...@icloud.com> wrote: Since the code I'm working on is resume fodder (i.e., "Yes, I code in Python! Check out my chess engine code on GitHub!"), I want it to be as P

Re: python chess engines

2016-05-07 Thread Christopher Reimer
On 5/3/2016 10:13 PM, DFS wrote: Wanted to start a new thread, rather than use the 'motivated' thread. Can you play your game at the console? Nope. Only displays the board on the console. An early version had the forward movement for pawns implemented. The way I think about a chess engine

Re: pylint woes

2016-05-07 Thread Christopher Reimer
On 5/7/2016 12:52 PM, Ray Cote wrote: I’m impressed with 10/10. My approach is to ensure flake8 (a combination of pyflakes and pep8 checking) does not report any warnings and then run pyLint as a final check. I just installed pyflakes and ran it against my 10/10 files. It's not complaining

Re: Pylint prefers list comprehension over filter...

2016-05-07 Thread Christopher Reimer
On 5/5/2016 6:37 PM, Stephen Hansen wrote: On Thu, May 5, 2016, at 06:26 PM, Christopher Reimer wrote: Which is one is correct (Pythonic)? Or does it matter? First, pylint is somewhat opinionated, and its default options shouldn't be taken as gospel. There's no correct: filter is fine. Since

Re: pylint woes

2016-05-07 Thread Christopher Reimer
On 5/7/2016 12:23 PM, Stephen Hansen wrote: On Sat, May 7, 2016, at 11:52 AM, Christopher Reimer wrote: You can do better. You should strive for 10/10 whenever possible, figure out why you fall short and ask for help on the parts that don't make sense. I think this is giving far too much

Re: Pylint prefers list comprehension over filter...

2016-05-07 Thread Christopher Reimer
On 5/5/2016 7:57 PM, Stephen Hansen wrote: On Thu, May 5, 2016, at 07:46 PM, Dan Sommers wrote: On Thu, 05 May 2016 18:37:11 -0700, Stephen Hansen wrote: ''.join(x for x in string if x.isupper()) The difference is, both filter and your list comprehension *build a list* which is not

Re: pylint woes

2016-05-07 Thread Christopher Reimer
On 5/7/2016 9:51 AM, DFS wrote: Has anyone ever in history gotten 10/10 from pylint for a non-trivial program? I routinely get 10/10 for my code. While pylint isn't perfect and idiosyncratic at times, it's a useful tool to help break bad programming habits. Since I came from a Java

Pylint prefers list comprehension over filter...

2016-05-05 Thread Christopher Reimer
Greetings, Below is the code that I mentioned in an earlier thread. string = "Whiskey Tango Foxtrot" ''.join(list(filter(str.isupper, string))) 'WTF' That works fine and dandy. Except Pylint doesn't like it. According to this link, list comprehensions have replaced filters and

Re: How to become more motivated to learn Python

2016-05-03 Thread Christopher Reimer
On 5/3/2016 8:00 PM, DFS wrote: How far along are you in your engine development? I can display a text-based chess board on the console (looks better with a mono font). 8 BR BN BB BQ BK BB BN BR 7 BP BP BP BP BP BP BP BP 6 __ __ __ __ __ __ __ __ 5 __ __ __ __ __ __ __ __

Re: How to become more motivated to learn Python

2016-05-03 Thread Christopher Reimer
On 5/3/2016 4:20 AM, Cai Gengyang wrote: So I have completed up to CodeAcademy's Python Unit 2 , now moving on to Unit3 : Conditionals and Control Flow. But I feel my motivation wavering , at times I get stuck and frustrated when trying to learn a new programming language ? This might not be

Re: Not x.islower() has different output than x.isupper() in list output...

2016-04-30 Thread Christopher Reimer
On 4/30/2016 10:11 AM, Stephen Hansen wrote: You're thinking of the whole "string", but you're operating on single-character substrings, and when " ".islower() is run, its false. Because the two-pronged test, a) if all cased characters are lowercase and b) there is at least one cased

Re: Not x.islower() has different output than x.isupper() in list output...

2016-04-30 Thread Christopher Reimer
On 4/29/2016 11:43 PM, Stephen Hansen wrote: The official documentation is accurate. That may be true on a technical level. But the identically worded text in the documentation implies otherwise. Maybe I'm nitpicking this. Even if I submitted a bug to request a clearer explanation in the

Re: Not x.islower() has different output than x.isupper() in list output...

2016-04-29 Thread Christopher Reimer
On 4/29/2016 6:29 PM, Stephen Hansen wrote: If isupper/islower were perfect opposites of each-other, there'd be no need for both. But since characters can be upper, lower, or *neither*, you run into this situation. Based upon the official documentation, I was expecting perfect opposites.

Not x.islower() has different output than x.isupper() in list output...

2016-04-29 Thread Christopher Reimer
Greetings, I was playing around with a piece of code to remove lowercase letters and leave behind uppercase letters from a string when I got unexpected results. string = 'Whiskey Tango Foxtrot' list(filter((lambda x: not x.islower()), string)) ['W', ' ', 'T', ' ', 'F'] Note

Not x.islower() Versus x.isupper Output Results

2016-04-29 Thread Christopher Reimer via Python-list
Greetings, I was playing around with a piece of code to remove lowercase letters and leave behind uppercase letters from a string when I got unexpected results. string = 'Whiskey Tango Foxtrot' list(filter((lambda x: not x.islower()), string)) ['W', ' ', 'T', ' ', 'F'] Note

Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer
On 4/27/2016 8:52 PM, Michael Torrie wrote: In fact if it were me I would save game state to some kind of ini file, which would mean manually going through each object and writing out the relevant data to the ini file using the right syntax. And then reverse the process when restoring from a

Re: Pythonic style

2016-04-27 Thread Christopher Reimer
On 4/27/2016 8:52 PM, Ethan Furman wrote: The point Ben was trying to make is this: you should never* call __dunder__ methods in normal code; there is no need to do so: - use len(), not __len__() - use next(), not __next__() - use some_instance.an_attribute, not

Re: Pythonic style

2016-04-27 Thread Christopher Reimer
On 4/27/2016 8:23 PM, Ben Finney wrote: If you want items in a mapping, explicitly use a Python ‘dict’ instance. If you want attributes that describe an object, explicitly use attributes of that object. Deliberately choose which one makes more sense. Okay, that makes sense. Thank you, Chris

Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer
On 4/27/2016 8:05 PM, Ethan Furman wrote: I ripped out the fetch_state because that will take more work -- you can't pass a Pawn's saved state in to Piece and get the results you want. pickle is worth looking at for saving/restoring. The original idea was to pass a Pawn dictionary to the

Re: Pythonic style (was: Differences between Class(Object) and Class(Dict) for dictionary usage?)

2016-04-27 Thread Christopher Reimer
On 4/27/2016 7:07 PM, Ben Finney wrote: I would say the latter is more Pythonic, because it: * Better conveys the intention (“set the value of the ‘self.key’ attribute”). * Uses the built-in mechanisms of Python (don't invoke magic attributes, instead use the system that makes use of

Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer
On 4/27/2016 7:00 PM, Michael Torrie wrote: I am guessing that the reason you are storing state as it's own dictionary is so that you can pass the state itself to the constructor? Someone said it was bad to store the object itself to file (my original plan) and that I should use a dictionary

Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer via Python-list
On 4/26/2016 8:56 PM, Random832 wrote: what exactly do you mean by property decorators? If you're just accessing them in a dictionary what's the benefit over having the values be simple attributes rather than properties? After considering the feedback I got for sanity checking my code, I've

Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer
On 4/27/2016 7:33 AM, Ian Kelly wrote: This class definition looks muddled. Because Test2 inherits from dict, the object referred to by "self" will be a dict, and self.__dict__ is actually a *different* dict, containing the attributes of self. The line: self.__dict__ = {'key', 'value'}

Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer
On 4/27/2016 7:24 AM, Ian Kelly wrote: Some other great questions to ask yourself are "do I really want len(my_object) to return the number of items in this dict" and "do I really want list(my_object) to return all the keys in this dict"? If the answer to all those is yes, then it's probably

Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer
On 4/26/2016 8:56 PM, Random832 wrote: what exactly do you mean by property decorators? If you're just accessing them in a dictionary what's the benefit over having the values be simple attributes rather than properties? After considering the feedback I got for sanity checking my code, I've

Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-26 Thread Christopher Reimer
Greetings, If I'm using a dictionary to store variables for an object, and accessing the variable values from dictionary via property decorators, would it be better to derive the class from object or dict? class Test1(object): def __init__(self): self.state = {'key':

Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Christopher Reimer
On 4/23/2016 8:19 PM, Michael Torrie wrote: The reason you weren't taught beyond class inheritance is because Java implements organization only through a class hierarchy. Whole generations of Java programmers think that program organization is through classes (a static main method means your

Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Christopher Reimer
On 4/23/2016 7:34 PM, Michael Torrie wrote Procedural programming does not necessarily mean BASIC-style goto hell. Not sure why you would think that. In fact that's not really what procedural programming is about. I mentioned several messages back that I spent two years writing procedural

Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Christopher Reimer
On 4/23/2016 6:38 PM, Michael Selik wrote: Why so many files? Python can easily support thousands of lines in a file. If it's just one file any text editor can do a quick find-replace. That goes back to the Java convention of having one class per file. It took a while to convince myself that

Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Christopher Reimer
On 4/23/2016 6:29 PM, Ian Kelly wrote: Python enums are great. Sadly, they're still not quite as awesome as Java enums. I remember enums more from C than Java. Although I haven't used them much in either language. I'm planning to immerse myself back into C via Cython. Depending on far I get

Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Christopher Reimer
On 4/23/2016 2:33 PM, Matt Wheeler wrote: This is still backwards to me. It prevents your classes from being suitable for restoring a stored game state, not just custom starting positions (which I think is what Ethan means by custom setups). I haven't thought that far about saving the game

Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Christopher Reimer
On 4/22/2016 1:40 PM, Michael Selik wrote: Frankly, for someone coming from Java, the best advice is to not write any classes until you must. Of course classes in Python are very useful. It's just that your Java habits are unnecessary and often counter-productive. I disagree. I wrote

Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Christopher Reimer
On 4/21/2016 10:25 PM, Stephen Hansen wrote: Why not, 'color in ("black", "white")'? Checkers seems popular around here. What if I want to change "white" to "red," as red and black is a common color scheme for checkers. Do I change a single constant variable or replace all the occurrences

  1   2   >