[Python-announce] SCons 4.6.0 released

2023-11-19 Thread Bill Deegan
A new SCons release, 4.6.0, is now available on the SCons download page:

https://scons.org/pages/download.html


Here is a summary of the changes since 4.5.2:

NEW FUNCTIONALITY
-

- D compilers : added support for generation of .di interface files.
  New variables DI_FILE_DIR, DI_FILE_DIR_PREFIX, DI_FILE_DIR_SUFFIX,
  DI_FILE_SUFFIX.
- MSVC: If available, native arm64 tools will be used on arm64 hosts for
VS2022.
- MSVC: If necessary, automatically define VSCMD_SKIP_SENDTELEMETRY for
VS2019 and later
  on arm64 hosts when using an arm (32-bit) build of python to prevent a
powershell
  error pop-up window (powershell dll not found).
- Add a LIBLITERALPREFIX variable which can be set to the linker's
  prefix for considering a library argument unmodified (e.g. for the
  GNU linker, the ':' in '-l:libfoo.a'). Fixes Github issue #3951.


CHANGED/ENHANCED EXISTING FUNCTIONALITY
---

- When debugging (--debug=pdb), the filenames SConstruct and SConscript
  are now recognized when manipulating breakpoints. Previously,
  only a full pathname to an sconscript file worked, as pdb requires
  a .py extension to open a file that is not an absolute path.
- Three unused non-public methods of the Environment Base class
  were dropped: get_src_sig_type, get_tgt_sig_type, _changed_source.
  These were unused remnants of the previously removed SourceSignatures
  and TargetSignatures features (dropped in 3.1.2).
- The --debug flag now has a 'json' option which will write information
  generated by --debug={count, memory, time, action-timestamps} and about
  the build.
- Obsoleted YACCVCGFILESUFFIX, it's being replaced by
YACC_GRAPH_FILE_SUFFIX.
  If YACC_GRAPH_FILE_SUFFIX is not set, it will respect YACCVCGFILESUFFIX.
- The yacc tool now understands the bison behavior of --header, --defines
  and --graph being called without an option-argument as being synonyms
  for -d (first two) and -g. -H also recognized as a synonym for -d.
  Default value for $YACC_GRAPH_FILE_SUFFIX changed to '.gv' to match
  current bison default (since bison 3.8). Set this variable to '.dot'
  if using byacc. Fixes #4326 and #4327.
- MSVC: When trying to find a valid msvc batch file, the existence of the
msvc compiler
  executable is verified for VS6 to VS2015 to avoid executing the msvc
batch file when
  the host/target tool is known not to be present. Always check that the
msvc compiler
  executable is found on the msvc script environment path after running the
msvc batch
  file.  This is predominately needed for recent versions of Visual Studio
where the msvc
  batch file exists but an individual msvc toolset may not support the
host/target
  architecture combination.  For example, when using VS2022 on arm64, the
arm64 native
  tools are only installed for the 14.3x toolsets.
- MSVC: When the msvc compiler executable is not found during setup of the
msvc
  environment, the warning message issued takes into account whether or not
a
  possibly erroneous compiler executable was already present in the scons
environment
  path.  See CHANGES.txt for details.
- Extend range of recognized Java versions to 20.
- Builder calls (like Program()) now accept pathlib objects in source lists.
- The Help() function now takes an additional keyword argument keep_local:
  when starting to build a help message, you can now retain help from
AddOption
  calls (options added for the project_, but omit help for SCons' own
cmdline
  options with "Help(newtext, append=True, local_only=True)".
- Calling SConscript() with a nonexistent file is now an error.
  Previously this succeeded - prior to SCons 3.0, silently; since 3.0, with
  a warning. Developers can still instruct such an SConscript() call not
  to fail by being explicit: pass keyword argument "must_exist=False".
  The "--warn=missing-sconscript" commandline option is no longer available
  as the warning was part of the transitional phase.
- Add missing directories to searched paths for mingw installs
- SCons.Util.types renamed to to SCons.Util.sctypes to avoid any possible
  confusion with the Python stdlib "types" module. Note that it was briefly
  (for 4.5.x only) possible to import directly from SCons.Util.types,
  although the preferred usage remains to import from SCons.Util only.
  Any code that did the direct import will have to change to import from
  SCons.Util.sctypes.
- Add JDK 21 LTS support
- The newly added --debug=sconscript option (new) will output notices when
  entering an exiting each SConscript as they are processed.

FIXES
-

- Fixed: when using the mingw tool, if an msys2 Python is used (os.sep
  is '/' rather than the Windows default '\'), certain Configure checks
  could fail due to the construction of the path to run the compiled check.
- C scanner's dictifyCPPDEFINES routine did not understand the possible
  combinations of CPPDEFINES - not aware of a "name=value" string either
  embedded in a sequence, or by itself.  The 

[Python-announce] SCons 4.5.2 Released

2023-03-21 Thread Bill Deegan
A new SCons release, 4.5.2, is now available on the SCons download page:

https://scons.org/pages/download.html

Here is a summary of the changes since 4.5.1:

FIXES
-

-  Fix a problem (#4321) in 4.5.0/4.5.1 where ParseConfig could cause an
   exception in MergeFlags when the result would be to add preprocessor
   defines to existing CPPDEFINES. The following code illustrates the
   circumstances that could trigger this:
  env=Environment(CPPDEFINES=['a'])
  env.Append(CPPDEFINES=['b'])
  env.MergeFlags({'CPPDEFINES': 'c'})

PACKAGING
-

- Remove the redundant `wheel` dependency from `pyproject.toml`,
  as it is added automatically by the setuptools PEP517 backend.


Thanks to the following contributors listed below for their contributions
to this release.
==
.. code-block:: text

git shortlog --no-merges -ns 4.5.1..HEAD
 3  Mats Wichmann
 2  William Deegan
 1  Michał Górny
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[Python-announce] SCons 4.5.1 Released

2023-03-06 Thread Bill Deegan
A new SCons release, 4.5.1, is now available on the SCons download page:

https://scons.org/pages/download.html

Here is a summary of the changes since 4.5.0:

FIXES
-

- Fix a problem in 4.5.0 where using something like the following code
  will cause a Clone()'d environment to share the CPPDEFINES with the
  original Environment() which was cloned. Causing leakage of changes
  to CPPDEFINES when they should be completely independent after the Clone.
  env=Environment(CPPDEFINES=['a'])
  env.Append(CPPDEFINES=['b']) (or AppendUnique,Prepend,PrependUnique)
  env1=env.Clone()
  env1.Append(CPPDEFINES=['c']) (or any other modification, but not
overwriting CPPDEFINES)
  Now env['CPPDEFINES'] will contain 'c' when it should not.


Thanks to the following contributors listed below for their contributions
to this release.
==
.. code-block:: text

git shortlog --no-merges -ns 4.5.0..HEAD

 3  William Deegan
 1  Mats Wichmann
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[Python-announce] SCons 4.5.0 Released

2023-03-05 Thread Bill Deegan
A new SCons release, 4.5.0, is now available on the SCons download page:

https://scons.org/pages/download.html


Here is a summary of the changes since 4.4.0:

NOTE: If you build with Python 3.10.0 and then rebuild with 3.10.1 (or
higher), you may
  see unexpected rebuilds. This is due to Python internals changing
which changed
  the signature of a Python Action Function.

NOTE: If you use a dictionary to specify your CPPDEFINES, you may see an
unexpected rebuild.
  The insertion order of dictionary keys is now preserved when
generating the command line.
  Previously these were sorted alphabecially.  This change to the
command line,
  while generating identical set of CPPDEFINES can change order and
cause a rebuild.


NEW FUNCTIONALITY
-

- Added ValidateOptions() which will check that all command line options
are in either
  those specified by SCons itself, or by AddOption() in
SConstruct/SConscript.  It should
  not be called until all AddOption() calls are completed. Resolves Issue
#4187
- Added --experimental=tm_v2, which enables Andrew Morrow's NewParallel Job
implementation.
  This should scale much better for highly parallel builds.  You can also
enable this via SetOption().
- Added FILE_ENCODING, to allow explicitly setting the text encoding for
files
  written by the Textfile() and Substfile() builders. If not specified,
Textfile() and Substfile() builders
  will write files as UTF-8.


DEPRECATED FUNCTIONALITY


- The qt tool has been renamed qt3.

CHANGED/ENHANCED EXISTING FUNCTIONALITY
---

- Added -fsanitize support to ParseFlags().  This will propagate to CCFLAGS
and LINKFLAGS.
- Calling EnsureSConsVersion() and EnsurePythonVersion() won't initialize
  DefaultEnvironment anymore.
- The console message from the Chmod() action function now displays
  octal modes using the modern Python syntax (0o755 rather than 0755).
- Migrated logging logic for --taskmastertrace to use Python's logging
module. Added logging
  to NewParallel Job class (Andrew Morrow's new parallel job implementation)
- Preliminary support for Python 3.12.
- Run LaTeX after biber/bibtex only if necessary
- Configure context methods CheckLib and CheckLibWithHeader now expose
  two additional keyword arguments: 'append', which controls whether to
append
  (the default) or prepend discovered libraries to $LIBS, and 'unique',
  which controls whether to add the library if it is already in the $LIBS
  list. This brings the library-adding functionality in Configure in line
  with the regular Append, AppendUnique, Prepend and PrependUnique methods.
- CPPDEFINES values added via a dictionary type are longer sorted by
  key. This used to be required to maintain a consistent order of
  commandline arguments between SCons runs, but meant macros were not
  always emitted in the order entered. Sorting is no longer required
  after Python interpreter improvements.  There might be a one-time
  rebuild of targets that involved such sorted keys in their actions.
- Renamed the 'qt' tools to 'qt3' since the logic in that tool is only for
QT version 3.
  Renamed all env vars which affect qt3 from QT_ to QT3_.  If you are still
using SCons
  to build QT 3 code, you'll need to update your SConscripts.  Note that
using 'qt' tool
  has been deprecated for some time.


FIXES
-

- Added missing newline to generated compilation database
(compile_commands.json)
- A list argument as the source to the Copy() action function is now
handled.
  Both the implementation and the strfunction which prints the progress
  message were adjusted.
- The Java Scanner processing of JAVACLASSPATH for dependencies (behavior
  that was introduced in SCons 4.4.0) is adjusted to split on the system's
  search path separator instead of on a space. The previous behavior meant
  that a path containing spaces (e.g. r"C:\somepath\My Classes") would
  lead to unexpected errors. If the split-on-space behavior is desired,
  pre-split the value: instead of: env["JAVACLASSPATH"] = "foo bar baz"
  use: env["JAVACLASSPATH"] = env.Split("foo bar baz")
  There is no change in how JAVACLASSPATH gets turned into the -classpath
  argument passed to the JDK tools.
- Ninja: Fix execution environment sanitation for launching ninja.
Previously if you set an
  execution environment variable set to a python list it would crash. Now it
  will create a string joining the list with os.pathsep
- Fixed command line argument --diskcheck: previously a value of 'none' was
ignored.
  SetOption('diskcheck','none') is unaffected, as it did not have the
problem.
- Fixed Issue #4275 - when outputting compilation db and TEMPFILE was in
use, the compilation db would have
  command lines using the generated tempfile for long command lines,
instead of the full command line for
  the compilation step for the source/target pair.
- A refactor in the caching logic for version 4.4.0 left Java inner classes
  failing 

[Python-announce] SCons 4.4.0 Released

2022-07-30 Thread Bill Deegan
A new SCons release, 4.4.0, is now available
on the SCons download page:

  https://scons.org/pages/download.html

Here is a summary of the changes since 4.3.0:

NOTE: If you build with Python 3.10.0 and then rebuild with 3.10.1 (or
higher), you may
  see unexpected rebuilds. This is due to Python internals changing
which changed
  the signature of a Python Action Function.


NEW FUNCTIONALITY
-

- Added MSVC_USE_SCRIPT_ARGS Environment variable which specifies command
line arguments
  to pass to the script specified by MSVC_USE_SCRIPT.
- Added Configure.CheckMember() checker to check if struct/class has the
specified member.
- Added SHELL_ENV_GENERATORS construction variable. This variable should be
set to a list
  (or an iterable) which contains functions to be called in order
  when constructing the execution environment (Generally this is the shell
environment
  variables). This allows the user to customize how (for example) PATH is
constructed.
  Note that these are called for every build command run by SCons. It could
have considerable
  performance impact if not used carefully.
- Added MSVC_USE_SETTINGS construction variable to pass a dictionary to
configure the msvc compiler
  system environment as an alternative to bypassing Visual Studio
autodetection entirely.
- Added MSVC_SDK_VERSION construction variable which allows building with a
specific Microsoft
  SDK version. This variable is used with the msvc batch file determined
via autodetection. Refer
  to the documentation for additional requirements and validation details.
- Added MSVC_TOOLSET_VERSION construction variable which allows building
with a specific toolset
  version. This variable is used with the msvc batch file determined via
autodetection.  This
  variable does not affect the autodetection and selection of msvc
instances. The toolset version
  is applied after an msvc instance is selected. This could be the default
version of msvc. Refer
  to the documentation for additional requirements and validation details.
Addresses issue #3265,
  issue #3664, and pull request #4149.
- Added MSVC_SPECTRE_LIBS construction variable which allows building with
spectre-mitigated
  Visual C++ libraries. This variable is used with the msvc batch file
determined via autodetection.
  Refer to the documentation for additional requirements and validation
details.
- Added MSVC_SCRIPT_ARGS construction variable which specifies command line
arguments that are
  passed to the msvc batch file determined via autodetection.  Refer to the
documentation for
  additional requirements and validation details.  Addresses enhancement
issue #4106.
- Ninja: Added new alias "shutdown-ninja-scons-daemon" to allow ninja to
shutdown the daemon.
  Also added cleanup to test framework to kill ninja scons daemons and
clean ip daemon logs.
  NOTE: Test for this requires python psutil module. It will be skipped if
not present.
- Ninja: Added command line variable NINJA_CMD_ARGS that allows to pass
through ninja command line args.
  This can also be set in your Environment().
- Added a global policy setting and an environment construction variable
for specifying the
  action to be taken when an msvc request cannot be satisfied. The
available options are "error",
  "exception", "warning", "warn", "ignore", and "suppress".  The global
policy variable may be
  set and retrieved via the functions msvc_set_notfound_policy and
msvc_get_notfound_policy,
  respectively.  These two methods may be imported from
SCons.Tool.MSCommon. The environment
  construction variable is MSVC_NOTFOUND_POLICY.  When defined, the
environment construction
  variable overrides the global policy setting for a given environment.
When the active policy
  is "error" or "exception", an MSVCVersionNotFound exception is raised.
When the active policy
  is "warning" or "warn", a VisualCMissingWarning warning is issued and the
constructed
  environment is likely incomplete. When the active policy is "ignore" or
"suppress", no action
  is taken and the constructed environment is likely incomplete.  As
implemented, the default
  global policy is "warning".  The ability to set the global policy via an
SCons command-line
  option may be added in a future enhancement.
- Added a global policy setting and an environment construction variable
for specifying the
  action to be taken when msvc script errors are detected. The available
options are "error",
  "exception", "warning", "warn", "ignore", and "suppress".  The global
policy variable may be
  set and retrieved via the functions msvc_set_scripterror_policy and
msvc_get_scripterror_policy,
  respectively.  These two methods may be imported from
SCons.Tool.MSCommon. The environment
  construction variable is MSVC_SCRIPTERROR_POLICY.  When defined, the
environment construction
  variable overrides the global policy setting for a given environment.
When the active policy
  is "error" or "exception", an MSVCScriptExecutionError exception is

[Python-announce] SCons 4.3.0 released

2021-11-18 Thread Bill Deegan
A new SCons release, 4.3.0, is now available
on the SCons download page:

  https://scons.org/pages/download.html


NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer
supported

Here is a summary of the changes since 4.2.0:

NEW FUNCTIONALITY
-

- Ninja - Added ninja API 'NINJA_FORCE_SCONS_BUILD' to force a node to
callback to scons.
- Add support for Visual Studio 2022.

DEPRECATED FUNCTIONALITY


- The qt tool, which targets Qt version 3, is deprecated. Qt3 has been
unsupported by
  upstream for many years.  Qt4 and Qt5 tools are available from
scons-contrib.

CHANGED/ENHANCED EXISTING FUNCTIONALITY
---

- Ninja - Expanded ninja Mkdir to also support Mkdir actions.
- Further PCH updates. It's now recommended that env['PCH'] should always
be a File node.
  Either via return value from env.PCH() or by explicitly using
File('StdAfx.pch').
- Change SCons.Platform.win32.get_architecture() to return
platform.platform() when run in an
  environment where neither: PROCESSOR_ARCHITEW6432 nor
PROCESSOR_ARCHITECTURE is set.
  This should fix platform tests which started failing when
HOST_OS/HOST_ARCH changes
  introduced by Aaron Franke (listed below) were merged.
- The Java tool now accepts more versions (up to 17.0), and is better
  able to detect the many builds of OpenJDK available since it became
  designated the reference Java implementation.

FIXES
-

- Fix reproducible builds. Restore logic respecting SOURCE_DATE_EPOCH when
set.
- Small fix to ensure CLVar default value is an empty list.
  See MongoDB bug report: https://jira.mongodb.org/browse/SERVER-59656
  Code contributed by MongoDB.
- Ninja - Fix ninja tool to never use for_sig substitution because ninja
does not use signatures. This
  issue affected CommandGeneratorAction function actions specifically.
- Fix PCH not being evaluated by subst() where necessary.
- Fix issue #4021.  Change the way subst() is used in Textfile() to not
evaluate '$$(' -> '$',
  but instead it should yield '$('.
- Ninja - Fix command line escaping for ninja dollar sign escape. Without
escaping ninja properly,
- Fix MSVS tests (vs-N.N-exec.py) for MSVS 6.0, 7.0, and 7.1 (import
missing module).
- Fix command line escaping for ninja dollar sign escape. Without escaping
ninja properly,
  the ninja file scons regenerate and callback invocations will lose the $
characters used in
  the scons command line which ninja uses itself for escaping. For Example:
  scons BUILD=xyz OTHERVAR=$BUILD
  Prior to this fix, it would cause ninja to fail to escape the dollar
sign, leading to the
  single dollar sign being used as a ninja escape character in the ninja
file.
- Ninja - Fixed an issue where if you control-c and/or killed ninja while
it was running scons to regenerate
  build.ninja you would end up with no build.ninja file and have to rerun
scons from scratch.
  Code contributed by MongoDB.

DEVELOPMENT
---

- Added --no-ignore-skips to runtest.py. Changed default to ignore skips
when setting
  runtest.py's exit status. Previously would exit 2 if any tests were
skipped.
  Now will only exit 2 if user specifies --no-ignore-skips and some tests
were skipped.

Thanks to the following contributors listed below for their contributions
to this release.
==
.. code-block:: text

git shortlog --no-merges -ns 4.2.0..HEAD
47  Mats Wichmann
46  William Deegan
14  Jacob Cassagnol
11  Daniel Moody
 8  Ryan Egesdahl
 5  Joseph Brill
 4  Omar Polo
 2  Brian Quistorff
 1  Aaron Franke
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[issue45825] Heap Segmentation Fault

2021-11-17 Thread Bill Borskey

Bill Borskey  added the comment:

No worries. I find bugs in my day job, thought this might be a useful segfault 
but it segfaults because it’s incrementing that reference count on the pyobj 
that don’t exist. So pretty lame. I did spend an hour tracking it down so I 
thought I’d let y’all know in case you wanted to fix it. 

Cheers 

> On Nov 17, 2021, at 6:08 AM, Zachary Ware  wrote:
> 
> 
> Zachary Ware  added the comment:
> 
> In general, as soon as you touch ctypes you're on your own :).  ctypes has no 
> protections for this kind of case, so you need to protect yourself.
> 
> If you came across this some way that *should* have been safe, please provide 
> more information. But just passing a random memory address to ctypes is 
> likely to cause segfaults or worse.
> 
> --
> nosy: +zach.ware
> resolution:  -> not a bug
> status: open -> pending
> 
> ___
> Python tracker 
> <https://bugs.python.org/issue45825>
> ___

--
status: pending -> open

___
Python tracker 
<https://bugs.python.org/issue45825>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45825] Heap Segmentation Fault

2021-11-16 Thread Bill Borskey


New submission from Bill Borskey :

Dereferencing a python object that does not exist through ctypes caused a 
segfault in pymalloc_alloc. 

rdi: 0x0006  rsi: 0x0006 

0   org.python.python   0x0001081ee277 pymalloc_alloc + 74
1   org.python.python   0x0001081ed3dc _PyObject_Malloc + 17
2   org.python.python   0x000108296a94 normalizestring + 55
3   org.python.python   0x000108296540 _PyCodec_Lookup + 76

Looks like six was passed to the allocator, not sure exactly what was written 
to it, or if I can control that. But I guess it was more than six bytes. I 
don't have the id I used with the debug info above, but: I had a smallish list 
of characters, overwrote it with zeros, called del on it. I checked the value a 
couple times with ctypes. What I think happened is the garbage collector 
finally reclaimed the memory and crashed when I dereferenced again with the bad 
value.

I checked it out using 0xCC to get an idea of where the value was landing, and 
I'm overwriting rbx directly. But it doesn't get as far as above and segfaults 
at O_get rather than the allocator. 

I looked and I see this function:

static PyObject *
O_get(void *ptr, Py_ssize_t size)
{
PyObject *ob = *(PyObject **)ptr;
if (ob == NULL) {
if (!PyErr_Occurred())
/* Set an error if not yet set */
PyErr_SetString(PyExc_ValueError,
"PyObject is NULL");
return NULL;
}
Py_INCREF(ob);
return ob;
}

Seems like the code is increasing the reference count on the non-existing 
python object at 0x and writing out of bounds. 

$ python3 -X dev
Python 3.9.2 (default, Mar 26 2021, 23:27:12) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.cast(0x, ctypes.py_object).value
Fatal Python error: Segmentation fault

(below does not have the heap debugger on it seemed to mess with results)

Current thread 0x000104b83dc0 (most recent call first):
  File "", line 1 in 
Segmentation fault: 11

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x00010e1be8c0  rbx: 0x  rcx: 0x00010e2775c9  
rdx: 0x00010e283890
  rdi: 0x00010e1be8c0  rsi: 0x0008  rbp: 0x7ffee20f24e0  
rsp: 0x7ffee20f24d0
   r8: 0x0004   r9: 0x6a2bff3e46d2619c  r10: 0x00010e1d4b80  
r11: 0x00010e1d4bb8
  r12: 0x00010defc5e0  r13: 0x7f94edc5c390  r14: 0x00010e1e1b90  
r15: 0x
  rip: 0x00010e2775d7  rfl: 0x00010286  cr2: 0x00010e2730f3

--
components: ctypes
files: debug.txt
messages: 406443
nosy: thewb
priority: normal
severity: normal
status: open
title: Heap Segmentation Fault
type: crash
versions: Python 3.9
Added file: https://bugs.python.org/file50444/debug.txt

___
Python tracker 
<https://bugs.python.org/issue45825>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Current thinking on required options

2021-04-19 Thread Bill Campbell
On Mon, Apr 19, 2021, Loris Bennett wrote:
>Hi,
>
>I have various small programs which tend to have an interface like the
>following example:
>
>  usage: grocli [-h] [-o {check,add,delete}] [-u USERS [USERS ...]] [-g GROUP]

I would do this with the action is first argument.

Usage: grocli check|add|delete [-u USERS ...]

Bill
-- 
INTERNET:   b...@celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www2.celestial.com/ 6641 E. Mercer Way
Mobile: (206) 947-5591  PO Box 820
Fax:(206) 232-9186  Mercer Island, WA 98040-0820

Force always attracts men of low morality.  -- Albert Einstein
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue43745] ssl.OPENSSL_VERSION still reporting 1.1.1i on windows 3.8.9/3.9.4

2021-04-09 Thread Bill Collins


Bill Collins  added the comment:

Confirmed, thanks!

--

___
Python tracker 
<https://bugs.python.org/issue43745>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43745] ssl.OPENSSL_VERSION still reporting 1.1.1i on windows 3.8.9/3.9.4

2021-04-08 Thread Bill Collins


Bill Collins  added the comment:

The embeddable dists for 3.9.4 have updated, but the 3.8.9 packages are still 
showing the builds from April 2nd.

--

___
Python tracker 
<https://bugs.python.org/issue43745>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43745] ssl.OPENSSL_VERSION still reporting 1.1.1i on windows 3.8.9/3.9.4

2021-04-06 Thread Bill Collins


Bill Collins  added the comment:

Thanks for the quick action on this!

I've downloaded the new 3.8.9/3.9.4 installers, but they are unable to run over 
my existing 3.8.9/3.9.4 installs; "Unable to install python 3.9.4 (64-bit) due 
to an existing install." This is probably fine as I can just 
uninstall/reinstall (I hope), so just FYI.

I've upgraded my 32-bit install from 3.9.2 to the new 3.9.4 installer without 
issue.

Are you able to also update the embeddable packages please?

--

___
Python tracker 
<https://bugs.python.org/issue43745>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43745] ssl.OPENSSL_VERSION still reporting 1.1.1i on windows 3.8.9/3.9.4

2021-04-06 Thread Bill Collins


New submission from Bill Collins :

>>> import sys,ssl
>>> sys.version
'3.9.4 (tags/v3.9.4:1f2e308, Apr  4 2021, 13:27:16) [MSC v.1928 64 bit (AMD64)]'
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.1.1i  8 Dec 2020'

I may well be holding it wrong, but something seems off.

--
components: Windows
messages: 390303
nosy: Bill Collins, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: ssl.OPENSSL_VERSION still reporting 1.1.1i on windows 3.8.9/3.9.4
type: security
versions: Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue43745>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: How to remove "" from starting of a string if provided by the user

2020-08-11 Thread Bill Campbell
On Tue, Aug 11, 2020, Ganesh Pal wrote:
>The possible value of stat['server2'] can be either (a)
>"'/fileno_100.txt'" or (b) '/fileno_100.txt' .

def stripquotes(s):
'''Strip leading single or double quotes to any depth'''
import re
pat = re.compile(r'^([\'"])(.*)(\1)$')
slast = None
while slast != s:
slast = s
s = pat.cub(r'\2', s)
return s
# end stripquotes(s)

Bill
-- 
INTERNET:   b...@celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www2.celestial.com/ 6641 E. Mercer Way
Mobile: (206) 947-5591  PO Box 820
Fax:(206) 232-9186  Mercer Island, WA 98040-0820

Democracy is the theory that the common people know what they
want and deserve to get it good and hard. == H.L. Mencken
-- 
https://mail.python.org/mailman/listinfo/python-list


SCons 4.0.1 Released

2020-07-16 Thread Bill Deegan
  A new SCons release, 4.0.1, is now available
  on the SCons download page:

  https://scons.org/pages/download.html

  Here is a summary of the changes since 4.0.1:

  NEW FUNCTIONALITY

- Added Environment() variable TEMPFILEDIR which allows setting the
directory which temp
  files createdby TEMPFILEMUNGE are created in.

  DEPRECATED FUNCTIONALITY

- N/A

  CHANGED/ENHANCED EXISTING FUNCTIONALITY

- N/A

  FIXES

- Fix fortran tools to set SHFORTRAN variables to $FORTRAN, similarly
SHF77, SHF90, SHF95,
  SHF03 and SHF08 will default to the variables $F77, $F90, $F95, $F03
and $F08 respectively.
  If you were depending on changing the value of FORTRAN (or
$F[0-9][0-9]) having no effect
  on the value of SHFORTRAN, this change will break that.   The values
of FORTRAN, F77, F90,
  F95, F03, F08 and SHFORTRAN, SHF77 (etc.) now are not overridden in
generate if alredy set
  by the user.
- Fix subprocess execution of 'lslpp' on AIX to produce text standard
i/o.
- Re-do the fix for suncxx tool (Oracle Studio compiler) now that only
Python 3 is supported,
  to avoid decoding errors.

  IMPROVEMENTS

- N/A

  PACKAGING

- N/A

  DOCUMENTATION

- N/A

  DEVELOPMENT

- N/A

  Thanks to the following contributors listed below for their contributions
to this release.

git shortlog --no-merges -ns 4.0.0..HEAD
12  William Deegan
 2  Rob Boehne
 1  Clemens Tolboom
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue39085] Improve docs for await expression

2020-06-29 Thread Bill Wallace


Bill Wallace  added the comment:

There are a few other places on the documentation that are imprecise or 
misleading for await. While the information needed is scattered around the 
docs, I think these can also be improved. I'm pretty sure these fit with this 
issue.

Developing with asyncio guide:
https://docs.python.org/3/library/asyncio-dev.html#concurrency-and-multithreading
 - first paragraph, "When a Task executes an await expression, the running Task 
gets suspended, and the event loop executes the next Task."  Taken by itself it 
isn't clear that execution of the awaitable starts immediately without 
intervention from the event loop. A possible fix might be to add "If the 
awaited expression is a coroutine its execution begins immediately and the  
running Task will not suspend till the awaited expression stalls waiting for a 
result." 

The same sentence is found in the Task documentation: 
https://docs.python.org/3/library/asyncio-task.html#task-object

--
nosy: +wwallace

___
Python tracker 
<https://bugs.python.org/issue39085>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Missing python curses functions?

2020-05-19 Thread Bill Campbell
On Tue, May 19, 2020, Alan Gauld via Python-list wrote:
>During my Covid19 lock-down I thought I'd spend my time translating
>the "Linux Curses Programming HOWTO" document into Pythonic curses.
>
>One of the functions discussed that does not appear to have
>a Python equivalent is attr_get() which gets the current
>attributes.

I haven't looked for it.

...
>Is anyone other than me still even using Python curses? :-)

Raises hand.

Bill
-- 
INTERNET:   b...@celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www2.celestial.com/ 6641 E. Mercer Way
Mobile: (206) 947-5591  PO Box 820
Fax:(206) 232-9186  Mercer Island, WA 98040-0820

Democracy Is Mob Rule with Income Taxes
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: ALGOL 60 at 60

2020-05-16 Thread Bill Campbell
On Sun, May 17, 2020, DL Neil via Python-list wrote:
>ALGOL 60 at 60: The greatest computer language you've never used and
>grandaddy of the programming family tree
>Back to the time when tape was king
>By Richard Speed 15 May 2020 at 09:47
>https://www.theregister.co.uk/2020/05/15/algol_60_at_60/

Boy does that bring back some memories :-).

ALGOL was the third programming language I learned after FORTRAN
and Assembly on the Bendix G-20 in early 1966.

I first learned ALGOL on G.E. time sharing, where input was paper
tape, although it didn't require loading the compilers from tape
so I never hat that pleasure.  I loved the block structure of ALGOL,
and started indenting FORTRAN so that the program logic stood out
even if FORTRAN didn't understand it.

...
>ALGOL was almost 'the machine language' for the Burroughs B6700 series (and
>similar) but concurring with the article, we regarded it as somewhat academic
>and majored in FORTRAN, COBOL, or both. (as distinct from those who defined
>ComSc as compiler writing, for whom ALGOL was a brilliant tool!)

I really got into ALGOL on a time sharing system using the
Burroughs B-5500 where ALGOL was the system's native language,
there was no Assembly Language per-se.  The OS MCP, (Master
Control Progam) was written entirely in ALGOL.  The FORTRAN
compiler generated ALGOL source, and I learned a lot looking at
the ALGOL output of the FORTRAN program.

Many of the programming methods I use today have their roots in
doing a lot of scientific programming in ALGOL on the B-5500,
then in BPL (Burroughs Programming Language) on Burroughs Medium
Systems, B-2500->B-4500.

Bill
-- 
INTERNET:   b...@celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www2.celestial.com/ 6641 E. Mercer Way
Mobile: (206) 947-5591  PO Box 820
Fax:(206) 232-9186  Mercer Island, WA 98040-0820

In free governments the rulers are the servants, and the people their
superiors & sovereigns." -- Benjamin Franklin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Scons-dev] SCons 3.1.2 Released

2019-12-21 Thread Bill Deegan
Glad that helped!
Big thanks to Mats Wichmann for that one!

On Sat, Dec 21, 2019 at 10:41 AM Eric Fahlgren 
wrote:

> On Mon, Dec 16, 2019 at 7:02 PM Bill Deegan 
> wrote:
>
>> - EXPERIMENTAL NEW FEATURE: Enable caching MSVC configuration
>>   If SCONS_CACHE_MSVC_CONFIG shell environment variable is set,
>>   SCons will cache the results of past calls to vcvarsall.bat to
>>   a file; integrates with existing memoizing of such vars.
>>   On vs2019 saves 5+ seconds per SCons invocation, which really
>>   helps test suite runs.
>>
>
> Thanks a bunch for this one!  Our bare, no-target 'scons' invocation is
> down to about 0.8 seconds now, and we can do a single DLL build in ~2.5 s,
> which makes things very snappy indeed.
> ___
> Scons-dev mailing list
> scons-...@scons.org
> https://pairlist2.pair.net/mailman/listinfo/scons-dev
>
-- 
https://mail.python.org/mailman/listinfo/python-list


SCons 3.1.2 Released

2019-12-16 Thread Bill Deegan
  A new SCons checkpoint release, 3.1.2, is now available
  on the SCons download page:

  https://scons.org/pages/download.html

  Here is a summary of the changes since 3.1.1:

  NOTE: The 4.0.0 Release of SCons will drop Python 2.7 Support

  NEW FUNCTIONALITY
- Added debug option "action_timestamps" which outputs to stdout the
absolute start and end time for each target.

  REMOVED FUNCTIONALITY
- Turn previously deprecated debug options into failures:
  --debug=tree, --debug=dtree, --debug=stree, --debug=nomemoizer.
- Remove deprecated SourceSignatures, TargetSignatures
- Remove deprecated Builder keywords: overrides and scanner
- Remove deprecated env.Copy
- Remove deprecated BuildDir plus SConscript keyword build_dir


  CHANGED/ENHANCED EXISTING FUNCTIONALITY
- Update Command() function to accept target_scanner, source_factory,
and target_factory arguments.
  This makes Command act more like a one-off builder.
- Added support for "-imacros" to ParseFlags
- EXPERIMENTAL NEW FEATURE: Enable caching MSVC configuration
  If SCONS_CACHE_MSVC_CONFIG shell environment variable is set,
  SCons will cache the results of past calls to vcvarsall.bat to
  a file; integrates with existing memoizing of such vars.
  On vs2019 saves 5+ seconds per SCons invocation, which really
  helps test suite runs.

  FIXES
- Fix suncxx tool (Oracle Studio compiler) when using Python 3.
Previously would throw an exception.
  Resolved by properly handling tool version string output as unicode.
- Resolved a race condition in multithreaded Windows builds with Python
2
  in the case where a child process is spawned while a Python action
has a
  file open. Original author: Ryan Beasley.
- Fix CheckFunc detection code for Visual 2019. Some functions
  (e.g. memmove) were incorrectly recognized as not available.
- Fix stacktrace when using SCons with Python 3.5+ and SunOS/Solaris
related tools.
- Latex: Avoid crash with UnicodeDecodeError on Python 3 when a Latex
log file in
  non-UTF-8 encoding (e.g. containing umlauts in Latin-1 encoding when
  the fontenc package is included with \usepackage[T1]{fontenc}) is
read.
- CmdStringHolder fix from issue #3428

  IMPROVEMENTS
- Improved threading performance by ensuring NodeInfo is shared
  across threads. Results in ~13% improvement for parallel builds
  (-j# > 1) with many shared nodes.
- Improve performance of Entry.disambiguate() by making check for
  most common case first, preventing unnecessary IO.
- Improved DAG walk performance by reducing unnecessary work when
  there are no un-visited children.


  PACKAGING

 - N/A

  DOCUMENTATION

-  N/A

  DEVELOPMENT

- N/A


Thanks to the following developers for their contributions to this release.
git shortlog --no-merges -ns 3.1.1..HEAD
59  Mats Wichmann
21  William Deegan
 8  Edoardo Bezzeccheri
 5  Adam Gross
 5  maiphi
 4  Ivan Kravets
 4  Mathew Robinson
 2  Jakub Kulík
 2  Jacek Kuczera
 2  Rob Boehne
 2  Jason Kenny
 2  Tim Gates
 1  Jakub Kulik
 1  Theogen Ratkin
 1  jw0k
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Vim settings for Python (was: tab replace to space 4)

2019-12-07 Thread Bill Campbell
On Sat, Dec 07, 2019, Peter J. Holzer wrote:

>As an aside, to prevent vim from inserting tabs in the first place, set
>expandtab
>sw=4
>and maybe also
>ts=4

Inserting a comment in the file like this makes thing easy.

# vim: expandtab sw=4 ts=4 nows wm=0

Bill
-- 
INTERNET:   b...@celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www2.celestial.com/ 6641 E. Mercer Way
Mobile: (206) 947-5591  PO Box 820
Fax:(206) 232-9186  Mercer Island, WA 98040-0820

Political language... is designed to make lies sound truthful and
murder respectable, and to give an appearance of solidity to pure
wind. -- George Orwell
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using Makefiles in Python projects

2019-11-11 Thread Bill Deegan
You could use SCons (native python... )

On Mon, Nov 11, 2019 at 2:04 PM Grant Edwards 
wrote:

> On 2019-11-11, Rhodri James  wrote:
> >> I'm sure it's possible to write Makefiles that work with both GNU make
> >> and NMake, but I imagine it's a rather limiting and thankless
> enterprise.
> >>
> >> Is that something you actually do? (Maybe it's great, I really wouldn't
> >> know. Do tell!)
> >
> > Trying to work cross-platform with NMake/GNU make is every bit as horrid
> > as you're imagining when you start getting clever, and I haven't tried
> > doing it for years.
>
> That's my experience as well.
>
> > Generally when I'm working on both Windows and Linux, Cygwin is
> > involved anyway so I just use GNU make and be done with it.
>
> And that's also what I usually do.  I've been tempted to try msys
> make/bash instead of Cygwin, but that's probably not going to happen
> until something stops working under Cygwin or I run out of more
> entertaining projects before spring.
>
> --
> Grant Edwards   grant.b.edwardsYow! I want another
>   at   RE-WRITE on my CEASAR
>   gmail.comSALAD!!
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Would you be interested in this Python open source project?

2019-10-08 Thread Bill Deegan
You might just consider working with the BuildBot project to add support
for lighter weight build workers.
Re-Re-Re-inventing the wheel is almost always wasted effort.

On Tue, Oct 8, 2019 at 8:33 AM Rhodri James  wrote:

> On 08/10/2019 11:22, Simon Connah wrote:
> > I'm posting this message as a way to gauge interest in the project and
> > to see if it is worth moving forward with. There are probably hundreds
> > of CI/CD tools out there and many more general devops tools but what I
> > want to build is a CI/CD tool that ONLY supports Python 3.6 or greater
> > and only runs on one Linux distribution (my preference is Ubuntu). This
> > way configuration would be much more simple than the vast majority of
> > devops tools which try to support every programming language that is
> > popular (or so it seems) on many different Linux distributions and even
> > Windows and macOS.
> >
> > My theory is that if you limit the devops tool to a very limited
> > subsection of the available options the system will be easier to
> > configure for users, more stable, easier to patch bugs in and generally
> > just be a better all around things for Python developers.
> >
> > I'd love to hear some feedback on the idea.
> >
>
> I think your reasoning is sound.  I probably wouldn't make a lot of use
> of it, but I live in Embedded Systems land where it's notoriously hard
> to do CI off the target silicon.  Other people living in more tractable
> problem spaces will probably be more enthusiastic.
>
> --
> Rhodri James *-* Kynesim Ltd
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Announcing Methodfinder

2019-09-10 Thread Bill Six
Sometimes you know the inputs and outputs for a procedure, but you don't
remember the name. methodfinder.find tries to find the name.

https://github.com/billsix/methodfinder

>>> import methodfinder
>>> methodfinder.find([]) == 0
len([])
sum([])
>>> methodfinder.find([]) == False
any([])
bool([])
callable([])
>>> methodfinder.find(3) == "3"
ascii(3)
format(3)
repr(3)
str(3)
>>> methodfinder.find([1,2,6,7], 6) == True
6 in [1, 2, 6, 7]
[1, 2, 6, 7].__contains__(6)
>>> methodfinder.find(" ",["foo", "bar"]) == "foo bar"
' '.join(['foo', 'bar'])
>>> methodfinder.find([1,2,3]) == 6
sum([1, 2, 3])
>>> methodfinder.find([1,2,3]) == 7
>>> methodfinder.find('1 + 1') == 2
eval('1 + 1')
>>> methodfinder.find(0) == 1
0.denominator
math.factorial(0)
>>> methodfinder.find(0.0) == 1.0
math.cos(0.0)
math.cosh(0.0)
math.erfc(0.0)
math.exp(0.0)
>>> methodfinder.find([1,2]) == [[1,2],[2,1]]
itertools.permutations([1, 2])
>>> methodfinder.find([1,2], [3,4]) == [[1,3],[2,4]]
itertools.zip_longest([1, 2], [3, 4])
zip([1, 2], [3, 4])
>>> methodfinder.find([1,2], lambda x, y: x + y) == 3
functools.reduce( at 0x7efca8f8f4d0>, [1, 2])
>>> methodfinder.find(-1,3) == 2
-1%3
-1+3
3+-1
>>> methodfinder.find(3,2) == 1.5
3/2
>>> methodfinder.find(-1) == 1
-(-1)
-1.bit_length()
-1.denominator
abs(-1)
>>> methodfinder.find(1,2) == 3
1+2
1^2
1|2
2+1
2^1
2|1
>>> methodfinder.find(1,1) == 1
1&1
1**1
1*1
1.__class__(1)
1.denominator
1.numerator
1.real
1//1
1|1
math.gcd(1, 1)
max(1, 1)
min(1, 1)
pow(1, 1)
round(1, 1)
>>> methodfinder.find([1,2], '__iter__') == True
hasattr([1, 2], '__iter__')


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


[issue38014] Python 3.7 does not compile

2019-09-07 Thread Bill Minasian


Bill Minasian  added the comment:

Under OSX 10.15 beta and Xcode 11.0 beta the following does not work:
./configure --enable-framework

DYLD_FRAMEWORK_PATH=/Users/bill/cpython ./python.exe -E -S -m sysconfig 
--generate-posix-vars ;\
if test $? -ne 0 ; then \
echo "generate-posix-vars failed" ; \
rm -f ./pybuilddir.txt ; \
exit 1 ; \
fi
/bin/sh: line 1: 78734 Segmentation fault: 11  
DYLD_FRAMEWORK_PATH=/Users/bill/cpython ./python.exe -E -S -m sysconfig 
--generate-posix-vars
generate-posix-vars failed

The following seems to work:
./configure --disable-framework

My guess is that this is an Xcode 11 beta issue.

--
nosy: +BMinas

___
Python tracker 
<https://bugs.python.org/issue38014>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



SCons 3.1.1 Released

2019-08-08 Thread Bill Deegan
 SCons - a software construction tool

What is SCons?

SCons is an Open Source software construction tool—that is, a
next-generation build tool. Think of SCons as an improved, cross-platform
substitute for the classic Make utility with integrated functionality
similar to autoconf/automake and compiler caches such as ccache. In short,
SCons is an easier, more reliable and faster way to build software.


Change Log

RELEASE 3.1.1 - Mon, 07 Aug 2019 20:09:12 -0500

  From William Deegan:
- Remove obsoleted references to DeciderNeedsNode which could cause
crash when using --debug=explain

  From Jason Kenny
- Add Fix and test for crash in 3.1.0 when using
Decider('MD5-timestamp') and --debug=explain

  From Ben Reed:
- Added -fmerge-all-constants to flags that get included in both
CCFLAGS and LINKFLAGS.

  From Mathew Robinson:
- Fix issue #3415 - Update remaining usages of EnvironmentError to
SConsEnvironmentError
  this patch fixes issues introduced in 3.1.0 where any of the
  following would cause SCons to error and exit:
- CacheDir not write-able
- JSON encoding errors for CacheDir config
- JSON decoding errors for CacheDir config
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37654] 2to3 no-ops on embeddable distribution

2019-07-22 Thread Bill Collins


New submission from Bill Collins :

Firstly, I'd acknowledge that expecting 2to3 to work on the embeddable 
distribution might be the problem, but the mode of failure is silent and 
delayed.

The problem is that 2to3 loads fix names by searching for files in a package 
that end in '.py' 
(https://github.com/python/cpython/blame/master/Lib/lib2to3/refactor.py#L30) 
which isn't much use on the embeddable distribution where everything is 
pre-comipled.

So, installing an sdist package that relies on 2to3 will succeed, but any 
attempt to then actually use the installed package will fail.

I'm not sure whether the correct behavior here might be to

1. Fix 2to3 to load from pyc files (explicitly enabling 2to3 based installation 
on embeddable)
2. Fix 2to3 to fail when no converters are found (or similar; explicitly 
*disabling* 2to3 based installation on embeddable).

Or something else entirely.

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 348304
nosy: Bill Collins
priority: normal
severity: normal
status: open
title: 2to3 no-ops on embeddable distribution
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue37654>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37641] Embeddable distribution pyc filenames show build machine location

2019-07-21 Thread Bill Collins


New submission from Bill Collins :

pyc files within the embeddable zip are compiled with their filename as the 
temporary directory in which they are compiled. Thus, stack traces will appear 
as (e.g.) D:\obj\windows-release\37win32_Release\msi_python\zip_win32\image.py, 
which is a little surprising and not obvious that it's actually from 
email/mime/image.py.

We currently work around this by updating the pyc files before shipping to be 
relative paths to Lib/; however, fixing this upstream would appear to be as 
simple as passing through the dest from _write_to_zip to _py_temp_compile 
(https://github.com/python/cpython/blob/21a92f8cda525d25a165b773fbe1bfffd303a000/PC/layout/main.py#L302)
 to be passed into _compile_one_py

--
components: Build, Installation, Windows
messages: 348235
nosy: Bill Collins, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Embeddable distribution pyc filenames show build machine location
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue37641>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



SCons 3.1.0 Released

2019-07-20 Thread Bill Deegan
A new SCons checkpoint release, 3.1.0, is now available
  on the SCons download page:

  https://scons.org/pages/download.html

SCons is an Open Source software construction tool—that is, a
next-generation build tool. Think of SCons as an improved, cross-platform
substitute for the classic Make utility with integrated functionality
similar to autoconf/automake and compiler caches such as ccache. In short,
SCons is an easier, more reliable and faster way to build software.

  Here is a summary of the changes since 3.0.5:

  NEW FUNCTIONALITY

- Added variable TEMPFILEARGJOIN to specify how to join arguments
written
  to temp files used when command lines exceed MAXLINELENGTH when the
  command uses $TEMPFILE{...}
- Support for MSVC 2019
- Upgraded and improved Visual Studio solution/project generation code
using the MSVSProject builder.
  - Added support for Visual Studio 2017 and 2019.
  - Added support for the following per-variant parameters to the
builder:
- cpppaths: Provides per-variant include paths.
- cppdefines: Provides per-variant preprocessor definitions.


  CHANGED/ENHANCED EXISTING FUNCTIONALITY

  - Fix performance degradation for MD5-timestamp decider.  NOTE: This
changes the Decider() function arguments.
  From:
  def my_decider(dependency, target, prev_ni):
  To:
  def my_decider(dependency, target, prev_ni, repo_node):
  Where repo_node is the repository (or other) node to use to check if
the node is out of date instead of dependency.

- Enhanced --debug=explain output. Now the separate components of the
dependency list are split up
  as follows:

  scons: rebuilding `file3' because:
   the dependency order changed:
   ->Sources
   Old:xxx New:zzz
   Old:yyy New:yyy
   Old:zzz New:xxx
   ->Depends
   ->Implicit
   Old:/usr/bin/python New:/usr/bin/python

- Changed: Pseudo-builders now inherit OverrideEnvironments. For
  example when calling a pseudo-builder from another
  pseudo-builder the override variables passed to the first
  pseudo-builder call had to be explicitly passed on to the
  internal pseudo-builder call. Now the second pseudo-builder call
  will automatically inherit these override values.

  FIXES
- Fix Issue #3350 - SCons Exception EnvironmentError is conflicting
with Python's EnvironmentError.
- Fix spurious rebuilds on second build for cases where builder has > 1
target and the source file
  is generated. This was causing the > 1th target to not have it's
implicit list cleared when the source
  file was actually built, leaving an implicit list similar to follows
for 2nd and higher target
  ['/usr/bin/python', 'xxx', 'yyy', 'zzz']
  This was getting persisted to SConsign and on rebuild it would be
corrected to be similar to this
  ['zzz', 'yyy', 'xxx', '/usr/bin/python']
  Which would trigger a rebuild because the order changed.
  The fix involved added logic to mark all shared targets as peers and
then ensure they're implicit
  list is all cleared together.
- Fix Issue #3349 - SCons Exception EnvironmentError is conflicting
with Python's EnvironmentError.
  Renamed to SConsEnvironmentError
- Fix Issue #3350 - mslink failing when too many objects.  This is
resolved by adding TEMPFILEARGJOIN variable
  which specifies what character to join all the argements output into
the tempfile. The default remains a space
  when mslink, msvc, or mslib tools are loaded they change the
TEMPFILEARGJOIN to be a line separator (\r\n on win32)
- Additional fix to issue #3135 - Also handle 'pure' and 'elemental'
type bound procedures

- Fix handling of Visual Studio Compilers to properly reject any
unknown HOST_PLATFORM or TARGET_PLATFORM
- Enable LaTeX scanner to find more than one include per line

  under which they would be observed), or major code cleanups

git shortlog --no-merges -ns 3.0.5..HEAD
64  William Deegan
56  Mats Wichmann
10  Adam Gross
 4  Mathew Robinson
 4  Peter Diener
 3  Lukas Schrangl
 1  Daniel Holth
 1  bdbaddog
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip vs python -m pip?

2019-06-21 Thread Bill Deegan
you must be picking up pip from a different python installl (or virtualenv)
than you are picking up python.
Check your %PATH%

On Fri, Jun 21, 2019 at 6:29 AM Malcolm Greene  wrote:

> 64-bit Python 3.6.8 running on Windows with a virtual environment
> activated.
>
> "pip -v" reports 19.0.3
> "python -m pip" reports 19.1.1
>
> Is this behavior by design or a bug?
>
> My takeaway is that its better to run "python -m pip ..." vs "pip ..."
> when running pip related tasks.
>
> Thoughts?
>
> Malcolm
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


SCons 3.0.5 Released

2019-03-26 Thread Bill Deegan
A new SCons release, 3.0.5, is now available on the SCons download page:

https://scons.org/pages/download.html

And via pypi:
pip install scons

SCons is a tool for building software (and other files).  SCons is
implemented in Python, and its "configuration files" are actually Python
scripts, allowing you to use the full power of a real scripting language
to solve build problems.  You do not, however, need to know Python to
use SCons effectively.


Here is a summary of the changes since 3.0.4:

CHANGED/ENHANCED EXISTING FUNCTIONALITY

  - Change the default for AppendENVPath to delete_existing=0, so path
order will not be changed, unless explicitly set (Issue #3276)
  - Add lex construction variable LEXUNISTD for turning off unix headers on
windows
  - Update lex tool to use win_flex on windows if available
  - Add the textfile tool to the default tool list

FIXES

  - Fix Issue #3283 - Handle using --config=force in combination with
Decider('MD5-timestamp').
3.0.2 in fix for issue #2980 added that deciders can throw
DeciderNeedsNode exception.
The Configure logic directly calls the decider when using
--config=force but wasn't handling
that exception.  This would yield minimally configure tests using
TryLink() not running and
leaving TypeError Nonetype exception in config.log
  - Fix Issue #3303 - Handle --config=force overwriting the Environment
passed into Configure()'s
Decider and not clearing it when the configure context is completed.
  - Add default paths for yacc tool on windows to include cygwin, mingw,
and chocolatey
  - Fix issue #2799 - Fix mingw tool to respect SHCCCOMSTR, SHLINKCOMSTR
and LDMODULECOMSTR
  - Fix Issue #3329 - Add support for MS SDK V10.0A (which is commonly
installed with VS2017)
  - Fix Issue # - Add support for finding vswhere under 32 bit windows
installs.
  - Update the MSVC tool to include the nologo flag by default in RCFLAGS
  - Fixed bug which threw error when running SCons on windows system with
no MSVC installed.


IMPROVEMENTS
  - Do not store build host+user name if reproducible builds are wanted


git shortlog --no-merges -ns 3.0.4..HEAD
34  William Deegan
33  Mats Wichmann
18  Daniel
 4  Daniel Moody
 3  Bernhard M. Wiedemann
 2  Maciej Kumorek
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Convert Windows paths to Linux style paths

2019-03-12 Thread Bill Campbell
On Tue, Mar 12, 2019, Malcolm Greene wrote:

>Looking for best practice technique for converting Windows style paths to
>Linux paths. Is there an os function or pathlib method that I'm missing or
>is it some combination of replacing Windows path separators with Linux path
>separators plus some other platform specific logic?

See os.path.join

Bill
-- 
INTERNET:   b...@celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www2.celestial.com/ 6641 E. Mercer Way
Mobile: (206) 947-5591  PO Box 820
Fax:(206) 232-9186  Mercer Island, WA 98040-0820

The very concept of objective truth is fading out of the world.  Lies will
pass into history.  -- George Orwell
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: preferences file

2019-01-27 Thread Bill Campbell
On Thu, Jan 24, 2019, Dave wrote:
>I'm doing a small application and want to add user preferences.  Did some
>googling to see if there are standard Python ways/tools, but it seems not so
>much.  My specific questions are:
>
>1. Best practices for a user preference file/system?

Generally I put them in the user's $HOME or $HOME/etc directory
with appropriate permissions unless working in a virtual
environement.
>2. File format favored and why - ini, JSON, etc?

I like ini for most user configuration files as the format is
simple, easy to read, and handled nicely with the ConfigParser
libraries.

>3. File location?  I'm using Ubuntu and I believe that the correct location
>would be home/.config/ .  What about Mac and Windows?

See above.  Same for Mac.  I don't do Windows.

Bill
-- 
INTERNET:   b...@celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www2.celestial.com/ 6641 E. Mercer Way
Mobile: (206) 947-5591  PO Box 820
Fax:(206) 232-9186  Mercer Island, WA 98040-0820

The budget should be balanced, the Treasury should be refilled, public
debt should be reduced, the arrogance of officialdom should be
tempered and controlled, and the assistance to foreign lands should be
curtailed lest Rome become bankrupt. People must again learn to work,
instead of living on public assistance. -- Cicero - 55 BC
-- 
https://mail.python.org/mailman/listinfo/python-list


SCons 3.0.4 Release

2019-01-23 Thread Bill Deegan
  A new SCons release, 3.0.4, is now available
  on the SCons download page:

  http://www.scons.org/download.php
  Or via pypi:
  pip install scons

  Here is a summary of the changes since 3.0.3:

  NEW FUNCTIONALITY

- Added TEMPFILESUFFIX to allow user to specify suffix for tempfiles
used for long command lines
- Initial support for ARM architectures with Microsoft Visual Studio
2017. You must set TARGET_ARCH
 to arm or arm64 to enable.

  FIXES

- Fixed issue detecting installs of Microsoft Visual Studio 2017 as
well as Microsoft build tools 2017.


git shortlog --no-merges -ns 3.0.3..HEAD
17  Daniel
10  Mats Wichmann
 4  Daniel Moody
 4  William Deegan
 3  anatoly techtonik
 1  Tobias Herzog
-- 
https://mail.python.org/mailman/listinfo/python-list


SCons Version 3.0.3 Released

2019-01-07 Thread Bill Deegan
  A new SCons release, 3.0.3, is now available on the SCons download page:

  https://scons.org/pages/download.html


  Here is a summary of the changes since 3.0.1:

  NEW FUNCTIONALITY

- Properly support versioned shared libraries for MacOS.  We've also
introduced two
  new env variables APPLELINK_CURRENT_VERSION and
APPLELINK_COMPATIBILITY_VERSION which will specify
  what is passed to the linkers -current_version and
-compatibility_version flags.  If not specified
  they will be derived from SHLIBVERSION as such:
  - APPLELINK_CURRENT_VERSION = SHLIBVERSION
  - APPLELINK_COMPATIBILITY_VERSION = all but the last digit in
SHLIBVERSION with .0 appended.
  Note that the values of the above will be validated. Valid format
for either APPLELINK variable is
  X[.Y[.Z]] where 0 <= X <= 65535, 0 <= Y <= 255, 0 <= Z <= 255.
- Add flag must_exist to SConscript() call to fail on missing script.
Not failing on missing script is now considered deprecated, and the
first instance will print a
deprecation message.
- Add xz compression format to packaging choices.
- Add Textfile/Substfile to default environment. (issue #3147)
- Added virtualenv support. A new function Virtualenv() determines
whether
SCons runs in a virtualenv. The search PATH may also be extended to
prefer executables from the current virtualenv over the ones
provided by
base environment. New option --enable-virtualenv provided to import
some
virtualenv-related variables to SCons and extend every
env['ENV']['PATH']
automatically. New option --ignore-virtualenv disables this. Two
environment variables, SCONS_ENABLE_VIRTUALENV and
SCONS_IGNORE_VIRTUALENV are supported for the same purpose.

  DEPRECATED FUNCTIONALITY

- Going forward calling SConscript on a non-existing SConscript file
will issue a warning.  Currently
  it will issue a deprecation notice.

  CHANGED/ENHANCED EXISTING FUNCTIONALITY

- Recognize new java 9, 10, 11 (as 9.0 and 10.0, 11.0)

  DOCUMENTATION
- Update some doc examples for Py3: map() now returns an iterable
  instead of a list.

  FIXES

- Fix issue #2980 with credit to Piotr Bartosik (and William Blevins).
This is an issue where using
 TimeStamp-MD5 Decider and CacheDir can yield incorrect md5's being
written into the .sconsign.
 The difference between Piotr Bartosik's patch and the current code
is that the more complicated
 creation of file to csig map is only done when the count of
children for the current node doesn't
 match the previous count which is loaded from the sconsign.


  Thanks to Bernard Blackham, William Deegan, Ray Donnelly, Andrew
Featherstone, Arda Fu,
  Philipp Maierhöfer,  Matthew Marinets, Fredrik Medley, Daniel Moody, Gary
Oberbrunner,
  Jonathon Reinhart, Zachary Tessler, Paweł Tomulik, Richard West, Mats
Wichmann, Bernhard M. Wiedemann,
  and Hao Wu for their contributions to this release.
  Contributors are listed alphabetically by their last name.

git shortlog --no-merges -ns 3.0.1..HEAD
   254  William Deegan
79  Daniel Moody
73  Mats Wichmann
17  Paweł Tomulik
16  Andrew Featherstone
 8  grbd
 7  maiphi
 6  Gary Oberbrunner
 6  Daniel
 4  Hao Wu
 3  Gabriel Russell
 2  MatthewMarinets
 2  Jonathon Reinhart
 2  ArdaFu
 1  Bernhard M. Wiedemann
 1  Isaac Pascual Monells
 1  Fredrik Medley
 1  Philipp Maierhoefer
 1  Piotr Kasprzyk
 1  Ray Donnelly
 1  Zachary Tessler
 1  cclauss
-- 
https://mail.python.org/mailman/listinfo/python-list


SCons 3.0.2 Release

2019-01-01 Thread Bill Deegan
  A new SCons release, 3.0.2, is now available on the SCons download page:

  https://scons.org/pages/download.html

  Here is a summary of the changes since 3.0.1:

  NEW FUNCTIONALITY

- Properly support versioned shared libraries for MacOS.  We've also
introduced two
  new env variables APPLELINK_CURRENT_VERSION and
APPLELINK_COMPATIBILITY_VERSION which will specify
  what is passed to the linkers -current_version and
-compatibility_version flags.  If not specified
  they will be derived from SHLIBVERSION as such:
  - APPLELINK_CURRENT_VERSION = SHLIBVERSION
  - APPLELINK_COMPATIBILITY_VERSION = all but the last digit in
SHLIBVERSION with .0 appended.
  Note that the values of the above will be validated. Valid format
for either APPLELINK variable is
  X[.Y[.Z]] where 0 <= X <= 65535, 0 <= Y <= 255, 0 <= Z <= 255.
- Add flag must_exist to SConscript() call to fail on missing script.
Not failing on missing script is now considered deprecated, and the
first instance will print a
deprecation message.
- Add xz compression format to packaging choices.
- Add Textfile/Substfile to default environment. (issue #3147)
- Added virtualenv support. A new function Virtualenv() determines
whether
SCons runs in a virtualenv. The search PATH may also be extended to
prefer executables from the current virtualenv over the ones
provided by
base environment. New option --enable-virtualenv provided to import
some
virtualenv-related variables to SCons and extend every
env['ENV']['PATH']
automatically. New option --ignore-virtualenv disables this. Two
environment variables, SCONS_ENABLE_VIRTUALENV and
SCONS_IGNORE_VIRTUALENV are supported for the same purpose.

  DEPRECATED FUNCTIONALITY

- Going forward calling SConscript on a non-existing SConscript file
will issue a warning.  Currently
  it will issue a deprecation notice.

  CHANGED/ENHANCED EXISTING FUNCTIONALITY

- Recognize new java 9, 10, 11 (as 9.0 and 10.0, 11.0)

  FIXES

- Fix issue #2980 with credit to Piotr Bartosik (and William Blevins).
This is an issue where using
 TimeStamp-MD5 Decider and CacheDir can yield incorrect md5's being
written into the .sconsign.
 The difference between Piotr Bartosik's patch and the current code
is that the more complicated
 creation of file to csig map is only done when the count of
children for the current node doesn't
 match the previous count which is loaded from the sconsign.


  Thanks to Bernard Blackham, William Deegan, Ray Donnelly, Andrew
Featherstone, Arda Fu,
  Philipp Maierhöfer,  Matthew Marinets, Fredrik Medley, Daniel Moody, Gary
Oberbrunner,
  Jonathon Reinhart, Zachary Tessler, Paweł Tomulik, Richard West, Mats
Wichmann, Bernhard M. Wiedemann,
  and Hao Wu for their contributions to this release.
  Contributors are listed alphabetically by their last name.

git shortlog --no-merges -ns 3.0.1..HEAD
   226  William Deegan
79  Daniel Moody
72  Mats Wichmann
17  Paweł Tomulik
16  Andrew Featherstone
 8  grbd
 7  maiphi
 6  Gary Oberbrunner
 6  Daniel
 4  Hao Wu
 3  Gabriel Russell
 2  MatthewMarinets
 2  Jonathon Reinhart
 2  ArdaFu
 1  Bernhard M. Wiedemann
 1  Isaac Pascual Monells
 1  Fredrik Medley
 1  Philipp Maierhoefer
 1  Piotr Kasprzyk
 1  Ray Donnelly
 1  Zachary Tessler
 1  cclauss
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Unable to get the gateway IP of wlan interface using python code

2018-11-12 Thread Bill Campbell
On Tue, Nov 13, 2018, srinivasan wrote:
>Dear Python Experts,
>
>*First method:*
>
>I need to get the IP address basically the gateway IP in my setup I get it
>as "192.168.178.1" when I run the below standalone python code.
>
>
>*def get_gateway_ip(self):*
>*"""*
>*Get the IP address to the WIFI module from the AP*
>*"""*
>
>*cmd = 'ip route show 0.0.0.0/0 <http://0.0.0.0/0> dev wlp1s0 | cut
>-d\  -f3'*
>*f = os.popen(cmd)*
>*return str(f.read().strip())*

This command should get the gateway IP.

Linux: cmd = "ip route list | awk '/^default/{print $3}'"

or perhaps

Linux: cmd = "netstat -rn | awk '/^0.0.0.0/{print $2}'"

OSX: cmd = "netstat -rn | awk '/^default/{print $2}'"

I don't have a freebsd system available to test this, but I think
this pattern should work:

re.compile(r'^(default|0\.0\.0\.0)\s+(\S+)')

Bill
-- 
INTERNET:   b...@celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www2.celestial.com/ PO Box 820; 6641 E. Mercer Way
Mobile: (206) 947-5591  Mercer Island, WA 98040-0820
Fax:(206) 232-9186  Skype: jwccsllc

On the free market, everyone earns according to his productive
value in satisfying consumer desires. Under statist distribution,
everyone earns in proportion to the amount he can plunder from
the producers. -- Murray N. Rothbard
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Google weirdness

2018-07-13 Thread Bill Deegan
I also got such.
I'm guessing your track record of searches has flagged you as someone they
might want to hire.

On Fri, Jul 13, 2018 at 5:36 AM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> On Thu, 12 Jul 2018 22:31:35 -0400, Travis McGee wrote:
>
> > I somehow managed to trigger the dialog below by typing in a certain
> > Python phrase to Google.
>
> Is the phrase a secret?
>
>
> > Anyone know what it's about?
>
> My guess is that either:
>
> 1) You have accidentally discovered a back door through Google's
> firewalls and security, and now have total control over their entire
> network of tens of thousands of computers around the world; or
>
> 2) it's an Easter egg and coding challenge.
>
>
> My money is on number 1.
>
>
>
>
> --
> Steven D'Aprano
> "Ever since I learned about confirmation bias, I've been seeing
> it everywhere." -- Jon Ronson
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Splitting up large python module impact on performance?

2018-06-12 Thread Bill Deegan
Greetings,

I'm doing some refactoring on a fairly large python codebase.
Some of the files are > 4000 lines long and contain many classes.

Should I expect any performance hit from splitting some of the classes out
to other files?

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


Re: [Python-Dev] [RELEASE] Python 2.7.15

2018-05-01 Thread Bill Deegan
Is it possible to get the release notes included on the download page(s)?

On Tue, May 1, 2018 at 10:35 AM, Guido van Rossum  wrote:

> Simple. I misread "latest" for "last" and was hopeful that no new bugs
> would need to be fixed between now and 2020. I will post a correction on
> Twitter now.
>
> On Tue, May 1, 2018 at 2:58 AM, Alex Walters 
> wrote:
>
> > I've gotten some mixed signals on the status of this release, notably
> from
> > the BDFL:
> >
> > https://twitter.com/gvanrossum/status/991170064417153025
> > "Python 2.7.15 released -- the last 2.7 release!" (and a link to this
> > thread)
> >
> > I was under the impression that 2.7 was being supported until 2020.  If
> > this
> > is the final release of 2.7, what would "support" constitute?  My
> > assumption
> > was that the final release of 2.7 would be sometime in 2020 (or much
> closer
> > to 2020 than 19 months).
> >
> > > -Original Message-
> > > From: Python-Dev  > > list=sdamon@python.org> On Behalf Of Benjamin Peterson
> > > Sent: Tuesday, May 1, 2018 12:10 AM
> > > To: python-list@python.org; python-annou...@python.org; python-
> > > d...@python.org
> > > Subject: [Python-Dev] [RELEASE] Python 2.7.15
> > >
> > > Greetings,
> > > I'm pleased to announce the immediate availability of Python 2.7.15,
> the
> > > latest bug fix release in the senescent Python 2.7 series.
> > >
> > > Source and binary downloads may be found on python.org:
> > >
> > >  https://www.python.org/downloads/release/python-2715/
> > >
> > > Bugs should be reported to https://bugs.python.org/
> > >
> > > The source tarball contains a complete changelog in the Misc/NEWS file.
> > The
> > > only change since the release candidate is a fix for undefined C
> behavior
> > that
> > > newer compilers (including GCC 8) have started to exploit.
> > >
> > > Users of the macOS binaries should note that all python.org macOS
> > installers
> > > now ship with a builtin copy of OpenSSL. Additionally, there is a new
> > > additional installer variant for macOS 10.9+ that includes a built-in
> > version of
> > > Tcl/Tk 8.6. See the installer README for more information.
> > >
> > > Happy May,
> > > Benjamin
> > > 2.7 release manager
> > > ___
> > > Python-Dev mailing list
> > > python-...@python.org
> > > https://mail.python.org/mailman/listinfo/python-dev
> > > Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> tritium-
> > > list%40sdamon.com
> >
> > ___
> > Python-Dev mailing list
> > python-...@python.org
> > https://mail.python.org/mailman/listinfo/python-dev
> > Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> > guido%40python.org
> >
>
>
>
> --
> --Guido van Rossum (python.org/~guido)
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: www.python.org down

2018-04-30 Thread Bill Deegan
back up for me.

On Mon, Apr 30, 2018 at 2:26 PM, Mark Lawrence 
wrote:

> On 30/04/18 19:17, Paul Moore wrote:
>
>> It's working for me now.
>> Paul
>>
>> On 30 April 2018 at 18:38, Jorge Gimeno  wrote:
>>
>>> Not sure who to report to, but the site comes back with a 503. Anyone
>>> know
>>> where I can direct this to?
>>>
>>> -Jorge L. Gimeno
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>
> When originally reported I was getting, and am still getting, 502.
>
> --
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
>
> Mark Lawrence
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: www.python.org down

2018-04-30 Thread Bill Deegan
Still 502 for me.

On Mon, Apr 30, 2018 at 2:17 PM, Paul Moore  wrote:

> It's working for me now.
> Paul
>
> On 30 April 2018 at 18:38, Jorge Gimeno  wrote:
> > Not sure who to report to, but the site comes back with a 503. Anyone
> know
> > where I can direct this to?
> >
> > -Jorge L. Gimeno
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: www.python.org down

2018-04-30 Thread Bill Deegan
Ditto. I see a 502.

On Mon, Apr 30, 2018 at 1:38 PM, Jorge Gimeno  wrote:

> Not sure who to report to, but the site comes back with a 503. Anyone know
> where I can direct this to?
>
> -Jorge L. Gimeno
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Minmax tictactoe :c Cannot understand why this does not work

2018-04-24 Thread Bill
You need a good lesson in "program documentation". Your code 
looks terrible--really!



fifii.ge...@gmail.com wrote:

class AiMove:
def __init__(self):
self.x = -1
self.y=-1
self.score = 0


def Imprimir(Matriz,n):
for i in range(n):
linea ="|"
for j in range(n):
if (Matriz[i][j] == 0):
linea+=" "
elif (Matriz[i][j]==- 1):
linea+="X"
elif (Matriz[i][j]== 1):
linea+="O"
linea+="|"
print linea 

print "-"

def Gameover(Matriz,n):
#Condicion tablero lleno
blancos=0;
for i in range(n):
contJfilas = 0
contCfilas = 0
contJcol = 0
contCcol = 0
for j in range(n):
if(Matriz[i][j]==0):
blancos = blancos + 1
if (Matriz[i][j]==1):
contCfilas= contCfilas+1
elif(Matriz[i][j]==-1):
contJfilas = contJfilas +1
if (Matriz[j][i]==1):
contCcol= contCcol +1
elif (Matriz[j][i]==-1):
contJcol= contJcol +1
#Condicion 3 en raya en fila o 3 en raya columna
if (contJcol==3 or contJfilas ==3):
return -1
elif (contCfilas==3 or contCcol ==3):
return 1
if blancos == 16:
return 2
else:
return 0

def getMejorM(Matriz, player,n):
rv = Gameover(Matriz,n)
if(rv== 1):
a = AiMove()
a.score = 10
return a
elif rv==-1:
a = AiMove()
a.score = -10
return a

elif rv ==2: #Si es empate
a = AiMove()
return a

movimientos = []
for i in range (n):
for j in range (n):
if(Matriz[i][j] == 0):
movimiento = AiMove()
movimiento.x = i
movimiento.y = j
Matriz[i][j] = player
if (player == 1):
movimiento.score = getMejorM(Matriz, 
-1,n).score
else:
movimiento.score = getMejorM(Matriz, 
1,n).score
movimientos.append(movimiento)
Matriz[i][j] = 0

#Escoger
auxb = 0
if player==1:
mejorscore = -10
for i in range (len(movimientos)):
if movimientos[i].score > mejorscore:
auxb= i
mejorscore = movimientos[i].score

elif player==-1:
peorscore = 10
for i in range (len(movimientos)):
if movimientos[i].score < peorscore:
auxb= i
peorscore = movimientos[i].score

#Retornar el mejor movimiento
return movimientos[auxb]



n=4
Matriz = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
for j in range(n):
Matriz[i][j] = 0
Imprimir(Matriz,n)
while True:
fila = int(raw_input("Ingresa casilla x: "))-1
columna = int(raw_input("Ingresa casilla y: "))-1
if (Matriz[fila][columna] == 0):
Matriz[fila][columna] = -1
#Mover(Matriz,n)
Imprimir(Matriz,n)
bestM = AiMove()
bestM = getMejorM(Matriz, 1, n)
Matriz[bestM.x][bestM.y] = 1
Imprimir(Matriz,n)
if Gameover(Matriz,n) != 0:
break

print "FIN"




















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


Re: please test the new PyPI (now in beta)

2018-03-29 Thread Bill Deegan
Re color.
Would the python.org background color (which is darker) work?
To my eyes the background on pypi looks like the highlight color on
python.org
(I've said this earlier, but just curious if that's what others see as well)


On Thu, Mar 29, 2018 at 2:33 PM, Ethan Furman  wrote:

> On 03/29/2018 11:01 AM, Sumana Harihareswara wrote:
>
>> On Wednesday, March 28, 2018 at 10:48:52 AM UTC-4, Ethan Furman wrote:
>>
>
> The new PyPI lists of projects wastes too much space, and the bright blue
>>>
>> >> is intolerable.  I can't use it.
>
>>
>> When you say the bright blue is intolerable, I presume it hurts your eyes
>>
> > -- is that right?
>
> That is correct.
>
> Color calibration varies across monitors, some people are sensitive to
>>
> > certain shades of light, etc., so I want to let the designer know more,
> > and ask about it in user testing.
>
> For me it's a matter of brightness; bright colors should be used as
> accents, not as the main course.
> (IMHO, of course ;)
>
> You probably know that, in a real pinch, you can turn off styling entirely
>>
> > for a site in your browser, but I would prefer that you not have to do
> that.
>
> I am vaguely aware of that, but my typical response to such web sites is
> to not use them.
>
> Are the little boxes replaceable by the package authors?  That would be
>>> interesting.
>>>
>>
>> I think you're talking about https://github.com/pypa/wareho
>> use/issues/2211 -
>>
> > if/when we implement that, project logo images could show up on the
> project
> > detail pages, and in search results and similar listings, instead of the
> > white cube.
>
> Cool, looking forward to it!
>
>
> --
> ~Ethan~
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: please test the new PyPI (now in beta)

2018-03-27 Thread Bill Deegan
The back ground blue on the pypi page is the highlight blue on the
python.org page, they should change the color to match to background
python.org color.

-Bill




On Tue, Mar 27, 2018 at 7:50 AM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> On Tue, 27 Mar 2018 22:25:44 +1100, Chris Angelico wrote:
>
> > On Tue, Mar 27, 2018 at 9:49 PM, Steven D'Aprano
> > <steve+comp.lang.pyt...@pearwood.info> wrote:
> >> As an extra bonus, even when searching is not reliant on Javascript,
> >> mangling the text in the search box often is, so unless I'm extra
> >> careful, whenever I want to search for (say) "aardvarks", I invariably
> >> end up searching for "searaardvarksch".
> >>
> >> At least the new PyPI search box is better than that. They get a point.
> >>
> >>
> > "Mangling the text" should never be necessary. The HTML5  tag has
> > a 'placeholder' attribute for a reason.
>
>
> You're assuming the page is using HTML5. I've used a lot of these that
> did it in Javascript, and didn't degrade gracefully if Javascript was
> disabled.
>
>
>
> --
> Steve
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python gotcha of the day

2018-03-13 Thread Bill

Dan Sommers wrote:

On Wed, 14 Mar 2018 04:08:30 +, Steven D'Aprano wrote:


Explain the difference between these two triple-quoted strings:



But remove the spaces, and two of the quotation marks disappear:

py> """\""
'"'


That's (a) a triple quoted string containing a single escaped quote,
followed by (b) a quoted empty string.  The two consecutive strings are
concatenated into a single string.


The last part stumped me!  :  )




(Too many years of shell programming to miss this one!)

Dan



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


Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-16 Thread Bill

boB Stepp wrote:

This article is written by Nathan Murthy, a staff software engineer at
Tesla.  The article is found at:
https://medium.com/@natemurthy/all-the-things-i-hate-about-python-5c5ff5fda95e

Apparently he chose his article title as "click bait".  Apparently he
does not really hate Python (So he says.).  His leader paragraph is:

"Python is viewed as a ubiquitous programming language; however, its
design limits its potential as a reliable and high performance systems
language.


Python is simply not a high performance system language, but it has 
other virtues. You would not likely choose Python for a sophisticated 
distributed computing application, but not everyone needs to write a 
sophisticated distributed computing application.  I believe those that 
do, will be conscientious enough to choose an appropriate tool.






Unfortunately, not every developer is aware of its
limitations."

As I currently do not have the necessary technical knowledge to
properly evaluate his claims, I thought I would ask those of you who
do.  I have neither the knowledge or boB-hours to write a large
distributed system code base, but I am curious if Python is truly
limited for doing these in the ways he claims.

BTW, I am not trying to start (another) heated, emotional thread.  You
guys do sometimes get carried away!  I honestly just what to know the
truth of the matters out of my continuing to learn Python.  I suspect
there is probably some truth in his claims, but I am not sure if he is
taking things out of their proper application contexts or not.

Thanks!


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


Re: correctness proof for alpha-beta algorithm

2017-12-20 Thread Bill

Steve D'Aprano wrote:

On Thu, 21 Dec 2017 08:37 am, Bill wrote:


namenobodywa...@gmail.com wrote:

On Tuesday, December 19, 2017 at 3:28:39 PM UTC-8, Steve D'Aprano wrote:


Does this have anything specifically to do with Python programming?

i'm working on a game-playing script (ie: in python), i want to incorporate
pruning into my search algorithm, and i'd like to understand why it works;
i'm not sure if that counts

Based upon your posts, I think you should just write your own. Then you
can be sure that it will work.

How long did you say you've been programming? Perhaps you've heard of
something we in the programming world call "bugs".


You're supposed to get rid those those.  Use Raid!  : )




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


Re: correctness proof for alpha-beta algorithm

2017-12-20 Thread Bill

namenobodywa...@gmail.com wrote:

On Tuesday, December 19, 2017 at 3:28:39 PM UTC-8, Steve D'Aprano wrote:


Does this have anything specifically to do with Python programming?

i'm working on a game-playing script (ie: in python), i want to incorporate 
pruning into my search algorithm, and i'd like to understand why it works; i'm 
not sure if that counts


Based upon your posts, I think you should just write your own. Then you 
can be sure that it will work. That's better than working with something 
that you don't understand.



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


Re: adding elif to for

2017-12-19 Thread Bill

bob gailer wrote:

Has any thought been given to adding elif to the for statement?


I don't think it is a good idea because it needlessly, from my point of 
view, embeds too much complexity into a single construct (making it more 
difficult to maintain, for instance). That's what language designer's do 
though--they kick ideas like that around.  If you have a great idea, 
maybe propose a new language.




for x in foo:
if y: break
elif a==b:
something
else:
something else

as a shortcut to:
for x in foo:
if y: break
else:
if a==b:
something
else:
something else
bob gailer


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


Re: Python Learning

2017-12-18 Thread Bill

Christian Gollwitzer wrote:


You don't need to explain a vtable to explain dynamic_cast. Only if 
you want to become a compiler writer. It is not even required, vtables 
are just the most common implementation.


dynamic_cast simply checks if the actual object that the pointer 
points to is an instance of a derived class, and then casts it into 
that. You could "explain" it with the following pseudo-code


template <T*, base*>
T* dynamic_cast<T*>(base *input) {
if (isinstanceof(base, *input)) { return (T*)input; }
else { return nullptr; }
}

How that works (particularly the "isinstanceof") is not the business 
of the programmer - it is sufficient to know that the compiler 
somewhere stores this information for every object.


Christian


With that, the students would "boo you off the stage!"... and maybe 
accuse you of being a "know it all".  ; )The point of college is 
more about teaching students to think rather than in being efficient.  I 
have little doubt that a tech school could "get through everything" much 
faster.


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


Re: Python Learning

2017-12-18 Thread Bill

Chris Angelico wrote:

On Sun, Dec 17, 2017 at 12:01 PM, Bill <bill_nos...@noway.net> wrote:


I think we are talking about the same people.
But in college, the prerequisite of "at least co-enrolled in pre-calc",
turned out to be the right one (based upon quite a lot of teaching
experience).

Fortunately for the programming world, college isn't when everyone
starts. I started coding at six years old. Should I have waited till I
had some pre-calc before getting into programming?


It probably wouldn't have hurt if you had co-enrolled in it.  ;)
And add an English course too to help you to write suitable documentation!
I would think a 6 year old would have priorities above coding--what's 
the hurry?


Bill



ChrisA


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


Re: Python Learning

2017-12-17 Thread Bill

Chris Angelico wrote:

On Mon, Dec 18, 2017 at 4:04 PM, Chris Angelico <ros...@gmail.com> wrote:

On Mon, Dec 18, 2017 at 3:54 PM, Bill <bill_nos...@noway.net> wrote:

Chris Angelico wrote:

I don't know about vtables as needing to be in ANY programming course.
They're part of a "let's dive into the internals of C++" course. You
certainly don't need them to understand how things work in Python,
because they don't exist; and I'm doubtful that you need to explain
them even to C++ programmers.


Then how are you going to explain dynamic_cast?


I wouldn't. I'd teach Python to beginning programmers. C++ is not a
good first language.

And even for C++ programners, you can go a pretty long way without dynamic_cast.
You either know it exists, and what it can do for you, or you don't.  If 
you want to teach a 2nd course in C++, and leave out vtables and 
dynamic_cast, I don't have a problem with that. If you always choose the 
lowest common denominator, your class may not be that interesting.  I 
told my students that my goal was for them was to learn how to learn so 
that they "didn't need me".




ChrisA


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


Re: Python Learning

2017-12-17 Thread Bill

Chris Angelico wrote:


I agree with some of that, but you then take it to absurdity. You most
certainly CAN drive a car without knowing how one works; in fact, with
this century's cars, I think that's very much the case. How many
people REALLY know what happens when you push the accelerator pedal,
and how that makes the car go faster? Originally, it would actually
open a valve and allow more fuel into the engine; now, it's all
managed by a computer. So how much can you really understand of how it
works?


You can understand the "systems" which comprise your car. Engine, 
Cooling, braking, transmission, exhaust, etc.  And you can similarly 
understand the systems which comprise the workings of your computer 
program. As it happens, I've been studying electronics lately.
In answer to your question, there is an "invisible line" between 
hardware and software which most people don't generally cross. As 
another response to your question, try to master all of the features of 
the emacs editor. Personally, I've never felt motivated enough to do so.





You can certainly use functions without knowing details of the
run-time stack, though you'll need at least SOME comprehension of it.

Avoiding functions and documentation, though, now you're just being ridiculous.

ChrisA


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


Re: Python Learning

2017-12-17 Thread Bill

Chris Angelico wrote:

I don't know about vtables as needing to be in ANY programming course.
They're part of a "let's dive into the internals of C++" course. You
certainly don't need them to understand how things work in Python,
because they don't exist; and I'm doubtful that you need to explain
them even to C++ programmers.


Then how are you going to explain dynamic_cast?



Polymorphism... actually, I could explain that to a three year old.

"Eat your broccoli"

"Eat your dessert"

See? Polymorphism. The same operation being done to different things
and having different results.

ChrisA


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


Re: Python Learning

2017-12-17 Thread Bill

Chris Angelico wrote:


I don't know about vtables as needing to be in ANY programming course.
They're part of a "let's dive into the internals of C++" course. You
certainly don't need them to understand how things work in Python,
because they don't exist; and I'm doubtful that you need to explain
them even to C++ programmers.


I guess "need to" is a relative thing. You can drive a car without know 
how one works. You can use functions with little knowledge of a run-time 
stack. You can avoid recursion if you are scared of it. And you can 
totally avoid functions if you are scared of them. And who needs 
documentation...seems like a big waste of time! Programmers don't need 
to know how to write, do they?  Ask some programmers that just taught 
themselves, and they will tell you!


After reading, writing, and arithmetic, then perhaps programming.




Polymorphism... actually, I could explain that to a three year old.

"Eat your broccoli"

"Eat your dessert"

See? Polymorphism. The same operation being done to different things
and having different results.

ChrisA


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


Re: Python Learning

2017-12-17 Thread Bill

Chris Angelico wrote:

On Mon, Dec 18, 2017 at 11:31 AM, Bill <bill_nos...@noway.net> wrote:

Larry Martell wrote:

So, your experience is that the style of learning you offer is

unsuitable to anyone who doesn't have some background in algebra.
That's fine. For your course, you set the prereqs. But that's not the
only way for someone to get into coding. You do NOT have to go to
college before you start creating software. That is also not an
opinion; it's a fact backed by a number of proven instances (myself
included).


You might benefit by a course in logic.  I never said that was the only way
to learn. I learned (BASIC) in 8th grade too.


You said earlier:


In my years of teaching experience, students who came to college without
the equivalent of "college algebra" were under-prepared for what was
expected of them. This is not just an opinion, it's a fact.

If you want to qualify that by saying that coming to college is not
the only way to learn programming, you'd better say so, because
otherwise, the tone of what you're saying says that students NEED
algebra prior to learning a programming language.


I tried pretty hard not to say that. I said they needed some 
"mathematical sophistication"--not actual mathematics.  My error was 
using that expression among an audience not so familiar with that 
terminology. That said, I think I would have a hard time explaining 
polymorphism and vtables to a student who had not grasped the 
distributive property of multiplication over addition.

You can try, and let me know how it goes for you... I've been there.

Bill




Logic isn't the problem here. Clarity of language is. Watch your
implications if you don't want to be misunderstood.

ChrisA


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


Re: Python Learning

2017-12-17 Thread Bill

Chris Angelico wrote:

On Mon, Dec 18, 2017 at 6:51 AM, Bill <bill_nos...@noway.net> wrote:

The point is that it takes a certain amount of what is referred to as
"mathematical maturity" (not mathematical knowledge) to digest a book
concerning computer programming.

Emphasis on *a book*.


In my years of teaching experience,
students who came to college without the equivalent of "college algebra"
were under-prepared for what was expected of them. This is not just an
opinion, it's a fact.

So, your experience is that the style of learning you offer is
unsuitable to anyone who doesn't have some background in algebra. That's fine. 
For your course, you set the prereqs.


I never said that they needed any knowledge of algebra.  But if they 
don't understand the logic behind an inequality, for instance, then may 
run into some trouble.

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


Re: Python Learning

2017-12-17 Thread Bill

Gregory Ewing wrote:

Bill wrote:
In my years of teaching experience, students who came to college 
without the equivalent of "college algebra" were under-prepared for 
what was expected of them.


This could be simply because it weeds out people who aren't
good at the required style of thinking. 


I think that's absolutely true.  If someone gets out of high school and 
doesn't understand college algebra (~8th grade math), they come into a 
programming class with an inherent disadvantage. They "can't understand" 
the book, just like they "couldn't" understand their math book.





If that's true,
anything that exercises mathematical thinking should have
the same effect. There just doesn't happen to be anything
else in the mainstream education curriculum that does that.



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


Re: Python Learning

2017-12-17 Thread Bill

Larry Martell wrote:

So, your experience is that the style of learning you offer is

unsuitable to anyone who doesn't have some background in algebra.
That's fine. For your course, you set the prereqs. But that's not the
only way for someone to get into coding. You do NOT have to go to
college before you start creating software. That is also not an
opinion; it's a fact backed by a number of proven instances (myself
included).


You might benefit by a course in logic.  I never said that was the only 
way to learn. I learned (BASIC) in 8th grade too.



I started coding when I was 16, in 1975. I wrote a downhill skiing
game in basic, which I had taught to myself. I went to collage when I
was 17, and I had taught myself FORTRAN and I tested out of the class.


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


Re: Python Learning

2017-12-17 Thread Bill

Rustom Mody wrote:

In response to


Rustom Mody wrote:

On Saturday, December 16, 2017 at 9:45:17 AM UTC+5:30, Bill wrote:

so it really doesn't make that much difference where one starts, just
"Do It!".  :  )

Really ¿?
https://en.wikipedia.org/wiki/Principles_of_learning#Primacy


On Sunday, December 17, 2017 Bill wrote:

You would give precedence to something written on a wikipedia page over
your experience?

Bill also wrote:

…in college, the prerequisite of "at least co-enrolled in pre-calc",
turned out to be the right one (based upon quite a lot of teaching
experience).

So… I dont understand where you are coming from:
Is there such a thing as a “learning curve” or not?


The point is that it takes a certain amount of what is referred to as 
"mathematical maturity" (not mathematical knowledge) to digest a book 
concerning computer programming. In my years of teaching experience, 
students who came to college without the equivalent of "college algebra" 
were under-prepared for what was expected of them. This is not just an 
opinion, it's a fact. Of course, you could argue that a student who 
arrives at college needing to take college algebra is of a certain 
category. In your words, they are not yet ready to face any sort of 
(steep) learning curve.


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


Re: Python Learning

2017-12-16 Thread Bill

Gregory Ewing wrote:

Bill wrote:
In my experience, if they do not have the basic (~pre-calc) math 
behind them, then learning from a textbook on a programming language, 
say,  may be a bit beyond them.


Very little mathematical *knowledge* is needed to get started
with programming. You can do a lot of useful things in Python
without even using any arithmetic.

What does seem to correlate is that if you're the sort of
person who finds maths interesting and fun to play with, you're
also likely to take to programming easily. The same kind of
logical thought processes are involved.



I think we are talking about the same people.
But in college, the prerequisite of "at least co-enrolled in pre-calc", 
turned out to be the right one (based upon quite a lot of teaching 
experience).

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


Re: Python Learning

2017-12-16 Thread Bill

Rustom Mody (Rustom Mody) wrote:

On Saturday, December 16, 2017 at 9:45:17 AM UTC+5:30, Bill wrote:

Chris Angelico wrote:

On Sat, Dec 16, 2017 at 8:51 AM, Bill wrote:

Varun R wrote:

Hi All,

I'm new to programming, can anyone guide me, how to start learning python
programming language,...plz suggest some books also.

Thanks all

Are you sure you want to learn Python first?
Python does enough things "behind the scene"
that it makes me question the wisdom of that.
Other points of view are welcome, of course.
Learning the primitives of C++ first, may make for an easier transition.
Surely this has been discussed before?

On the contrary, that makes Python an *excellent* first language. We
don't force people to learn about the chemistry of petrochemical
combustion before letting them learn how to drive a car; we don't make
people understand TCP/IP networking before they're allowed to type
something into Google. And if you DO want people to start off with a
lower-level language, why C++? Why not machine code (or at least
assembly code), since that's what the CPU actually executes?

Most decent introductions to C++ discuss machine language (it helps make
sense of compilation).
As you indirectly suggest, learning is something of a circular process,
so it really doesn't make that much difference where one starts, just
"Do It!".  :  )

Reallyâ¿?
https://en.wikipedia.org/wiki/Principles_of_learning#Primacy



You would give precedence to something written on a wikipedia page over 
your experience?
In our current context, we are talking about self-learning where one is 
one's own teacher. To my mind, if one gets that part right, one doesn't 
need to worry about the other types. I learned a great deal from BYTE 
magazine and before that Popular Electronics. Computer technology is so 
ubiquitous today, that the interested person one need only grab hold of 
something and start learning. YouTube for instance, offers a plethora of 
places to "begin".  I tell students, that if they have the math behind 
them, then the doors of science will be open to them. In my experience, 
if they do not have the basic (~pre-calc) math behind them, then 
learning from a textbook on a programming language, say,  may be a bit 
beyond them.

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


Re: Python Learning

2017-12-15 Thread Bill

Chris Angelico wrote:

On Sat, Dec 16, 2017 at 8:51 AM, Bill <bill_nos...@noway.net> wrote:

Varun R wrote:

Hi All,

I'm new to programming, can anyone guide me, how to start learning python
programming language,...plz suggest some books also.

Thanks all


Are you sure you want to learn Python first?
Python does enough things "behind the scene"
that it makes me question the wisdom of that.
Other points of view are welcome, of course.
Learning the primitives of C++ first, may make for an easier transition.
Surely this has been discussed before?

On the contrary, that makes Python an *excellent* first language. We
don't force people to learn about the chemistry of petrochemical
combustion before letting them learn how to drive a car; we don't make
people understand TCP/IP networking before they're allowed to type
something into Google. And if you DO want people to start off with a
lower-level language, why C++? Why not machine code (or at least
assembly code), since that's what the CPU actually executes?


Most decent introductions to C++ discuss machine language (it helps make 
sense of compilation).
As you indirectly suggest, learning is something of a circular process, 
so it really doesn't make that much difference where one starts, just 
"Do It!".  :  )


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


Re: Python Learning

2017-12-15 Thread Bill

Varun R wrote:

Hi All,

I'm new to programming, can anyone guide me, how to start learning python 
programming language,...plz suggest some books also.

Thanks all


Are you sure you want to learn Python first?
Python does enough things "behind the scene"
that it makes me question the wisdom of that.
Other points of view are welcome, of course.
Learning the primitives of C++ first, may make for an easier transition.
Surely this has been discussed before?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Processing Game Help

2017-12-10 Thread Bill

Lauren Porter wrote:

Hello all! I've been trying to create a game in Python Processing where a 
spaceship moves horizontally in order to miss a collision with an asteroid. I'm 
having difficulty making it so that the game quits when an asteroid hits the 
spaceship, could anybody help? Here is my code.


The code looks rather "naked" with any sort of documentation.
Do you want to ask us to figure out how it is supposed to work in order 
to help you?
My debugging suggestion is "print, print, print!" so you can follow what 
your code is doing.
I find that the sooner I start doing that, the sooner my debugging 
session is over.  Good luck!


Bill


As you can see, I tried using globals in order use variables from previous 
classes, but nothing has worked. For this specific approach, no error message 
popped up, but nothing happened either. Thanks so much!

COLORS = {"black":"#00", "white":"#FF",
   "red":"#FF", "green":"#00FF00",
   "blue":"#D1F5FF", "yellow":"#00",
   "orange":"#FFA500", "hendrixorange":"#F58025",
   "purple":"#9B30FF", "gray":"#808080", "lightgray": "#CACACA",
   "darkgray":"#A9A9A9"}
import random
asteroid = []
spaceship = []
stars = []
justPressed = False
aX = 0
aY = 0
x = 0
y = 0

def setup():
 global aX, aY, X, Y
 size(640, 480)
 for s in range(1):
 X = 320
 Y = 440
 spaceship.append(Space(X, Y, COLORS["orange"]))
 for a in range(4):
 aX = random.randint(0, 640)
 aY = 0
 asteroid.append(Asteroid(aX, aY, COLORS["orange"]))
 for d in range(100):
 randX = random.randint(0, 640)
 randY = random.randint(0, 480)
 stars.append(Star(randX, randY, COLORS["orange"]))



class Space:
 def __init__(self, x, y, color):
 self.x = x
 self.y = y
 self.color = color

 def spaceship(self):
 fill(COLORS["blue"])
 stroke(COLORS["white"])
 ellipse(self.x, self.y, 75, 75) #body
 fill(COLORS["green"])
 fill(COLORS["gray"])
 stroke(COLORS["green"])
 ellipse(self.x, self.y + 20, 120, 35)
 stroke(COLORS["orange"])
 fill(COLORS["purple"])
 ellipse(self.x, self.y + 20, 10, 10)
 ellipse(self.x + 30, self.y + 20, 10, 10)
 ellipse(self.x - 30, self.y + 20, 10, 10)
 
 def move(self, dx, dy):

 self.x += dx
 self.y += dy

class Asteroid:
 def __init__(self, x, y, color):
 self.x = x
 self.y = y
 self.color = color
 
 def update(self):

 self.velx = 0
 self.vely = random.randint(1, 5)
 self.x += self.velx
 self.y += self.vely
 if self.y > 480:
 self.y = 0
 self.x = random.randint(1,640)
 
 def asteroid(self):

 fill(COLORS["lightgray"])
 stroke(COLORS["white"])
 ellipse(self.x, self.y, 50, 50)
 fill(COLORS["gray"])
 ellipse(self.x +15, self.y + 6, 15, 15)
 ellipse(self.x -12, self.y + 7, 10, 10)
 ellipse(self.x + 5, self.y - 13, 11, 11)
 ellipse(self.x - 12, self.y - 9, 7, 7)
 ellipse(self.x + 2, self.y + 18, 7, 7)
 
class Star:

 def __init__(self, x, y, color):
 self.x = x
 self.y = y
 self.color = color

 def star(self):
 fill(COLORS["white"])
 ellipse(self.x, self.y, 3, 3)


def draw():
 global justPressed
 background(COLORS["black"])
 for f in stars:
 f.star()
 for f in spaceship:
 f.spaceship()
 if f.x < 60:
 f.move(3, 0)
 elif f.x > 580:
 f.move(-3, 0)
 elif justPressed :
 if key == 'd':
 f.move(3, 0)
 elif key == 'a':
 f.move(-3, 0)
 for f in asteroid:
 f.asteroid()
 f.update()
 #collision detection 'for' loop
 distance = sqrt(((aX - X)**2) + ((aY - Y)**2))
 for f in asteroid:
 if distance < 62.5:
 background(COLORS["red"])
 
 
def keyTyped():

 global justPressed
 justPressed = True
 print("typed", key)
 
def keyPressed():

 global justPressed
 justPressed = True
 print("pressed", key)



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


Re: Python homework

2017-12-06 Thread Bill
I think carelessness in choosing variable names may be at the root of 
the problem.



nick.martin...@aol.com wrote:

I have a question on my homework. My homework is to write a program in which 
the computer simulates the rolling of a die 50
times and then prints
(i). the most frequent side of the die
(ii). the average die value of all rolls.
I wrote the program so it says the most frequent number out of all the rolls for example 
(12,4,6,14,10,4) and will print out "14" instead of 4 like I need.
This is what I have so far:
import random

def rollDie(number):
 rolls = [0] * 6
 for i in range(0, number):
 roll=int(random.randint(1,6))
 rolls[roll - 1] += 1
 return rolls

if __name__ == "__main__":
 result = rollDie(50)
 print (result)
 print(max(result))


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


SCons 3.0.1 released

2017-11-15 Thread Bill Deegan
   SCons - a software construction tool

  Release Notes


This is SCons, a tool for building software (and other files).  SCons is
implemented in Python, and its "configuration files" are actually Python
scripts, allowing you to use the full power of a real scripting language
to solve build problems.  You do not, however, need to know Python to
use SCons effectively.

Please go to http://scons.org/pages/download.html to get the latest
production
release of SCons.

So that everyone using SCons can help each other learn how to use it more
effectively, please go to http://scons.org/lists.html#users to sign up for
the scons-users mailing list.

RELEASE 3.0.1 - Mon, 12 Nov 2017 15:31:33 -0700

  Please consult the RELEASE.txt file for a summary of changes since the
last
  release and consult the CHANGES.txt file for complete a list of changes
  since last release.  This announcement highlights only the important
  changes.
Please note the following important changes since release 2.5.1:

   This is the initial release supporting both python 3.5+ and 2.7.x
and pypy
   There are some important changes:

   - Any print statements must now use python 3 syntax of "print()"
   - All node content should be in bytes. This is the default in python
2.7.x,
 in Python 3 all strings are by default unicode. byte and/or
bytearray
 should be used if you construct content for return by a custom
node type's
 get_content() method.
   - There are some (as yet unresolved issue) using Literal()'s in some
context with
 Python 3
   - pypy should be supported, please report any issues to the user's
mailing list.
   - Currently if you switch back and forth between python 2.7.x and
3.5+ you will
 need to remove your sconsign file.  This should be resolves
shortly, but
 regardless switching between python 2.7.x and 3.5+ will not use
compatible
 sconsigns and as such incremental builds should be expected to
rebuild
 anything changed since the previous scons run with the same
version of python.
   - It is likely that migrating from 2.5.1 -> 3.0.0 alpha will cause
rebuilds due
 to the significant number of changes in the codebase.

   - Removed deprecated tools CVS, Perforce, BitKeeper, RCS, SCCS,
Subversion.
   - Removed deprecated module SCons.Sig
   - See CHANGES.txt for more details on other changes
   - 3.0.0 should be slightly faster than 2.5.1.  Changes yielded a 15%
speed up for
 null incremental builds.
   - Updated D language scanner support to latest: 2.071.1.
   - python -m SCons should now run SCons if it's installed PYTHONPATH


Please note the following important changes since release 2.4.1:
   We're enhancing implicit language scanning functionality to improve
   correctness.  SCons now honors scanner keys for implicit dependencies
   and correctly changes scanner type (if necessary) when traversing
   implicit dependency trees.

   This enhancement resolves missing dependencies
   with built-in scanners including SWIG (#2264) and QT:
   * http://scons.tigris.org/issues/show_bug.cgi?id=2264

   -  This enhancement broadens the horizon for handling heterogeneous
  data flow environments (E.G. software builds):
  -
http://article.gmane.org/gmane.comp.programming.tools.scons.user/26596

   - SCons may find new (and correct) dependencies in cross-langauge
contexts.
 - Update may cause rebuilds, especially in heterogeneous data
environments.
 - Update may find previously missed dependencies errors (E.G.
cycles).
   - Discovered in some QT test cases.
   - SCons handles the SCANNERS variable differently.
 -  Previously, the Install builder would scan implicit
dependencies for
a scanner found in SCANNERS (but not for built-in scanners),
but now
the Install builder will not scan recursively regardless in
order
to optimize Install behaviour and bring orthogonality to
previous behaviour.

- SCons handles cache directories a bit differently/
  - Cache files are now stored in 256 subdirectories in the cache
directory by
default (this stresses NFS less). Existing cache directories will
remain as
current, but SCons will prompt you to run scons-configure-cache
which will
allow you to migrate to the new layout, or confirm you want to use
the
existing layout.

- New external tool scons-configurecache which allows some
configuration of
  how files in the cache are controlled.

  Please note the following important changes since release 2.4.0:
- Fix to swig tool - pick-up 'swig', 'swig3.0' and 'swig2.0' (in order).
- Fix to swig tool - respect env['SWIG'] provided by user.
- Fix for Bug # 2791 - Setup.py fails unnecessarily under Jython.
- Fixed license of SVG titlepage 

Re: Easiest way to access C module in Python

2017-11-06 Thread Bill

John Pote wrote:

Hi all,
I have successfully used Python to perform unit and integration tests 
in the past and I'd like to do the same for some C modules I'm working 
with at work. There seem to be a number of ways of doing this but 
being busy at work and home I looking for the approach with the least 
learning curve.


I don't want to add the C modules into the CPython build itself as 
I've never done this and at work it's a real pain getting admin rights 
to do this, and when you do it lasts just 24 hours. The C modules are 
likely to change frequently as bugs are found and features added.


The other option I'm considering is to use sockets and write a C 
wrapper round the C modules I want to test. This has the advantage for 
me that I know about sockets from Python & C points of view and I get 
complete control of the C compile process. This may be important as 
the C modules come from an embedded project and I don't want to change 
them in any way.


Are there any other approachs to this problem?
I'll be using Python 3.5 (work) and 3.6 (home).
Feedback appriciated.



Install Oracle's "Virtual Box" software on your computer.  It's free. 
Then install a version of Linux on it (or something else, if you 
prefer).  Whatever you do, if you don't like it, you can replace your 
installation in a matter of minutes.

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


Re: Getting started with python

2017-10-30 Thread Bill

subhendu.pand...@gmail.com wrote:

Hi,

Could you please help me with the below if possible:


Possible and reasonable are two different things.  Why don't you try 
some web searches and try to answer some of your own questions.  I offer 
this advice as a Python newbe myself.


Bill




1. Best site to go ahead for python.
2. How python is different from other languages and future scope of it.
3. Tasks that are getting done using python in present.
4. Link where I can be able to get python videos, ebooks from basics to expert 
level free.

Thanks
Subhendu


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


Re: Let's talk about debuggers!

2017-10-25 Thread Bill

Fabien wrote:

On 10/25/2017 03:07 PM, Thomas Jollans wrote:

What options are there for Python (that work)?


PyCharm's debugger is fine (also available in the community edition)

+1



Cheers,

Fabien


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


Re: I used list, def. why li += [100,200] , and li = li + [100,200] is different

2017-10-23 Thread Bill

Rob Gaddi wrote:

On 10/23/2017 09:29 AM, 임현준 wrote:

I am a Korean student, and I am a beginner in English and Python.;(

I can't understand about this def

If I want to print

[1,2,3,4,5]
[1,2,3,4,5,100,200]

I will make code like this, and I can understand code.


def modify(li):
  li += [100,200]

list = [1,2,3,4,5]
print(list)
modify(list)
print(list)


BUT, when I make code like this.

I will make code like this, and I can understand code.


def modify(li):
  li = li + [100,200]

list = [1,2,3,4,5]
print(list)
modify(list)
print(list)



python print

[1,2,3,4,5]
[1,2,3,4,5]

why 'li+= [100,200]'and 'li = li + [100,200]' 's print is different
please help me



Lists are mutable, they can be changed.  Your call to += is equivalent 
to a call to li.extend([100, 200]), which changes the single existing 
object pointed to by the "li" reference.  The second time, however, 
you take the existing value that "li" refers to [1,2,3,4,5], create a 
new object that is ([1,2,3,4,5] + [100,200]), and reassign the local 
reference "li" to point to that new object.  Then your function ends, 
"li" goes out of scope, nothing points to that newly created object 
and it gets lost.





The problem and both solutions are great!  Thanks for posting!

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


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

2017-10-12 Thread Bill

Marko Rauhamaa wrote:

Grant Edwards :


I like [const qualifiers] in C because it allows the linker to place
them in ROM with the code. It also _sometimes_ provides useful
diagnostics when you pass a pointer to something which shouldn't be
modified to something that is going to try to modify it.

Unfortunately, "const" is so tacky in practice that the language and the
standard libraries have rendered it useless.

One example is the surprising fact that string literals in C are "char
*" and not "const char *".


If not, you couldn't pass a string literal to a function having prototype
void f(char *s);
Of course, if f tries to modify *s, there will be a run time error as 
character string literals are stored in a "special place", and are not 
mutable. This improves performance.



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


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

2017-10-11 Thread Bill

Grant Edwards wrote:

On 2017-10-11, Bill <bill_nos...@whoknows.net> wrote:

Grant Edwards wrote:

On 2017-10-11, Bill <bill_nos...@whoknows.net> 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.

It's not really used for "laying out" web pages.  Thats what HTML and
CSS do.  PHP is for server-side generation of dynamic content and
handling of submitted forms and uploaded data.


Thank you. I DO appreciate learning about the correct terminology.


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


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

2017-10-11 Thread Bill

Mikhail V 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?

Python? Superior syntax for sure


I believe that.  What accounts for the popularity of PHP then?
--
https://mail.python.org/mailman/listinfo/python-list


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

2017-10-11 Thread Bill

Grant Edwards wrote:

On 2017-10-11, Bill <bill_nos...@whoknows.net> 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


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

2017-10-10 Thread Bill

Dennis Lee Bieber wrote:

On Tue, 10 Oct 2017 20:48:26 -0400, Bill <bill_nos...@whoknows.net>
declaimed the following:


cast stones at C/C++.  People started programming in C in the late 70's,
and before that some were programming in B ("B Programming Language"),

Preceded by BCPL (which leads to the joke that the language that
supplants C will be named P)


PL-I has already been taken.  That is a pretty free-wheeling language 
compared to Fortran, where, IIRC, you had to start in the 7th column. 
Oops, hand me another punch card... :)


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


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

2017-10-10 Thread Bill

Steve D'Aprano wrote:

On Tue, 10 Oct 2017 06:06 am, Stefan Ram wrote:


In his book about programming, Bjarne Stroustrup writes:

|We try hard to avoid "white lies"; that is, we refrain from
|oversimplified explanations that are clear and easy to
|understand, but not true in the context of real languages and
|real problems.


Bjarne Stroustrup is famous for designing one of the most heavyweight,
baraque, hard-to-understand, difficult-to-use programming languages in common
use. While C++ has many excellent features, and is constrained by the need to
be compatible with C, I don't think many people believe that it is a
well-designed language.



It is a well-designed language.  It is and was carefully thought out. 
One could argue that there are perhaps "too many ways" to do a given 
thing in Python (one could say it's features are "not orthogonal"). I'm 
sure you are familiar with where the language drew its name.   I'm not 
here to "cast stones", I like Python. I just think that you shouldn't 
cast stones at C/C++.  People started programming in C in the late 70's, 
and before that some were programming in B ("B Programming Language"), 
if I recall correctly. Python generally runs "further ways from the 
hardware" than these other languages, and in some sense, it still would, 
*even if* you were able to statically compile it to machine language. To 
me if feels like Python runs like an application.   I don't wish to 
debate this as I have other needs this week. But I felt compelled to try 
to explain why maybe you shouldn't be casting stones at C/C++.


One thing you didn't bring up at all, is that the audiences for the 
languages appears to be different. You still need folks who can encode 
data structures and write device drivers, from scratch.  And "woe" if 
you need performance, such as applications involving AI.


Cheers,
Bill


But even if it were the best language in the world, and Stroustrup the
greatest language designer in the history of computing, what makes you think
that he knows anything about teaching?




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


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

2017-10-10 Thread Bill

Rhodri James wrote:

On 09/10/17 20:06, Stefan Ram wrote:

r...@zedat.fu-berlin.de (Stefan Ram) writes:

Steve D'Aprano <steve+pyt...@pearwood.info> writes:
At various stages of education, we teach many lies-to-children, 
including:

Many of those lies can be perfectly true in some sense.
I pick some examples:


   Another noun phrase with "lie" is "white lie".

   In his book about programming, Bjarne Stroustrup writes:

|We try hard to avoid "white lies"; that is, we refrain from
|oversimplified explanations that are clear and easy to
|understand, but not true in the context of real languages and
|real problems.


That would go a long way to explaining why I tried and failed to learn 
C++ three times from Stroustrup's books.


He is surely one of the best authors in computer science (at least based 
upon "The C++ Programming Language", 3rd ed.).  He indicates that he 
assumes that the reader has some experience developing serious 
software.  Beazley's, "Python: Essential Reference" is one of the best 
books I've seen since. It doesn't have the same depth, but it (too) 
provides articulate answers, head-on. Both books have 5-star rankings on 
Amazon.com. That doesn't mean that either of them is right for 
everybody. Come back to Stroustrup's book "after" you learn C++ 
somewhere else, and maybe you'll enjoy it more.


Bill

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


Re: why does memory consumption keep growing?

2017-10-05 Thread Bill

Fetchinson . wrote:

Hi folks,

I have a rather simple program which cycles through a bunch of files,
does some operation on them, and then quits. There are 500 files
involved and each operation takes about 5-10 MB of memory. As you'll
see I tried to make every attempt at removing everything at the end of
each cycle so that memory consumption doesn't grow as the for loop
progresses, but it still does.

import os

for f in os.listdir( '.' ):

 x = [ ]

 for ( i, line ) in enumerate( open( f ) ):

 import mystuff
 x.append( mystuff.expensive_stuff( line ) )
 del mystuff

 import mystuff
 mystuff.some_more_expensive_stuff( x )
 del mystuff
 del x


What can be the reason? I understand that mystuff might be leaky, but
if I delete it, doesn't that mean that whatever memory was allocated
is freed? Similary x is deleted so that can't possibly make the memory
consumption go up.

Any hint would be much appreciated,
Daniel



Try calling the garbage collector explicitly.

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


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

2017-10-05 Thread Bill

Marko Rauhamaa wrote:

That's good advice, but it's not all that dangerous to express off-topic
statements in this newsgroup.



It may not be "dangerous", but I find it a little annoying.  I wasn't 
going to say anything, but now you are bringing it up explicitly.



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


Re: Introducing the "for" loop

2017-10-05 Thread Bill

Stefan Ram wrote:

"ROGER GRAYDON CHRISTMAN" <d...@psu.edu> writes:

On Wed, Oct 4, 2017 22:42 Stefan Ram (r...@zedat.fu-berlin.de) wrote:
Steve D'Aprano <steve+pyt...@pearwood.info> writes:

So, "bottom-up" in this case means: iterators should be
taught before for-loops.
Why?

The easy answer here is to not use the range in the first for loop.

   I never intended to use »range«. But I also will not use lists.

   Very early in the course, I teach numeric and string literals:

1, 2.3, 'abc'

   then come operators, functions and »if«, »while« and »try«.
   But neither »range« nor lists have been shown so far.


As long as I have two teachers here, which textbooks are you using? I am 
hoping to teach a college course in Python next fall.


Thanks,
Bill





   The basic course may already and there after about 12 - 18 hours.
   (This time includes many exercises in the classroom.)

   But if I have time to introduce »for«, I'll do it as follows
   at this point in the course:

   

   We want to walk through (traverse) a string
   character-by-character:

   To do this we need a walker. A walker can be
   obtained using »iter«:

|>>> walker = iter( 'abc' )

   Now, we can get character after character from the walker
   using »next« (transcript simplified):

|>>> next( walker )
|'a'
|>>> next( walker )
|'b'
|>>> next( walker )
|'c'
|>>> next( walker )
|StopIteration

   We can use »while« to automate this:

def example():
 walker = iter( 'abc' )
 try:
 while True:
 print( next( walker ))
 except StopIteration:
 pass

   A walker also is known as an /iterator/.

   An object, one can get an iterator from
   is called an /iterable object/.

   Strings are iterable objects.

   This for-loop does just what our previous
   while-loop did:

def example():
 for ch in 'abc':
 print( ch )

   It gets an iterator from »'abc'« and then does the suite
   repeatedly with »ch« being the result of a each »next«
   call until StopIteration.

   

   No »range«, no list.

   (Yes, »print('\n'.join('abc'))« can do the same and will
   be shown later in the course if there is still time.)



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


Re: Creating a Dictionary

2017-10-04 Thread Bill

Stefan Ram wrote:

   One might wish to implement a small language with these commands:

Explain why. What is the advantage?




F - move forward
B - move backward
L - larger stepsize
S - smaller stepsize

   . One could start with the following pseudocode for a dictionary:

{ 'F': lambda: myturtle.forward( s ),
   'B': lambda: myturtle.backward( s ),
   'L': lambda: global s; s *= 2,
   'S': lambda: global s; s /= 2 }

   . But lambda-expressions cannot contain statements.

   In real Python one could write something like (untested):

def f():
 myturtle.forward( s )

def b():
 myturtle.backward( s )

def l():
 global siz
 size *= 2

def s():
 global siz
 size /= 2

{ 'F': f,
   'B': b,
   'L': l,
   'S': s }

   . Is this more readable or less readable?

   Any other suggestions?



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


Re: Python community "welcoming" feedback

2017-10-04 Thread Bill

Leam Hall wrote:
A while back I pointed out some challenges for the Python community's 
intake of new coders. Mostly focusing on IRC and the Python e-mail list.


What is the Python e-mail list?

Thanks,
Bill




Several people have stepped up their "welcome" game and I've been very 
impressed with the way things are going.


Great job!

Leam


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


Re: The "loop and a half"

2017-10-03 Thread Bill

Stefan Ram wrote:

   Is this the best way to write a "loop and a half" in Python?


Is your goal brevity or clarity, or something else (for instance, what 
does the code written by the other members of your "team" look 
like--woudn't it be nice if it matched)?


Bill



x = 1
while x:
 x = int( input( "Number (enter 0 to terminate)? " ))
 if x:
 print( f'Square = { x**2 }' )

   In a C-like language, one could write:

while x = int( input( "Number (enter 0 to terminate)? " ))
 print( f'Square = { x**2 }' )

   .



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


Re: newb question about @property

2017-10-03 Thread Bill

Steve D'Aprano wrote:

On Tue, 3 Oct 2017 06:51 am, Bill wrote:


Can you inspire me with a good decorator problem (standard homework
exercise-level will be fine)?


Here is a nice even dozen problems for you. Please ask for clarification if any
are unclear.


Thank you for sharing the problems on decorators!   I just finished 
reading Bruce Eckels' note on decorators (as well as some of the 
comments left by readers), which you shared a link to, and found the 
whole discussion very informative. If I was to point to two details, the 
analogy of decorator's with macros is helpful to bear in mind, as is the 
remark that "@Wrapper(def f..)" reassigns f to the composition. With the 
latter unstated, the matter can cause confusion!   %-)


Bill





(1) Write a decorator which simply prints a descriptive message and the name of
the decorated function once, when the function is first decorated.

E.g. if you write:

@decorate
def spam(x):
 return x + 1  # for example

print(spam(1))
print(spam(2))


Python should print:

Decorating function spam.
2
3


Note: "spam" must not be hard-coded, it must be taken from the function being
decorated. (Hint: all functions have their name available as func.__name__.)


(2) Modify the decorator from (1) so that calling the wrapped function also
print a descriptive message such as "Calling function spam". The expected
output will be:

Decorating function spam.
Calling function spam.
2
Calling function spam.
3


(3) Write a decorator that checks that the decorated function's first argument
is a non-empty string, raising an appropriate exception if it is not, and lets
through any other arguments unchanged.


(4) Same as above, except the first argument is automatically stripped of
leading and trailing whitespace and forced to uppercase.


(5) Write a decorator which injects the argument 10 into the list of arguments
received by the wrapped function. E.g. if you write:

@inject
def add(a, b):
 return a + b

@inject
def sub(a, b):
 return a - b

print(add(5), sub(5))

Python should print "15 5". (And *not* "15 -5".)


(6) [ADVANCED] Modify the decorator in (5) so that it takes an argument telling
it what value to inject into the list of arguments:

@inject(99)
def sub(a, b):
 return a - b

print(sub(5))

will now print "94".


(7) Write a decorator which checks the decorated function's two arguments are
given smallest first, swapping them around if needed.


(8) Write a decorator which prints the name of the wrapped function, its
arguments, and the time, each time the wrapped function is called.


(9) [ADVANCED] Modify the decorator from (8) to take an argument specifying the
path to a file, and use the logging module to log the details to that file
instead of printing them.


(10) Write a decorator which adds an "cache" attribute initialised to an empty
dictionary to the decorated function.


(11) Write a decorator which wraps a class (not function!), and adds a "help"
method to the class which prints a message as shown below. For example:

@addhelp
class Spam:
 pass

@addhelp
class Eggs:
 pass

x = Spam()
x.help()
y = Eggs()
y.help()

will print:

See http://example.com/Spam
See http://example.com/Eggs

(Hint: classes also have a __name__ attribute.)


(12) [ADVANCED] Write a decorator which wraps a class, and applies the decorator
from (10) above to each non-dunder¹ method in the class. That is, after:

@addcaches
class MyClass:
 def foo(self):
 pass
 def bar(self):
 pass

print(MyClass.foo.cache, MyClass.bar.cache)

should print "{} {}".



¹ Remember that dunder methods are those that start with two leading and
trailing underscores: "Double UNDERscore" methods.


* * *


Bruce Eckel has an excellent introduction to Python decorators, from way back
when they were first introduced in 2008. His introduction is notable because:

- he points out explicitly that Python decorators are not the same as
   the Decorator design pattern (I thought they were!);

- he recommends using a class as the decorator, and building the extra
   functionality in object oriented fashion, rather than functional
   programming fashion (this may give an easier introduction to those
   who aren't familiar with functional idioms);

- and he correctly predicted that the introduction of the @ syntactic
   sugar would have a big impact on the way people think about Python
   code.


http://www.artima.com/weblogs/viewpost.jsp?thread=240808

Feel free to read his post before trying the problems I set.





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


Re: newb question about @property

2017-10-03 Thread Bill

Bill wrote:

Chris Angelico wrote:

Decorators are fairly straight-forward if you understand higher-order
functions.  

ChrisA



I was just minding my own business, and thought to write my first 
decorator for a simple *recursive* function f.  The decorator WORKS if 
f does not make a call to itself 
(it really wasn't). 


Using the (PyCharm) debugger, I determined that my inner function that 
was calling my wrapped (Fibonacci sequence) function but wasn't 
returning anything to the invoking environment. I fixed it for the sake 
of a good, if costly, lesson.  Not much of a wrapper, but it "works".  A 
version which merely prints a tab before the function call, instead of a 
row of asterisks produces output which is more interesting to look at.


def wrap(func):
def inner(*args, **kwargs):
print('*'*20)
a= func(*args, **kwargs)
print(a)
print('*'*20)
return a
return inner


Bill

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


Re: newb question about @property

2017-10-02 Thread Bill

Chris Angelico wrote:

Decorators are fairly straight-forward if you understand higher-order
functions.  

ChrisA



I was just minding my own business, and thought to write my first 
decorator for a simple *recursive* function f.  The decorator WORKS if f 
does not make a call to itself.Otherwise, f seems to have 
"difficulty" calling itself (I get a typerror, f(n) has value 
"NoneType").   What is the explanation for this?  Does f have a new name 
because it has a decorator on it now?


Note: I am not using functools.wraps since I don't yet understand the 
reason I might do that yet (first things first... ).


Thanks!

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


Re: newb question about @property

2017-10-02 Thread Bill

Steve D'Aprano wrote:

There's no need to set the radius and the diameter, as one is completely derived

from the other


Good point; I'm glad I submitted my code for grading.  Sort of a "trick 
question" to ask me to add diameter and then take off points because I 
used it!  ; )


Bill




and the transformation is cheap enough to perform on the fly as
needed.

Consider what happens if, due to a bug or an accident, you end up with a Circle
instance that says the radius is 5 and the diameter is 20. They can't *both* be
right, and


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


Re: newb question about @property

2017-10-02 Thread Bill

Chris Angelico wrote:

On Tue, Oct 3, 2017 at 6:23 AM, Larry Hudson via Python-list
<python-list@python.org> wrote:

On 10/01/2017 03:52 PM, Bill wrote:

Steve D'Aprano wrote:

The definitive explanation of descriptors is here:
https://docs.python.org/3/howto/descriptor.html


Thank you!  It is next on my list.   Then I'll try that Circle problem you
mentioned as an exercise last night!  I don't expect run into any
difficulties.  : )


Except perhaps for your sense of time...  "I'll try" implies the future,
"last night" is the past.:-)   :-)

(Couldn't resist...)

Yes, but "you mentioned" implies the past. I think you have an
operator precedence issue. Kappa

ChrisA



Reading the "definitive explanation of descriptors" took me longer than 
expected..  I am as overly optimistic as any programming person..   ;)


Can you inspire me with a good decorator problem (standard homework 
exercise-level will be fine)?  Otherwise  I will go create one which 
will prints a row of asterisks before and after the call to the original 
function (which I think I should do). But maybe you have something more 
interesting? Or maybe you can refer me to a good source of Python 
problems, so I can bug you less?


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


Re: newb question about @property

2017-10-02 Thread Bill

Steve D'Aprano wrote:
Circle didn't use any setters, but I could have let you set the 
diameter, which in

turn would set the radius:

circle.radius = 2
assert circle.diameter == 4
circle.diameter == 2  # requires a setter
assert circle.radius == 1

Getting that to work is left as an exercise :-)

It WAS a good exercise!!  I was concerned about "infinite recursion" 
between my two property setters..  Thanks!   Next?  :)


Bill


import math


class Circle(object):
""" Define a circle class with radius and diameter""" def __init__(self, 
radius):
self.radius = radius
self.diameter =2*radius

@property def radius(self):
return self._radius

@radius.setter def radius(self, value):
self._radius = value
self._diameter=2*value

@property def diameter(self):
return self._diameter

@diameter.setter def diameter(self, value):
self._diameter = value
self._radius = value /2 @property def area(self):
return math.pi *self.radius **2 @property def circumference(self):
return 2 * math.pi *self.radius

## Start here ## circle = Circle(1 / math.pi)
print("Area = {:.2f}".format(circle.area))
print("Circumference = {:.2f}".format(circle.circumference))

circle.radius =2 assert circle.diameter ==4 print("Area = 
{:.2f}".format(circle.area))
print("Circumference = {:.2f}".format(circle.circumference))

circle.diameter =2 # requires a setter assert circle.radius ==1 print("Area = 
{:.2f}".format(circle.area))
print("Circumference = {:.2f}".format(circle.circumference))



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


Re: newb question about @property

2017-10-01 Thread Bill

Steve D'Aprano wrote:

The definitive explanation of descriptors is here:
https://docs.python.org/3/howto/descriptor.html


Thank you!  It is next on my list.   Then I'll try that Circle problem 
you mentioned as an exercise last night!  I don't expect run into any 
difficulties.  : )


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


Re: newb question about @property

2017-10-01 Thread Bill

Stephan Houben wrote:

Op 2017-10-01, Bill schreef <bill_nos...@whoknows.net>:

I watched an example on YouTube where someone wrote a simple descriptor
("@Time_it) to output the amount of time that it took ordinary functions
to complete.To be honest, I AM interested in descriptors.

Are you sure you are not confusing deSCRIPTtors and deCORAtors here?


Yet, you are absolutely correct!  Thank you for clarifying! From your 
description, I can see that it was *decorators*, which drew my 
interest.  It appears that *property* is perhaps both a decorator and a 
descriptor, at least when used as in the examples we have been 
discussing.  According to the language grammar, which all newbys like me 
should have handy (remember my ADT acronym from another thread?), 
decorators can be applied to a classdef, a funcdef, or a async_funcdef 
(the latter I assume is a "callback" function definition).   Surely the 
difference in syntax between funcdef and async_funcdef will be revealed 
to me by looking closer at the grammar! : )


Bill



@Time_it

is decorator syntax.

Despite the similarity in the words, there are totally different things.

Descriptors are objects with __get__, and optionally __set__ and
__delete__ methods (i.e. they implement the descriptor protocols).

Decorators aren't really an official type, but loosely speaking these
are any functions which can be applied meaningfully with a single
function or class as argument. Some very mundane functions can be
(ab)used as decorators.

In [1]: @repr
...: def hello():
...: pass
...:

In [2]: hello
Out[2]: ''

Stephan


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


Re: newb question about @property

2017-10-01 Thread Bill

Steve D'Aprano wrote:

On Sun, 1 Oct 2017 05:46 pm, Bill wrote:


If you were going to show non-Python users, say science undergraduates
and faculty, that Python is an interesting tool (in 45 minutes), would
one delve into descriptors?

Hell no :-)
Oops, I see I used the word "descriptor", where I meant "decorator" (at 
least newb is still in the subject line).   I don't even know what a 
descriptor is yet--I know a bit more about meta-classes! %-) So, on your 
list, I'm basically up to the leading edge of (5), writing decorators. 
But my previous programming experience helped me to blast through (1) to 
(4).  Going forward, it appears the walkway will be a little steeper.  I 
do appreciate your list as it improves my perspective.


From the point of view of getting others to be interested, I'm not sure 
*classes* and object oriented design/thinking do it.  I think they are 
more of an acquired taste... Functions, on the other hand, are easy to 
like, I think--especially in Python.





I think there's a hierarchy of difficulty/complexity/mind-bogglingness in
Python. From least complex to most:

- Using Python in an imperative fashion, as in simple scripts.

- Writing your own functions.

- Writing your own classes.

- Writing generators.

- Using decorators, including property.

- Writing your own decorators.

- Writing your own descriptors.

- Writing your own metaclasses (a.k.a. "the killer joke").

I wouldn't touch the last three in a beginner's class, not unless they already
had a significant amount of programming experience.




I am thinking maybe. Here is what I am
thinking at this moment: trivial applications (probably), list
comprehensions (definitely), generators (maybe briefly). Whatever I
would discuss, I think ending with descriptors could be a strong finish.

That depends on whether your aim is to confuse them or not :-)

I don't think the descriptor protocol is something you'll be able to explain in
five or ten minutes. *Using* descriptors like property, sure, that's fine.



But I'm certainly not merely interested for the sake of my talk, I
obtain some satisfaction in learning how things work.  If you can
suggest any references for descriptors which you think are good, I would
be interested.

The definitive explanation of descriptors is here:

https://docs.python.org/3/howto/descriptor.html


Thanks!

Bill






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


Re: newb question about @property

2017-10-01 Thread Bill

Steve D'Aprano wrote:


[1] Technically, the interpreter knows nothing about properties. What it cares
about is *descriptors*. Properties are just one kind of descriptor, as are
methods. But I'm intentionally not talking about the gory details of
descriptors. Feel free to ask if you care, but honestly, you don't need to care
unless you are writing your own descriptor class.

I found the following page to be a very easily accessible discussion 
about descriptors (it represents the state of my knowledge about 
descriptors).   You got more?  : )


https://www.programiz.com/python-programming/decorator


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


Re: newb question about @property

2017-10-01 Thread Bill

Steve D'Aprano wrote:

Circle
didn't use any setters, but I could have let you set the diameter, which in
turn would set the radius:

circle.radius = 2
assert circle.diameter == 4
circle.diameter == 2  # requires a setter
assert circle.radius == 1

Getting that to work is left as an exercise :-)


I may start that exercise in a few minutes!



But most commonly, computed attributes need to store some data aside, somewhere.
You could use a global variable, or write it to a file, or stick it in a list.
All of these things have obvious problems, so the most sensible approach it to
stick the data in a private attribute.

The interpreter doesn't enforce notions of private/public when it comes to
Python classes, but there's a very strong convention that anything starting
with a single underscore is private.



[1] Technically, the interpreter knows nothing about properties. What it cares
about is *descriptors*. Properties are just one kind of descriptor, as are
methods. But I'm intentionally not talking about the gory details of
descriptors. Feel free to ask if you care, but honestly, you don't need to care
unless you are writing your own descriptor class.


Thank you, and everyone else who has contributed to this thread, for 
helping me.  Each contribution I read helped me to get further ahead!


I watched an example on YouTube where someone wrote a simple descriptor 
("@Time_it) to output the amount of time that it took ordinary functions 
to complete.To be honest, I AM interested in descriptors. I may 
reexamine whether David Beazley has more to say about them in his book  
"Python: Essential Reference", which I have been reading. Obviously, I 
still have some gaps in my understanding after my first reading.


If you were going to show non-Python users, say science undergraduates 
and faculty, that Python is an interesting tool (in 45 minutes), would 
one delve into descriptors? I am thinking maybe. Here is what I am 
thinking at this moment: trivial applications (probably), list 
comprehensions (definitely), generators (maybe briefly).   Whatever I 
would discuss, I think ending with descriptors could be a strong finish. 
But I'm certainly not merely interested for the sake of my talk, I 
obtain some satisfaction in learning how things work.  If you can 
suggest any references for descriptors which you think are good, I would 
be interested.


Thanks,
Bill

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


Re: newb question about @property

2017-09-30 Thread Bill

Ned Batchelder wrote:

On 9/30/17 7:18 PM, Bill wrote:

Ned Batchelder wrote:

On 9/30/17 5:47 PM, Bill wrote:
I spent a few hours experimenting with @property. To my mind it 
seems like it would be preferable to just define (override) 
instance methods __get__(), __set__(), and possibly __del__(), as 
desired, as I could easily provide them with "ideal" customization. 
Am I overlooking something?




It would be easier to comment if you showed the two options. One 
with @property, and one with __get__ etc.


A downside to __get__ is that you need to create a class with those 
methods, and then instantiate that class as an attribute in your 
real class, whereas @property can be used without a lot of rigamarole.


--Ned.


I am basically mimmicking what I see at (the very bottom of) this page:

https://www.programiz.com/python-programming/property


Can you show us the code you are using it to mimic that?

--Ned.


Here it is, Ned. It's my first attempt at using classes in Python.
I still have to learn how to incorporate datetime appropriately!  :)

import datetime


# object oriented example class Employee(object):
''' This class will abstract an employee. Class date members name, a 
string birthday, a date object address, a string position It also has a 
static data member for the number of employees. ''' num_employees =0 # class data item @classmethod def get_num_employees(cls):

return Employee.num_employees

def __init__(self, name, birthdate, address, position):
Employee.num_employees +=1 self.name = name
self.birthdate = birthdate
self.address = address
self.position = position

@property def address(self):
print("**Hi from address-getter**")
return self._address

@address.setter def address(self, value):
print("*Hi, from address setter()!")
self._address = value


def __del__(self):

print("*** Hi, from __del__()")
##Employee.num_employees -= 1 def __str__(self):
return 'Name: {}, Born: {} \nAddress: {} \nPosition: {} \n'.\
format(self.name,self.birthdate,self.address,self.position)

class SalesPerson(Employee):
def __init__(self, name, bdate, addr):
super().__init__(name, bdate, addr,"Salesperson")


def main():
emp1 = Employee("Sam","4/30/1970","212 Elm","Programmer")
emp2 = SalesPerson("Gene","5/1/79","414 Maple")
## Note: learn to use datetime.date--> str print(emp1)
print(emp2)
emp1.address ="230 Main Street" # call setter? print(emp1)
del(emp1)
print("Number of employees", Employee.get_num_employees())
   




print('*'*30)
main()#call main()

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


Re: newb question about @property

2017-09-30 Thread Bill

Steve D'Aprano wrote:

On Sun, 1 Oct 2017 08:47 am, Bill wrote:


I spent a few hours experimenting with @property. To my mind it seems
like it would be preferable to just define (override) instance methods
__get__(), __set__(), and possibly __del__(), as desired, as I could
easily provide them with "ideal" customization. Am I overlooking something?

Probably.


You and Ned are both right.  Up until a few minutes ago, I wasn't 
thinking about a class having more than 1 attribute that I wanted to 
change.  And now I realize that __get__ doesn't really make sense in 
that context (in the back of my mind was the notion that @property 
defined __get__, __set__ and __del__) and I allowed that to obscure my 
vision.   I was on the verge of giving up anything to do with computers, 
forever.  : )


BTW, your example (below) is very nice!  I may have seen something 
similar before, but I am starting to appreciate it better now.  I think 
all of this would have made a bit more sense (to me), if instead of just 
"@property", the syntax was "@property.getter".  Now I am forced to ask 
the question, why did they use the underscore (on temperature) in the 
example on the bottom of this page? Is one forced to introduce new 
identifiers in order to define a setter?


https://www.programiz.com/python-programming/property

Thanks!
-Bill



This is a particularly simple example, with only getters. How would you write it
by overriding __get__?


class Circle(object):
 def __init__(self, centre, radius):
 self.centre = centre
 self.radius = radius

 @property
 def diameter(self):
 return 2*self.radius

 @property
 def area(self):
 return pi*self.radius**2

 @property
 def circumference(self):
 return pi*self.diameter





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


newb question about @property

2017-09-30 Thread Bill
I spent a few hours experimenting with @property. To my mind it seems 
like it would be preferable to just define (override) instance methods 
__get__(), __set__(), and possibly __del__(), as desired, as I could 
easily provide them with "ideal" customization. Am I overlooking something?


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


  1   2   3   4   5   6   7   8   9   10   >