strange syntax rules on list comprehension conditions

2008-01-18 Thread Nicholas
I was quite delighted today, after extensive searches yielded nothing, to
discover how to place an else condition in a list comprehension.
Trivial mask example:
>>> [True if i <5 else False for i in range(10)]   # A
[True, True, True, True, True, False, False, False, False, False]

I then experimented to drop the else statement which yields an error
>>> [i if i>3 for i in range(10)]
Traceback (  File "", line 1
this syntax works of course
>>> [i if i>3 else i for i in range(10)]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Does anybody else find this lack of symmetry odd?

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

Relative imports in Python 3.0

2008-12-17 Thread Nicholas
Imagine a module that looks like

ModuleDir
 __init__.py
 a.py
 b.py


In python 2.x I used to have tests at the end of each of my modules,
so that module b.py might look something like

import a
 ..
 ..

if __name__ == '__main__':
   runtests()

But under Python 3.0 this seems impossible.  For usual use import a.py
has to become the line:

from . import a

But if I use that form it is no longer possible to run b.py as a
standalone script without raising an error about using relative
imports.

I am sure I am not the first to run into this issue, but what is the
solution?

Best wishes,

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


Conversion of npyscreen module to python 3 -- help!

2009-10-05 Thread Nicholas
Dear Pythoners,

Like a loyal python coder, I was attempting to convert a library to
python 3.  I have been stung in various ways by the new import
semantics - the tests that used to live happily within the module have
now had to be moved elsewhere. So be it.

But even though I have removed all the obvious things that are causing
it to break, and even refactored the whole file-scheme of the module
to make conversion more straight-forward, I'm still unable to get the
code to work.

I am clearly committing some horrible sin that works well in python 2
but which doesn't in python 3.  Despite reading the Release notes and
PEPs over and over, though, I can't see what is wrong.

If anyone could spare the time to have a quick look at the code at

http://code.google.com/p/npyscreen/

over and provide enlightenment, I would be extremely grateful.  (the
source code in the hg archive is more recent than the package for
download)

Best wishes,

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


[Q] Function Point Analysis (FPA) - Equivalent lines of code of Python

2010-09-09 Thread Nicholas
Hi,

  In FPA, there are tables which shows equivalent lines of code for
each Function Point (FP) for a number of programming languages.

  e.g. http://www.qsm.com/?q=resources/function-point-languages-table/index.html

  However, I have yet to find the figures for Python.

  Is someone able to advise the closest language equivalent.

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


Re: from future import pass_function

2012-07-25 Thread Nicholas Cole
On Wed, Jul 25, 2012 at 9:40 AM, Ulrich Eckhardt
 wrote:
> What do you think?
>

I enjoyed the question, but actually I don't think this is a good idea.

1.  If you really needed something like this, you could define it easily.

def do_nothing(*args, **keywords):
   return None

2. If it were a built-in function, you would be able to override it,
and then there would be chaos.

Best,

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


sys.path in python3.3

2012-08-26 Thread Nicholas Cole
Dear List,

In all previous versions of python, I've been able to install packages
into the path:

~/Library/Python/$py_version_short/site-packages

but in the rc builds of python 3.3 this is no longer part of sys.path.

Before I go hacking the install, is there a reason that this path was
removed?  Is there a recommended way to get it back, or is this a
gentle way of pushing us all to use virtualenv rather than installing
user-specific packages?

Best wishes,

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


Re: sys.path in python3.3

2012-08-26 Thread Nicholas Cole
On Sun, Aug 26, 2012 at 8:21 PM, Ned Deily  wrote:
> In article
> ,
>  Nicholas Cole  wrote:
>> In all previous versions of python, I've been able to install packages
>> into the path:
>>
>> ~/Library/Python/$py_version_short/site-packages
>>
>> but in the rc builds of python 3.3 this is no longer part of sys.path.
>>
>> Before I go hacking the install, is there a reason that this path was
>> removed?  Is there a recommended way to get it back, or is this a
>> gentle way of pushing us all to use virtualenv rather than installing
>> user-specific packages?
>
> It should be working if you are using an OS X framework build.  What is
> the value of sys.path?

I'm using the compiled version supplied by python.org.


Python 3.3.0rc1 (v3.3.0rc1:8bb5c7bc46ba, Aug 25 2012, 10:09:29)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/Library/Frameworks/Python.framework/Versions/3.3/lib/python33.zip',
'/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3',
'/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages']
>>>

This contrasts with (for python3.1)

Python 3.1.1 (r311:74543, Aug 24 2009, 18:44:04)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/Library/Frameworks/Python.framework/Versions/3.1/lib/python31.zip',
'/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1',
'/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/site-packages',
'/Users/nicholas/Library/Python/3.1/site-packages']


Best wishes,

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


Re: sys.path in python3.3

2012-08-26 Thread Nicholas Cole
On Sun, Aug 26, 2012 at 10:23 PM, Ned Deily  wrote:
> In article
> ,
>  Nicholas Cole  wrote:
>
>> On Sun, Aug 26, 2012 at 8:21 PM, Ned Deily  wrote:
>> > In article
>> > ,
>> >  Nicholas Cole  wrote:
>> >> In all previous versions of python, I've been able to install packages
>> >> into the path:
>> >>
>> >> ~/Library/Python/$py_version_short/site-packages
>> >>
>> >> but in the rc builds of python 3.3 this is no longer part of sys.path.
>> >>
>> >> Before I go hacking the install, is there a reason that this path was
>> >> removed?  Is there a recommended way to get it back, or is this a
>> >> gentle way of pushing us all to use virtualenv rather than installing
>> >> user-specific packages?
>> >
>> > It should be working if you are using an OS X framework build.  What is
>> > the value of sys.path?
>>
>> I'm using the compiled version supplied by python.org.
>
> The directory needs to exist otherwise the path is not included (see
> site.py).

It certainly does exist. Distutils will happily put packages into it,
but import won't find them.

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


Re: sys.path in python3.3

2012-08-27 Thread Nicholas Cole
On Mon, Aug 27, 2012 at 12:18 AM, Ned Deily  wrote:
> In article
> ,
>  Nicholas Cole  wrote:
>> It certainly does exist. Distutils will happily put packages into it,
>> but import won't find them.
>
> That's odd!  It works for me on 10.8 and it worked for me yesterday on
> 10.7 which I tested just after completing the python.org installer
> builds.  Perhaps there is some permission issue.  Or the path name isn't
> quite correct.  Or you have some PYTHON* environment variable set, like
> PYTHONNOUSERSITE?

I'm also on 10.8.

NPSC: nicholas$ set | grep PYTHON
NPSC: nicholas$

The only user configuration I've done is to create the following
configuration file:

NPSC:~ nicholas$ cat .pydistutils.cfg
[install]
install_lib = ~/Library/Python/$py_version_short/site-packages
install_scripts = ~/bin

I should say, this has been a problem for all of the python3.3 alpha
and beta releases, on previous releases of OS X.

I can't understand why it works on your setup, though, because I
haven't done anything at all (that I can think of) that ought of
affect it.  I wonder if the logic that adds the directory to sys.path
is being too clever for everyone's good?

Best wishes,

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


Re: sys.path in python3.3

2012-08-27 Thread Nicholas Cole
On Mon, Aug 27, 2012 at 10:05 AM, Ned Deily  wrote:
> In article <503b3247$0$6877$e4fe5...@news2.news.xs4all.nl>,
>  Hans Mulder  wrote:
>> On 26/08/12 20:47:34, Nicholas Cole wrote:
>> It has been changed to
>>
>> ~/Library/Python/$py_version_short/lib/python/site-packages
>>
>> You can find the path it's looking for in site.USER_SITE
>
> That is correct.
>
>> It would be nice if there were some magic code you could use
>> for "install_lib" in your .pydistutils.cfg file that worked
>> in both 3.2 and 3.3.
>
> As I explained in my reply that overlapped with yours, I believe you
> will find that 3.2 and 3.3 behave the same.   The difference is with 3.1
> (which is no longer supported); likewise, the same change occurred in
> 2.7.  So all of the current actively supported released behave the same
> way.  That's not much help if you need to use 2.6 or 3.1.

Dear Hans and Ned,

Thank you both for your answers, and Ned, thank you especially for
answering at such length.

I do love the things that are "documented if you know where to look."
I'm by no means a stranger to python's documentation, but I am sure
that I would never, ever have found it.  Now that I come to think of
it, I think I probably hit this when I first had a look at  2.7, put
in a sym-link and forgot all about it.  I suppose that now that 2.7 is
the default on OS X, I suppose it is time to move to the correct
directory properly.

Very best wishes,

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


Tarfile and usernames

2012-12-30 Thread Nicholas Cole
Dear List,

I'm hoping to use the tarfile module in the standard library to move some
files between computers.

I can't see documented anywhere what this library does with userids and
groupids.  I can't guarantee that the computers involved will have the same
users and groups, and would like the archives to be extracted so that the
files are all owned by the extracting user.

Essentially, I do *not* with to preserve the owner and groups specified in
the archives.

What is the right way to achieve this?

Best wishes,

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


Re: Tarfile and usernames

2012-12-30 Thread Nicholas Cole
On Sun, Dec 30, 2012 at 8:07 PM, Albert Hopkins wrote:
>
>
> On Sun, Dec 30, 2012, at 01:57 PM, Nicholas Cole wrote:
>
> Dear List,
>
> I'm hoping to use the tarfile module in the standard library to move some
> files between computers.
>
> I can't see documented anywhere what this library does with userids and
> groupids.  I can't guarantee that the computers involved will have the same
> users and groups, and would like the archives to be extracted so that the
> files are all owned by the extracting user.
>
> Essentially, I do *not* with to preserve the owner and groups specified in
> the archives.
>
>
> Each "member" in the tar file has misc. metadata associated with it, which
> can be retrieved with the get_info() method.  You can add/modify this
> metadata if creating a TarFile.
>
> However, it should be stated that by default (on *nix anyway) if the user
> is not root then user/groups are assigned to the user exctracting the file
> (because only root can assign userids/non-member-groups).   The TarFile
> extract*() methods pretty much inherit the same behavior as the *nix tar
> command.  So if you are extracting as a non-root user, you should expect
> the same behavoir.  If you are extracting as root but don't want to change
> user/groups may have to extract it manually or create your own class by
> inheriting TarFile and overriding the .chown() method.
>
>

Thank you for this.  I guess that since the behaviour is not defined in the
documentation, it would probably be safest to inherit and change chown into
a no op.

I know that on *most* systems these days ordinary users cannot chown, and
also that people shouldn't be running things as root.  But you can't be too
careful - and predicting what a given user will do is always dangerous!

Best wishes,

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


Re: PyWart: Module access syntax

2013-01-12 Thread Nicholas Cole
On Fri, Jan 11, 2013 at 6:01 AM, Rick Johnson
wrote:

>
> Python's module/package access uses dot notation.
>
>   mod1.mod2.mod3.modN
>
> Like many warts of the language, this wart is not so apparent when first
> learning the language. The dot seems innocently sufficient, however, in
> truth it is woefully inadequate! Observe:
>
>  name1.name2.name3.name4.name5
>
>
I find it reassuring to have these kinds of questions on the list, because
they actually remind me how brilliantly designed Python is.

As the user of a module I shouldn't care about the internal arrangement of
objects and files.  I don't care.  More than that, as the writer of a
module I should be free to refactor the internals of a module without
breaking existing code.

There is absolutely nothing wrong at all with the syntax. In fact, it's
fantastic.

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


I have issues installing pycrypto (and thus fabric) with pip

2013-01-28 Thread Nicholas Kolatsis
I'm not sure this is the right place for this but I'm don't know where else to 
put this.

I want to give fabric a try (as recommended here: 
http://www.jeffknupp.com/blog/2012/10/24/starting-a-django-14-project-the-right-way/).
 Installing fabric results in two dependencies (paramiko and pycrypto) being 
installed as well. All is dandy until it is time to install pycrypto.

A bit of searching reveals this in the documentation:

Package tools

We strongly recommend using pip to install Fabric as it is newer and generally 
better than easy_install. However, a combination of bugs in specific versions 
of Python, pip and PyCrypto can prevent installation of PyCrypto. Specifically:

Python = 2.5.x
PyCrypto >= 2.1 (which is required to run Fabric >= 1.3)
pip < 0.8.1

When all three criteria are met, you may encounter No such file or directory 
IOErrors when trying to pip install Fabric or pip install PyCrypto.

The fix is simply to make sure at least one of the above criteria is not met, 
by doing the following (in order of preference):

Upgrade to pip 0.8.1 or above, e.g. by running pip install -U pip.
Upgrade to Python 2.6 or above.
Downgrade to Fabric 1.2.x, which does not require PyCrypto >= 2.1, and 
install PyCrypto 2.0.1 (the oldest version on PyPI which works with Fabric 1.2.)


(dp130128)cheeky@n5110:~/proj/dp130128$ yolk -l
Django  - 1.4.3- active 
Python  - 2.7.3- active development 
(/usr/lib/python2.7/lib-dynload) <--check
South   - 0.7.6- active 
argparse- 1.2.1- active development (/usr/lib/python2.7)
pip - 1.2.1- active  <--check
setuptools  - 0.6c11   - active 
wsgiref - 0.1.2- active development (/usr/lib/python2.7)
yolk- 0.4.3- active 

I've got pip and python covered above but I'm still unable to install fabric as 
shown below.

(dp130128)cheeky@n5110:~/proj/dp130128$ pip install fabric
Downloading/unpacking fabric
  Running setup.py egg_info for package fabric

warning: no previously-included files matching '*' found under directory 
'docs/_build'
warning: no previously-included files matching '*.pyc' found under 
directory 'tests'
warning: no previously-included files matching '*.pyo' found under 
directory 'tests'
Downloading/unpacking paramiko>=1.9.0 (from fabric)
  Running setup.py egg_info for package paramiko

Downloading/unpacking pycrypto>=2.1,!=2.4 (from paramiko>=1.9.0->fabric)
  Running setup.py egg_info for package pycrypto

Installing collected packages: fabric, paramiko, pycrypto
  Running setup.py install for fabric

warning: no previously-included files matching '*' found under directory 
'docs/_build'
warning: no previously-included files matching '*.pyc' found under 
directory 'tests'
warning: no previously-included files matching '*.pyo' found under 
directory 'tests'
Installing fab script to /home/cheeky/.virtualenvs/dp130128/bin
  Running setup.py install for paramiko

  Running setup.py install for pycrypto
warning: GMP or MPIR library not found; Not building 
Crypto.PublicKey._fastmath.
building 'Crypto.Hash._MD2' extension
gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC 
-std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/MD2.c 
-o build/temp.linux-i686-2.7/src/MD2.o
src/MD2.c:31:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /home/cheeky/.virtualenvs/dp130128/bin/python 
-c "import 
setuptools;__file__='/home/cheeky/.virtualenvs/dp130128/build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n',
 '\n'), __file__, 'exec'))" install --record 
/tmp/pip-0X00No-record/install-record.txt --single-version-externally-managed 
--install-headers /home/cheeky/.virtualenvs/dp130128/include/site/python2.7:
running install

running build

running build_py

running build_ext

running build_configure

warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.

building 'Crypto.Hash._MD2' extension

gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC 
-std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/MD2.c 
-o build/temp.linux-i686-2.7/src/MD2.o

src/MD2.c:31:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1


Command /home/cheeky/.virtualenvs/dp130128/bin/python -c "import 
setuptools;__file__='/home/cheeky/.virtualenvs/dp130128/build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n',
 '\n'), __file__, 'exec'))" install --record 
/tmp/pip-0X00No-record/install-record.txt --single-version-externally-managed 
--install-headers /home/cheeky/.virtualenvs/dp130128/include/site/python2.7 
failed

Re: I have issues installing pycrypto (and thus fabric) with pip

2013-01-29 Thread Nicholas Kolatsis
Thanks. I've gotten everything working now.

For anyone else who comes along, 'sudo apt-get install python-dev' did the job.

> 
> Note that Fabric is useful for much, MUCH more than this.
> 

I look forward to finding out :)

> 
> Off-topic: why is your virtualenv/project name so weird?
> 

Noted. It's the naming pattern that I use for my projects. I should use 
something better but I'm using this because I usually restart something several 
times before I'm happy with it. I was reading up on branching with git earlier. 
It looks like that will put an end to this bad practice.
-- 
http://mail.python.org/mailman/listinfo/python-list


'string_escape' in python 3

2012-04-06 Thread Nicholas Cole
In Python 2 given the following raw string:

>>> s = r"Hello\x3a this is a test"

the escaping could be removed by use of the following:

>>> s.decode('string_escape')

In Python 3, however, the only way I can see to achieve the same
result is to convert into a byte stream and then back:

>>> bytes(s, 'utf-8').decode('unicode_escape')


This seems very ugly (and slightly 'wrong').  Is there no way to do
this without using bytes?  Have I missed something?

Best wishes,

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


Re: 'string_escape' in python 3

2012-04-07 Thread Nicholas Cole
On Sat, Apr 7, 2012 at 12:10 AM, Ian Kelly  wrote:
 import codecs
 codecs.getdecoder('unicode_escape')(s)[0]
> 'Hello: this is a test'
>
> Cheers,
> Ian

Thanks, Ian.  I had assumed that if a unicode string didn't have a
.decode method, then I couldn't use a decoder on it, so it hadn't
occurred to me to try that

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


Re: Maintaining Multiple Copies of Python (Linux)

2012-05-30 Thread Nicholas Fitzkee
On Wednesday, May 30, 2012 7:55:33 PM UTC-5, Ben Finney wrote:

> The consensus solution for this is ‘virtualenv’
> http://pypi.python.org/pypi/virtualenv>.
> 
> It is so popular as a solution for the kinds of problems you describe
> that its functionality will come into core Python, as discussed in PEP
> 405 http://www.python.org/dev/peps/pep-0405/>, for Python 3.3.
> 
> Until you start using Python 3.3, you can install ‘virtualenv’ as a
> third-party package.

Thanks, Ben.

I took a look at this, and I'm a little confused.  First, it doesn't seem all 
that different from "./configure --prefix=ENV" with the exception that you save 
a little space re-using some libraries.  Second, it really doesn't solve my 
problem, because if ENV/bin/python is my PATH, it can still be confused with 
/usr/bin/python.  What am I missing?

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


Re: Dialog boxes in curses

2011-08-13 Thread Nicholas Cole
On Sat, Aug 13, 2011 at 4:37 PM, Irmen de Jong  wrote:
> On 13-8-2011 17:21, f...@slick.airforce-one.org wrote:
>> Hello.
>>
>> I've googled for hints but I didn't find anything, I hope it's not an
>> RTFM question :^)
>>
>> I want to have dialog boxes (a message with Yes/No/Cancel options,
>> possibly with keyboard accels) in python + curses.
>>
>> Does anyone have a pointer to docs about this?
>>
>> Thanks!

Or have a look at code.google.com/p/npyscreen

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


Re: OT: Code Examples

2011-03-01 Thread Nicholas Devenish

On 01/03/2011 09:24, Richard Dobson wrote:

But - I am ~still~ caught out by the
semantic significance of indenting. Looks OK enough on paper, but doing
it interactively is another matter.


I still don't fully understand this argument. With Python, I am still 
doing indentation almost exactly the same way I was in any other 
language (and should be - I haven't ever seen any arguments for not 
indenting logical blocks).


The only difference is, I don't need to put a block-end-identifier.

I suppose I see how one could argue that this could potentially cause 
*mildly* confusing code, but only in extreme examples, and mainly only 
for multi-screen functions, that should rarely exist (and these are 
confusing even with bracketed blocks).

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


Re: Fun with 'str' and 'bytes'

2011-03-06 Thread Nicholas Devenish

On 04/03/2011 16:40, nn wrote:

As far as I know, that is pretty much it. Also see:

http://bugs.python.org/issue3982


That is a depressing bug report, and really comes across as people who 
don't use networking commenting on the requirements of people who write 
networking code.


It's good to see that the idea was getting a bit more treatment last yeat.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What is the best book to learn Python from Perl and C++ background

2011-03-06 Thread Nicholas Devenish

On 04/03/2011 17:49, Ignoramus20691 wrote:

I bought a "Hello World!" book for my 9 year old son. The book teached
"programming for kids" and it does it in Python.

I do not know any Python, but I am very comfortable with C++ and perl.
I wrote a little over 100k lines of perl.

I want to learn Python quickly to help him with his studies/fun.

I would prefer a "no shit" book that quickly teaches a language to
programmers.


I moved to python after a heavy C++ background - I boosted myself to 
self-supporting status with OReilleys "Learning Python" on and off over 
the course of a weekend, skipping the parts that looked familiar.


For some reason I didn't use the official python tutorial, though I have 
used it as a semi-reference on occasion since - it might be a good idea 
to start with that and see if it is efficient enough for you.

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


Import statements and multiprocessing

2018-01-30 Thread Nicholas Cole
Dear List,

I have a strange problem on python 3.6.1

I am using the multiprocessing function to parallelize an expensive
operation, using the multiprocessing.Pool() and Pool.map() functions.

The function I am passing to map calls a function in another file
within the same model.  And that file has a

from .some_file_in_the_package import *

line at the top.

However, in each function called in that file, I seem to need to put
an explicit important statement buried within the function in order
for the code to work:

def some_function():
from .some_file_in_the_package import ThisObject

It is as if in the worker processes created by Pool.map() the from .
import * directive is being completely ignored.

With the explicit import statements everything works as expected.

What could be going wrong?

Best wishes,

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


Re: Import statements and multiprocessing

2018-01-30 Thread Nicholas Cole
On Tue, Jan 30, 2018 at 4:23 PM, Steven D'Aprano
 wrote:
> On Tue, 30 Jan 2018 15:54:30 +, Nicholas Cole wrote:

> I would say you're probably misinterpreting the nature of the problem.
> Import * isn't a directive that can be ignored.
>
> Can you show us a *simplified* demonstration? A minimal sample program
> which we can run that demonstrates the issue?

[snip]

I find it extremely odd.

File A:

the multiprocessing code and the map function.

file B: a set of library functions called by the function called in file A.

file C: included in file B by use of a from .C import * statement.


But none of the functions in B can see the objects defined in C unless
an explicit relative import is included in their functions.

In single process code this seems to work perfectly.

Producing a simplified version is not trivial. But I shall see what I
can do.  At any rate, in our current code, the import * directive *is*
ineffective in subprocesses.

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


Re: Import statements and multiprocessing

2018-01-30 Thread Nicholas Cole
On Tue, Jan 30, 2018 at 4:33 PM, Nicholas Cole  wrote:
> On Tue, Jan 30, 2018 at 4:23 PM, Steven D'Aprano
>  wrote:
>> On Tue, 30 Jan 2018 15:54:30 +, Nicholas Cole wrote:
>
>> I would say you're probably misinterpreting the nature of the problem.
>> Import * isn't a directive that can be ignored.
>>
>> Can you show us a *simplified* demonstration? A minimal sample program
>> which we can run that demonstrates the issue?
>
> [snip]

Ah! Looking at our code, I was wrong.  The from .this_package import *

directive is not importing a single file but a subpackage __init__ file.

That __init__ file does not have its own __all__ statement, but seems
to just be relying on importing from different files in the
subpackage.

Could that be the problem?  Even so, I'm unsure why it is showing up
only when used in multiprocessing and works fine everywhere else.

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


Re: Import statements and multiprocessing

2018-01-31 Thread Nicholas Cole
On Tue, Jan 30, 2018 at 7:26 PM, Terry Reedy  wrote:
> On 1/30/2018 10:54 AM, Nicholas Cole wrote:
>
>> I have a strange problem on python 3.6.1
>
> [involving multiprocessing]

Interestingly it seems to have been a very subtle circular import
problem that was showing up only in multiprocessing, and which wasn't
raising an exception at the time of the import.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Guido van Rossum resigns as Python leader

2018-07-13 Thread Nicholas Cole
On Fri, 13 Jul 2018 at 08:51, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> On Fri, 13 Jul 2018 22:29:29 +1000, Chris Angelico wrote:
>
> > To be quite frank, the proposal would have quietly died on python-ideas
> > if it hadn't been for Guido's explicit support early on. (I know this
> > for sure because the same proposal HAS quietly died, more than once.)
> > The controversy came because the rest of the world disagreed with Guido,
> > not because of anything that I am capable of in myself.
>
> I think Guido's post makes it fairly clear that what pushed him over the
> edge was not the opposition to the PEP in the first place, but
> (extrapolating from his comments) the levels of abuse he (probably)
> received privately and on social media after his announcement was made.
>
> The downside of being the visible face of a popular language while having
> a publicly visible email address.
>
>
Oh people are awful.

I hope (though don’t expect) he will change his mind.

Is it irrational to wonder whether projects should be looking to migrate to
new languages? This kind of announcement makes me worry for the future.

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


Re: Guido van Rossum resigns as Python leader

2018-07-13 Thread Nicholas Cole
On Fri, 13 Jul 2018 at 10:04, Chris Angelico  wrote:

> On Fri, Jul 13, 2018 at 11:54 PM, Nicholas Cole 
> wrote:
> > Is it irrational to wonder whether projects should be looking to migrate
> to
> > new languages? This kind of announcement makes me worry for the future.
> >
>
> The Python committers are currently in charge. If you don't trust
> them, you should have jumped ship ages ago. :)



It’s a fair point. I guess until this day I hadn’t really examined *why* I
trusted Python, but a lot of it had to do with the fact that I trusted the
project lead to make sensible decisions about evolving the language. Every
time he’s made a call in the past that struck me as odd it has turned out
to be for the best.

But I manage a project that needs to answer questions on “sustainability”
all the time — I guess that a lot of questions in that area recently have
made this annxement seem more alarming than it might otherwise.

Best wishes,

Nicholas.



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


Re: Guido van Rossum resigns as Python leader

2018-07-13 Thread Nicholas Cole
On Fri, 13 Jul 2018 at 10:31, Jim Oberholtzer 
wrote:

> Nicholas:
>
> I am relatively new to Python, and my system of choice, IBM i  on POWER,
> now supports Python directly.  The open source movement is so strong that I
> think Python will be just fine.  I've been a system programmer for 35
> years, and this tooling (along with the 1000's APIs that IBM has put into
> IBM i (OS/400, iSeries, System I,  all the same thing) over the years makes
> this one of the most powerful tools I have in my toolkit.
>
> Might there be a bit of chaos for a while, sure, there always is when the
> unexpected occurs, however I sympathize with Guido in many ways since 90%
> of people will jump on a target just because it's a target, without even
> knowing or caring about the underlying issue.  It's today's hyper-partisan
> world where the internet shields people from direct contact and thus the
> responsibility for what you say and do.  That's why I always sign my posts
> with my real name and include my company name, to ensure to don't get
> involved in flame wars etc.
>
> While I'm genuinely sad to see that Guido chose to bow out under these
> circumstances, I also see a bright future.  Remember, the addition of the
> POWER line of servers in IBM i (yes AIX and Linux run there too) adds a
> significant number of shops that might adopt Python.  That means Python is
> growing on its own. The legacy is written already, it will just get
> better.


Jim,

Thank you for this very measured and civilized reply

Nicholas.

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


List comprehension strangeness

2019-07-22 Thread Nicholas Cole
I was profiling a slow function in an application last week, and came
across something that I still can’t explain. Inside a loop that was being
called 4 times, inside a for loop that ran for a few dozen times there was
a list compression of the form:

[x.id for x in some_function()]

According to the profiler, some_function was being called 52,000 times —
many, many times more than the few dozen it should have been. And sure
enough, removing the comprehension did indeed speed up the function.

It is very strange and feels like a possible bug in python. Has anyone ever
encountered anything similar?

Best wishes,

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


Re: Fwd: PYTHON BUG. deleting elements of list.

2020-09-09 Thread Nicholas Cole
On Wed, Sep 9, 2020 at 8:52 AM Chris Angelico  wrote:

[snip]
> And if you absolutely have to mutate in place:
>
> items[:] = [i for i in items if i not in "bcd"]

How does that work to mutate in place?
-- 
https://mail.python.org/mailman/listinfo/python-list


String manipulation

2005-04-13 Thread Nicholas Graham

I'm writing a program that requires some string manipulations.  Let's say 
I have a string

s='x'

Now, the ascii code for 'x' is 0x78.  I want to be able to perform 
operations on this number, and print the character corresponding to the 
results of the operation.  For example, the pseudo-code looks like:

-read in string s from external file (for simplicity, we'll keep s='x')

-determine the code for s (should be 0x78 or 120 in base 10), store it in 
variable c

-add a literal to c (let's say c=c+1)

-find out which character corresponds to the new code c=0x79

-store the character in a new string s2

At the end of this, I want s2='y'

Any suggestions?

NG

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


Packaging a private project

2013-12-16 Thread Nicholas Cole
Dear List,

What is the best way to distribute a private, pure python, Python 3
project that needs several modules (some available on pypi but some
private and used by several separate projects) in order to run?

I'd like to include everything that my project needs to run in a
single package.  The best way to do this seems to be to be to create
symlinks to the source code of the "3rd party" modules I need and
create a setup.py file that includes them in its "packages" list.  Is
this what other people do?

But even more ideally, I'd like to package my script and its
dependencies in a single zip file that can be executed by python
directly.  I see several declarations that this is possible online,
but I can't find a simple recipe for converting a script and its
dependencies into this kind of distribution. Could someone give me a
pointer to a description of "the right way to do it".

I'm making life harder for myself by using python 3 (PyInstaller still
only supports Python 2) and by the fact that I can't release some of
the necessary code publicly.  Releasing modules and scripts on pypi
has become very easy -- I'd forgotten how hard packaging private code
is!

Thank you for any help.

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


Re: "More About Unicode in Python 2 and 3"

2014-01-06 Thread Nicholas Cole
I hardly know which of the various threads on this topic to reply to!

No one is taking Python 2.7 away from anyone.  It is going to be on the net
for years to come.  Goodness! I expect if I wanted to go and download
Python 1.5 I could find it easily enough.

Like everyone else, when Python 3 came out I was nervous.  A lot of my code
broke - but it broke for a good reason.  I had been being cavalier about
strings and ASCII and bytes.  A lot of my code was working by accident
rather than by design, or because my users had never fed it anything that
would make it fall over.  Of course, my first reaction was a defensive one,
but once I had got over that and got my head around Python 3's view of the
world, I was pleased I had.  I find writing in Python 3 leads to more
robust code.  I like the way it forces me to do the right thing, and I like
the way it raises errors if I try to get away with something I shouldn't.
Going back to Python 2 now feels a bit like stepping back to the seductive
and permissive hell of PHP in some ways!  If I could be sure that I was
coding just for me and not having to support things still running on Python
2, I would move to Python 3.3 and not look back.  Except, yes, there are
still libraries that haven't made the changeblast!

Python 2.7 is there if your software was written to run on the 2 series.  I
am sure it will either be distributed with (as default or option) major
operating systems for some time.  I am totally unpersuaded by the argument
that 'back porting' more and more into Python 2 will ease the transition.
 I think it will just use up developer time, and delay further the day when
releasing new code for Python 3 only becomes not only reasonable but the
natural and default choice.

I am really glad to see that at least one distribution of Linux is moving
to Python 3 as the default.  I'd much rather see developer time spent
improving Python 3 than managing a transition.

I realised when Python 3.0 came out that eventually I would have to move to
Python 3.  I spent the next release in a state of denial.  But I had years
to get used to it, and I'm glad I have.  It "feels" more robust.  Of
course, I haven't ported every little program: but no one is forcing me
too!

All of these threads are written as if everyone's code is about to be
broken.  It isn't.  But if you want the new features, you need to make a
move, and it is probably time to write all new code in Python 3. If there's
a dependency holding you back, then there will be a Python 2 interpreter
around to run your code.  That all seems pretty reasonable and
straightforward to me.

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


Python program distribution - a source of constant friction

2014-01-06 Thread Nicholas Cole
o run on it is a worthy dream.  Perhaps all the pieces to do
this all seamlessly exist already, but if so they need much better
documentation, somewhere that it is really easy to find it.

IMHO, anyway.

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


Re: Python program distribution - a source of constant friction

2014-01-06 Thread Nicholas Cole
On Monday, 6 January 2014, Chris Angelico wrote:

> On Tue, Jan 7, 2014 at 10:39 AM, Nicholas Cole 
> >
> wrote:
> > But what about the end-user?  The end-user who just wants a blob (he
> doesn't
> > care about what language it is in - he just wants to solve the problem at
> > hand with your shiny, cool, problem-solving application).
>
> This is where OS-provided package managers really shine. It should be
> possible to type:
>
> $ sudo apt-get install shiny-cool-problem-solver
>
> and have it go and fetch Python, the magical library you need
> (matching to the binary architecture of the target platform), and your
> code, plop them all into the right places in the file system, and give
> you a new command "shinycool" that just happens to shebang into
> Python. Well and good. Trouble is... Windows isn't up there. And
> trying to maintain packages for lots of different platforms is a lot
> of work.
>

Even providing packages for (unfamiliar?) Linux distributions is a lot of
work - unless a distribution picks up responsibility for an application.
 For sending applications to end users, something they can just copy
straight into a bin/ directory is a real winner.  The python zip file
format is really good for many things, and from the end-user point of view
extremely low friction.  Even so, things like that are harder to create
than they could be, or less prominently documented than one might have
expected.

Case in point: I have an application a friend/colleague of mine would like
to look at.  I've no idea if he is running Debian or Redhat or FreeBSD or a
Mac.  Assuming I've not used any C extensions, it is *possible* to create
something that will run on all of the above without any fuss at his end.
 It just isn't nearly as easy as it could be, which must be a shame.

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


Re: Python program distribution - a source of constant friction

2014-01-16 Thread Nicholas Cole
On Tue, Jan 7, 2014 at 12:09 AM, Nicholas Cole  wrote:

[SNIP]

> Even so, things like that are harder to create than they
> could be, or less prominently documented than one might have expected.
>
> Case in point: I have an application a friend/colleague of mine would like
> to look at.  I've no idea if he is running Debian or Redhat or FreeBSD or a
> Mac.  Assuming I've not used any C extensions, it is *possible* to create
> something that will run on all of the above without any fuss at his end.  It
> just isn't nearly as easy as it could be, which must be a shame.
>
> Nicholas.

In a spirit of trying to not only highlight problems, but start to solve them:

https://pypi.python.org/pypi/ncdistribute/

Feedback is very welcome.  Version 1 is a naive approach - it doesn't
filter the included files at all, and will include all detected
dependencies that are not part of the standard library.

Best wishes,

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


Re: Self healthcheck

2014-01-22 Thread Nicholas Cole
On Wednesday, 22 January 2014, Asaf Las  wrote:

> On Wednesday, January 22, 2014 5:08:25 AM UTC+2, Chris Angelico wrote:
> > I assume you're talking about pure Python code, running under CPython.
> > (If you're writing an extension module, say in C, there are completely
> > different ways to detect reference leaks; and other Pythons will
> > behave slightly differently.) There's no way to detect truly
> > unreferenced objects, because they simply won't exist - not after a
> > garbage collection run, and usually sooner than that. But if you want
> > to find objects that you're somehow not using and yet still have live
> > references to, you'll need to define "using" in a way that makes
> > sense. Generally there aren't many ways that that can happen, so those
> > few places are candidates for a weak reference system (maybe you map a
> > name to the "master object" representing that thing, and you can
> > recreate the master object from the disk, so when nothing else is
> > referring to it, you can happily flush it out - that mapping is a good
> > candidate for weak references).
> >
> > But for most programs, don't bother. CPython is pretty good at keeping
> > track of its own references, so chances are you don't need to - and if
> > you're seeing the process's memory usage going up, it's entirely
> > possible you can neither detect nor correct the problem in Python code
> > (eg heap fragmentation).
> > ChrisA
>
> Hi Chris
>
> Yes the question was about CPython. But i am not after CPython leaks
> though detecting these would be good, but my own mistakes leading to
> accumulation of data in mutable structures.
> there will be few processes running python code standalone communicating
> across servers and every activity will be spread over time so
> i have to persistently keep record of activity and remove it later when
> activity is finished. In addition to checking objects directly i would
> like to analyze also app health indirectly via checking amount of data
> it holds. let say there is permanently 100 activities per second and
> typical object count figure is 1000 (in abstract units averaged over long
> enough time window), so i would check throughput and memory to see if my
> program is healthy in terms of leaking resources and generate log if it
> is not.
> Input to such module will be traffic events (whatever event significant
> to object creation).
> So i am looking for proper way to detect memory held by CPython app. And
> it would be good if memory can be deduced down to object/class name so
> blamed one could be identified and reported.
>
>
There are some good tools recommended here:

http://stackoverflow.com/questions/110259/which-python-memory-profiler-is-recommended

 But in general: use weak references wherever possible would be my advice.
They not only prevent cycles but will highlight the kinds of bug in your
code that is likely to cause the sort of problem you are worried about.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: __init__ is the initialiser

2014-02-03 Thread Nicholas Cole
On Mon, Feb 3, 2014 at 12:07 AM, Chris Angelico  wrote:
> On Mon, Feb 3, 2014 at 10:40 AM, Roy Smith  wrote:
>> I'm reasonably sure you posted this as humor, but there is some truth in
>> what you said.  In the crypto/security domain, you often want to keep a
>> key or cleartext around only for the time it's needed, and scrub the
>> memory it was occupying as soon as it is no longer in use.
>>
>> I don't know how you would do that in Python.
>
> I did, but you're right.
>
> It's fundamentally not possible in pure Python, because there's no way
> to flag a block of memory as "do not page this to disk". For what
> you're talking about to be at all possible, you would need support
> from the language, from the OS, and possibly from the CPU as well. I'm
> sure this sort of thing exists, but if it does, it'll probably be
> something that Python itself wouldn't concern itself with - you'd get
> it via openssl or something.
>
> There have been occasional times I've wanted an "explicit destruction"
> feature. Rather than the facetious exception I listed above, it'd be
> better to have all those references (including the original one in a,
> since there's nothing special about that) turn into some kind of "null
> state" - either None, or a special object that marks itself as a
> destructed/destroyed (terminology debates aside) object. With custom
> types, I can mark them off with a special flag, and check that all the
> time; but I can't, for instance, have a dict that maps some lookup
> keyword to its output file, and then destroy output files to remove
> all their references from everywhere in the dict. (I have had
> something along these lines, a bit more complicated than this, but not
> in Python.)

Can't you get close to that using weakrefs?  I'll admit that care is required.

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


Re: __init__ is the initialiser

2014-02-03 Thread Nicholas Cole
On Monday, 3 February 2014, Chris Angelico  wrote:

> On Tue, Feb 4, 2014 at 12:50 AM, Nicholas Cole 
> >
> wrote:
> >> There have been occasional times I've wanted an "explicit destruction"
> >> feature. Rather than the facetious exception I listed above, it'd be
> >> better to have all those references (including the original one in a,
> >> since there's nothing special about that) turn into some kind of "null
> >> state" - either None, or a special object that marks itself as a
> >> destructed/destroyed (terminology debates aside) object. With custom
> >> types, I can mark them off with a special flag, and check that all the
> >> time; but I can't, for instance, have a dict that maps some lookup
> >> keyword to its output file, and then destroy output files to remove
> >> all their references from everywhere in the dict. (I have had
> >> something along these lines, a bit more complicated than this, but not
> >> in Python.)
> >
> > Can't you get close to that using weakrefs?  I'll admit that care is
> required.
>
> Weakrefs are a related tool, but solving a different problem. What I
> wanted here was an easy way to force all references to a particular
> file to be wiped out, based on one of the existing references. Here's
> a concocted setup that's broadly similar to what I was doing, which
> might illustrate the issue:
>
> log_files = {}
>
> def add_log_file(fn, *keywords):
> f = open(fn, "w")
> for kw in keywords: log_files[kw]=f
>
> for line in process_me_line_generator():
> kw = line.split()[0]
> f = log_files.get(kw)
> if not f: continue
> f.write(line+"\n")
> if 'quit' in line:
> # Okay, let's now close this file.
> destruct(f)
>
>
> In this particular case, I could use "f.close()" and "if not f or
> f.closed: continue", but that requires that the object cooperate in
> this way, and I'm not entirely sure about resource usage. (I was
> actually working with a database connection object, IIRC, which didn't
> offer me a way to inquire if it was still open or not.) To do this
> with weak refs, I'd have to have some other source of strong refs, and
> closing would be done by digging through that list, disposing of it
> from there, and then triggering garbage collection. I suppose it could
> be made to work, but it feels like going about everything backwards.
>
> ChrisA
>

When I have had similar problems, I've wrapped the 'strong' reference to
the thing I might need to destroy inside an object, and had the 'destroy'
method delete it.

I'll admit that it isn't quite as convenient as having something that would
work for arbitrary objects at arbitrary moments, but it works almost
exactly as you describe for the file object above, and it can be quite neat
and tidy.

Best wishes,

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


Python (?) webserver for WSGI

2014-02-09 Thread Nicholas Cole
Dear List,

What is the latest "best-practice" for deploying a python wsgi
application into production?

For development, I've been using CherryPyWSGIServer which has been
working very well (and the code is small enough to actually ship with
my application).  But I would like some way of deploying a server
listening on port 80 (and then dropping root privileges).

I have looked at using gunicorn + ngnix, but that gives me 3 layers
that I need to set up:

- my own application
- gunicorn
- ngnix

Compared to using something like CherryPyWSGIServer (where a single
line of code starts my application!) that seems like overkill and
rather complicated for a small application.

I'm not expecting 1000s of users (or even dozens!), but this is an
application that will be accessible to "the internet" and  so server
security is a concern (which is why I don't want to use anything that
labels itself as a "development" webserver).

As far as I can tell, this is something of a fast-moving target.  What
advice do people have?  I'm using python 3, in case it makes a
difference.

Best wishes,

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


Python (?) webserver for WSGI

2014-02-09 Thread Nicholas Cole
On Sunday, 9 February 2014, Asaf Las
>
wrote:

> On Sunday, February 9, 2014 11:05:58 PM UTC+2, Nicholas wrote:
> > Dear List,
> >
> >
> >
> > What is the latest "best-practice" for deploying a python wsgi
> > application into production?
> >
> > For development, I've been using CherryPyWSGIServer which has been
> > working very well (and the code is small enough to actually ship with
> > my application).  But I would like some way of deploying a server
> > listening on port 80 (and then dropping root privileges).
> >
> > I have looked at using gunicorn + ngnix, but that gives me 3 layers
> > that I need to set up:
> >
> > - my own application
> > - gunicorn
> > - ngnix
>
> Yes, but are you after simplicity of setup or reliability?
> If security is your concern - eventually you have to dive into
> routines of verifying settings auditing etc and spend
> week(s) if you have no solid prior experience in that field and even
> after that there is still a lot to learn.
>

[snip]

Yes, I managed a large apache installation for some years.  I suppose that
my hope was that in 2014 there might be some better, simpler way to run
smaller web applications, especially with the tulip async stuff becoming
part of the language.  I don't think running a WSGI application to serve
basic requests should NEED a lot of special setting up
-- 
https://mail.python.org/mailman/listinfo/python-list


Sample sqlite databases for use in python

2014-10-26 Thread Nicholas Cannon
Hello I am making a data management program and although i can make my own 
databases I would like a couple sample ones to check out. Of course I searched 
on google for sample db's and I downloaded some but they are not working and I 
keep getting: 
File is not a database or encrypted

The error is not exactly like that but it does say that it may be encrypted or 
not a database. I want the end user to take a database and load it in to my 
program but I dont wont this happening even if the file is a sqlite3 one as 
well. 
-- 
https://mail.python.org/mailman/listinfo/python-list


XML Patch

2014-10-26 Thread Nicholas Cole
Hi All,

I'm looking for a python library that can parse XML Documents and
create xml-aware "diff" files, and then use those to patch documents.
In other words, I'd like something similar to the Google
diff-match-patch tools, but something which is XML aware.

I can see several projects on Pypi that can generate some form of xml
diff, but I can't seem to see anything that can also do the patching
side of things.

Does anyone have any recommendations?

Best wishes,

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


Re: XML Patch

2014-10-27 Thread Nicholas Cole
On Mon, Oct 27, 2014 at 7:28 AM, Stefan Behnel  wrote:
> Hi,
>
> please keep this on-list.

Sorry about that. Wrong button!

[snip]

>> Yes - I want to store a series of XML diffs/patches and be able to
>> generate documents by applying them.
>
> Could you be a little more specific? There are lots of ways to generate
> XML, but I never heard of anyone who wanted to do this based on diffs
> between other documents. What kind of document differences are you talking
> about here?

I don't think the specific documents matter, and I don't think it's a
unique use-case.  Here's Microsoft talking about XML diff and patching
(including a hypothetical example):

http://msdn.microsoft.com/en-gb/library/aa302294.aspx

There's a tool here to do it:

http://xmlpatch.sourceforge.net

I'd just really like to be able to do something similar in Python.

Best wishes,

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


Re: Trees

2015-01-20 Thread Nicholas Cole
On Mon, Jan 19, 2015 at 11:52 PM, Devin Jeanpierre
 wrote:
> On Mon, Jan 19, 2015 at 3:08 PM, Steven D'Aprano
>  wrote:
>> Zachary Gilmartin wrote:
>>
>>> Why aren't there trees in the python standard library?
>>
>> Possibly because they aren't needed? Under what circumstances would you use
>> a tree instead of a list or a dict or combination of both?
>>
>> That's not a rhetorical question. I am genuinely curious, what task do you
>> have that you think must be solved by a tree?
>
> In general, any time you want to maintain a sorted list or mapping,
> balanced search tree structures come in handy.
>
> Here's an example task: suppose you want to represent a calendar,
> where timeslots can be reserved for something. Calendar events are not
> allowed to intersect.

Maybe because I'm not a computer scientist, I can't immediately see
why this is a "Tree" problem and not a "Database" problem.  Genuinely
interested.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python is DOOMED! Again!

2015-01-21 Thread Nicholas Cole
I don't think that Python is doomed. I *do* think that type-hinting is
useful, and Python has borrowed a syntax that is similar to that used in
other languages, so that it is a familiar one to many developers.

It is a stretch to call it intuitive though, either to write or to
read. Personally, I would have favoured a doc string solution. The magic
comments that are part of the current proposal are genuinely intuitive, I
think. The function definition syntax is something to be learned and which
it takes me a little time to process even though I'm getting used to it. I
find that it's still a slight effort to remember which way around the name
of the argument and the type go. I'm sure I've seen one language that does
the oppoosite, and the fraction of a second it takes me to remember is a
tiny friction. There's no doubt, too, that long function definitions
(Python functions tend to have lots of arguments in the real world) are
going to look cluttered, and cluttered by lots of magic punctuation.

So useful, yes. Familiar already to those who use other languages, yes.
Intuitive, no. And there is a linguistic reason for that:

Consider this:

Define function add taking price1, price2, print_error equals true.

Yes, Python wouldn't understand that, but turning it in to a valid
definition requires only a tiny amount of effort.

Type definitions add a whole level of complexity:

Define function add taking the float price1, the float price2, print_error
equals the Boolean true. Make the function return a float.

Converting that into python simply requires more effort: in other words the
gap between what one might say in speech and what the code looks like is
bigger.

The reason for this is that a lot of information is being compressed in to
a small space. In English writing it is usually clearer to avoid long and
complicated sentences with lots of subclauses (even if they make perfect,
logical sense) in favour of shorter ones, and I think there is a parallel
here.

I would have preferred Python to mimic:

Define function add taking price1, the price2, print_error equals true.
Price1 is a float. Price2 is a float. The function returns a float.

But now this is sounding a little like something from Larry Wall, and so I
had better stop!  I wasn't trying to re-litigate the decisions that have
been taken, just to understand the friction.

Just my £0.2

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


Re: Python is DOOMED! Again!

2015-01-21 Thread Nicholas Cole
On Thu, Jan 22, 2015 at 5:56 AM, Chris Angelico  wrote:
> On Thu, Jan 22, 2015 at 4:50 PM, Nicholas Cole  
> wrote:
>> I would have preferred Python to mimic:
>>
>> Define function add taking price1, the price2, print_error equals true.
>> Price1 is a float. Price2 is a float. The function returns a float.
>>
>> But now this is sounding a little like something from Larry Wall, and so I
>> had better stop!
>
> Actually, it sounds like pre-ANSI C. Something like this:
>
> float add(price1, price2)
> float price1;
> float price2;
> {
> ... body of function ...
> }
>
> Compare the more modern C style:

I hadn't thought of that, but yes, you are quite right right.  I think
my point stands. I've ever programmed anything serious in any kind of
C, but the pre-ANSI C style is instantly readable to me (except maybe
that I had to look three times to find the return signature because my
eye glossed over the float at the start.

Far more intuitive than what is being proposed^W^W is part of Python 3. :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python is DOOMED! Again!

2015-01-22 Thread Nicholas Cole
On Thu, Jan 22, 2015 at 8:10 AM, Mario Figueiredo  wrote:
> In article <54c0a571$0$13002$c3e8da3$54964...@news.astraweb.com>,
> steve+comp.lang.pyt...@pearwood.info says...
>>
>> The point isn't that there are no other alternative interpretations
>> possible, or that annotations are the only syntax imaginable, but that
>> they're not hard to guess what they mean, and if you can't guess, they're
>> not hard to learn and remember.
>
> Possibly one common use case will be Unions. And that factory syntax is
> really awful and long when you look at a function definition with as
> little as 3 arguments. The one below has only 2 arguments.
>
> def handle_employees(emp: Union[Employee, Sequence[Employee]], raise:
> Union[float, Sequence[float]]) -> Union[Employee, Sequence[Employee],
> None]:
>
> That's for a generic list-like container. Have fun with the Mapping
> union.

To be fair, is it clearer with some kind of formatting?

def handle_employees(
emp: Union[Employee, Sequence[Employee]],
raise: Union[float, Sequence[float]])
-> Union[Employee, Sequence[Employee], None]:

I still find that hard to read, but the line breaks help.  Just for
fun, I'd like to put out that without all of that noise the function
reads:

def handle_employees(employees, raise):
.
return employees

And suddenly it looks like what most people who know anything about
programming recognise as Python again! With some kind of doc-string or
similar syntax it would read something like:

def handle_employees(employees, rasie):
# employees: Union[Employee, Sequence[Employee]]
# raise:  Union[float, Sequence[float]]
# return: Union[Employee, Sequence[Employee], None]
.
return employeees

There's a reasonable case that this is not all that dissimilar from
the function annotation syntax above, but the difference is surely
that in the one case you see immediately that there are two arguments,
and in the other you can't be sure without parsing some very cluttered
punctuation-heavy syntax.

Still, it would have been nicer to be able to write something like
this (where the Unions are implicit):

def handle_employees(employees, rasie):
# employees: Employee, Sequence[Employee]
# raise:  float, Sequence[float]
# return: Employee, Sequence[Employee], None


Yes, I know that function annotations have been defined for a while,
and yes, I know that they are similar to a syntax used in other
languages, and yes, I know that they are optional.  All the same,
either they are going to become the norm or they are not. If they
become the norm (as I think they will because type hinting seems to
solve many problems that the community cares about) then I think we
have to accept that an important part of the language will become much
more cluttered, much less intuitive, and much more off-putting to
many.

I think the fact that the current proposals mix the annotation syntax
with an inline comment syntax is also horrible (though I don't see any
alternatives).  I would much rather have put all of the "magic" in to
comments or none.

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


Python is DOOMED! Again!

2015-01-22 Thread Nicholas Cole
On Thursday, 22 January 2015, Chris Angelico > wrote:

> On Thu, Jan 22, 2015 at 7:10 PM, Mario Figueiredo 
> wrote:
> > Possibly one common use case will be Unions. And that factory syntax is
> > really awful and long when you look at a function definition with as
> > little as 3 arguments. The one below has only 2 arguments.
> >
> > def handle_employees(emp: Union[Employee, Sequence[Employee]], raise:
> > Union[float, Sequence[float]]) -> Union[Employee, Sequence[Employee],
> > None]:
>
> Hold on a moment, how often do you really do this kind of thing with
> "might be one of them or a sequence"? Do you really have a function
> that could take an Employee and a float, or a sequence of Employees
> and a single float, or a single Employee and a sequence of floats, or
> a sequence of both? Or do you, much more likely, actually have two
> separate functions:
>
> def handle_employee(emp: Employee, raise: float) -> Optional[Employee]:
>
> def handle_employees(emp: Sequence[Employee], raise: Sequence[float])
> -> List[Employee]:
>
> The union in the return value seems particularly unlikely... and unhelpful.
>

Hang on! The particular example may not make a lot of sense but there are
plenty of places in ordinary Python where functions can accept different
objects in arguments and return different things. The point here is that
that will become rapidly messy and hard to read.

Perhaps the new PEP will discourage this kind of thing and perhaps that is
to be welcomed not feared, but I don't think the example itself was
particularly contrived. I've seen it in plenty of code in the wild.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python is DOOMED! Again!

2015-01-24 Thread Nicholas Cole
On Sat, Jan 24, 2015 at 5:51 AM, Steven D'Aprano
 wrote:


> and Ruby has an experimental one:
>
> http://blog.codeclimate.com/blog/2014/05/06/gradual-type-checking-for-ruby/

Interesting.  Ruby has avoided the magic comment, and the typing is
done in annotations rather than in the function signatures.  It's
interesting to see them go a different way so that we can compare the
two approaches.

I rather like it.  It's a shame that the rest of Ruby's syntax is
inferior to python's. ;-)

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


Re: why indentation should be part of the syntax

2014-03-02 Thread Nicholas Cole
On Sun, Mar 2, 2014 at 2:38 PM, Roy Smith  wrote:
> In article ,
>  Stefan Behnel  wrote:
>
>> Haven't seen any mention of it on this list yet, but since it's such an
>> obvious flaw in quite a number of programming languages, here's a good
>> article on the recent security bug in iOS, which was due to accidentally
>> duplicated code not actually being as indented as it looked:
>>
>> https://www.imperialviolet.org/2014/02/22/applebug.html
>>
>> Stefan
>
> Hogwash.  What this looks like is two gotos in a row.  Anybody who
> reviewed this code would have thrown up a red flag when they saw two
> gotos in a row.  If anything, the "incorrect" indentation makes it even
> more obvious.  Any static code analyzer would have also caught this as
> an unreachable statement.
>
> Paraphrasing this into Python, you get:
>
> def bogus():
> if SSLHashSHA1.update(hashCtx, serverRandom) != 0:
> raise fail
> if SSLHashSHA1.update(hashCtx, signedParams) != 0:
> raise fail
> raise fail
> if SSLHashSHA1.final(hashCtx, hashOut) != 0:
> raise fail
>
> which is syntactically valid (at least, I can import it), but clearly
> not what the author intended.  So how did Python's indentation rules
> save us?

Actually, that's incorrect.  The bug (written in Python) would have been:

if SSLHashSHA1.update(hashCtx, signedParams) != 0:
raise fail
raise fail # ie. no indent.

If written with the indent, it's a useless line of code, but it
doesn't become a bug.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-03 Thread Nicholas Cole
Swift may yet be good for PyObjC (the python bridge to the various
Apple libraries); it is possible that there is some kind of
translation table that PyObjC can make use of to make its own method
names less ugly.

Of course, I wish they had picked Python rather than inventing their
own language.  But Apple put a huge stock in the ability of their
libraries to make full use of multiple cores.  The GIL is surely the
sticking point here. It is also clear (reading the Swift
documentation) that they wanted a script-like language but with strict
typing.

It looks to me like there are a lot of strange design choices, the
logic of which I do not fully see.  I suspect that in a few years they
will have to go through their own "Python 3" moment to make things a
little more logical.

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


Re: PEP8 revised: max line lengths

2013-08-03 Thread Nicholas Cole
On Friday, 2 August 2013, Chris “Kwpolska” Warrick wrote:

[snip]

>
> So, what are you feasting for?  Nothing?


I have long since ceased to be amazed at the number of people who would
like their personal and arbitrary preferences, and the rationalisations
that go with them, to be validated and endorsed by others, in law if
possible and in policy documents if not!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Nicholas Cole
On Thu, Aug 8, 2013 at 11:38 AM, Neatu Ovidiu  wrote:

>
>
> > But what's your use case?
> >
> > Does it occur often enough that you cannot afford a two-liner like
> I think uses cases are plenty.
>
>
The possible cases I can think of would be better served with list
comprehensions (what you seem to want is to create lists based on other
lists) - but maybe I'm missing something.  Could we have one example?

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


Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Nicholas Cole
On Thu, Aug 8, 2013 at 12:50 PM, Neatu Ovidiu  wrote:

> On Thursday, August 8, 2013 2:44:05 PM UTC+3, Neatu Ovidiu wrote:
> > On Thursday, August 8, 2013 2:12:53 PM UTC+3, Nicholas wrote:
> >
> > > On Thu, Aug 8, 2013 at 11:38 AM, Neatu Ovidiu 
> wrote:
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > > > But what's your use case?
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > Does it occur often enough that you cannot afford a two-liner like
> >
> > >
> >
> > > I think uses cases are plenty.
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > > The possible cases I can think of would be better served with list
> comprehensions (what you seem to want is to create lists based on other
> lists) - but maybe I'm missing something.  Could we have one example?
> >
> > >
> >
> > >
> >
> > >
> >
> > > N.
> >
> >
> >
> > This can be useful for doing all kinds of basic stuff. For example if
> you wanted to take 4 items of a list at at a time, do something with them
> and then update the list.
> >
> >
> >
> > jobs = ['job1', 'job2', 'job3', 'job4', 'job5', 'job6', 'job7', 'job8',
> 'job9', 'job10']
> >
> > while jobs:
> >
> > print(jobs.pop_slice(0,4))
> >
> >
> >
> > should output
> >
> >
> >
> > 'job1', 'job2', 'job3', 'job4'
> >
> > 'job5', 'job6', 'job7', 'job8'
> >
> > 'job9', 'job10'
>
> The idea "popped" in my mind while thinking about this question.
>
> http://stackoverflow.com/questions/18121416/right-split-a-string-into-groups-of-3/18122084
> I founded the list comprehensions solutions kind of cumbersome and thought
> that there should be a simple way to do this kind of stuff.
> --
> http://mail.python.org/mailman/listinfo/python-list
>


Still seems a bit like a solution looking for a problem to me.

Why would you want to take four items at a time for a job from an arbitrary
part of a list?  I agree splitting a string into groups of three looks a
bit cumbersome in the example you've given, but a generator could be
written quite easily, and would almost certainly be quicker than trying to
alter the list in place.

Best wishes,

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


Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Nicholas Cole
On Thu, Aug 8, 2013 at 2:32 PM, Neatu Ovidiu  wrote:

> On Thursday, August 8, 2013 4:08:13 PM UTC+3, Nicholas wrote:
> > On Thu, Aug 8, 2013 at 12:50 PM, Neatu Ovidiu  wrote:
> >
> >
> >
> >
> > On Thursday, August 8, 2013 2:44:05 PM UTC+3, Neatu Ovidiu wrote:
> >
> > > On Thursday, August 8, 2013 2:12:53 PM UTC+3, Nicholas wrote:
> >
> > >
> >
> > > > On Thu, Aug 8, 2013 at 11:38 AM, Neatu Ovidiu 
> wrote:
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > > But what's your use case?
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > > Does it occur often enough that you cannot afford a two-liner like
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > I think uses cases are plenty.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > The possible cases I can think of would be better served with list
> comprehensions (what you seem to want is to create lists based on other
> lists) - but maybe I'm missing something.  Could we have one example?
> >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > N.
> >
> > >
> >
> > >
> >
> > >
> >
> > > This can be useful for doing all kinds of basic stuff. For example if
> you wanted to take 4 items of a list at at a time, do something with them
> and then update the list.
> >
> > >
> >
> > >
> >
> > >
> >
> > > jobs = ['job1', 'job2', 'job3', 'job4', 'job5', 'job6', 'job7',
> 'job8', 'job9', 'job10']
> >
> > >
> >
> > > while jobs:
> >
> > >
> >
> > > print(jobs.pop_slice(0,4))
> >
> > >
> >
> > >
> >
> > >
> >
> > > should output
> >
> > >
> >
> > >
> >
> > >
> >
> > > 'job1', 'job2', 'job3', 'job4'
> >
> > >
> >
> > > 'job5', 'job6', 'job7', 'job8'
> >
> > >
> >
> > > 'job9', 'job10'
> >
> >
> >
> > The idea "popped" in my mind while thinking about this question.
> >
> >
> http://stackoverflow.com/questions/18121416/right-split-a-string-into-groups-of-3/18122084
> >
> > I founded the list comprehensions solutions kind of cumbersome and
> thought that there should be a simple way to do this kind of stuff.
> >
> > --
> >
> > http://mail.python.org/mailman/listinfo/python-list
> >
> >
> >
> >
> >
> > Still seems a bit like a solution looking for a problem to me.
> >
> >
> >
> > Why would you want to take four items at a time for a job from an
> arbitrary part of a list?  I agree splitting a string into groups of three
> looks a bit cumbersome in the example you've given, but a generator could
> be written quite easily, and would almost certainly be quicker than trying
> to alter the list in place.
> >
> >
> >
> > Best wishes,
> >
> >
> > N.
>
> You are perfectly right. But I looked at it more like an improvement in
> the style of writing solutions and also a natural option because slices are
> highly present all over in python.
>


I wasn't knocking it.  I was just trying to think it through.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 450 Adding a statistics module to Python

2013-08-11 Thread Nicholas Cole
On Sun, Aug 11, 2013 at 12:50 PM, Skip Montanaro  wrote:

> > See the Rationale of PEP 450 for more reasons why “install NumPy” is not
> > a feasible solution for many use cases, and why having ‘statistics’ as a
> > pure-Python, standard-library package is desirable.
>
> I read that before posting but am not sure I agree. I don't see the
> screaming need for this package.  Why can't it continue to live on
> PyPI, where, once again, it is available as "pip install ..."?


Well, I *do* think this module would be a wonderful addition to the
standard library.  I've often used python to do analysis of data, nothing
complicated enough to need NumPy, but certainly things where I've needed to
find averages etc. I've rolled my own functions for these projects, and I'm
sure they are fragile.  Besides, it was just a pain to do them.

PyPI is terrific. There are lots of excellent modules on there.  It's a
wonderful resource.  But I think that the standard library is also a
wonderful thing, and where there are clearly defined modules, that serve a
general, well-defined function and where development does not need to be
very rapid, I think they should go into the Standard Library.

I'm aware that my opinion is just that of one user, but I read this PEP and
I thought, "Thank Goodness! That looks great.  About time too."

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


Did the 3.4.4 docs get published early?

2015-06-10 Thread Nicholas Chammas
For example, here is a "New in version 3.4.4" method:

https://docs.python.org/3/library/asyncio-task.html#asyncio.ensure_future

However, the latest release appears to be 3.4.3:

https://www.python.org/downloads/

Is this normal, or did the 3.4.4 docs somehow get published early by
mistake?

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


Re: Did the 3.4.4 docs get published early?

2015-06-10 Thread Nicholas Chammas
Also, just replacing the version number in the URL works for the python 3
series (use 3.X even for python 3.0), even farther back than the drop down
menu allows.

This does not help in this case:

https://docs.python.org/3.4/library/asyncio-task.html#asyncio.ensure_future

Also, you cannot select the docs for a maintenance release, like 3.4.3.

Anyway, it’s not a big deal as long as significant changes are tagged
appropriately with notes like “New in version NNN”, which they are.

Ideally, the docs would only show the latest changes for released versions
of Python, but since some changes (like the one I linked to) are introduced
in maintenance versions, it’s probably hard to separate them out into
separate branches.

Nick
​

On Wed, Jun 10, 2015 at 10:11 AM Nicholas Chammas <
nicholas.cham...@gmail.com> wrote:

> For example, here is a "New in version 3.4.4" method:
>
> https://docs.python.org/3/library/asyncio-task.html#asyncio.ensure_future
>
> However, the latest release appears to be 3.4.3:
>
> https://www.python.org/downloads/
>
> Is this normal, or did the 3.4.4 docs somehow get published early by
> mistake?
>
> Nick
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Did the 3.4.4 docs get published early?

2015-06-11 Thread Nicholas Chammas
Sorry, somehow the formatting in my previous email didn't come through
correctly.

This part was supposed to be in a quote block:

> Also, just replacing the version number in the URL works for the python 3
series
> (use 3.X even for python 3.0), even farther back than the drop down menu
allows.

Nick

On Wed, Jun 10, 2015 at 2:25 PM Nicholas Chammas 
wrote:

> Also, just replacing the version number in the URL works for the python 3
> series (use 3.X even for python 3.0), even farther back than the drop down
> menu allows.
>
> This does not help in this case:
>
> https://docs.python.org/3.4/library/asyncio-task.html#asyncio.ensure_future
>
> Also, you cannot select the docs for a maintenance release, like 3.4.3.
>
> Anyway, it’s not a big deal as long as significant changes are tagged
> appropriately with notes like “New in version NNN”, which they are.
>
> Ideally, the docs would only show the latest changes for released versions
> of Python, but since some changes (like the one I linked to) are introduced
> in maintenance versions, it’s probably hard to separate them out into
> separate branches.
>
> Nick
> ​
>
> On Wed, Jun 10, 2015 at 10:11 AM Nicholas Chammas <
> nicholas.cham...@gmail.com> wrote:
>
>> For example, here is a "New in version 3.4.4" method:
>>
>> https://docs.python.org/3/library/asyncio-task.html#asyncio.ensure_future
>>
>> However, the latest release appears to be 3.4.3:
>>
>> https://www.python.org/downloads/
>>
>> Is this normal, or did the 3.4.4 docs somehow get published early by
>> mistake?
>>
>> Nick
>>
>>
-- 
https://mail.python.org/mailman/listinfo/python-list


venv issues

2015-11-03 Thread Nicholas Cole
I'm using python3.5 (installed from binaries) on the latest OS X.

I have a curious issue with virtual environments on this machine (but
not on my other machine).


$ python3.5 -m venv testenv
$ source testenv/bin/activate
(testenv)$ python -m pip
/private/tmp/testenv/bin/python: No module named pip
$

Logging in as a different user and creating a venv works perfectly, so
it's clearly a config issue somewhere, but I've tried removing
~/.bashrc and ~/.bash_profile and that doesn't help.

The sys.path for that venv is: ['',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python35.zip',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload',
'/private/tmp/testenv/lib/python3.5/site-packages']

I'm sure I'm overlooking something obvious, but can anyone suggest what?

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


Re: venv issues

2015-11-03 Thread Nicholas Cole
On Tue, Nov 3, 2015 at 12:27 PM, Wolfgang Maier
 wrote:
> On 03.11.2015 11:32, Nicholas Cole wrote:
>>
>> I'm using python3.5 (installed from binaries) on the latest OS X.
>>
>> I have a curious issue with virtual environments on this machine (but
>> not on my other machine).
>>
>>
>> $ python3.5 -m venv testenv
>> $ source testenv/bin/activate
>> (testenv)$ python -m pip
>> /private/tmp/testenv/bin/python: No module named pip
>> $
>>
>> Logging in as a different user and creating a venv works perfectly, so
>> it's clearly a config issue somewhere, but I've tried removing
>> ~/.bashrc and ~/.bash_profile and that doesn't help.
>>
>> The sys.path for that venv is: ['',
>> '/Library/Frameworks/Python.framework/Versions/3.5/lib/python35.zip',
>> '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5',
>>
>> '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin',
>>
>> '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload',
>> '/private/tmp/testenv/lib/python3.5/site-packages']
>>
>
> Is there something special about your /private/tmp folder? In other words,
> do things work if you create a venv in a different place.
> If you go to /private/tmp/testenv/lib/python3.5/site-packages is there a pip
> folder and what are its permission settings?

/private/tmp/testenv/lib/python3.5/site-packages

is completely empty.

There's nothing special about that folder, though. The problem exists
everywhere.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: venv issues

2015-11-03 Thread Nicholas Cole
On Tue, Nov 3, 2015 at 1:59 PM, Chris Angelico  wrote:
> On Tue, Nov 3, 2015 at 9:32 PM, Nicholas Cole  wrote:
>> Logging in as a different user and creating a venv works perfectly, so
>> it's clearly a config issue somewhere, but I've tried removing
>> ~/.bashrc and ~/.bash_profile and that doesn't help.
>
> What happens if you create a brand new user, then copy in all
> dot-files and directories from your current one? Does it exhibit the
> same problem?

No. And that helped me find the problem.  I had an old

.pydistutils.cfg

file with a line:

install_lib = ~/Library/Python/$py_version_short/lib/python/site-packages

That completely upset the venv.

(whether it should have done or not, I don't know. I would have
expected venv to ignore pydistutils.cfg)

Thank you both for your help!

Best,

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


Re: how to check if a value is a floating point or not

2014-06-18 Thread Nicholas Cannon
On Thursday, June 19, 2014 1:53:31 PM UTC+8, Nicholas Cannon wrote:
> I am making a calculator and i need it to support floating point values but i 
> am using the function isnumeric to check if the user has entered an int 
> value. I need the same for floating point types so i could implement an or in 
> the if statement that checks the values the user has entered and allow it to 
> check and use floating points. If you need the source code i am happy to give 
> it to you. Thank you for your help

I am using python 2.7.7 and i have come up with away but there is still 
possible errors for this. What i did was i this

#checks if the user input is an integer value
def checkint(a):
if a.isnumeric():
return True
else:
if a.isalpha():
return False
else:
return True

The parameter a is the users input by the raw_input function. I first test if 
it is normal int with the isnumeric function. Unfortunately this function picks 
up the decimal as false. This means if the user inputs a float it has to be 
false. I then test if this input has any alphabetical characters if it does not 
the user could have only entered  something like 12.5 oppose to abc.d. This 
method works fine and it i have  tested it and it works fine. if incase this 
input did have a letter it would be picked up by the isalpha function. There is 
one annoying error doing it this way and that is if you enter 12.ab or ab.12 it 
will say that it is okay. Still working on this so this should get sorted out 
soon.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to check if a value is a floating point or not

2014-06-19 Thread Nicholas Cannon
Guys i am only a beginner at python most of the stuff you are saying i need to 
do i dont understand.
-- 
https://mail.python.org/mailman/listinfo/python-list


How to distribute python console program

2014-06-21 Thread Nicholas Cannon
I have a simple program that is ran in the console with 2 modules and i was 
wondering how i could like export it so i could give it to someone to use as 
like a utlitie in the console?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to distribute python console program

2014-06-22 Thread Nicholas Cole
On Sun, Jun 22, 2014 at 3:51 AM, Nicholas Cannon
 wrote:
> I have a simple program that is ran in the console with 2 modules and i was 
> wondering how i could like export it so i could give it to someone to use as 
> like a utlitie in the console?

I'm assuming that the 'someone' you want to give it to has python
installed (if they are running any kind of linux or OS X they should
do).

If so, you can use something like

https://pypi.python.org/pypi/ncdistribute/

to make single zip file that contains your code and all its
dependencies.  There is no need to unpack the zip file - python can
run it without unpacking, so you simply put the your_utility_name.pyz
file somewhere in the user's path and it can be run easily.  You can
even rename it so that it doesn't have the .pyz filename.

If you want to send your application to someone who doesn't have
python installed, things are trickier.

http://cx-freeze.sourceforge.net

aims to help you do that kind of thing.

Hope that helps,

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


Standard library Help

2014-07-11 Thread Nicholas Cannon
Hey i would like to know alot more about the standard library and all of its 
functions and so on and i know it is huge and i would basically like to learn 
only the useful stuff that i could use and all of those features. i have been 
looking around and i cant really find anything so i wondering if you guys would 
know any places to learn it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Mac python py2app problem

2014-07-15 Thread Nicholas Cannon
Hey i have made an app and i have made a .msi for windows with py2exe and i 
have also exported it with py2app on mac. No problems here they all work fine. 
I then put the .msi on sourceforge and it works great but when i put the .app 
on there and download it it says something like i can open this on old 
architecture or something so i have to put it through google drive and i dont 
like this like i share the link and folder and people can download it there but 
it is dodgy. Could someone please help me out like if there is a .msi type 
thing for mac with py2exe?
-- 
https://mail.python.org/mailman/listinfo/python-list


I need an idea for practise!

2014-07-17 Thread Nicholas Cannon
Ok I would say I am almost a intermediate python programer. I have made 2 
programs(with GUI). And basically they are quite boring(a text editor and 
calculator). I love programming but i am lost of ideas i actually suck at 
finding good creative ideas. Now i am not looking to use these ideas make them 
and then try get money for it. I am only a kid and would love some like real 
world project ideas to learn more about python. Yeah so if any one would like 
to give me some ideas to train my self on that would be so cool!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Mac python py2app problem

2014-07-17 Thread Nicholas Cannon
On Wednesday, July 16, 2014 9:56:56 AM UTC+8, Nicholas Cannon wrote:
> Hey i have made an app and i have made a .msi for windows with py2exe and i 
> have also exported it with py2app on mac. No problems here they all work 
> fine. I then put the .msi on sourceforge and it works great but when i put 
> the .app on there and download it it says something like i can open this on 
> old architecture or something so i have to put it through google drive and i 
> dont like this like i share the link and folder and people can download it 
> there but it is dodgy. Could someone please help me out like if there is a 
> .msi type thing for mac with py2exe?

Yeah i have zipped it up and put it on sourceforge and then when you download 
the zip it says it is incomplete. I do like the idea of making a .dmg file 
because i have used them downloading other apps and it works great but i dont 
know how to make them! would be great if you guys could give me a link to how 
to do this!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I need an idea for practise!

2014-07-17 Thread Nicholas Cannon
When I say i suck at finding good creative ideas I dont mean like I can think 
of  anything its more like i cant think of anything that is within my scope of 
skill. These ideas are great guys thanks. Also the gui tool kit i used for the 
apps is tkinter because i am reading a book about python and it covers that 
tool kit. Also i like this idea of ssh'ing to a server where i could have a 
python program that allows files to be uploaded to a database and brought down 
from the data base. I am just not so good with the hardware so I dont really 
now how to create one. Also I wouldnt mind putting more functionality into my 
programs and stuff that sounds alright and also re inventing the wheel sounds 
like good practise.
-- 
https://mail.python.org/mailman/listinfo/python-list


I am stuck on OOP

2014-07-18 Thread Nicholas Cannon
Just quickly i am quite stuck on OOP and i really need like a good video and i 
cant find any. If anyone knows any please link it i really need it because i 
know OOP is important.
-- 
https://mail.python.org/mailman/listinfo/python-list


Html Parsing stuff

2014-07-21 Thread Nicholas Cannon
Ok i get the basics of this and i have been doing some successful parsings and 
using regular expressions to find html tags. I have tried to find an img tag 
and write that image to a file. I have had no success. It says it has 
successfully wrote the image to the file with a try... except statement but 
when i try to open this it says that the image has like no been saved correctly 
or is damaged. This was just reading the src attribute of the tag and trying to 
save that link to a .jpg(the extension of the image). Ok so i looked deeper and 
added a forward slash to the url and then added the image src attribute to it. 
I then opened that link with the urllib.urlopen() and then read the contents 
and saved it to the file again. I still got the same result as before. Is there 
a function in beautiful soup or the urllib module that i can use to save and 
image. This is just a problem i am sorting out not a whole application so the 
code is small. Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Html Parsing stuff

2014-07-21 Thread Nicholas Cannon
dont worry it has been solved
-- 
https://mail.python.org/mailman/listinfo/python-list


I want to do something with data

2014-07-23 Thread Nicholas Cannon
Hey i am interested in using data in my programs. I know every program uses 
data but i want to do like large data processing and pick results out of a data 
like querying database. I dont really know what this is called though. Is it 
data analytics? im not sure but I would like to do this stuff. What would i 
need to learn because i know the basic file opening and stuff and also know how 
to open csv files aswell as grab data from the web. I dont know much else about 
handling data other than regular expressions which is handy when grabbing data 
from the web. I f any one could like guide me on what to learn that would be so 
good.
-- 
https://mail.python.org/mailman/listinfo/python-list


Best place to find sample data

2014-07-26 Thread Nicholas Cannon
Hey I need some sample data to test out and do stuff with. Also I am having 
strange errors with idle when i load a .txt file read it and then print it, 
idle crashes well kind of freezes. Not sure what is wrong here. Also I am 
having troubles with Numpy and its loadtxt function:

ValueError: cannot set an array element with a sequence

So all i need is a good site to download some data from and maybe some fixes 
for these problems.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Best place to find sample data

2014-07-26 Thread Nicholas Cannon
On Saturday, July 26, 2014 9:41:11 PM UTC+8, Nicholas Cannon wrote:
 Also I am having troubles with Numpy and its loadtxt function:
> 
> 
> 
> ValueError: cannot set an array element with a sequence

I found out why this has occurred because the csv file i was using didnt have a 
consistent amount of values in each line so when the load text tried to load it 
into a list or whatever some lines had a missing index or something.

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


Re: Best place to find sample data

2014-07-26 Thread Nicholas Cannon
Oh the above is quoted here just the bottom line in added in 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-01 Thread Nicholas Cole
On Fri, Aug 1, 2014 at 12:22 PM, Chris Angelico  wrote:
> On Fri, Aug 1, 2014 at 9:10 PM, Wolfgang Keller  wrote:
>> Thankfully, all actually user-friendly operating systems (MacOS,
>> TOS, RiscOS, probably AmigaOS, MacOS X) spare(d) their users the
>> bottomless cesspit of "package management" and/or "installers".
>>
>> Because on such operating systems, each and every application is an
>> entirely self-contained package that doesn't need any "packages" or
>> "installers" to use it.
>
> You mean everyone has to reinvent the proverbial wheel AND worry about
> dependency collisions? Yeah, that's a heavenly thought.

Actually, that's not right.  RiscOS had and OS X has (I'm sure the
others do as well) a concept that is similar to a shared library.  But
the joy of an application bundle is that installing an application
does not scatter its own files all over the file-system, putting
configuration files here, binary resources there, library files
somewhere else, executable files somewhere else again.  The result on
one of these other systems is that uninstalling an application is a
simple matter of deleting the relevant bundle, which contains all of
the resources necessary for that application.  All that remains are
whatever files exist within user directories.

I've worked with both.  Quite honestly, I really wish that other
operating systems had gone down this route. MS didn't possibly to make
it harder to steal software, and Unix...well, *nix has the concept of
the "distribution" that will manage all of this for you.  We all know
the problems that this causes.

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


Tkinter grid autosize help

2014-08-02 Thread Nicholas Cannon
So i have a basic calculator program and i have a label that i want to go 
across the top to show the numbers and stuff like on a normal calculator. The 
only way i can make the buttons look neat and then when i keep pressing one the 
label gets larger and then half the buttons move out of the screen. I cant seem 
to fix this i have tried columnspan, columnconfigure and heaps of other stuff 
and non works it always expands. is there a way i can stop the grid from 
expanding?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter grid autosize help

2014-08-02 Thread Nicholas Cannon
On Saturday, August 2, 2014 10:38:28 PM UTC+8, Nicholas Cannon wrote:
> So i have a basic calculator program and i have a label that i want to go 
> across the top to show the numbers and stuff like on a normal calculator. The 
> only way i can make the buttons look neat and then when i keep pressing one 
> the label gets larger and then half the buttons move out of the screen. I 
> cant seem to fix this i have tried columnspan, columnconfigure and heaps of 
> other stuff and non works it always expands. is there a way i can stop the 
> grid from expanding?



ok here is the code:

#window setup
main = Tk()
main.title('Calculator')
main.geometry('300x350')
main.resizable()

app = Frame(main)
app.grid()
app.columnconfigure(0, weight=500)
app.columnconfigure(1, weight=500)


#number view label
number = ' '
numberView = Label(app, text= number)
numberView.grid(row=0, column=0, columnspan=100)

#Num Pad Buttons below
num1 = '1'
button1 = Button(app, text='1', command= lambda: add(num1), width=5)
button1.grid(row=1, column=0)

num2 = '2'
button1 = Button(app, text='2', command= lambda: add(num2), width=5)
button1.grid(row=1, column=1)

num3 = '3'
button1 = Button(app, text='3', command= lambda: add(num3), width=5)
button1.grid(row=1, column=2)

num4 = '4'
button1 = Button(app, text='4', command= lambda: add(num4), width=5)
button1.grid(row=2, column=0)

num5 = '5'
button1 = Button(app, text='5', command= lambda: add(num5), width=5)
button1.grid(row=2, column=1)

num6 = '6'
button1 = Button(app, text='6', command= lambda: add(num6), width=5)
button1.grid(row=2, column=2)

num7 = '7'
button1 = Button(app, text='7', command= lambda: add(num7), width=5)
button1.grid(row=3, column=0)

num8 = '8'
button1 = Button(app, text='8', command= lambda: add(num8), width=5)
button1.grid(row=3, column=1)

num9 = '9'
button1 = Button(app, text='9', command= lambda: add(num9), width=5)
button1.grid(row=3, column=2)

num0 = '0'
button1 = Button(app, text='0', command= lambda: add(num0), width=5)
button1.grid(row=4, column=1)

main.mainloop()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter grid autosize help

2014-08-02 Thread Nicholas Cannon
On Saturday, August 2, 2014 10:38:28 PM UTC+8, Nicholas Cannon wrote:
> So i have a basic calculator program and i have a label that i want to go 
> across the top to show the numbers and stuff like on a normal calculator. The 
> only way i can make the buttons look neat and then when i keep pressing one 
> the label gets larger and then half the buttons move out of the screen. I 
> cant seem to fix this i have tried columnspan, columnconfigure and heaps of 
> other stuff and non works it always expands. is there a way i can stop the 
> grid from expanding?

Ok so I have just started out Tkinter and I feel I should study more of it 
because some of the code given is quite intimidating to me right now. Also I 
have only been coding python for 3 months right now. I think I need to learn 
how to write python better haha. I appreciate the help guys.
-- 
https://mail.python.org/mailman/listinfo/python-list


Tkinter menu crash

2014-08-05 Thread Nicholas Cannon
Ok so the first part of the program(until the start of the menu) worked fine. 
It ran and did what I wanted it to do. I wanted to then implement a new 
menu(for practise) and then it crashes. Don't know why but it just crashes. 
(also tips on the code will be appreciated and I gave just started Tkinter 
programming)

Here is the code:


from Tkinter import *
import tkMessageBox as tm

def submit():
#message box with yes no 
tm.askyesno(title='Submit Text', message='Are you sure')

def info():
tm.showinfo(title='About', message='Just a test Tkinter UI sample')


#getting the text from the entrybox and
#packs it into a label
mtext = text.get()
label1 = Label(app, text=mtext)
label1.pack()

#root window setup
root = Tk()
root.geometry('480x480+200+200')
root.title('Basic Tk UI')

#frame set up
app = Frame(root)
app.pack()

#variable and entry box set up
text = StringVar()
entry = Entry(app, textvariable=text)
entry.pack()

#button set up
button1 = Button(app, text='Submit text', command= submit)
button1.pack()

#menu construction
menubar = Menu(root)

filemenu = Menu(menubar)
filemenu.add_command(label='About', command= info)
filemenu.add_command(label='Quit', command= root.destroy)
filemenu.add_cascade(label='TK UI Sample', menu=filemenu)

root.config(menu=menubar)



#loop to listen for events
root.mainloop()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter menu crash

2014-08-05 Thread Nicholas Cannon
Ok so I am on 2.7.8.
> What x.y.z version of Python. How did you run it, exactly?

> Adding filemenu as a submenu of filemenu leads to infinite loop regress. 
> 
> On 3.4.1 with tcl/tk 8.6, this does not crash, but it might on an 
> 
> earlier version of Python and tcl/tk.
> Since menubar is left empty, it is not displayed.  Fix both problems with
> 
>menubar.add_cascade(label='TK UI Sample', menu=filemenu)
> 
> root.config(menu=menubar)
Yeah this fixed the problem. So the main menu object needs to be cascade 
instead of the filemenu. Will this need to be done every I create a new menu?


>and ran -- no crash, no error message, no menu. I entered text into box, 
>clicked Submit text, and OK on popup, and nothing happens. 
Im not quite sure what is happening here. Oh I just looked at the code and the 
part that sends the entry box text is in the wrong place or must have been 
unindented I have fixed this now and it works great.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter menu crash

2014-08-05 Thread Nicholas Cannon
I am confused. When I did menu bar.add_cascade why don't I do 
filemenu.add_cascade. Is it because I am adding a cascade to the main menubar?  
-- 
https://mail.python.org/mailman/listinfo/python-list


Tkinter frame reset

2014-08-08 Thread Nicholas Cannon
Ok so I am working on a little project and I cant seem to solve something with 
it. I have a label and then a clear button and I want all the numbers in the 
label to clear when I push the button. This button is on a separate frame to 
the buttons. I would like to clear the frame and then set all the widgits back 
to how they were one you first open the app(Label being blank). I have tried to 
destroy it with frame.destry() and then try re create it in a function but it 
never recreates its self. Also when I tried grid_forget() on it, it never came 
back either when I tried to frame it and then grid it back on there. I can 
clear the label by just adding a long blank string to it to overwrite the 
numbers behind because I would like to have the user add more numbers in there 
like starting fresh. This long blank string wont work because the buttons add 
on to the existing string so the label keeps getting updated with the new 
buttons pressed. I tried to remove the label but that never came back
  either. Please help me with trying to clear the label or the whole window 
back to its original blank settings
-- 
https://mail.python.org/mailman/listinfo/python-list


Best place to start of learning the raspberry pi

2014-08-24 Thread Nicholas Cannon
Hey I bought a raspberry pi, a bread board and all this electronics stuff and i 
really enjoy programming stuff in python and i have had a decent of practise 
with python. I really wont to get into making things with electronics(i have 
had a lot of practise with soldering as well) and then program them with 
python. Where is the best place to learn all this starting of from the 
beginning like the basics of electronics?
-- 
https://mail.python.org/mailman/listinfo/python-list


Raspberry pi, python and robotics

2014-08-30 Thread Nicholas Cannon
I really enjoy engineering at school and we make like fighting robots and 
stuff(simple stuff of course) and i really enjoy it. I have got a raspberry pi 
and a decent understanding of python and i want to do make stuff like RC cars 
and drones and stuff. Also I like electronics. Is there any good places to 
learn all this stuff like down to the basics of electronics because I have 
looked around and all the books I have seen just throw some electronics 
together and say yep thats done. I would like to work on my own projects after 
I get a grip on the basics. Where could I find some good recourses on this 
stuff.
-- 
https://mail.python.org/mailman/listinfo/python-list


python script monitor

2014-09-15 Thread Nicholas Cannon
I have made an app that is not fully stable and I would like to monitor the 
performance of the app and try and improve the speed of it. I tried to use the 
activity monitor on the mac but what I want I'm to see how much ram, cup and 
other stats on what resources that app is using. Is there any apps to 
specifically monitor a certain app. I am on Mac is so any suggestions that 
could work with that would be great.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python script monitor

2014-09-16 Thread Nicholas Cannon
Nah I mean like there is performance issues. It delivers result that I want 
just mot very conveinetly fast.
-- 
https://mail.python.org/mailman/listinfo/python-list


Love to get some feedback on my first python app!!!

2014-09-20 Thread Nicholas Cannon
I have created my first python program and I have learnt a lot about python 
from this group and wanted some feedback. I am still improving it and trying to 
tackle some performance and GUI stuff so keep that in mind. I don't think it is 
the best program but is a good product of 3 months of python.

link: https://github.com/nicodasiko/Article-Grab 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-20 Thread Nicholas Cannon
On Saturday, September 20, 2014 9:17:27 PM UTC+8, Nicholas Cannon wrote:
> I have created my first python program and I have learnt a lot about python 
> from this group and wanted some feedback. I am still improving it and trying 
> to tackle some performance and GUI stuff so keep that in mind. I don't think 
> it is the best program but is a good product of 3 months of python.
> 
> 
> 
> link: https://github.com/nicodasiko/Article-Grab

Yeah this is exactly what I was looking for I know the comments are horrible 
and I had no idea about the camelCase stuff. Should I use 
'''
Use this commenting on my functions or not. I think they are called docStrings 
or something
'''
I have a free day today and I am going to fix up some GUI stuff and try and 
slim down the processing and amount of variables because it doesnt really run 
as fast. Thanks for the help Chris Angelico!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-20 Thread Nicholas Cannon
I have just committed a new main.py file on github. I added alot more comments 
and slimmed down the getinfo() function. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-21 Thread Nicholas Cannon
On Saturday, September 20, 2014 9:17:27 PM UTC+8, Nicholas Cannon wrote:
> I have created my first python program and I have learnt a lot about python 
> from this group and wanted some feedback. I am still improving it and trying 
> to tackle some performance and GUI stuff so keep that in mind. I don't think 
> it is the best program but is a good product of 3 months of python.
> 
> 
> 
> link: https://github.com/nicodasiko/Article-Grab

I just updated the whole app to include a scroll bar, loading bar and I used 
multi threading to update the scroll bar whilst scraping the data from the web. 
I need to work on performance though but I have defiantly improved it now!
-- 
https://mail.python.org/mailman/listinfo/python-list


How to not enable a user to close the root tkinter window

2014-09-22 Thread Nicholas Cannon
I have a project I am working on(https://github.com/nicodasiko/Article-Grab) 
which grabs info from the internet then displays it on the screen. It is a 
multithreaded program so as the function that retrieves the data from the 
internet there is also another function running in parallel which updates a ttk 
loading bar. Pretty simple multi threaded stuff. But I found out that the user 
can close the window whilst the threads are running which generates an error 
and is not healthy. Is there a way I can make the root tkinter window not close 
whilst the threads are running. I did this with the search bar and search 
button. Or can I safely stop the running threads and make them drop everything 
error free? Any help will be apreciated!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Nicholas Cannon
Ok I'm confused. Do I need to do better comments? I know the text is not that 
great but that is my next obstacle I am going to tackle. I mostly need to know 
where I am going wrong such as what is expectable readable code and what is not 
and how to fix this. This is good feedback thanks to all of you guys. All I 
want to do is learn and become better and neater!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Love to get some feedback on my first python app!!!

2014-09-22 Thread Nicholas Cannon
Also I have just been coding for about and hour and a half and added a lot more 
code to it but it is not fully finished yet so it is not on github yet.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to not enable a user to close the root tkinter window

2014-09-22 Thread Nicholas Cannon

The git hub has not actually been updated yet I am working on somethine else 
then committing the update. How would I stop the threads though. I'am using the 
Thread from threading function. 
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >