make_obcallback(): could not import mod_python.apache

2005-02-16 Thread Christopher
I am running:

Fedora Core 1
Python 2.4
Apache 1.3.3
mod_python 2.7.11

When I try to access the test mptest.py file I receive:

> Internal Server Error

When starting apache in my error_log I find:

> [Wed Feb 16 20:41:44 2005] [warn] Loaded DSO libexec/mod_python.so
uses plain Apache 1.3 API, this module might crash under $

and

> make_obcallback(): could not import mod_python.apache.
> make_obcallback(): could not call init.
> [Wed Feb 16 20:43:31 2005] [error] [client x.x.x.x] python_handler:
make_obcallback returned no obCallBack!

from when I attempt access that file.

If I attempt to run Python on the command line and then import
mod_python I receive:

ImportError: No module named mod_apache.apache
>>> import mod_python.apache
Traceback (most recent call last):
 File "", line 1, in ?
 File "/usr/local/lib/python2.4/site-packages/mod_python/apache.py",
line 55, in ?
   import _apache
ImportError: No module named _apache

Any guidance would be greatly appreciated.

Christopher

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: jitpy - Library to embed PyPy into CPython

2014-12-08 Thread Christopher
On Saturday, December 6, 2014 3:30:56 PM UTC-5, Albert-Jan Roskam wrote:
> 
> On Fri, Dec 5, 2014 8:54 PM CET Mark Lawrence wrote:
> 
> >For those who haven't heard thought this might be of interest 
> >https://github.com/fijal/jitpy
> 
> Interesting, but it is not clear to me when you would use jitpy instead of 
> pypy. Too bad pypy alone was not included in the benchmarks (cython would 
> have also been nice).

There are plenty of situations. For example, I am building an app that requires 
access to modules that don't currently work under pypy. With this tool I could 
still take advantage of pypy JIT, but use CPython for other stuff.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: jitpy - Library to embed PyPy into CPython

2014-12-09 Thread Christopher
  To: Albert-Jan Roskam
On Saturday, December 6, 2014 3:30:56 PM UTC-5, Albert-Jan Roskam wrote:
> 
> On Fri, Dec 5, 2014 8:54 PM CET Mark Lawrence wrote:
>
> >For those who haven't heard thought this might be of interest 
https://github.com/fijal/jitpy
>
> Interesting, but it is not clear to me when you would use jitpy instead of 
pypy. Too bad pypy alone was not included in the benchmarks (cython would have 
also been nice).

There are plenty of situations. For example, I am building an app that requires 
access to modules that don't currently work under pypy. With this tool I could 
still take advantage of pypy JIT, but use CPython for other stuff.

--- SoupGate-Win32 v1.05
 * Origin: nntp.gatew...@.piz.noip.me> (1:249/999)
--- Synchronet 3.15b-Win32 NewsLink 1.92
SpaceSST BBS Usenet <> Fidonet Gateway
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Building Python 2.5.2 for Itanium

2008-11-23 Thread Christopher
On Nov 21, 3:50 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> >   I need to compile that module for that release and platform, but I
> > have been unable to discover which MS compiler version and runtime was
> > used to generate the binaries.  My understanding is that Python 2.5.2
> > in general uses Visual Studio 2003, but MS does not appear to have
> > shipped an Itanium compiler with that version of VS.
>
> That's correct. See PCbuild/readme.txt for (somewhat) detailed
> instructions; in essence, you need to use vsextcomp, if you want to
> use the official build process.
>
> >   I know that there is an Itanium compiler in VS2K5 Team System, and
> > also a pre-release version was shipped with the Windows 2003 SP1
> > Platform SDK.
>
> I don't think that is a pre-release. The SDK had been shipping with
> an Itanium compiler for quite some time, and it is the official compiler
> to build binaries for Win64/IA-64 (to my knowledge, it is the compiler
> that Windows itself was built with).
>
> > However, the compiler in the SDK appears to basically
> > be an earlier version of the VS2K5 compiler.
>
> That might be. The more critical issue is what CRT to link with.
> I had been building the Python Itanium binaries always with the SDK
> compiler (of different SDKs, actually); the SDK then would always
> link with msvcrt.dll. If you use VS2K5, you might end up linking
> with a different CRT, which would be bad.
>
> >   When I run setup.py build, the distutils die b/c it is apparently
> > not the right compiler version.
>
> Correct. distutils is not used for building on Windows.
>
> Wrt. the original issue: I am quite skeptical that you can make ctypes
> work on Win64/IA-64. There is are several reasons why it wasn't build,
> such as it doesn't compile, and, if it would compile, it wouldn't work.
> So prepare to do some porting of libffi. Alternatively, rewrite the code
> that requires ctypes to use a plain extension module, which is probably
> easier to port to Itanium.
>
> Regards,
> Martin

Thank you very much.  I appreciate the information.  I will look into
the libffi porting, but it probably will be more time-efficient to
create a native-code module to hit the functions I need.  I appreciate
your responding.

-={C}=-
--
http://mail.python.org/mailman/listinfo/python-list


Re: 404 not found on for Python 2.6 Itanium

2008-11-23 Thread Christopher
On Nov 21, 7:35 pm, r0g <[EMAIL PROTECTED]> wrote:
> Martin v. Löwis wrote:
> >> In any case, my concern with dropping a stock python itanium distro
> >> involves the vastly diminished probability that others will provide
> >> Itanium versions of, for example py2exe and pywin32.
>
> > Well, I had been providing Itanium binaries for 2.4 and 2.5, and neither
> > py2exe nor pywin32 ever emerged.
>
> > It *is* fairly unlikely that the community will provide Itanium support
> > for anything, as nobody really has the hardware to run it on. So if you
> > are using Itanium, you will have to do all the porting yourself.
>
> >>  I would certainly be willing to help with testing and building and
> >> bug fixing to the extent that my secular job allows it.
>
> > If you start providing binaries, we would be happy to link to them
> > from the release pages (provided they arrive within some reasonable
> > time after the release, otherwise, the link would go off the download
> > page, or the windows page).
>
> > I have personally given up with Windows on Itanium - it just isn't
> > worth my time. We do have new Itanium hardware, but we run VMS and
> > HP-UX on it. Why would anybody run Windows on Itanium? You can't
> > get any games for it :-)
>
> > For some time, there was interest in Python for AlphaNT, and that
> > interest has died away also. It seems that even Microsoft has lost
> > interest in Itanium as a Windows platform - they never released
> > Office for it, for example, and Windows 2008 on Itanium is also
> > crippled.
>
> > Regards,
> > Martin
>
> If you can't get the compile working could you maybe try using a pure
> python implementation of the ctypes module, say the one from pypy?
>
> Roger.

No. I am using ctypes to access Windows .dll functions primarily.  I
didn't want to have to write a native code module b/c it's such a
hassle and cytpes works so well.

-={C}=-
--
http://mail.python.org/mailman/listinfo/python-list


Re: 404 not found on for Python 2.6 Itanium

2008-11-23 Thread Christopher
On Nov 21, 8:55 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
> Christopher wrote:
> >> Yes. It's too much effort to build, and too few users that actually
> >> use it. Users are still free to build it themselves, and to share
> >> the build with others.
>
> > I guess that I don't understand why you feel there is so much effort
> > involved.  I developed a set of makefiles that build Python and all
> > dependencies from the command line using nmake.  The only thing you
> > have to do is specify debug and cpu.  The rest is taken care of by the
> > Makefiles.  Of course, this dev setup uses VS 2005, but it could be
> > made to work with VS 2008 with little trouble.  The setup is designed
> > to cross compile the x64 and ia64 architectures.
>
> Martin builds two tested installer/uninstallers that work on nt, xp, and
> vista and include IDLE and docs as Microsoft Help files.  The 2.6 doc
> change apparently required changes in the doc build, and 3.0 changes
> changed something about IDLE.  To me, that seems enough for one volunteer.
>
> tjr

No criticism was intended.  It was merely an RFI.

-={C}=-
--
http://mail.python.org/mailman/listinfo/python-list


Re: Building Python 2.5.2 for Itanium

2008-11-24 Thread Christopher
On Nov 21, 3:50 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> >   I need to compile that module for that release and platform, but I
> > have been unable to discover which MS compiler version and runtime was
> > used to generate the binaries.  My understanding is that Python 2.5.2
> > in general uses Visual Studio 2003, but MS does not appear to have
> > shipped anItaniumcompiler with that version of VS.
>
> That's correct. See PCbuild/readme.txt for (somewhat) detailed
> instructions; in essence, you need to use vsextcomp, if you want to
> use the official build process.


I am trying to follow the official build process.  I installed
vsextcomp, and it appears to work fine.  However, I have a number of
resource errors when I try to build pythoncore.

My first error was:


Compiling resources...
\Python-2.5.2\Pc\python_nt.rc(35) : error RC2104 : undefined keyword
or key name: MS_DLL_ID

So I remarked out the String table section:

STRINGTABLE DISCARDABLE
BEGIN
1000,   MS_DLL_ID
END

then I got:

Compiling resources...
\Python-2.5.2\Pc\python_nt.rc(44) : error RC2104 : undefined keyword
or key name: FIELD3

So I removed FIELD3 from:

#define PYVERSION64 PY_MAJOR_VERSION, PY_MINOR_VERSION, FIELD3,
PYTHON_API_VERSION

Finally, I received:

Compiling resources...
\Python-2.5.2\Pc\python_nt.rc(65) : error RC2104 : undefined keyword
or key name: PYTHON_DLL_NAME



Having so many errors I began to suspect something else had failed.

Lo and behold! --

Performing Custom Build Step
'.\make_versioninfo.exe' is not recognized as an internal or external
command,
operable program or batch file.
Project : error PRJ0019: A tool returned an error code from
"Performing Custom Build Step"

---

I had to manually build make_version.exe, which seems to have
generated those fields.  I'm not sure what the problem was with the
build of make_version.  The only error I could find was "unable to
create response file."

I experienced the same problem with make_buildinfo.  After manually
building it, I was able to build pythoncore.

I am now looking into getting ctypes to build correctly.  My
investigations show that ctypes supports ia64, so I may be able to
make some progress on this front.

-={C}=-


--
http://mail.python.org/mailman/listinfo/python-list


Re: Guido's new method definition idea

2008-12-08 Thread Christopher
>
> I'd like this new way of defining methods, what do you guys think?
> Anyone ready for writing a PEP?

I don't really see any advantage.  IMHO, it is not clearer, it is not
more concise, it makes the definition of class shared variables look
really out of place.  It also makes the new programmer wonder where
the function attaches if you *don't* specify self. I also give it a
-1.
--
http://mail.python.org/mailman/listinfo/python-list


Re: 404 not found on for Python 2.6 Itanium

2008-11-21 Thread Christopher

> Yes. It's too much effort to build, and too few users that actually
> use it. Users are still free to build it themselves, and to share
> the build with others.

I guess that I don't understand why you feel there is so much effort
involved.  I developed a set of makefiles that build Python and all
dependencies from the command line using nmake.  The only thing you
have to do is specify debug and cpu.  The rest is taken care of by the
Makefiles.  Of course, this dev setup uses VS 2005, but it could be
made to work with VS 2008 with little trouble.  The setup is designed
to cross compile the x64 and ia64 architectures.


-={C}=-
--
http://mail.python.org/mailman/listinfo/python-list


Building Python 2.5.2 for Itanium

2008-11-21 Thread Christopher
Hello,

  A tool that we use needs to be ported to Itanium.  It wsa written
for Python 2.5.2, and so I was happily using the Itanium version of
that release.  However, as I have gotten deeper into the port, I see
that ctypes was not included with the Itanium Python 2.5.2 release.

  I need to compile that module for that release and platform, but I
have been unable to discover which MS compiler version and runtime was
used to generate the binaries.  My understanding is that Python 2.5.2
in general uses Visual Studio 2003, but MS does not appear to have
shipped an Itanium compiler with that version of VS.

  I know that there is an Itanium compiler in VS2K5 Team System, and
also a pre-release version was shipped with the Windows 2003 SP1
Platform SDK.  However, the compiler in the SDK appears to basically
be an earlier version of the VS2K5 compiler.

  When I run setup.py build, the distutils die b/c it is apparently
not the right compiler version.

  I am basically looking for some direction w/r to the compiler
environment needed to build modules loadable by Python 2.5.2,
Itanium.

  Thanks!
   -={C}=-
--
http://mail.python.org/mailman/listinfo/python-list


Re: What text editor is everyone using for Python

2009-06-02 Thread Christopher
On May 25, 1:35 pm, LittleGrasshopper  wrote:
> With so many choices, I was wondering what editor is the one you
> prefer when coding Python, and why. I normally use vi, and just got
> into Python, so I am looking for suitable syntax files for it, and
> extra utilities. I dabbled with emacs at some point, but couldn't get
> through the key bindings for commands. I've never tried emacs with vi
> keybindings (I forgot the name of it) but I've been tempted.
>
> So what do you guys use, and why? Hopefully we can keep this civil.

I use Eclipse with PyDev for serious projects.  However, when that is
too heavy or not available I use:

1) nano over ssh with syntax highlighting for python turned on
2) notepad++ on standalone Windows systems where I need to do quick
edits or fixes.

I used to use Crimson Editor, but it is not being developed anymore,
and notepad++ does everything crimson used to do and more.

-={C}=-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some syntactic sugar proposals

2010-11-17 Thread Christopher
> ? Of course we can write it as
>     t = foo() if pred(foo()) else default_value
> but here we have 2 foo() calls instead of one. Why can't we write just
> something like this:
>     t = foo() if pred(it) else default_value
> where "it" means "foo() value"?

i don't like magic names. what about:

t = foo() as v if pred(v) else default_value


-- 
http://mail.python.org/mailman/listinfo/python-list


Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-15 Thread Christopher
I have the following problem:

Python 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> t="Python26"
>>> import re
>>> re.sub(r"python\d\d", "Python27", t)
'Python26'
>>> re.sub(r"python\d\d", "Python27", t, re.IGNORECASE)
'Python26'
>>> re.sub(r"Python\d\d", "Python27", t, re.IGNORECASE)
'Python27'
>>>

---

Perhaps this is intended behavior, but it seems like the last two
results should be the same, not the first two.  In other words, the
call to re.sub with re.IGNORECASE on should return "Python27" not
"Python26".

This appears to be the case when using compiled pattern matching:

>>> r=re.compile(r"python\d\d", re.IGNORECASE)
>>> r.sub("Python27", t)
'Python27'

---

Is this a known bug?  Is it by design for some odd reason?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-16 Thread Christopher
On Aug 15, 8:07 pm, Steven D'Aprano  wrote:
> On Sun, 15 Aug 2010 16:45:49 -0700, Christopher wrote:
> > I have the following problem:
>
> >>>> t="Python26"
> >>>> import re
> >>>> re.sub(r"python\d\d", "Python27", t)
> > 'Python26'
> >>>> re.sub(r"python\d\d", "Python27", t, re.IGNORECASE)
> > 'Python26'
> >>>> re.sub(r"Python\d\d", "Python27", t, re.IGNORECASE)
> > 'Python27'
> > Is this a known bug?  Is it by design for some odd reason?
> >>> help(re.sub)
>
> Help on function sub in module re:
>
>     sub(pattern, repl, string, count=0)
>     ...
>
> You're passing re.IGNORECASE (which happens to equal 2) as a count
> argument, not as a flag. Try this instead:
>
> >>> re.sub(r"python\d\d" + '(?i)', "Python27", t)
>
> 'Python27'
>

Thanks. Somehow I didn't notice that other argument after looking at
it a million times. :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: www.python.org website is down?

2009-08-10 Thread Christopher
On Aug 8, 5:50 pm, Pouya Khankhanian  wrote:
> On Aug 8, 11:49 am, Sharath  wrote:
>
>
>
> > On Aug 8, 11:33 am, Pouya Khankhanian  wrote:
>
> > > On Aug 8, 11:17 am, "Martin v. Löwis"  wrote:
>
> > > > > This is probably a stupid question, but Is there going to be any data
> > > > > loss if it turns out that the disk has died completely? I assume there
> > > > > are backups of the repo that are geographically distributed.
>
> > > > Yes, we have backups, and are restoring them at the moment. However,
> > > > we still haven't given up on the original disks: they are (probably)
> > > > fine; it's just the RAID controller that has failed (and we can't buy a
> > > > replacement before Monday).
>
> > > > Regards,
> > > > Martin
>
> > > Is there a mirror site to download the latest python installer? Every
> > > mirror I have found on the web redirects me to python.org.
> > > Best
> > > Peter
>
> > Python FTP mirror sites also have the same problem. They are not being
> > mirrored for some require a password. Is there any other way to get a
> > copy?
>
> > Sharath Venkatesha
>
> Website is back up! Thanks for all the hard work

Actually, it appears to be down again.
-- 
http://mail.python.org/mailman/listinfo/python-list


Computing win/loss records in Python

2012-08-25 Thread Christopher McComas
Greetings,

I have code that I run via Django that grabs the results from various sports 
from formatted text files. The script iterates over every line in the formatted 
text files, finds the team in the Postgres database updates their w/l record 
depending on the outcome on that line, saves the team's row in the db, and then 
moves on to the next line in the file. 

I'm trying to get away from Django for this project, I want to run the files, 
get the W/L results and output a formatted text file with the teams and their 
W/L records. What's confusing me I guess how to store the data/results as the 
wins and losses tally up. We're talking hundreds of teams, thousands of games, 
but a quick example would be:

Marshall
Ohio State
Kentucky
Indiana

Marshall,24,Ohio State,48,
Kentucky,14,Indiana,10,
Marshall,10,Indiana,7,
Ohio State,28,Kentucky,10

That's just a quick example, I can handle seperating the data in the lines, 
figuring it all out, I just am unsure of how to keep a running total of a 
team's record. I would do "for line in file:" then on the first line I see that 
Marshall lost so they would have 1, Ohio State won so they'd have 1 win. It'd 
go to the next line Kentucky 1 win, Indiana 1 loss, then on the 3rd line, 
Marshall got a win so they'd have 1 win, but it would have to remember that 
loss from line 1...

Does this make sense?

Thanks,
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The pythonic way equal to "whoami"

2011-06-08 Thread Christopher Head
On Wed, 08 Jun 2011 21:58:17 +0800
TheSaint  wrote:

> Kushal Kumaran wrote:
> 
> > os.geteuid
> This return 0 for *root* . I don't know if it's a standard for all
> distro. Mine is Archlinux.
> I'd just like to avoid error caused by wrong access by user
> 

It is. Until Linux capabilities, EUID==0 used to be special-cased in the
kernel as being the test for binding to network ports <1024, bypassing
filesystem access control, changing the system time, and so on. Since
Linux caps, it's theoretically possible to use a different UID, but for
compatibility and convenience, as well as because PID 1 (/sbin/init) is
still invoked by the kernel as UID 0, everyone still does that.

Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Questions about os.waitpid(pid, options) on windows

2011-07-15 Thread Christopher Head
On Mon, 11 Jul 2011 20:59:29 -0700 (PDT)
Fan  wrote:

> It seems that waitpid take process handle instead of process id as the
> first parameter on Windows.  On Unices platform, the first parameter
> is process id.
> 
> This interface is a little bit confusing. What's the purpose for such
> a design?
> 
> Thanks a lot,
> Fan

I would assume it's because that's how the underlying OS primitives
work. Under Windows, concepts of "process ID" and "process handle" both
exist (and are separate), and the functions that wait for events to
occur (WaitForSingleObject, WaitForMultipleObjects, and so on) take
handles of various sorts, including process handles. Under Linux, there
is no such thing as a process handle, only a process ID, and waitpid
(the system call) takes a process ID.

Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Messed up Mac installation

2011-08-16 Thread Christopher Brewster
Are there instructions somewhere online as to how to sort out a messed
up installation of Python on a Mac?
I have a 2 month old Macbook running Snow Leopard, I installed Python
2.7.1 some time ago. Now when I run 'python' this is what it shows.
But easy_install and pip are installing modules to the python2.6
(which shipped with the OS). If I run 'python2.6' then I have access
to the modules installed with pip.

Oh and weirdly if I tell pip to uninstall modules it says the module
does not exist. For example: "/Library/Frameworks/Python.framework/
Versions/2.7/bin/pip run on Tue Aug 16 11:46:28 2011
Cannot uninstall requirement reportlab, not installed"

So why is it installing to one place (the 2.6 library) and trying to
uninstall elsewhere (the 2.7 library)?

I know this has been discussed many times but I do not know how to
track this down.
Thanks for any pointers.

Christopher
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope of function parameters

2011-05-29 Thread Christopher Head
On Sun, 29 May 2011 16:19:11 -0400
Henry Olders  wrote:

> > def fnc2(c):
> > c = c[:]
> >c[1] = 'having'
> >return c
> 
> Thank you, Wolfgang. That certainly works, but to me it is still a
> workaround to deal with the consequence of a particular decision.
> From my perspective, a function parameter should be considered as
> having been assigned (although the exact assignment will not be known
> until runtime), and as an assigned variable, it should be considered
> local.
> 
> Henry

This has nothing to do with function parameters and everything to do
with what a "variable name" actually means. You can get the same effect
with only globals:

>>> x=[1,2,3]
>>> y=x
>>> x.append(7)
>>> y
[1, 2, 3, 7]

Why in the world does "y" end with 7, even though it was appended to
"x"? Simple: because "x" and "y" are two names for the same list, as
Henry explained. No functions involved, no locals, no parameters, no
scoping. Again, if "y=x" were instead "y=x[:]" then the output would be
"[1,2,3]" because "y" would refer to a copy of the list rather than the
same list.

Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Python hoodie

2011-05-31 Thread Christopher James
Hi all!

I LOVE Python, and want to spread the word by sporting this awesome sweater
shown at: http://www.freewear.org/?page=show_item&id=FW0067 which I found by
looking on the merchandise page of python.org.

However, I live in the United States and before checking out I noticed that
on top of the US$40 it was going to cost an additional US$45 for SHIPPING!
 I guess because of customs and such.

Anyway, where can I get one of these sweatshirts sent to me for a reasonable
shipping price in the U.S.?  I would be happy to buy one and show my love
for Python, but US$85 is a little steep for a hoodie for me.

Cheers!
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


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 obscure way.

Thanks,

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using Python 2

2017-09-08 Thread Christopher Reimer
> On Sep 8, 2017, at 6:57 AM, Ned Batchelder  wrote:
> 
> What is it that CompSci folks want that developers don't
> want, that ruined Python 3?

Long-winded debates about obscure language features that left the layman 
programmers in the bit bucket about 50+ comments ago.

While some of this can be informative and enlightening, it can also be a bit  
tedious to read. Just saying...

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple board game GUI framework

2017-09-11 Thread Christopher Reimer
> On Sep 11, 2017, at 3:58 AM, Paul Moore  wrote:
> 
> I'm doing some training for a colleague on Python, and I want to look
> at a bit of object orientation. For that, I'm thinking of a small
> project to write a series of classes simulating objects moving round
> on a chess-style board of squares.
> 
> I want to concentrate on writing the classes and their behaviour, and
> not on display issues, but I would like it if the resulting program
> was reasonably interesting. To that end, I was thinking of putting
> together a frontend that displayed the objects moving round on a board
> (rather than, for example, just printing out lists of co-ordinates).
> I'd build the frontend, then my student could write the object classes
> and drop them into the framework.
> 
> My problem is that I've never written any sort of game code for
> Python, which is basically what this is. And I don't have a lot of
> time to develop something. So I was wondering - are there any
> ready-made examples of the sort of driver I'm thinking of? Something
> like a framework for a Chess or Othello game, but with the actual game
> logic isolated so I could easily rip it out and replace it with my
> own. I've done some searching around, but most of the examples I've
> seen seem to have the display and game logic intermingled (at least to
> my untrained eye).
> 
> Any suggestions? If not, I guess I'll just have to write my own. I'm
> sure I could - it's just that I don't want my training to be messed up
> because of bugs in my code...
> 
> Thanks,
> Paul
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I started something similar to this and didn't get far. I wrote a base class 
called Piece that had common attributes (I.e., color and position) and abstract 
methods (i.e., move). From the base class I derived all the piece types. That's 
the easy part.

The board is a bit tricky, depending on how you set it up. The board of 64 
squares could be a list, a dictionary or a class. I went with a Board class 
that used a coordinate system (i.e., bottom row first square was (0, 0) and top 
row last square (7, 7)) and kept track of everything on the board.

The furthest I got with this was a simple text display and interface to move 
pawns and bishops forward.

Chess may look straight forward but it can get complicated in a hurry. If you 
look at the computing literature, chess has been a never ending rabbit hole for 
50+ years. 

Chris R.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "tkinter"

2017-09-13 Thread Christopher Reimer
> On Sep 13, 2017, at 5:28 AM, Stefan Ram  wrote:
> 
>  I presume that "tkinter" is intended to be pronounced
>  "logically":
> 
> T K inter (tee kay inter /ti keI In t%/)
> 
>  . But it would be faster to pronounce it 
> 
> T kinter (tee kinter /ti kIn t%/)
> 
>  . So far I've only ever read it, never heard it.
>  But while I am aware that the logical pronunciation should
>  be the correct one, I actually like the faster one.
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

When I started my technical career 20+ years ago, tcl/tk was pronounced 
"tickle" by the engineers.  Not sure if that was correct then or now.

Chris R. 
-- 
https://mail.python.org/mailman/listinfo/python-list


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.
> The ones I've seen, including new ones, are Python 2.
> 
> Some people here use Py3 but I haven't heard (or don't remember) enough
> about what they're working on, to know if those are py3 codebases of any
> size.  If they say yes, I'll take their word for it, but this is a
> self-selected group of course.
> 
>> That simply isn't true, unless you think it more likely everyone who
>> discusses their Python 3 code base is lying.
> 
> People discuss Python language issues here a lot, but don't discuss as
> much about code bases.
> 
> I know when I install a new OS (currently Debian 9 which was released
> a month or so ago) and type "python" on the command line, I get Py2.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

FreeNAS 11 (based on FreeBSD) has Python 3.6.1 installed and uses Django for 
the web interface.

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 cool kids 
>> --
>> and is also too stupid to know how dumb they are.
>> 
>> "Hi, I've been programming in Python for what seems like days now, and here's
>> all the things that you guys are doing wrong. I insist that you fix them
>> immediately, it doesn't matter how much code it will break, that's not
>> important. What is important is that Javascript programmers like me shouldn't
>> be expected to learn anything new or different when they program with 
>> Python."
>> 
>> /rant off
>> 
>> And no, for once it wasn't Ranting Rick.
> 
> The thing that struck me about the interaction (on Python-Ideas, btw) was 
> that Javascript actually is adding new language features at an impressive 
> pace, and many of them seem very Pythonic.  But they sometimes choose 
> different syntax.
> 
> For example, their "spread" operator is ..., where Python uses *:
> 
> new_list = [new_start, *old_list, new_end]
> 
> vs:
> 
> new_array = [new_start, ...old_array, new_end]
> 
> Making Python more like Javascript (in this case) would have required 
> breaking existing Python programs. Javascript could have use * as the spread 
> operator without breaking anyone. But they didn't, and I wonder if anyone 
> petitioned them to keep compatibility with Python to easy the plight of the 
> multi-lingual programmer.
> 
> --Ned.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I came across a blog post that pointed out that those who advocate for a 
particular JavaScript framework probably know enough JavaScript for the 
framework but not enough JavaScript to figure out a problem with the framework. 
Since frameworks are an abstraction of JavaScript, you really need to know 
JavaScript to avoid getting stuck with a framework. I know enough JavaScript to 
get the JQuery eye candy to work and I'm confused by all the frameworks 
available. I picked up a JavaScript ebook to familiarize myself with the 
language. This isn't the same JavaScript that I learned in the early 2000's. 

Chris R. 
-- 
https://mail.python.org/mailman/listinfo/python-list


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  writes:
> of course, I use calculators and computers but I still understand the
> theory behind what I am doing.
 
   I started out programming in BASIC. Today, I use Python,
   the BASIC of the 21st century. Python has no GOTO, but when
   it is executed, its for loop eventually is implemented using
   a GOTO-like jump instruction. Thanks to my learning of BASIC,
   /I/ can have this insight. Younger people, who never learned
   GOTO, may still be able to use Python, but they will not
   understand what is going on behind the curtains. Therefore, for
   a profound understanding of Python, everyone should learn BASIC
   first, just like I did!
>>> 
>>> Tsk.  You should have learned (a fake simplified) assembler first, then
>>> you'd have an appreciation of what your processor actually did.
>>> 
>>> :-)
>> 
>> Tsk, Tsk.  Before learning assembly, you should design an instruction
>> set and implement it in hardare.  Or at least run in in a VHDL
>> simulator.  [Actually, back in my undergrad days we used AHPL and
>> implemented something like a simplified PDP-11 ISA.]
>> 
>> Alternatively, you should design an instruction set and implement it
>> using microcode and AM2900 bit-slice processors.
>> 
>> --
>> Grant Edwards   grant.b.edwardsYow! Could I have a drug
>>  at   overdose?
>>  gmail.com
>> 
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>> 
> 
> Even Assembly is easy nowadays:
> https://fresh.flatassembler.net/index.cgi?page=content/1_screenshots.txt
> -- 
> https://mail.python.org/mailman/listinfo/python-list

Is assembly still a thing today? 

I wanted to take assembly in college but I was the only student who showed up 
and the class got cancelled. I dabbled with 8-but assembly as a kid. I can't 
imagine what assembly is on a 64-bit processor.

Chris R. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: errors with json.loads

2017-09-20 Thread Christopher Reimer
> On Sep 20, 2017, at 5:03 PM, Stefan Ram  wrote:
> 
> Dennis Lee Bieber  writes:
>> After removing all the \xa0 bytes
>> and trying to decode it I get...
> 
>  I did the same here, before I read your post.
>  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 
> Newsgroups: comp.lang.python
> Subject: Setting property for current class from property in an different 
> class...
> Date: Wed, 6 Sep 2017 19:24:40 -0700
> Message-ID: 
> 
>  , and when I removed them, I was able to execute the
>  source from his post from 2017-Sep-06 without errors.
> 
>  So I was feeling to lazy to bother this time.
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I had a NBSP in my code?! News to me...

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 suggest that
> 
> if x>y :
> pass
> 
> should be written
> if x > y:
>pass
> 
> Personally, I like seeing a space before the colon (:).   And then in
> 
> my_list = [ i for i in range(0, 10) ]
> it complains about my extra space inside of the brackets.
> 
> If you are teaching beginning students, do you expect them to try to follow 
> these sorts of conventions?  Is it perfectly fine to let "taste" guide you 
> (I'm just trying to get a feel for the philosophy here)?   I also notice 
> "break" and exception handling is used much more in Python than in C++, for 
> instance.  I was taught "break" and "continue" led to "unstructured 
> code"--but that was a while back.  I can still see their use  causing 
> potential trouble in (really-long) real-world code.
> 
> Bill
> 
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I came across a Python script on Github that did what I needed except for some 
trivial modifications to make it Python 3 compatible. I did consider 
contributing changes to make the script Python 2 and 3 compatible. However, the 
script was written an idiosyncratic, anti-PEP8 style that was hard to match and 
the author previously rejected all Python 3 contributions. Forking the script 
to make it Python 2/3 compatible *and* PEP8 compliant would require too much 
effort on my part, especially since I needed to use the script only once.

Chris R. 
-- 
https://mail.python.org/mailman/listinfo/python-list


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,
> suppose that package requires you call an initialize function of some
> sort. Where does that go? I know about setUp and setUpClass methods in
> unittest.TestCase. Is order of execution of doctests deterministic
> across modules (say, when tests are run through nosetests)?
> 
> In my case, I didn't know what order things would be called, so I
> added a call to initialize() at the start of every doctest and added a
> setUpClass class method to all my TestCase subclasses. Just in case.
> It worked okay because my initialize function can be called multiple
> times. What about situations where it can only be called once? Do you
> have to define some sort of super_initialize() function for your tests
> which guarantees that your initialize function is called precisely
> once?
> 
> This all seems rather messy. I'm open to better ways to do this, but
> as I've only had one cup of coffee this morning, no spark of insight
> has zapped my frontal cortex as yet.
> 
> Thx,
> 
> Skip
> -- 
> https://mail.python.org/mailman/listinfo/python-list

Seems like you’re overthinking this. You should be able to unit test any part 
of your code in isolation. If not, you need to refactor your code. I generally 
don’t use test classes in pytest.

Chris R. 
-- 
https://mail.python.org/mailman/listinfo/python-list


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 3.5). AFAIK, I haven't written any 
version-specific code.

How do I determine the lowest version of Python to run?

I'm leaning towards installing the latest minor version of each available major 
version, running tox to run the unit tests against each one, and seeing what 
blows up.

Thank you, 

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 out how to package a project; a good tutorial 
> URL would be appreciated on that, too.
> 
> Thanks!
> 
> Leam
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I'm looking at tox that will automatically set up virtualenv for running unit 
tests under different versions of Python. 

https://tox.readthedocs.io/en/latest/

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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  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 against each one, and 
>> seeing what blows up.
> 
> Perhaps you can use the service of Travis (travis-ci.org) to avoid installing 
> the Python
> versions yourself. They have lots of older versions available to run tests on.
> 
> Irmen
> -- 
> https://mail.python.org/mailman/listinfo/python-list

Travis might be a bit of an overkill for my project. Someone suggested docker 
containers and there is a docker plugin for tox that looks promising.

Chris R. 
-- 
https://mail.python.org/mailman/listinfo/python-list


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  
wrote:
> 
>> On Oct 5, 2017, at 1:11 PM, Irmen de Jong  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 against each one, and 
>>> seeing what blows up.
>> 
>> Perhaps you can use the service of Travis (travis-ci.org) to avoid 
>> installing the Python
>> versions yourself. They have lots of older versions available to run tests 
>> on.
>> 
>> Irmen
>> -- 
>> https://mail.python.org/mailman/listinfo/python-list
> 
> Travis might be a bit of an overkill for my project. Someone suggested docker 
> containers and there is a docker plugin for tox that looks promising.
> 
> Chris R. 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

So I got tox and tox-docker installed. When I went to install Docker for 
Windows, it wouldn't work because Hyper-V wasn't available on Windows 10 Home. 
After paying Microsoft $99 for the privilege, I got Windows 10 Pro installed 
and Docker started working. I've read that all the cool programming kids are 
using Docker these days. I certainly hope it was worth the cost. O_o

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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  
wrote:
> 
> Op 2017-10-06, Christopher Reimer schreef :
> 
>> So I got tox and tox-docker installed. When I went to install Docker
>> for Windows, it wouldn't work because Hyper-V wasn't available on
>> Windows 10 Home. After paying Microsoft $99 for the privilege, I got
>> Windows 10 Pro installed and Docker started working. I've read that
>> all the cool programming kids are using Docker these days. I certainly
>> hope it was worth the cost. O_o
> 
> You could have just used a Linux VM in Virtualbox for $0, and run Docker
> in that.
> 
> Stephan
> -- 
> https://mail.python.org/mailman/listinfo/python-lists 

My $200 Dell laptop couldn't handle that combo and it would add an extra layer 
of complexity to my programming setup.

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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.  There aren't enough stones in the world...
>> 
> 
> PHP seems (seemed?) popular for laying out web pages.  Are their vastly 
> superior options? I'm a little naive in this matter, thus my question.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

AFAIK, JavaScript frameworks has largely replaced PHP. I personally use Pelican 
to generate static web pages and use JavaScript sparingly.

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 existing library, like Time4J, first.
>> 
>>  Though in many cases, an ISO 8601 time string 
>>  represented by a (named )Python tuple should
>>  be sufficient for a time stamp.
>> 
>>  E.g., ( year, month, day, hour, minute, seconds,
>>  zone_offset ).
>> 
> 
> Python provides a datetime (also: date, time, timedelta) type. Use it.
> 
> https://docs.python.org/3/library/datetime.html
> 
> When working with time zones, the standard library needs a little help.
> Luckily, there's a module for that. https://pypi.python.org/pypi/pytz
> 
> -- Thomas
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I wrote a blog post about muddling through the timestamp problem, showing 
examples for datetime, slice-and-dice text, and pytz. Since I was dealing with 
time zone-specific timestamps, I went with pytz in the end.

https://www.kickingthebitbucket.com/2017/04/04/the-python-time-zone-rabbit-hole/

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2017-10-17 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 3.4 might be moot for my program. It choked on a starred 
expression in a unit test. The starred expression got changed in Python 3.5 and 
my unit tests pass in Python 3.5/3.6. I don't think I can live without that 
feature. 

Thank you,

Chris R. 
-- 
https://mail.python.org/mailman/listinfo/python-list


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
> very confused when they get an AttributeError on requests.get().

For my web scraper program, I'm using "requestor.py" for requests. :)

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 machine. I guess it's the same for the Mac: Your version of MacOS
> happens to include Python 2.6, so this is what PyCharm uses.

I find it hard to believe that a professor would recommend downloading an IDE 
at the start of an intro class. Students usually start off with a text editor.

Chris R. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Keep or drop index.html from Django?

2017-10-27 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 URLs as clean as 
possible (i.e., no *.html at the end). I can go either way with this. What's 
the best practice for this?

Thank you,

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 word like ex:-123 One hundred twenty three?
>> 
>> Here’s  one I 
>> did earlier, in Algol 68.
>> 
>> Conversion to Python is left as an exercise for the reader.
> 
> I think that gives away rather more than I wanted the student to see.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I thought the classic homework problem was to convert an Arabic numeral into a 
Roman numeral. Bonus points for correctly converting any number above 12 and/or 
copyright year from any old movie. Most students have seen Roman numerals on 
clocks (1-12).

Maybe that's too hard for today's kids with digital clocks.

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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
 archiving your messages?
>>>   I am posting to a Usenet newsgroup. I am not aware of any
>>>   "Python-List mailing list".
>>> 
>>>   I am posting specifically to the Usenet, because I am aware
>>>   of it's rules and I like it and wish to support it.
>>> 
>>>   I do not post to a "mailing list" because I do not know which
>>>   rules apply for mailing lists and whether mailing lists in
>>>   general or any specific mailing list is an environment that I
>>>   like or wish to support.
>>> 
>> 
>> The dual nature of this online community has long been confusing and 
>> complicated.  It's both a newsgroup and a mailing list.  Add in Google 
>> Groups, and you really have three different faces of the same content.
>> 
>> The fact is, posting to comp.lang.python means that your words are also 
>> being distributed as a mailing list. Because of your messages' headers, 
>> they are not in the archive of that list 
>> (https://mail.python.org/pipermail/python-list/2017-November/thread.html), 
>> or in Google Groups 
>> (https://groups.google.com/forum/#!topic/comp.lang.python/0ejrtZ6ET9g). 
>> It makes for odd reading via those channels.
>> 
>> I don't understand the motivation for limiting how words are 
>> distributed, but others on this list also do it. For example, Dennis Lee 
>> Bieber's messages are not in the Python-List archives either. If 
>> something is worth saying, why not let people find it later?
> 
> To which I would add:
> Setting headers is hardly a working method.
> Somebody quotes Stefan or Dennis and they are on the archives
> And some quote including emails some not
> etc
> -- 
> https://mail.python.org/mailman/listinfo/python-list

A troll tried to prove that I was too retarded to program in Python by claiming 
that I asked a question on this list in the archives that could have been 
answered by searching the web. The funny thing is that none of the links that 
the troll provided answered my question.

Chris R. 
-- 
https://mail.python.org/mailman/listinfo/python-list


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:
 Where are your unittests for these unittests?
>>> 
>>> No, the point of having unit tests is to build confidence that the
>>> code in question works correctly. It's *possible* that the code is
>>> broken, and that the test is also broken in a way that hides the
>>> brokenness of the code, but this is much less likely than the case
>>> where just the code is broken. This is also the reason why the
>>> philosophy of test-drive development stipulates that one should write
>>> the test *first*, run it and watch it fail (this ensures that the test
>>> is actually testing *something*) and then and only then write the code
>>> to make the test pass.
>> 
>> To be fair, TDD doesn't actually prove that the test isn't broken. It
>> only protects you against one class of error: tests that actually
>> aren't testing anything. Proponents of TDD will argue that this class
>> of error is quite common; true or not, it's still only one particular
>> kind of failure. It's definitely possible for tests to be wrong in
>> such a way that they don't detect faulty code.
>> 
>> So what do we do? WE TEST BY HAND. Ultimately, unit testing is a tool,
>> not a magic wand. It's up to us to actually put it to use to improve
>> code quality.
> 
> Certainly. I wasn't trying to advocate for TDD here, which I don't
> even practice regularly myself.
> -- 
> https://mail.python.org/mailman/listinfo/python-list

For anyone who is interested, "Test-Driven Development with Python: Obey the 
Testing Goat: Using Django, Selenium, and JavaScript" by Harry J.W. Percival. 
The second edition came out this year. A good introduction to unit and function 
testing.

Chris R. 
-- 
https://mail.python.org/mailman/listinfo/python-list


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 Hudson via Python-list  wrote:
> I remember it well.  It's what I used to initially learn C.  I'm a
> completely self-taught, hobby programmer.  Been around since the
> MITS Altair.  How many remember that beast??
 
 Remember it and still have it in the basement.
>>> I read a lot about the Altair in Byte in those days, but never had a
>>> chance to touch it. Wasn't it horrible expensive?
>> 
>> I can't remember what is was going for but I bought mine used for
>> $1,000.  It had a number of add-ons including a keyboard and floppy
>> drives.  The power supply was also beefed up.
>> 
>> It also had a replacement bezel.  It seems that the original Altair's
>> silk screened front panel was crappy and rubbed off easily.  Some
>> company sold one but it says "Cycloid" instead of "Altair" on it.
> 
> I think the first BASIC Interpreter ever sold by Gates & Friend was for this 
> machine? How did you use your floppy drives on this machine 
> (Open-Write-Close)?

Paper tape reader. The first time I came across a paper tape reader when I 
visited the university as a teenager in 1984. A CNC machine read the paper tape 
to drill six holes in a piece of metal.

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


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 getting in the 
> way.
> 
> Can you turn off such warnings?

IIRC, if you turn off this warning, it also turns off a more useful warning 
somewhere else.

My favorite PyCharm warning bug is creating a base class with an implemented 
getter and an unimplemented setter. When the base class is inherited and the 
setter is implemented, the IDE warns that the getter is missing. The workaround 
is to implement the getter with a super call. This bug is several years old and 
no one had fixed it because it has workaround.

Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psychocomputational analysis toolkit in Python?

2018-03-08 Thread Christopher Mullins
You might find MNE useful, and if what you're doing happens to fit
somewhere in their package you could contribute to it -- they're a good
group to work with.

https://www.martinos.org/mne/stable/index.html
https://github.com/mne-tools/mne-python
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psychocomputational analysis toolkit in Python?

2018-03-08 Thread Christopher Mullins
> Would it be possible to emulate a minimally functional brain-to-brain
coupling system entirely in Python?

I don't know what that would entail, but the links I shared have a mailing
list and a very responsive gitter, both of which would be great places to
ask about that!  (You're welcome to ask here of course, but this being the
general python mailing list, it's a shot in the dark.)  Good luck!

Chris
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-10 Thread Christopher Mullins
In the code you linked, I don't see where the *R*equest is used. The
request variable is setup by flask when you annotate the function with the
resource endpoint and POST method. It contains the content of the request
which can be converted to json if that content type was specified.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-12 Thread Christopher Mullins
>
> Could you please give some context when you reply, TIA
>

Whoops, thanks for the reminder Mark.

So what for the Request is used  for then?


In general when you see that something in Python starts with a capital
letter, that indicates a class. Check out the relevant section of the PEP8
coding style [1], this is a good reference to have on hand.  (This
generalization doesn't apply to builtin types which follow a separate
convention, also outlined in [1] -- and of course there are a numerous
exceptions.)

This holds for your variable in question "request" which is an instance of
the Request class.  Check out [2] for more information on this.  PyCharm
tries to do its best but I've had this problem too.  You can always open up
a python REPL and look at the object yourself:

>>> import flask
>>> r = flask.Request
>>> r

>>> dir(r)

and so on.  When I'm working in python I like to keep one of these open for
this purpose.

HTH,
Chris

[1] https://www.python.org/dev/peps/pep-0008/#class-names
[2] http://flask.pocoo.org/docs/0.12/api/#incoming-request-data
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python3.7 error PYQT5 - NameError: name 'self' is not defined

2018-09-21 Thread Christopher Mullins
>
> Hi when I disconnect the internet I get an error NameError: name 'self' is
> not defined. I really dont get it.. thanks all. Is that a bug? or my fault?

Exception in thread Thread-1:
> Traceback (most recent call last):
>   File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py",
> line 93, in secret
> print(ping('google.com'))
>   File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py",
> line 72, in ping
> conn.connect((addr, 80))
> socket.gaierror: [Errno 11001] getaddrinfo failed
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
>   File
> "C:\Users\Alon\AppData\Local\Programs\Python\Python37-32\lib\threading.py",
> line 917, in _bootstrap_inner
> self.run()
>   File
> "C:\Users\Alon\AppData\Local\Programs\Python\Python37-32\lib\threading.py",
> line 865, in run
> self._target(*self._args, **self._kwargs)
>   File "C:\programming Alon\stock market app\PROJECT\AlonStockMarket.py",
> line 95, in secret
> self.pushButton.setDisabled(True)
> NameError: name 'self' is not defined


Looks like `self` is supposed to be referring to an instance of the class
`Ui_AlonStockMarketApp` (which has the pushButton attribute) but you've
defined the secret function outside of that class.  Try defining that
function inside your class.

HTH,
Chris
-- 
https://mail.python.org/mailman/listinfo/python-list


How much sanity checking is required for function inputs?

2016-04-17 Thread Christopher Reimer

Greetings,

I'm currently building a chess engine to learn the finer details of 
Python. When I learned all flavors of Java in community college a decade 
ago, we had to sanity check the hell out of the input values for every 
function and wrote a lot of redundant code in addition to the 
getters/setters code.


Here's the input sanity checking I got for a generator function to 
return a set of chess pieces for a specified color and position.



def generate_set(color, positions):

if color not in [VARS['COLOR_BLACK'], VARS['COLOR_WHITE']]:
raise Exception("Require \'{}\' or \'{}\' for input value, got 
\'{}\' instead.".format(VARS['COLOR_BLACK'], VARS['COLOR_WHITE'], color))


if len(positions) != 16:
raise Exception("Require 16 positions for input value, got {} 
instead.".format(len(positions)))



The two sanity checks are fairly straight forward. Color input has to 
match the color constant strings. Positions input has to have 16 items.


I *could* sanity check the positions input to determine if it had a list 
of 16 valid coordinates. The reason I don't is because the code that 
calls this function builds the coordinates from constants with valid 
coordinates. However, if I was doing this in my Java classes, one of my 
instructors rap me on the knuckles for not sanity checking to nth degree.


How much sanity checking is too much in Python?

Thank you,

Chris R


--
https://mail.python.org/mailman/listinfo/python-list


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

2016-04-17 Thread Christopher Reimer

On 4/17/2016 3:18 PM, Michael Selik wrote:


I'd rather turn the question around: how much sanity checking is
necessary or useful? You'll find the answer is "surprisingly little"
compared to your experience in Java.


I'm looking for a pythonic approach to sanity checking. From what I read 
elsewhere, sanity checking belongs in the unit tests and/or library 
classes designed for other people to use. I haven't seen many examples 
of sanity checks that is common in Java.



For example, you don't need to
explicitly check whether the color is present in your dictionary,
because it'll give you a KeyError if you look up a bad key.


Without the sanity check against the constant dictionary, the color 
variable could be anything (it should be a string value). Looking at the 
code again, I should relocate the sanity checks in the Piece base class.



Why does the len of positions need to be 16?


The positions variable is list of coordinates for 16 chess pieces (eight 
pawns, two rooks, two knights, two bishops, a king and a queen) for each 
color, locating the pieces on either the bottom quarter (i.e., [(1,1), 
..., (2,8)]) or the top quarter (i.e., [(7,1), ..., (8,8)]) of the board.


Thanks,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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

2016-04-19 Thread Christopher Reimer

On 4/19/2016 1:02 AM, Michael Selik wrote:


Why relocate rather than remove? What message would you provide that's
better than ``KeyError: 42`` with a traceback that shows exactly which
dictionary is being used and how?


I think you misread my code. No dictionary exception occurs in the 
sanity checks. Below is the full function with the revised sanity check 
for positions that compares the input list with the two valid lists of 
board positions.



def generate_set(color, positions):

if positions not in [VARS['COORDINATES'][VARS['BOARD_BOTTOM']],
 VARS['COORDINATES'][VARS['BOARD_TOP']]]:
raise Exception("List for positions contains no valid 
coordinates, "

"got {} instead.".format(positions))

# generate objects according to color and position
for position in positions:
rank, file = position
if rank in VARS['RANK_NOBILITY']:
if file in VARS['FILE_ROOK']:
yield Rook(color, position)
elif file in VARS['FILE_BISHOP']:
yield Bishop(color, position)
elif file in VARS['FILE_KNIGHT']:
yield Knight(color, position)
elif file is VARS['FILE_QUEEN']:
yield Queen(color, position)
elif file is VARS['FILE_KING']:
yield King(color, position)
else:
yield Pawn(color, position)



I meant, what goes wrong if the number of positions input is other than
16? Without these "sanity" checks, your functions might be reusable in,
say, a checkers game.


Chess has 16 pieces (six types) on each side that are set up on the 
board in a particular order. Checkers has 12 pieces (one type) on each 
side that are set up on alternating squares in no particular order. 
Since I'm writing a chess engine because it has endless supply of 
programming changes, I have no desire to write reusable code for two 
similar but different games at the same time.


Thanks,

Chris R.

--
https://mail.python.org/mailman/listinfo/python-list


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

2016-04-21 Thread Christopher Reimer

Greetings,

Thanks to everyone for providing feedback. Here's my revised code to 
generate a set of chess pieces.



class PieceFactory(object):

def factory(color, piece, position):
if piece == 'Bishop':
return Bishop(color, position)
if piece == 'King':
return King(color, position)
if piece == 'Knight':
return Knight(color, position)
if piece == 'Pawn':
return Pawn(color, position)
if piece == 'Queen':
return Queen(color, position)
if piece == 'Rook':
return Rook(color, position)

raise PieceException('No valid Piece object for factory, 
got {}'

 ' instead'.format(piece))

factory = staticmethod(factory)


def generate_set(color, pieces, positions):

for piece, position in zip(pieces, positions):
yield getattr(PieceFactory, 'factory')(color, piece, position)


The input values for 'pieces' and 'positions' are 16-item lists zipped 
together to produce a piece name and a position coordinate for the 
factory method. With slight modifications to the code, the factory 
method could also return checker pieces.


I got the factory method from here: 
http://python-3-patterns-idioms-test.readthedocs.org/en/latest/Factory.html


I do plan to incorporate a sanity test in each Piece class to validate 
the initial position value. Pawns have 16 specific positions. Bishop, 
Knight and Rook each have four specific positions. King and Queen each 
have two specific positions. An invalid value will raise an exception.


Finally, VARS['VARIABLE_NAME'] got change to const['variable_name']. 
Should smell better.


Thanks,

Chris R

--
https://mail.python.org/mailman/listinfo/python-list


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

2016-04-21 Thread Christopher Reimer

On 4/21/2016 6:54 PM, Tim Chase wrote:


I'd simplify this code to something like

   class PieceFactory(object):
 @staticmethod
 def factory(color, piece, position):
   try:
 return {
   'Bishop': Bishop,
   'King': King,
   'Knight': Knight,
   'Pawn': Pawn,
   'Queen': Queen,
   'Rook': Rook,
   }[piece](color, position)
   except KeyError:
 raise PieceException(...)


I like this better. I'll probably remove the try/except and let the 
KeyError filter up.


Thanks,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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

2016-04-21 Thread Christopher Reimer

On 4/21/2016 7:10 PM, Ethan Furman wrote:

I do plan to incorporate a sanity test in each Piece class to validate
the initial position value. Pawns have 16 specific positions. Bishop,
Knight and Rook each have four specific positions. King and Queen each
have two specific positions. An invalid value will raise an exception.


This will make it so you cannot use your PieceFactory for custom setups.



The sanity check won't be in the PieceFactory, but in the Piece class as 
an interface and each Piece subclass will implement the correct 
positions for comparison.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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

2016-04-21 Thread Christopher Reimer

On 4/21/2016 7:20 PM, Stephen Hansen wrote:
Whyyy are you using getattr? Something wrong with 
PieceFactory.factory(color, piece, position)? (Or, better yet, yield 
piece_factory(color, piece, position) where piece_factory is just a 
function)


Because the example I found used it, I implemented it, and it worked in 
my code. Based on feedback that I gotten from this list, I'll go back 
and clean it up.



I... that... what... I'd forget that link and pretend you never went
there. Its not helpful.


I found it on the Internet, so it must be true -- and Pythonic at that!

What's the contents of this big dictionary that has everything in it 
for some reason?


Keep in mind that I'm coming from a Java background (not by choice) with 
a smattering of C programming. I initially had ALL THESE CONSTANTS in 
different parts of my code and couldn't easily use them across different 
modules. I didn't like all these constants, created a singleton class 
that uses ConfigParser, dumped everything into a .ini file, and accessed 
from in each module. As I learn to write Pythonic code, the constants 
may go away. Switching from my original code to the factory method 
eliminated a half-dozen constants.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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

2016-04-23 Thread Christopher Reimer

On 4/21/2016 9:46 PM, Ethan Furman wrote:

Oh! and Enum!!!  ;)


OMG! I totally forgot about Enum. Oh, look. Python supports Enum. Now I 
don't have to roll my own!


Hmm... What do we use Enum for? :)

Thank you,

Chris R.

--
https://mail.python.org/mailman/listinfo/python-list


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 in the 
files?


Some of these constants are shortcuts. Instead of writing slice(0, 16) 
or slice(48, 64), and getting the two confused, I write 
const['board_bottom'] or const['board_top'], respectively, when I want 
to pull the correct set of positions from coordinates list.



That said, if you're wanting to share constants across different parts
of your code, use a module.


I did that at first, made it into a dictionary class and added 
ConfigParser to the mix. I had a lot of fun putting that one together. 
However, as I refactor my code further as I learn new things, it will 
probably get changed or removed. Being a research project, I'm willing 
to dive into every rabbit hole that I come across to learn Python properly.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 procedural scripts and translated old BASIC games 
into Python for two years. One day I came across a Python book that 
described the principles of subclassing from a base class for chess 
pieces, but there was no code to demonstrate the process. I had no 
problem creating the Python classes. That's how my research project got 
started to build a chess engine. If you ever check the academic 
literature for chess programming, this research project could turn into 
a lifelong endeavor.


I had to confront all the bad habits I brought over Java and change my 
code to be more Pythonic. This is where I started having fun, learning 
the tricks and collapsing multi-line code into a single line code. I've 
learned more about Python in the few weeks than I had in two years of 
writing procedural scripts and translating BASIC goto hell.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 state. I'm under the 
impression that pickle (or something else) would save and load the 
instantiated object of each piece. If that's not the case, I'll change 
the code then.


The sanity check does have an exemption for pawn promotion, where a pawn 
reaching the other side of the board can be promoted to another piece 
(typically a queen). I played Sargon II chess on the Commodore 64 for 
five years as a teenager. The worst game I ever won was when the 
computer had nine queens on the board. I thought the computer was 
cheating outrageously but a chess rule book confirmed that promotion was 
a legit move.


https://en.wikipedia.org/wiki/Promotion_(chess)

If I need to add an exemption to custom plays, I'll add it then. Right 
now I'm cleaning up the existing code from all the bad Java habits.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 into this chess program, I might need a 
speed boost here and there.


Thank you,

Chris R.

--
https://mail.python.org/mailman/listinfo/python-list


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 mixing classes and functions in a 
single file was okay. Once I finished cleaning up the code for this 
round, I'll merge four files into one file (~500 lines) and have four 
files (main.py, display.py, engine.py and utility.py).



Or just use one file to keep things easier. But, yes, I agree a module
of constants is appropriate for bigger projects.


That's the other problem I'm running into. Building a chess engine is a 
big project. This is probably bigger than the Java XML parser I built 
from scratch for a college project. I can't seem to find any information 
on how to build bigger programs. Community college taught me how to 
program, but it didn't teach me how to go beyond class inheritance.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 scripts AND translating BASIC games into Python, which can be 
goto hell if the program has a drop-down structure that makes sense only 
from following the entry point of the goto statement (see link for example).


http://www.atariarchives.org/basicgames/showpage.php?page=9

I try to follow the BASIC program structure as closely as possible, get 
it working in Python, and use pylint to make my code PEP8-compliant. 
Pylint frequently complains about exceeding a dozen if branches in the 
main function. I then create helper functions to reduce the if branches. 
Sometimes that makes the Python version either shorter or longer than 
the original BASIC program.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 code is procedural, by
the way).
I never wanted to learn Java in the first place. My community college 
couldn't afford to renew the Microsoft site license, which local 
employers required to learn C/C++ in MS Visual Studio, and all flavors 
of Java got taught for the programming classes instead. I wanted to 
learn C/C++. I even wanted to learn assembly language, but I was the 
only student who showed up for the class and it got cancelled.


Of course, it probably doesn't help that I got a job in help desk 
support after I graduated with A.S. degree in Java and never programmed 
professionally. Thinking like a programmer helped me resolved many IT 
problems over the last 12 years. My current job in computer security 
requires tinkering with PowerShell scripts as Python is strictly 
prohibited in this Windows shop. I have made Python my main programming 
language at home.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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': 'value'}

Or:

class Test2(dict):
def __init__(self):
self.__dict__ = {'key', 'value'}

I haven't seen a good pro/con discussion on the Internet for using one 
over the other. I played with both in my code. Doesn't seem to make a 
great difference either way. Using object seems to be the most simplest 
approach.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 
decided to simplify the base class for the chess pieces (see code 
below). All the variables are stored inside a dictionary with most 
values accessible through properties. A custom dictionary can be loaded 
through the constructor and or saved out through the fetch_state method. 
The subclasses only have to implement the is_move_valid method, which is 
different for each type of chess piece.


Thank you,

Chris R.



class Piece(object):
def __init__(self, color, position, state=None):
if state is None:
self._state = {
'class': self.__class__.__name__,
'color': color,
'first_move': True,
'initial_position': position,
'move_count': 0,
'name': color.title() + ' ' + self.__class__.__name__,
'notation': color.title()[:1] + 
self.__class__.__name__[:1],

'position': position
}
else:
self._state = state

@property
def color(self):
return self._state['color']

def fetch_state(self):
return self._state

def is_move_valid(self, new_position, board_state):
raise NotImplementedError

@property
def move_count(self):
return self._state['move_count']

@property
def name(self):
return self._state['name']

@property
def notation(self):
return self._state['notation']

@property
def position(self):
return self._state['position']

@position.setter
def position(self, position):
self._state['position'] = position
if self._state['first_move']:
self._state['first_move'] = False
self._state['move_count'] += 1
--
https://mail.python.org/mailman/listinfo/python-list


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 fair to say that 
your object is-a dict and should be modeled as such.


These questions are more useful for me to consider. For my chess piece 
base class, the answer is no.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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'}

is essentially equivalent to:

 self.key = value

and will be regardless of whether you inherit from object or dict. If
you find this distinction confusing, then I recommend not inheriting
from dict.


Which expression is Pythonic? I've seen both used in various examples on 
the Internet.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 instead. This is my 
implementation of that idea. However, saving and loading data is far 
down my to do list.


I know you've stated reasons for doing things the way you have, but 
this self._state dict smells a bit funny, especially where you have 
self._state = state, which means that several instances could have the 
exact same state object at the same time and strikes me as mildly 
un-pythonic and very confusing. "State" is what instances themselves 
are supposed to track by design. I recommend you use this feature 
rather than duplicating it with your own error-prone dict handling. 


So far the code is working as designed for new chess pieces (see below).

Thank you,

Chris R.

Rook('white', (1, 1)) @ 2106251742008
Knight('white', (1, 2)) @ 2106251755648
Bishop('white', (1, 3)) @ 2106251755760
Queen('white', (1, 4)) @ 2106251755872
King('white', (1, 5)) @ 2106251755984
Bishop('white', (1, 6)) @ 2106251756096
Knight('white', (1, 7)) @ 2106251756208
Rook('white', (1, 8)) @ 2106251756320
Pawn('white', (2, 1)) @ 2106251756432
Pawn('white', (2, 2)) @ 2106251756544
Pawn('white', (2, 3)) @ 2106251756656
Pawn('white', (2, 4)) @ 2106251756768
Pawn('white', (2, 5)) @ 2106251756880
Pawn('white', (2, 6)) @ 2106251756992
Pawn('white', (2, 7)) @ 2106251757104
Pawn('white', (2, 8)) @ 2106251757216
Pawn('black', (7, 1)) @ 2106251742288
Pawn('black', (7, 2)) @ 2106251742400
Pawn('black', (7, 3)) @ 2106251742512
Pawn('black', (7, 4)) @ 2106251742624
Pawn('black', (7, 5)) @ 2106251742736
Pawn('black', (7, 6)) @ 2106251742848
Pawn('black', (7, 7)) @ 2106251742960
Pawn('black', (7, 8)) @ 2106251743072
Rook('black', (8, 1)) @ 2106251743184
Knight('black', (8, 2)) @ 2106251742120
Bishop('black', (8, 3)) @ 2106251740608
Queen('black', (8, 4)) @ 2106251740496
King('black', (8, 5)) @ 2106251740832
Bishop('black', (8, 6)) @ 2106251741672
Knight('black', (8, 7)) @ 2106251741784
Rook('black', (8, 8)) @ 2106251741896

--
https://mail.python.org/mailman/listinfo/python-list


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 them behind the scenes).

* Expresses that intention more concisely (fewer terms).

* Expresses that intention more clearly (less syntactic noise).


In short,  my original code before I turned it into a separate 
dictionary. *sigh*


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 constructor of 
the Pawn object. The Piece object will throw a NotImplementedError if 
called directly. I guess I'll have to look at pickle sooner rather than 
later.



Also, your code will give the same notation to Kings and Knights.


Good catch. I knew I was forgetting something. I overrode variable in 
the Knight class to produce the correct notation.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 R.

--
https://mail.python.org/mailman/listinfo/python-list


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 
some_instance.__dict__['an_attribute']




DOH! I need a doughnut. :)

Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 file.  XML could be another format
used for your file, if you're into that kind of thing.


Funny that you should mention the ini file. I wrote a ConfigParser class 
for my const['whatever'] variable. It wouldn't take much to use that in 
the meantime until I get a handle on pickle.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 the space characters in the list.

list(filter((lambda x: x.isupper()), string))

['W', 'T', 'F']

Note that there are no space characters in the list.

Shouldn't the results between 'not x.islower()' and 'x.isupper()' be 
identical?


The final form of this code is this:

list(filter(str.isupper, string))

['W', 'T', 'F']

Thank you,

Chris R.


--
https://mail.python.org/mailman/listinfo/python-list


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.

str.islower(): "Return true if all cased characters [4] in the string 
are lowercase and there is at least one cased character, false otherwise."


https://docs.python.org/3/library/stdtypes.html?highlight=islower#str.islower

str.isupper(): "Return true if all cased characters [4] in the string 
are uppercase and there is at least one cased character, false otherwise."


https://docs.python.org/3/library/stdtypes.html?highlight=isupper#str.isupper

Here's the footnote that may or not be relevant to this discussion: "[4] 
Cased characters are those with general category property being one of 
“Lu” (Letter, uppercase), “Ll” (Letter, lowercase), or “Lt” (Letter, 
titlecase)."


A bug in the docs?

Thank you,

Chris R.


--
https://mail.python.org/mailman/listinfo/python-list


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 
documentation, I doubt it would get change. The programmer still has an 
obligation to test the code to make sure that it works as expected, 
which was what I did that until I found the concise statement that 
worked exactly as I wanted it to.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 character. b) is failing. Ergo, 
you're getting the underscores.


I see where the problem lies in my thinking. I went looking for a single 
line solution for the whole string. If I had constructed a for loop and 
tried to reduce it to a single line, I *may* have understood the 
relationship between the different parts. Or maybe not. Blaming the 
documentation is a lot easier. ;)


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 a technical question per say, but it is a Python programming 
related one. How do you motivate a person (either yourself or your child) to 
become more interested in programming and stick with it ? Is determination in 
learning (especially in a tough field like software) partly genetic ?

Related , This is a very well written essay on determination by Paul Graham 
http://www.paulgraham.com/determination.html

Gengyang


I started out translating old BASIC games into Python. These are the 
same BASIC games that I tried to program into my Commodore 64 without 
much success when I was much younger. Many of these BASIC games are a 
good introduction to classical programming problems like rolling dice 
and playing cards.


http://www.atariarchives.org/basicgames/

When I realized that I wasn't learning enough about the Python language 
from translating BASIC games, I started coding a chess engine. If you 
ever look at the academic literature for chess programming from the last 
50+ years, you can spend a lifetime solving the programming challenges 
from implementing the game of kings.


Thank you,

Chris R.


--
https://mail.python.org/mailman/listinfo/python-list


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   __ __ __ __ __ __ __ __

 4   __ __ __ __ __ __ __ __

 3   __ __ __ __ __ __ __ __

 2   WP WP WP WP WP WP WP WP

 1   WR WN WB WQ WK WB WN WR

 A  B  C  D  E  F  G  H


With feedback from this list, I had to break a lot of bad Java habits to 
make the code more Pythonic. Right now I'm going back and forth between 
writing documentation and unit tests. Once I finalized the code in its 
current state, I'll post it up on GitHub under the MIT license. Future 
updates will have a fuller console interface and moves for individual 
pieces implemented.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 the Pylint 
warning can be disabled.


http://stackoverflow.com/questions/3569134/why-doesnt-pylint-like-built-in-functions

Here's the replacement code using list comprehension:

''.join([x for x in string if x.isupper()])

Which is one is correct (Pythonic)? Or does it matter?

Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 background, I had to unlearn everything 
from Java before I could write Pythonic code. It might help to use an 
IDE that offers PEP8-compliant code suggestions (I use PyCharm IDE).



That's about as good as it's gonna get!


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.


pylint says "Consider using enumerate instead of iterating with range 
and len"


the offending code is:
for j in range(len(list1)):
  do something with list1[j], list2[j], list3[j], etc.


This code is reeking with bad habits to be broken. Assigning a throwaway 
variable to walk the index is unnecessary when Python can do it for you 
behind the scenes. As Chris A. pointed out in his post, you should use 
zip() to walk through the values of each list at the same time.


Thank you,

Chris R.

--
https://mail.python.org/mailman/listinfo/python-list


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 needed, and wasteful. The above skips building a
list, instead returning a generator ...

filter used to build a list, but now it doesn't (where "used to" means
Python 2.7 and "now" means Python 3.5; I'm too lazy to track down the
exact point(s) at which it changed):

Oh, didn't know that. Then again the OP was converting the output of
filter *into* a list, which wasted a list either way.


My line of code was something I copied off the Internet and modified it 
until it did I exactly what I wanted it to do. That means that the many 
Python 2 code examples available on the Internet are using a redundant 
list operation with Python 3. Isn't that a "smell" that pylint should 
pick up on?


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 weight to pylint's opinion on what
is "good" or "bad" programming habits.


I forgot to add the warning, "Use pylint with a dash of salt on a lemon 
slice and a shot of tequila." :)


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 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 
Pythonic and PEP8-compliant as possible. That includes scoring 10/10 
with pylint. Never know when an asshat hiring manager would reject my 
resume out of hand because my code fell short with pylint.


For my purposes, I'm using the list comprehension over filter to keep 
pylint happy.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 about anything. So I ran it against my unit tests that I'm 
still writing, haven't cleaned up and checked against pylint. I got 
dinged for using a star import on a file with a common variables, which 
was an easy fix.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 is it doesn't even display a 
board.  It accepts a move as input, records the move, analyzes the 
positions after the move, and returns the next move.


My code has display and engine as separate classes with a main loop 
coordinating things between the two. The main loop requests the board 
state (dict) from the engine class and passes that to show board on the 
display class.



Here's the UCI protocol.
http://download.shredderchess.com/div/uci.zip


Very interesting. Something to add to my research notes. I'll muddle 
through with my code and let it grow organically for now.  If I decide 
to write a chess engine that implements the UCI protocol, I'll start 
over with a clean slate.


Thank you,

Chris R.

--
https://mail.python.org/mailman/listinfo/python-list


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
 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 Pythonic and PEP8-compliant as possible. That includes scoring 
10/10 with pylint. Never know when an asshat hiring manager would 
reject my resume out of hand because my code fell short with pylint. 
For my purposes, I'm using the list comprehension over filter to keep 
pylint happy. 

Wrong thinking. Make it Pythonic - but don't concern yourself with
pylint's final score. Read pylint's output and learn from it, but
don't treat a 10/10 score as the ultimate in ratings, because it just
isn't.

I agree with that in principle. But...

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
Recruiters and hiring managers *are* hobgoblins with with little minds. 
And definitely not PEP8-complaint. :)


When I was out of work for two years (2009-10), underemployed for six 
months (working 20 hours per month), and filed for Chapter Seven 
bankruptcy in 2011, I  only had 20 job interviews during that time. That 
was a learning experience. I did everything possible to present myself 
and my resume as perfectly as possible. When I had another bout of 
unemployment that lasted eight months (2013-14), I had 60 job interviews 
and three job offers to pick from at the end. Of course, that was for IT 
support contracts. Maybe programming jobs will have fewer hobgoblins.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 :

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
checking the company out.

Would you want to work for an asshat hiring manager?

Of course, you might not have the luxury of being picky.


Most asshat managers I've dealt with often say to me, "Here's a mole 
hole, go fix it." I look at the mole hole (little problem), look at the 
mountain (big problem) in the distant, and jump over the mole hole to 
start climbing the mountain. After I reduce the mountain to a mole hole, 
the asshat manager gets promoted and I'm looking for a job again.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 and the other core
developers, and you and feel obligated to follow them.

They should at least add a disclaimer "Using the default options, pylint
checks that your code complies with the pylint-approved subset of Python."


I wasn't aware that I was picking sides in a religious war by altering 
one line of code. O_o


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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

Recruiters and hiring managers *are* hobgoblins with with little minds.
And definitely not PEP8-complaint. :)


Do you think that recruiters and hiring managers read your code at all, let
alone that they read it will an eye to PEP 8 compliance?


I meant more than a few technical professionals who got pushed out of 
the job to become recruiters. They tend to ask about everything on the 
resume to poke holes where they can. Each time I tightened the wording 
of my resume whenever they exposed something. If I posted a GitHub link 
on my resume, they *would* check it out. If they know Python, they 
*would* run it.


As for PEP 8 compliance, it was a joke (see the smiley). Laugh, it was 
funny.



No recruiter[1] will do this. No recruiter will even know what PEP 8 is.
They're looking for technical buzzwords ("ten years experience with
Django"), they aren't qualified to judge whether your Django code is good,
bad or indifferent. That's up to the client.


When I used to apply to Linux system admin jobs, the recruiters would 
have a checklist box for the "Red Hat GUI Thing" as an absolute 
requirement. My Linux work experience was exclusively remote command 
line. On the rare occasions that I have used the Linux GUI, I always 
used what got installed as the default GUI for Fedora or Mint.


The first time I said I didn't know what the "Red Hat GUI Thing" was and 
explained that I was fast learner, the recruiter hung up on me. I tried 
to argue with other recruiters that I knew the command line equivalent 
for the GUI. No dice. Some recruiters even accused me of making up 
techno-babble. They all hung up on me. After a dozen phone calls like 
that (all for positions at different companies), I generally stopped 
applying to Linux jobs.


This year I built an inexpensive PC to run Linux and installed the 
current Red Hat Linux. Guess what? The "Red Hat GUI Thing" wasn't 
installed. In fact, the GUI was Gnome by default. According to my 
coworkers, Red Hat started phasing out their own branded GUI several 
years ago. I guess the recruiters haven't gotten the memo yet, as I had 
a phone call about the "Red Hat GUI Thing" last year.



A hiring manager with a technical background might, once you are in
consideration for the job. More likely they will delegate any judgement to
a technical manager, or programmer, who may or may not be a hobgoblin with
a little mind.


Every hiring manager I've ever interviewed with had a technical 
background. The only exception was when the final interview was with the 
marketing director at hardware company. I declined to take the job. If 
you know your Dilbert, it's bad luck when a hardware company is run by 
the marketing department. I wasn't surprised that the company filed 
bankruptcy a few years later.


Thank you,

Chris R.

--
https://mail.python.org/mailman/listinfo/python-list


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:

   https://en.wikipedia.org/wiki/Six_Californias>

Each state gets two senate seats, and California, being the most
populous state, suffers.


The Six Californias is a proposal to divide up the 54 electoral votes 
that California has in presidential elections, which is a solidly blue 
state for the Democrats. Half the population lives in the Los Angeles, 
San Francisco and Sacramento regions. Put these three regions into 
separate states, the other three regions will become solidly red states 
for the Republicans and tilt the presidential elections in their favor. 
The proposal is a solution for the underlying problem that the 
California Republican Party has more in common with the endangered 
spotted owl than one-tenth of the US population. It's easier to redraw 
the lines than compete for votes.


Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 terrorists pythonists are


I wonder how many Americans are aware that they use Hindu-Arabic 
numerals in daily transactions?


https://en.wikipedia.org/wiki/Hindu%E2%80%93Arabic_numeral_system

Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 teachers, particularly but not only
for very young children.


A college instructor encouraged me to become a teacher,  especially as 
boys from single mom families needed a daily role model. I looked into 
it and took some preparatory childhood classes. When the local 
university had a presentation for their teacher program, I went, saw how 
sausage got made, and ran like hell.


Thank you,

Chris R.

--
https://mail.python.org/mailman/listinfo/python-list


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 Zuckerberg, Larry Ellison and Jeff Bezos) , a very large
percentage. Science and Technology is in a sense the most egalitarian
field in the world, because it involves using your brains and
creativity. You don't need to have a father who is a director at
Goldman Sachs or a mother who is the admissions officer at Harvard to
succeed in this line.

Bill Gates III's father was a prominent lawyer, his mother was on the
board of directors for First Interstate BancSystem and United Way, and
one of his grandfathers was a national bank president. Gates himself
went to Harvard.

Zuckerberg's paternal grandparents were successful middle class,
described as  being the first on the block to own a colour TV. (This was
back in the days when colour TVs were an expensive toy that few could
afford.) His parents were also very successful professionals: a dentist
and a psychiatrist. And he too went to Harvard. Despite the jeans and
tee-shirts Zuckerberg is known for wearing, he's firmly from the
professional/upper class.

Bezos comes from a family of land-holders from Texas. His grandfather
was regional director of the U.S. Atomic Energy Commission, and was
financially successful enough to retire at an early age. He didn't go to
Harvard, but he did go to Princeton.

Ellison is the son of an unwed mother who gave him up for adoption by
her aunt and uncle, comfortably middle-class. That makes him the closest
out of the group as a "regular guy".

And at least 2 of the above reached their position using business
practices that could be described as less than 100% honorable & above
board.


What do you expect from people who haven't graduated from Harvard? :P

Thank you,

Chris R.
--
https://mail.python.org/mailman/listinfo/python-list


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 self._first_move:
self._first_move = False
self._position = position

Blank is a subclass of the Piece class that represents an empty space on 
the board and  is a placeholder in the Board class _state dict. Since 
Blank is a placeholder and not a playable game piece, I want to make 
@position.setter non-operational (i.e, make no changes to the position 
value).


@Piece.position.setter
def position(self, position):
pass

This code works and the corresponding unit test blows up because I 
haven't changed it yet, but the PyCharm IDE complains that the 
Blank.position signature doesn't match the Piece.position signature. 
Never mind that I copy and paste the identical declaration from the 
Piece class.


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 super seems redundant.  Not sure if I 
found a bug with the PyCharm hint feature or I'm not subclassing the 
@property setter correctly. Which is it?


Thank you,

Chris R.

--
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   >