What kind of "thread safe" are deque's actually?

2023-03-27 Thread Travis Griggs
A while ago I chose to use a deque that is shared between two threads. I did so 
because the docs say:

"Deques support thread-safe, memory efficient appends and pops from either side 
of the deque with approximately the same O(1) performance in either direction.”

(https://docs.python.org/3.11/library/collections.html?highlight=deque#collections.deque)

Earlier today, looking through some server logs I noticed that from time to I’m 
getting a

RuntimeError: deque mutated during iteration

I guess this surprised me. When I see “thread safe”, I don’t expect to get 
errors.

Interestingly the error also only started showing up when I switched from 
running a statistics.mean() on one of these, instead of what I had been using, 
a statistics.median(). Apparently the kind of iteration done in a mean, is more 
conflict prone than a median?

I’ve got a couple ways I can work around this. But I was surprised.
-- 
https://mail.python.org/mailman/listinfo/python-list


mapLast, mapFirst, and just general iterator questions

2022-06-14 Thread Travis Griggs
I want to be able to apply different transformations to the first and last 
elements of an arbitrary sized finite iterator in python3. It's a custom 
iterator so does not have _reversed_. If the first and last elements are the 
same (e.g. size 1), it should apply both transforms to the same element. I'm 
doing this because I have an iterator of time span tuples, and I want to clamp 
the first and last elements, but know any/all of the middle values are 
inherently in range.

A silly example might be a process that given an iterator of strings, chops the 
the outer characters off of the value, and uppercases the final value. For 
example:


def iterEmpty():
return iter([])

def iter1():
yield "howdy"

def iter2():
yield "howdy"
yield "byebye"

def iterMany():
yield "howdy"
yield "hope"
yield "your"
yield "day"
yield "is"
yield "swell"
yield "byebye"

def mapFirst(stream, transform):
try:
first = next(stream)
except StopIteration:
return
yield transform(first)
yield from stream

def mapLast(stream, transform):
try:
previous = next(stream)
except StopIteration:
return
for item in stream:
yield previous
previous = item
yield transform(previous)

def main():
for each in (iterEmpty, iter1, iter2, iterMany):
baseIterator = each()
chopFirst = mapFirst(baseIterator, lambda x: x[1:-1])
andCapLast = mapLast(chopFirst, lambda x: x.upper())
print(repr(" ".join(andCapLast)))


This outputs:

''
'OWD'
'owd BYEBYE'
'owd hope your day is swell BYEBYE'

Is this idiomatic? Especially my implementations of mapFirst and mapList there 
in the middle? Or is there some way to pull this off that is more elegant?

I've been doing more with iterators and stacking them (probably because I've 
been playing with Elixir elsewhere), I am generally curious what the 
performance tradeoffs of heavy use of iterators and yield functions in python 
is. I know the argument for avoiding big list copies when moving between 
stages. Is it one of those things where there's also some overhead with them, 
where for small stuff, you'd just be better list-ifying the first iterator and 
then working with lists (where, for example, I could do the first/last clamp 
operation with just indexing operations).
-- 
https://mail.python.org/mailman/listinfo/python-list


Polymorphic imports

2021-09-21 Thread Travis Griggs
I guess this is kind of like mocking for testing. I have a simple module that's 
imported in a number of other spots in my program. There's a condition in the 
OS/filesystem where I'd like to import a polymorphically compatible variant of 
the same module. Can this be accomplished in a sort of once-and-only once spot?

For example, consider something like this:

client/
  module_a
  module_a_prime
lib/
  paths
   lib_a
   lib_b
   ...
model/
  model_a
  model_b
  ...
top_level_a
top_level_b
...


I have a number of imports of module_a. I have a paths module that isolates all 
of my file system access, and that's where the determination can be made which 
one to use, so I tried to do something like:

def dynamic_client_module():
   return client.module_a_prime if the_condition_occurs else client.module_a


Hoping that I could do something like

from lib import paths
import paths.dynamic_client_module()

But this seems to not work. Import can only take real modules? Not programatic 
ones?

Is there a Not-Too-Evil-Way(tm) to add a level of programmatic indirection in 
the import declarations? Or some other trick from a different angle? 
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue44507] Favor needed ASAP

2021-06-24 Thread Glenn Travis


New submission from Glenn Travis :

- This mail is in HTML. Some elements may be ommited in plain text. -

Hi to you!
Need a favor from you, do you have an account with Amazon?
Glenn Travis

--
messages: 396511
nosy: Old Sub Sailor
priority: normal
severity: normal
status: open
title: Favor needed ASAP

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



[issue32824] Docs: Using Python on a Macintosh has bad info per Apple site

2021-04-29 Thread Glenn Travis

Glenn Travis  added the comment:

Here is a copy of the Apple Python call as of April 29, 2021.  To my way of 
thinking it seems that Apple is saying that someday they will indeed eliminate 
all the included “scripting” software from macOS and they further imply that 
one should install an. Up-to-date version of one’s particular chosen software. 

Last login: Thu Apr 29 08:22:47 on console
% python

WARNING: Python 2.7 is not recommended. 
This version is included in macOS for compatibility with legacy software. 
Future versions of macOS will not include Python 2.7. 
Instead, it is recommended that you transition to using 'python3' from within 
Terminal.

Python 2.7.16 (default, Feb 28 2021, 12:34:25) 
[GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy 
on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
% exit
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

> On Apr 28, 2021, at 4:25 PM, Glenn Travis  wrote:
> 
> 
> Glenn Travis  added the comment:
> 
> I see that this remains alive. I do have a newer question. Apple continues to 
> say that they are going to drop all their included versions of python and I 
> believe ruby in some future version of macOS. I thought that this would 
> happen in Big Sur, but python versions 2.7.16 still remains with us, why, I 
> don’t know.
> 
>> On Apr 28, 2021, at 3:21 PM, Irit Katriel  wrote:
>> 
>> 
>> Change by Irit Katriel :
>> 
>> 
>> --
>> versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.6, 
>> Python 3.7, Python 3.8
>> 
>> ___
>> Python tracker 
>> <https://bugs.python.org/issue32824>
>> ___
> 
> --
> 
> ___
> Python tracker 
> <https://bugs.python.org/issue32824>
> ___

--

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



[issue32824] Docs: Using Python on a Macintosh has bad info per Apple site

2021-04-28 Thread Glenn Travis

Glenn Travis  added the comment:

I see that this remains alive. I do have a newer question. Apple continues to 
say that they are going to drop all their included versions of python and I 
believe ruby in some future version of macOS. I thought that this would happen 
in Big Sur, but python versions 2.7.16 still remains with us, why, I don’t know.

> On Apr 28, 2021, at 3:21 PM, Irit Katriel  wrote:
> 
> 
> Change by Irit Katriel :
> 
> 
> --
> versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.6, 
> Python 3.7, Python 3.8
> 
> ___
> Python tracker 
> <https://bugs.python.org/issue32824>
> ___

--

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



Re: Fun Generators

2021-04-23 Thread Travis Griggs



> On Apr 23, 2021, at 05:55, Frank Millman  wrote:
> 
> On 2021-04-23 7:34 AM, Travis Griggs wrote:
>> Doing an "industry experience" talk to an incoming class at nearby 
>> university tomorrow. Have a couple points where I might do some "fun things" 
>> with python. Said students have been learning some python3.
>> I'm soliciting any *fun* generators people may have seen or written? Not so 
>> much the cool or clever ones. Or the mathematical ones (e.g. fib). Something 
>> more inane and "fun". But still showcasing generators uniqueness. Short and 
>> simple is good.
>> Thanks in advance!
> 
> Have you looked at this?
> 
> http://www.dabeaz.com/generators/
> 
> Frank Millman
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list


I hadn't. But now I have. These are really cool. But not as whimsical/simple as 
I would have hoped. They're actually useful :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Fun Generators

2021-04-22 Thread Travis Griggs
Doing an "industry experience" talk to an incoming class at nearby university 
tomorrow. Have a couple points where I might do some "fun things" with python. 
Said students have been learning some python3.

I'm soliciting any *fun* generators people may have seen or written? Not so 
much the cool or clever ones. Or the mathematical ones (e.g. fib). Something 
more inane and "fun". But still showcasing generators uniqueness. Short and 
simple is good.

Thanks in advance!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Canonical conversion of dict of dicts to list of dicts

2021-03-30 Thread Travis Griggs


> On Mar 30, 2021, at 12:11, Stestagg  wrote:
> 
> For completeness, from 3.5 onwards, you can also do the following:
> 
> [{'name': n, **d} for n, d in dod.items()]
> 

Reading through these, personally I like this one best. I'm curious what about 
it was enabled in 3.5? Was **kwarg expansion inside a dict literal not possible 
before then? Anyway, I like that it uses simple elemental parts that have been 
around a long long time in Python.

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


Code Formatter Questions

2021-03-28 Thread Travis Griggs
I've been looking into using a code formatter as a code base size has grown as 
well as contributing developers. I've found and played with autopep, black, and 
yapf. As well as whatever pycharm has (which may just be gui preferences around 
one of those 3).

I have 2 questions:
1) Are there any major other formatters that I can/should look at? I see some 
"online" pretty printers, but I'm after something I can run on whole recursive 
directories of code.

2) I use more and type annotations (at least at the trivial level). But I like 
to have variable annotations tightly bound to the identifier, kind of like a 
subscript. So I want to see 

  def foo_bar(baz:int) -> bool:
yak:str = 'howdy mates'

And NOT 

  def foo_bar(baz: int) -> bool:
yak: str = 'howdy mates'

In other cases though (dictionaries for example), I'm fine with (and prefer) 
the spacing.

Is there anyway to make any of these formatters do this?

We write a lot of Swift and Kotlin as well as which uses the same general 
syntax (identifier:Type) for type annotation, and we'd like to have some 
consistency across the styles (we pack the couplets in those two).


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


[issue40649] [Errno 1]

2020-05-17 Thread Glenn Travis


Glenn Travis  added the comment:

I think that you are referring to Gatekeeper.  Something that I have run into 
with various applications, such as certain utility files in Ortho4XP and even 
when adding aircraft to X-Plane(some of the developers refuse to become 
approved Apple developers).

--
stage:  -> resolved
status: open -> closed

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



[issue40649] [Errno 1]

2020-05-17 Thread Glenn Travis


Glenn Travis  added the comment:

As per your suggestion I have sent an email to python help, just looking for 
info regarding what you would consider the key permission settings.

--

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



[issue40649] [Errno 1]

2020-05-17 Thread Glenn Travis


Glenn Travis  added the comment:

ok, fine.
So what permissions would indicate that "the Python interpreter can read it."
The Get Info screenshot that he sent me looks just like mine with regard to 
permissions. The long list in terminal shows nothing special. 

I am not having problems running the scripts.

--

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



[issue40649] [Errno 1]

2020-05-16 Thread Glenn Travis


Glenn Travis  added the comment:

I think that I will ask him to reinstall Python. Which can be a scary process 
for him.

--

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



[issue40649] [Errno 1]

2020-05-16 Thread Glenn Travis


Change by Glenn Travis :


Added file: https://bugs.python.org/file49159/errormessage.jpg

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



[issue40649] [Errno 1]

2020-05-16 Thread Glenn Travis


Glenn Travis  added the comment:

I think that there is something odd going on with his python install.
He just tried to run a very simple python script that I made for him,

print('Hello there python interperter')

And he got the same error message again.  I do not know what more information 
you need, I sent the copy and paste terminal error text.

--

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



[issue40649] [Errno 1]

2020-05-16 Thread Glenn Travis


Change by Glenn Travis :


--
title: [Errno 1} -> [Errno 1]

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



[issue40649] [Errno 1}

2020-05-16 Thread Glenn Travis


New submission from Glenn Travis :

A fellow on the X-Plane forum reported getting this:

cd desktop/Ortho4XP-130

ianrobertson@Ians-iMac Ortho4XP-130 % python3 Ortho4XP_v130.py

/Library/Frameworks/Python.framework/Versions/3.8/bin/python3: can't open file 
'Ortho4XP_v130.py': [Errno 1] Operation not permitted

he is able to run python3.8.2 from the terminal and get it to work with the 
interpreter for a print('Howdy') but Ortho4Xp not.

is this a python thing, an ortho thing or some root cause from installing 
python?

--
messages: 369065
nosy: TotallyLost
priority: normal
severity: normal
status: open
title: [Errno 1}

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



[issue40477] Python Launcher app on macOS 10.15 Catalina fails to run scripts

2020-05-15 Thread Glenn Travis


Glenn Travis  added the comment:

Is there no way to edit a previous comment?
Anyway, I can get it to work as described, but the Launcher Preferences window 
also opens when I run a script.  Did I miss a setting?

--

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



[issue40477] Python Launcher app on macOS 10.15 Catalina fails to run scripts

2020-05-14 Thread Glenn Travis


Glenn Travis  added the comment:

It is working now. However, I end up with two terminal windows open.
One is the one that I opened and the second appears to have been opened by the 
Launcher??

--

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



[issue40477] Python Launcher app on macOS 10.15 Catalina fails to run scripts

2020-05-14 Thread Glenn Travis


Glenn Travis  added the comment:

Thank you Ned.

So close now.  After your final fix, if I understood you correctly, we will no 
longer have to open Terminal? 

And, excuse my vast knowledge gap, but will it ever be possible to not have the 
terminal run in the future?

--

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



[issue40477] Python Launcher app on macOS 10.15 Catalina fails to run scripts

2020-05-14 Thread Glenn Travis


Glenn Travis  added the comment:

Well heck.
I just tried it, and got an error.  The error does not occur when I run the 
script directly from the Terminal, nor when I run it via IDLE (double click)

Last login: Thu May 14 07:57:11 on ttys000
But what do I know? % cd '/Volumes/BigHDD/Ortho4XP-master/' && 
'/usr/bin/pythonw'  '/Volumes/BigHDD/Ortho4XP-master/Ortho4XP_v130.py'  && echo 
Exit status: $? && exit 1
Traceback (most recent call last):
  File "/Volumes/BigHDD/Ortho4XP-master/Ortho4XP_v130.py", line 9, in 
import O4_Imagery_Utils as IMG
  File "./src/O4_Imagery_Utils.py", line 597
SyntaxError: Non-ASCII character '\xc2' in file ./src/O4_Imagery_Utils.py on 
line 597, but no encoding declared; see http://python.org/dev/peps/pep-0263/ 
for details
But what do I know? %

--

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



[issue40477] Python Launcher app on macOS 10.15 Catalina fails to run scripts

2020-05-14 Thread Glenn Travis


Glenn Travis  added the comment:

I appreciate the update.
As an aside, I keep the terminal in the dock.

--

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



[issue40477] Launcher on Catalina

2020-05-11 Thread Glenn Travis


Glenn Travis  added the comment:

I tried to report this concern under Documentation, but got shot down as 
duplicate.

I have the same results. I tried to make Launcher the default "Open With" 
application for a script, also tried dragging (and Option dragging) the script 
to the Launcher, neither worked. 

I have received several results:
1. Nothing happens
2. Preference window opens
3. Launcher window with a run button opens; the run button does nothing.

--
nosy: +TotallyLost

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



[issue32824] Docs: Using Python on a Macintosh has bad info per Apple site

2020-05-09 Thread Glenn Travis

Glenn Travis  added the comment:

Thank you, but how in the world does one know where to look or find that 
document at github.  I tried to search earlier and got hundreds of listings for 
python doc. 

Sent from my iPhone

> On May 9, 2020, at 16:36, Glenn Travis  wrote:
> 
> Thank you Remi
> 
> 
>> On May 9, 2020, at 4:15 PM, Rémi Lapeyre  wrote:
>> 
>> 
>> Rémi Lapeyre  added the comment:
>> 
>> Hi Gleen, the best way forward is to propose an improvement to the current 
>> documentation. It will get reviewed and merge if appropriate.
>> 
>> The source for this part is at 
>> https://github.com/python/cpython/blob/master/Doc/using/mac.rst and you can 
>> find the information needed to contribute in the Python Dev Guide: 
>> https://devguide.python.org/.
>> 
>> --
>> nosy: +remi.lapeyre
>> 
>> ___
>> Python tracker 
>> <https://bugs.python.org/issue32824>
>> ___
>

--

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



[issue32824] Docs: Using Python on a Macintosh has bad info per Apple site

2020-05-09 Thread Glenn Travis

Glenn Travis  added the comment:

Thank you Remi

> On May 9, 2020, at 4:15 PM, Rémi Lapeyre  wrote:
> 
> 
> Rémi Lapeyre  added the comment:
> 
> Hi Gleen, the best way forward is to propose an improvement to the current 
> documentation. It will get reviewed and merge if appropriate.
> 
> The source for this part is at 
> https://github.com/python/cpython/blob/master/Doc/using/mac.rst and you can 
> find the information needed to contribute in the Python Dev Guide: 
> https://devguide.python.org/.
> 
> --
> nosy: +remi.lapeyre
> 
> ___
> Python tracker 
> <https://bugs.python.org/issue32824>
> ___

--
nosy: +Old Sub Sailor

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



[issue32824] Docs: Using Python on a Macintosh has bad info per Apple site

2020-05-09 Thread Glenn Travis


Glenn Travis  added the comment:

So, how do we wake this sleeping concern up?

--
nosy: +TotallyLost

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



[issue40580] Macintosh Documentation Still Bad

2020-05-09 Thread Glenn Travis


Glenn Travis  added the comment:

Pull - Request?

--

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



[issue40580] Macintosh Documentation Still Bad

2020-05-09 Thread Glenn Travis

Glenn Travis  added the comment:

Thank you for your reply.  I just wanted to renew or recall attention to the 
older one.  It seems to have been dormant for too long.

A C program is like a fast dance on a newly waxed dance floor by people 
carrying razors.  -W.R.

And now for something completely different. -M.P

> On May 9, 2020, at 2:39 PM, Rémi Lapeyre  wrote:
> 
> 
> Rémi Lapeyre  added the comment:
> 
> Hi Gleen, this looks like there already exists an issue for this problem, 
> please use it instead of opening a new one. 
> 
> Can you please open a new Pull-Request for solving this issue?
> 
> --
> nosy: +remi.lapeyre
> 
> ___
> Python tracker 
> <https://bugs.python.org/issue40580>
> ___

--
nosy: +Old Sub Sailor

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



[issue40580] Macintosh Documentation Still Bad

2020-05-09 Thread Glenn Travis


New submission from Glenn Travis :

This was reported two years ago, and still is not fixed

https://bugs.python.org/issue32824#msg312028

and the documentation is even older.  It starts off referencing
"Mac OS X 10.8" and Apple Documents that are archived.

Then the section referencing using the Finder and Python Launcher does not work 
with macOS Catalina. 

Can this finally be corrected?

--
messages: 368536
nosy: TotallyLost
priority: normal
severity: normal
status: open
title: Macintosh Documentation Still Bad
type: resource usage
versions: Python 3.8

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



[issue38739] pyperformance html5lib cannot import Mapping (and fails)

2019-11-11 Thread Travis Lazar


Travis Lazar  added the comment:

FYI: this affects tornado_http and django_template as well.

--

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



[issue38739] pyperformance html5lib cannot import Mapping (and fails)

2019-11-08 Thread Travis Lazar


Travis Lazar  added the comment:

Really appreciate all the commentary and references here. Thanks for that.

The resolution of disabling html5lib in pyperformance is good. I'll assume no 
html5lib benchmarking in pyperformance (master) until a version of html5lib is 
released compatible with 3.9.

Thanks again.

--

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



[issue38739] pyperformance html5lib cannot import Mapping (and fails)

2019-11-07 Thread Travis Lazar


Travis Lazar  added the comment:

Forgot to include that this was built on an aarch64 (Ampere eMAG) system.

--

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



[issue38739] pyperformance html5lib cannot import Mapping (and fails)

2019-11-07 Thread Travis Lazar


New submission from Travis Lazar :

When running pyperformance html5lib test, the application crashes with 
"ImportError: cannot import name 'Mapping' from 'collections' 
(/py3buildpath/lib/python3.9/collections/__init__.py)"

To reproduce:

1 - Build Python from source. I produced with git commit 
befa032d8869e0fab4732d910f3887642879d644 from cpython GitHub.

2 - Run pyperformance with: /py3buildpath/bin/pyperformance run 
--python=/py3buildpath/bin/python3 --venv venvpath -b html5lib -o output.json

3 - Immediate crash is seen with message:

#!/bin/sh
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_tokenizer.py",
 line 16, in 
from ._trie import Trie
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_trie/__init__.py",
 line 3, in 
from .py import Trie as PyTrie
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_trie/py.py",
 line 6, in 
from ._base import Trie as ABCTrie
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/html5lib/_trie/_base.py",
 line 3, in 
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' 
(/root/py3-tot-no/lib/python3.9/collections/__init__.py)
ERROR: Benchmark html5lib failed: Benchmark died
Traceback (most recent call last):
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/run.py",
 line 132, in run_benchmarks
bench = func(cmd_prefix, options)
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/benchmarks/__init__.py",
 line 244, in BM_html5lib
return run_perf_script(python, options, "html5lib")
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/run.py",
 line 98, in run_perf_script
run_command(cmd, hide_stderr=not options.verbose)
  File 
"/usr/local/src/pyperf-tot-no-venv/lib/python3.9/site-packages/pyperformance/run.py",
 line 66, in run_command
raise RuntimeError("Benchmark died")
RuntimeError: Benchmark died

--
components: Tests
messages: 356219
nosy: Travis Lazar
priority: normal
severity: normal
status: open
title: pyperformance html5lib cannot import Mapping (and fails)
type: crash
versions: Python 3.9

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



How do/can I generate a PKCS#12 file the cryptography module?

2019-02-13 Thread Travis Griggs
I’m using the cryptography module (https://cryptography.io/en/latest/) to try 
and generate some cert/key/identities.

It's pretty easy using said module to generate the contents of .pem file for a 
private key:

keyPEMBytes = privateKey.private_bytes( 
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.TraditionalOpenSSL,
encryption_algorithm=serialization.NoEncryption())

It’s also easy to generate the contents of a .cer/.pem file for an associated 
cert:

certBytes = certificate.public_bytes(encoding=serialization.Encoding.PEM)

But I need them (and their chain) balled up on a single .p12 (PKCS12) file. 
Said module documents how to parse/consume PKCS12 formats, but nothing (that I 
can find) about how one can generate them.

My understanding of PKI stuff is hit and miss though, so maybe I'm just not 
searching the right keyword in the documentation?

I can create the .p12 file at the command line on Linux using

openssl pkcs12 -export -out myIdentity.p12 -inkey myPrivKey.pem -in 
myCert.crt -certfile myCertChain.crt

So I could just wrap calls like this with subprocess/cmd and mess with 
tempfiles/pipes. I was hoping to keep it all in memory/python though.

Is there a different python TLS library that I should be considering, that can 
do this?

(stack overflow version if you’re into the points and all that: 
https://stackoverflow.com/questions/54677841/how-do-can-i-generate-a-pkcs12-file-using-python-and-the-cryptography-module)


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


More elegant way to avoid this hacky implementation of single line reduce for grouping a collection?

2019-01-25 Thread Travis Griggs
Yesterday, I was pondering how to implement groupby, more in the vein of how 
Kotlin, Swift, Objc, Smalltalk do it, where order doesn’t matter. For example:

def groupby(iterable, groupfunc):
result = defaultdict(list)
for each in iterable:
result[groupfunc(each)].append(each)
return result

original = [1, 2, 3, 4, 5, 1, 2, 4, 2]
groupby(original, lambda x: str(x)) ==> {‘1’: [1, 1], ‘2’: [2, 2, 2], ‘3’: 
[3], ‘4’: [4, 4], ‘5’: [5]}

Easy enough, but I found myself obsessing about doing it with a reduce. At one 
point, I lost sight of whether that was even a better idea or not (the above is 
pretty simple); I just wanted to know if I could do it. My naive attempt didn’t 
work so well:

grouped = reduce(
lambda grouper, each: grouper[str(each)].append(each),
allValues,
defaultdict(list))

Since the result of the append() function is None, the second reduction fails, 
because the accumulator ceases to be a dictionary.

I persisted and came up with the following piece of evil, using a tuple to move 
the dict reference from reduction to reduction, but also force the (ignored) 
side effect of updating the same dict:

grouped = reduce(
lambda accum, each: (accum[0], accum[0][str(each)].append(each)),
allValues,
(defaultdict(list), None))[0]

My question, only for the sake of learning python3 fu/enlightenment, is there a 
simpler way to do this with a reduce? I get there’s lots of way to do a 
groupby. The pursuit here is what’s the simplest/cleverest/sneakiest way to do 
it with reduce, especially if the quality that gorupfunc (str() in this 
example) is only called once per item is persevered.


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


[issue34758] http.server module sets incorrect mimetype for WebAssembly files

2018-09-20 Thread Travis O'Neill


New submission from Travis O'Neill :

Mimetype is set to application/octet-stream for .wasm files instead of the 
correct application/wasm.  This causes streaming compile feature to fail 
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming).

--
components: Library (Lib)
messages: 325935
nosy: Travis O'Neill
priority: normal
severity: normal
status: open
title: http.server module sets incorrect mimetype for WebAssembly files
versions: Python 3.7

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



Google weirdness

2018-07-12 Thread Travis McGee
I somehow managed to trigger the dialog below by typing in a certain 
Python phrase to Google. Anyone know what it's about? It shows up in 
what appears to be terminal screen.


Viz:

Google has a code challenge ready for you.
Been here before?

This invitation will expire if you close this page.

Success! You've managed to infiltrate Commander Lambda's evil 
organization, and finally earned yourself an entry-level position as a 
Minion on her space station.


From here, you just might be able to subvert her plans to use the 
LAMBCHOP doomsday device to destroy Bunny Planet. Problem is, Minions 
are the lowest of the low in the Lambda hierarchy. Better buck up and 
get working, or you'll never make it to the top...


For a list of commands type help. To get started with your first 
challenge type request.


foobar:~/ guest$
--
https://mail.python.org/mailman/listinfo/python-list


Simplest way to clobber/replace one populated directory with another?

2018-05-15 Thread Travis Griggs
I have a directory structure that might look something like:

Data
Current
A
B 
C 
Previous
A 
X

In as simple/quick a step as possible, I want to rename Current as Previous 
including the contents and wiping out the original such that it is now:

Data
Previous
A
B
C

I've tried something like:

from pathlib import Path
src = Path('Data/Current’)
dest = Path('Data/Previous’)
src.replace(dest)

The docs led me to hope this would work:

"If target points to an existing file or directory, it will be 
unconditionally replaced.”

But it *does* appear to be conditional. I get a "Directory not empty" 
exception. I guess I could recursively delete the ‘Previous' directory first. 
Is that basically the only solution? Or is there a better way to achieve this?

(I prefer `pathlib`, but if `os` or `shutil` is the better hammer here, I'm not 
opposed to them)

(I am running on Linux)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33421] Missing documentation for typing.AsyncContextManager

2018-05-14 Thread Travis DePrato

Change by Travis DePrato <trav...@umich.edu>:


--
pull_requests: +6507

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



[issue33421] Missing documentation for typing.AsyncContextManager

2018-05-14 Thread Travis DePrato

Change by Travis DePrato <trav...@umich.edu>:


--
pull_requests: +6508

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



[issue33421] Missing documentation for typing.AsyncContextManager

2018-05-03 Thread Travis DePrato

New submission from Travis DePrato <trav...@umich.edu>:

The documentation for the typing module makes no mention of 
AsyncContextManager, which is defined in Lib/typing.py as

AsyncContextManager = _alias(contextlib.AbstractAsyncContextManager, T_co)

as of >= Python 3.8; before 3.8, no such AbstractAsyncContextManager class 
exists.

--
assignee: docs@python
components: Documentation
messages: 316145
nosy: Travis DePrato, docs@python, eric.araujo, ezio.melotti, willingc
priority: normal
severity: normal
status: open
title: Missing documentation for typing.AsyncContextManager
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8

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



Re: Most pythonic way to implement byte stuffing algorithm

2018-04-17 Thread Travis Griggs


> On Apr 17, 2018, at 11:15 AM, MRAB <pyt...@mrabarnett.plus.com> wrote:
> 
> On 2018-04-17 17:02, Travis Griggs wrote:
>> I posted this on SO, but… yeah…
>> I'm doing some serial protocol stuff and want to implement a basic byte 
>> stuffing algorithm in python. Though really what this really generalizes to 
>> is “what is the most pythonic way to transform one sequence of bytes where 
>> some bytes are passed through 1:1, but others are transformed to longer 
>> subsequences of bytes?” I’m pretty sure this rules out the use of 
>> transform() which expects a 1:1 mapping.
> [snip]
> There are only 256 possible input bytes, so just put them into a dict and 
> look them up.
> -- 
> https://mail.python.org/mailman/listinfo/python-list


So something like this?

LUT = list(bytes([x]) for x in range(256))
LUT[PacketCode.Escape] = bytes([PacketCode.Escape, PacketCode.Escape ^ 0xFF])
LUT[PacketCode.Start] = bytes([PacketCode.Escape, PacketCode.Start ^ 0xFF])
LUT[PacketCode.Stop] = bytes([PacketCode.Escape, PacketCode.Stop ^ 0xFF])
def stuff6(bits):
   return b''.join(LUT[x] for x in bits)

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


Most pythonic way to implement byte stuffing algorithm

2018-04-17 Thread Travis Griggs
I posted this on SO, but… yeah… 

I'm doing some serial protocol stuff and want to implement a basic byte 
stuffing algorithm in python. Though really what this really generalizes to is 
“what is the most pythonic way to transform one sequence of bytes where some 
bytes are passed through 1:1, but others are transformed to longer subsequences 
of bytes?” I’m pretty sure this rules out the use of transform() which expects 
a 1:1 mapping.


So far, I've come with 5 different approaches, and each of them has something I 
don't like about it:

1 Via Generator

def stuff1(bits):
for byte in bits:
if byte in _EscapeCodes:
yield PacketCode.Escape
yield byte ^ 0xFF
else:
yield byte

This may be my favorite, but maybe just because I'm kind of fascinated by yield 
based generators. I worried that the generator would make it slow, but it's 
actually the second fastest of the bunch.


2 Simply bytes()

def stuff2(bits):
result = bytes()
for byte in bits:
if byte in _EscapeCodes:
result += bytes([PacketCode.Escape, byte ^ 0xFF])
else:
result += bytes([byte])
return result

Constantly has to create single element arrays just to throw them out because 
I'm not aware of any "copy with one additional element" operation. It ties for 
the slowest of the bunch.


3 Use bytearray()

def stuff3(bits):
result = bytearray()
for byte in bits:
if byte in _EscapeCodes:
result.append(PacketCode.Escape)
result.append(byte ^ 0xFF)
else:
result.append(byte)
return result

Seems better than the direct bytes() approach. Actually slower than the yield 
generator and can do one byte at a time (instead of needing intermediate 1 
element collections). But it feels brutish. It's middle of the pack performance.


4 BytesIO()

def stuff4(bits):
bio = BytesIO()
for byte in bits:
if byte in _EscapeCodes:
bio.write(bytes([PacketCode.Escape, byte ^ 0xFF]))
else:
bio.write(bytes([byte]))
return bio.getbuffer()

I like the stream based approach here. But it is annoying that there doesn't 
seem to be something like a write1() API that could just add 1 byte, so I have 
to make those intermediate bytes again. If there was a "write single byte", I'd 
like this one. It ties for slowest.


5 Use replace()

def stuff5(bits):
escapeStuffed = bytes(bits).replace(bytes([PacketCode.Escape]), 
bytes([PacketCode.Escape, PacketCode.Escape ^ 0xFF]))
stopStuffed= escapeStuffed.replace(bytes([PacketCode.Stop]), 
bytes([PacketCode.Escape, PacketCode.Stop ^ 0xFF]))
return stopStuffed.replace(bytes([PacketCode.Start]), 
bytes([PacketCode.Escape, PacketCode.Start ^ 0xFF]))

This is the fastest. But I don't like the way the code reads and the 
intermediate sweeps.
-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: AnacondaCON February 7-9, Austin TX --- Python powered Open Data Science Conference

2017-01-12 Thread Travis Oliphant
AnacondaCON February 7-9, Austin Texas
  http://anacondacon17.io

3-day Anaconda Open Data Science User Conference celebrating a strong
Python success story.


Hello everyone,

It has been 5 years since Peter Wang and I started Continuum Analytics with
the objective of expanding the commercial adoption of Python for
data-science, quantitative, computational, and numerical computing.  Thanks
to the amazing community and my colleagues at Continuum we've seen that
objective come to fruition and company after company is choosing Python as
their forward looking numerical computing modeling and data-science
language.

We created Anaconda to make it easy for individuals and organizations to
adopt the rich suite of tools and libraries that are commonly used by
scientists, engineers, and mathematicians.  As Anaconda has lowered the
barrier for people to adopt the open data science software stack we've seen
a significant increase in use by people who previously were unlikely to
move beyond Excel, and organizations who are recognizing the kind of value
that a strategic investment in Python can bring them.

Nearly 8 million people have downloaded Anaconda this year many of whom are
using Python for the first time (and choosing Python 3.X).  It's been a
dream come true to see all of our early efforts around SciPy, NumPy, and
Python come to fruition in the enterprise.   It's been an incredible
journey and is something the Python community can and should celebrate.

With that background I am excited to announce AnacondaCON, a 3 day Anaconda
user conference happening February 7-9 in Austin Texas.  We currently have
2-for-1 pricing until January 16th (2 tickets for $999).   We have an amazing
line up of speakers from industry, government, academia and, of course,
Continuum. https://anacondacon17.io/speakers/

Peter and I will both be speaking there.  I will be speaking about the
future of open data science including what community-oriented open-source
technologies we specifically will be working on and contributing to that
continue the success of numpy, scipy, pandas, conda, numba, bokeh, dask,
spyder, holoviews, phosphorjs, jupyter, and more.

I will also be discussing some ideas we are pursuing on the future of array
computing for Python 3.X and how to build a substructure for vector
computing that integrates better with the broader Python ecosystem and is
inspired by and can use the typing hints becoming popular in Python 3.X.

Python's future in technical computing and data science has never been
brighter and AnacondaCON is a great opportunity to connect with an
interesting segment of this larger community and catch up with others
interested in enterprise adoption of Python for data science and numerical
/ technical computing.

I really hope to see you there.

Best,

Travis Oliphant
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-25 Thread Travis Griggs

> On Oct 25, 2016, at 5:55 AM, Chris Angelico  wrote:
> 
> On Tue, Oct 25, 2016 at 11:45 PM, Marko Rauhamaa  wrote:
>> Chris Angelico :
>> 
>>> On Tue, Oct 25, 2016 at 11:09 PM, Marko Rauhamaa  wrote:
 Blocking calls are evil.
>>> 
>>> Oh, that's why. Got it. So because blocking calls are fundamentally
>>> evil, we have to... what? What's so bad about them? Remember, not
>>> every program is a server handling myriad clients.
>> 
>> Myriads or not, we are talking about interactive (or reactive) programs.
>> The paradigm of choice is event-driven programming.
> 
> Have you watched "Tron"? A program goes to the I/O tower to receive a
> message from the User. It's an active operation on the part of the
> program. The user cannot initiate it, only the program can.
> 
> Tron is extremely accurate in this way.

Thanks for this ChrisA. Rest of this thread has been meh for me, but this one 
post, definitely won my MostValueablePost for the thread. :)

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


Re: Why don't we call the for loop what it really is, a foreach loop?

2016-09-14 Thread Travis Griggs


> On Sep 13, 2016, at 13:57, rgrigo...@gmail.com wrote:
> 
> It would help newbies and prevent confusion.

for each in ['cake'] + ['eat', 'it'] * 2:
print(each)


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


[issue27217] IDLE 3.5.1 not using Tk 8.6

2016-06-04 Thread Glenn Travis

Glenn Travis added the comment:

Alas, I apologize

--

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



[issue27217] IDLE 3.5.1 not using Tk 8.6

2016-06-04 Thread Glenn Travis

Glenn Travis added the comment:

Thank you again,
Does that mean that I will need to reinstall 8.6 when python 3.6 comes out?
> On Jun 4, 2016, at 11:34 AM, Ned Deily <rep...@bugs.python.org> wrote:
> 
> 
> Ned Deily added the comment:
> 
> Well, 8.6 is the latest version of Tcl/Tk but, because Apple does not yet 
> ship 8.6 in OS X, we have continued to use 8.5.  That will change in Python 
> 3.6.
> 
> --
> 
> ___
> Python tracker <rep...@bugs.python.org>
> <http://bugs.python.org/issue27217>
> ___

--

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



[issue27217] IDLE 3.5.1 not using Tk 8.6

2016-06-04 Thread Glenn Travis

Glenn Travis added the comment:

Ok, 
Thank you. I wonder why they have OS X version 8.6, which seems to be the 
default dl link page?
> On Jun 4, 2016, at 11:25 AM, Ned Deily <rep...@bugs.python.org> wrote:
> 
> 
> Ned Deily added the comment:
> 
> Assuming you are using the Python 3.5.1 from the python.org OS X binary 
> installer, you need to install a version of Tcl/Tk 8.5 (such as ActiveTcl 
> 8.5.18), not 8.6, as is described here: 
> https://www.python.org/download/mac/tcltk/.
> 
> --
> resolution:  -> not a bug
> stage: test needed -> resolved
> status: open -> closed
> type: behavior -> 
> 
> ___
> Python tracker <rep...@bugs.python.org>
> <http://bugs.python.org/issue27217>
> ___

--

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



[issue27217] IDLE 3.5.1 not using Tk 8.6

2016-06-04 Thread Glenn Travis

New submission from Glenn Travis:

I do not know if this is truly an issue, but it is a concern to me. 

I installed Tk 8.6 after reading all the Macintosh OS warnings online and in 
the IDLE window. However, according to the About IDLE box, IDLE is still 
"using" 8.5; and the warning still appears when I open IDLE. 

I may have missed it, but I did not see any way update IDLE or some Unix file 
to correct this in the online documentation.

--
files: About IDLE.png
messages: 267255
nosy: Old Sub Sailor
priority: normal
severity: normal
status: open
title: IDLE 3.5.1 not using Tk 8.6
type: resource usage
Added file: http://bugs.python.org/file43196/About IDLE.png

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



Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-31 Thread Travis Griggs

> On Mar 30, 2016, at 2:36 PM, Gregory Ewing  
> wrote:
> 
> Tim Golden wrote:
> 
>> (I don't know how other English-speaking groups say the word, but in
>> England the first syllable is stressed and the second is the
>> conventional short "uh" sound).
> 
> I can attest that New Zealand follows the UK on this. I was
> surprised when I first heard an American pronounce it too.
> 
> The curious can hear the difference on these pages:
> 
> British:  http://www.oxforddictionaries.com/definition/english/python
> American: http://www.dictionary.com/browse/python?s=t

That does it. If I ever make some sort of open source module for pythun/pythawn 
I’ll be sure to call it either tuhmayto/tomawto. Or maybe I’ll call it 
puhtayto/potawto.

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


How to fix my imports/file structure

2016-01-20 Thread Travis Griggs
I wrote a simple set of python3 files for emulating a small set of mongodb 
features on a 32 bit platform. I fired up PyCharm and put together a directory 
that looked like:

minu/
client.py
database.py
collection.py
test_client.py
test_database.py
test_client.py

My imports are simple. For example, client.py has the following at the top:

from collection import Collection

Basically, client has a Client class, collection has a Collection class, and 
database has a Database class. Not too tough.

As long as I cd into the minu directory, I can fire up a python3 interpreter 
and do things like:

>>> from client import Client
>>> c = Client(pathstring='something’)

And everything just works. I can run the test_files as well, which use the same 
sorts of imports.

I'd like to modularize this, so I can use it another project by just dropping 
the minu directory alongside my application's .py files and just have 
everything work. E.g.

SomeDirectory/
application.py
minu/
…

and application.py does something like:

from minu.client import Client

When I try this though, and am running python3 from another directory, the 
local imports don't work. I placed an empty init.py in the minu directory. That 
made it so I could import minu. But the others broke. I tried using things like 

from .collection import Collection #added the dot

but then I can't run things in the original directory anymore, like I could 
before. What is the simple/right way to do this?

I have looked around a bit with Dr. Google, but none of the examples really 
clarify this well (at least, for me), feel free to point out the one I missed.
-- 
https://mail.python.org/mailman/listinfo/python-list


Confused by python-dbus weird behavior

2016-01-11 Thread Travis Griggs
This may not be a great list for this question (which would be?); it’s a big 
group, and I’m hoping there’s some people here that cross into these same areas.

I’m new to dbus, it seems it’s a sort of CORBA for the Linux world. :) Python 
seems to be a popular way to interact with it. I’m trying to interact with the 
BlueZ services for Bluetooth LE stuff, and the scant hints I can find seem to 
indicate dbus is the preferred way going forward. The BlueZ distribution even 
provides example code. That said, my question should be independent of whether 
this was BLE or a dbus interface for a Calculator program.

There is a class defined as such:

class Characteristic(dbus.service.Object):
def __init__(self, bus, index, uuid, flags, service):
# … set a bunch of attributes
dbus.service.Object.__init__(self, bus, self.path)

@dbus.service.method(GATT_CHRC_IFACE, in_signature='ay')
def WriteValue(self, value):
print('Default WriteValue called, returning error’)
raise NotSupportedException()

Then I have a subclass of my own:

class MyCharacteristic(Characteristic):
def __init__(self, bus, index, uuid, flags, service):
Characteristic.__init__(self, bus, index, uuid, flags, service)
# … set some of my own attributes

def WriteValue(self, value):
print(‘Got write value:’, value)
self.anotherMethod(value)
print(‘back from anotherMethod’)

def anotherMethod(self, value):
print(‘pondering this value:’, value)

My program does not call WriteValue directly. It seems to be called by the 
bluetooth machinery. The mainloop, or something like that. I don’t honestly 
know. I just know I use some other boilerplate code involving registration and 
the mainloop, to get it all running. And so the MyCharacteristic.WriteValue() 
method DOES get fired. I see the output. But when it gets to the anotherMethod 
call, it just seems to... not. More callbacks may fire later. But that’s the 
end of that one. I’ve tried this under python2 AND python3.

So my basic python-dbus question is: Is this some nuance where a callback 
method, inheriting from what looks like a proxy of some sort 
(dbus.service.Object) should/can not send messages to itself?

Help me python-obis, help me. You’re my only hope.


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


Re: When I need classes?

2016-01-11 Thread Travis Griggs

> On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach  
> wrote:
> 
> Essentially, classes (as modules) are used mainly for organizational purposes.
> 
> Although you can solve any problem you would solve using classes
> without classes, solutions to some big problems may be cheaper and
> more feasible using classes.

As a long term OO purist practitioner, I would add to this. Obviously, you can 
organize your code any way you want, with or without classes. You could put all 
your functions with an odd number of letters in one class, and all of the even 
numbered ones in another class. 

Having listened to the guy (Alan Kay) who coined the term (Object Oriented 
Programming) quite a bit over the years, I believe that the focus of OO (of 
which classes are a particular implementation approach) is to bind behavior to 
data. In “traditional” programming approaches, one focused on the algorithm 
(behavior) first, and then figured out what data needed to flow where to get 
the job done. Classes provided a mechanism to turn that equation, generally 
speaking, around. One thinks about the data first, and then figures out what 
behavior binds best to that data. And how that data will interact (inter-object 
behavior, often called messages) to get your job done. For some (many) 
problems, this can be a real win. And for some, not so much.

I think, this is often why, for a simple script, OO just kind of gets in the 
way. You have a straightforward procedure that you just want to do. The state 
(data) is not rich enough to make making it the focal point of your program.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24628] load_workbook giving ValueError: invalid literal for int()

2015-07-13 Thread Travis

New submission from Travis:

This code works fine with all my workbooks except the one with a heavier amount 
of data. Please let me know if you want the excel file I am trying to open with 
this code.

--
components: IDLE, IO, Installation, Interpreter Core, Library (Lib), Macintosh
files: Test2.py
messages: 246701
nosy: ned.deily, ronaldoussoren, traviswilcox
priority: normal
severity: normal
status: open
title: load_workbook giving ValueError: invalid literal for int()
type: compile error
versions: Python 2.7
Added file: http://bugs.python.org/file39920/Test2.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24628
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Simplest/Idiomatic way to count files in a directory (using pathlib)

2015-06-22 Thread Travis Griggs
I should proof my posts before I send them, sorry

Subject nearly says it all.

If i’m using pathlib, what’s the simplest/idiomatic way to simply count how 
many files are in a given directory?

I was surprised (at first) when

   len(self.path.iterdir())

didn’t work.

I don’t see anything in the .stat() object that helps me.

I could of course do the 4 liner:

   count = 0
   for _ in self.path.iterdir():
   count += 1
   return count

The following seems to obtuse/clever for its own good:

   return sum(1 for _ in self.path.iterdir())
-- 
https://mail.python.org/mailman/listinfo/python-list


Simplest/Idiomatic way to count files in a directory (using pathlib)

2015-06-22 Thread Travis Griggs
Subject nearly says it all.

If i’m using pathlib, what’s the simplest/idiomatic way to simply count how 
many files are in a given directory?

I was surprised (at first) when

len(self.path.iterdir())

I don’t say anything on the in the .stat() object that helps me.

I could of course do the 4 liner:

count = 0
for _ in self.path.iterdir():
count += 1
return count

The following seems to obtuse/clever for its own good:

return sum(1 for _ in self.path.iterdir())
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23915] traceback set with BaseException.with_traceback() overwritten on raise

2015-04-12 Thread Travis A. Everett

Travis A. Everett added the comment:

Thanks, Martin--I should've thought to check to see if it'd just been pushed 
back in the list. I was just focusing on a workaround for another problem and 
did a double-take when the traceback value didn't match what was set.

This resolution is fine by me, but a note in the doc for with_traceback 
(https://docs.python.org/3/library/exceptions.html#BaseException.with_traceback)
 that it'll be immediately bumped back in the list when raised (as in the 
documentation's usage example) might help clarify for others.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23915
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23915] traceback set with BaseException.with_traceback() overwritten on raise

2015-04-11 Thread Travis A. Everett

New submission from Travis A. Everett:

When BaseException.with_traceback(tb) is used, the __traceback__ property is 
properly set, but the property gets overwritten when the exception is raised. 

The attached file demonstrates the issue by raising exception a, which doesn't 
use with_traceback, and exception b, which uses 
with_traceback(a.__traceback__). It also demonstrates that the exception object 
can't observe this change. Executing the attached file produces output like:

a.__traceback__ before raise: [None]
a.__traceback__ after raise : [traceback object at 0x7f95c5a21708]
b.__traceback__ before raise: [traceback object at 0x7f95c5a21708]
b.__traceback__ after raise : [traceback object at 0x7f95c5a21748]

--
files: exctest.py
messages: 240483
nosy: abathur
priority: normal
severity: normal
status: open
title: traceback set with BaseException.with_traceback() overwritten on raise
type: behavior
versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file38898/exctest.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23915
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23902] let exception react to being raised or the setting of magic properties (like __cause__) within Python

2015-04-09 Thread Travis Everett

New submission from Travis Everett:

I've been working on a testing tool which raises its own exceptions from those 
thrown by code under test. The tool's exceptions do some analysis to categorize 
and add additional information to the underlying exceptions, and they need 
access to the __cause__ property in order to build this information.

Unfortunately, because the __cause__ property isn't available on the exception 
objects at init time, some number of workarounds must be employed which make 
the exception harder to use properly and code handling it less intuitive. While 
the workarounds are fine at the moment, it would be ideal if the exceptions 
could be notified instead of burdening the site of each use with workarounds.

It seems sufficient to call a magic method on the exception immediately after 
these the traceback/cause/context parameters have been set while it is being 
raised, allowing the exception to perform any essential work. A 
bells-and-whistles implementation might be a magic method called at raise time 
with all of these properties as arguments (and the responsibility to deal with 
them)--but I assume there are reasons exception objects don't already have this 
level of control.

--
messages: 240377
nosy: abathur
priority: normal
severity: normal
status: open
title: let exception react to being raised or the setting of magic properties 
(like __cause__) within Python
type: enhancement
versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23902
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Concatenating Strings

2015-04-09 Thread Travis Griggs
I was doing some maintenance now on a script of mine… I noticed that I compose 
strings in this little 54 line file multipole times using the + operator. I was 
prototyping at the time I wrote it and it was quick and easy. I don’t really 
care for the way they read. Here’s 3 examples:

if k + ‘_@‘ in documents:

timeKey = k + ‘_@‘

historyKey = thingID + ‘_’ + k

I’m curious where others lean stylistically with this kind of thing. I see *at 
least* 2 other alternatives:

Use join():

if ‘’.join((k, ‘_@‘)) in documents:

timeKey = ‘’.join((k, ‘_@‘))

historyKey = ‘_’.join((thingID, k))

I don’t really like any of these. Maybe the 3rd, but I’d really rather see the 
pattern out. I also don’t like that I have to double the parens just to get a 
single arg joinable tuple for join()

Use format():

if ‘{}_@‘.format(k) in documents:

timeKey =  ‘{}_@‘.format(k)

historyKey = ‘{}_{}’.format(thingID, k)

I like these because you see a template of the values. But its still longer 
than just using +.

So I’m curious from those more seasoned, when they tend to use which 
approaches, and why.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [SerialConnection] Help

2015-04-09 Thread Travis Griggs

 On Apr 7, 2015, at 8:42 AM, Hugo Caldas hcalda...@gmail.com wrote:
 
  read and write the port values with multi threading 

Care to elaborate what you mean by this part? In general, serial ports and 
multi threading don’t mix well. IOW, you’ll need to use multithreading pieces 
to make sure you serialize your access to your serial port.

As other have pointed out, pyserial is the package you want. Documentation is 
pretty good. We use it a lot. -- 
https://mail.python.org/mailman/listinfo/python-list


Re: MicroPython 1.4.1 released

2015-04-09 Thread Travis Griggs

 On Apr 4, 2015, at 4:43 PM, Damien George damien.p.geo...@gmail.com wrote:
 
 Hello everyone,
 
 We are pleased to announce the release of MicroPython version 1.4.1!
 
 MicroPython is an implementation of Python 3.4 which is optimised for
 systems with minimal resources, including microcontrollers.
 
 Since our last announcement, this release is both more micro and
 more Python.
 
 Code size of the bare Thumb2 architecture version has dropped to under
 71k (without reduction of features), the RAM usage has been further
 optimised, and support for 16-bit microcontrollers has been proven via
 the port to a PIC microcontroller with just 8k RAM.
 
 On the Python side of things, there is now a stackless mode with
 both strict and non-strict behaviour.  Strict will always use the heap
 to allocate a call frame, where non-strict will fall back to the C
 stack if the heap is exhausted.  More special methods have been
 implemented, along with proper descriptors, OrderedDict class, basic
 frozen module support and the ability to override builtins, among
 other things.
 
 The test suite has grown and coverage of the code is now beyond 91%.
 
 Many other features have been implemented for the ports to various
 microcontroller platforms, bugs have been fixed and the docs have been
 improved.  A full change log is available at
 https://micropython.org/resources/micropython-ChangeLog.txt .
 
 For more information about the project please visit
 http://micropython.org/
 https://github.com/micropython/micropython

This is cool. I’m glad you guys are doing this and glad you are seeing some 
promise and success. I’ve enjoyed reading your updates, especially the 
technical ones. I wish you’d do one on whatever you’re doing for memory 
management in your particular python variant. GC in a tightly constrained 
environment is interesting.

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


Re: Newbie looking for elegant solution

2015-03-25 Thread Travis Griggs

 On Mar 24, 2015, at 8:28 PM, Chris Angelico ros...@gmail.com wrote:
 
 On Wed, Mar 25, 2015 at 2:13 PM,  otaksoftspamt...@gmail.com wrote:
 I have a list containing 9600 integer elements - each integer is either 0 or 
 1.
 
 Starting at the front of the list, I need to combine 8 list elements into 1 
 by treating them as if they were bits of one byte with 1 and 0 denoting bit 
 on/off (the 8th element would be the rightmost bit of the first byte).
 
 Speed is not of utmost importance - an elegant solution is. Any suggestions?
 
 Oooh fun!
 
 l = [1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 
 1]
 list(int(''.join(str(i) for i in l),2).to_bytes(len(l)//8,'big'))
 [177, 105, 117]
 
 Convert it into a string, convert the string to an integer
 (interpreting it as binary), then convert the integer into a series of
 bytes, and interpret those bytes as a list of integers.
 
 Example works in Python 3. For Python 2, you'll need ord() to get the
 integers at the end.
 
 I'm not sure how elegant this is, but it's a fun trick to play with :)
 
 Next idea please! I love these kinds of threads.

Me too. These are my favorite threads. Here’s my entry:

[sum(b  (7 - i) for i, b in enumerate(bits)) for bits in zip(*[l[n::8] for n 
in range(8)])]

I think there has to be a better way to do the left hand part, but I liked the 
zipped iterators on 8 slices.

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


Re: Python Worst Practices

2015-03-02 Thread Travis Griggs

 On Mar 1, 2015, at 5:53 PM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
 
 On Sun, 1 Mar 2015 20:16:26 + (UTC), alister
 alister.nospam.w...@ntlworld.com declaimed the following:
 
 
 The language is called English, the clue is in the name. interestingly 
 most 'Brits' can switch between American English  English without too 
 much trouble (I still have a problem with Chips) 
 
   Okay... Is that a reference to (US) Fries, or US usage reference to
 (UK) Crisps.
 
   Might as well add the confusion of biscuit  cookie (my biscuits look
 like your scones)... And lets not bring up the subject of suspenders...
 Bonnets, boots, and lifts.
 
   A pub's a bar; a bar's a gate; a gate's a street

Reminds me of Richard Lederer’s writings. 

http://www.etni.org.il/farside/crazyenglish.htm

Whether or not Brits should sprinkle the letter ‘u’ around for some extra 
spice, seems like the very smallest of our worries.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyston 0.3 self-hosting

2015-02-27 Thread Travis Griggs

 On Feb 24, 2015, at 9:47 PM, Steven D'Aprano 
 steve+comp.lang.pyt...@pearwood.info wrote:
 
 Pyston 0.3, the latest version of a new high-performance Python 
 implementation, has reached self-hosting sufficiency:
 
 
 http://blog.pyston.org/2015/02/24/pyston-0-3-self-hosting-sufficiency/
 

Does it do python3.4 yet?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Worst Practices

2015-02-27 Thread Travis Griggs

 On Feb 25, 2015, at 12:45 PM, Mark Lawrence breamore...@yahoo.co.uk wrote:
 
 http://www.slideshare.net/pydanny/python-worst-practices
 
 Any that should be added to this list?  Any that be removed as not that bad?

I read ‘em. I thought they were pretty good, some more than others. And I 
learned some things. I especially liked the first one, since I’ve struggled 
with that one a bunch. In the context of “hey, accept Python for what it is”, I 
agree greatly with it. Memorize the builtins, and stay the heck away from them. 
I’ve been burned many times because I stored some bytes in a binding call, er, 
uh, ‘bytes’. And having mentored some people learning Python in the early 
stages, any explanation other than “Thou Shalt Never Use These Holy Words” just 
confuses people.

That said… 

If I were giving a talk at SPLASH (or some other suitable polyglot conference), 
I might do one called “Language Design Worst Practices”.

One of my first slides might be titled:

Abuse Common Tokens in Confusing Ways

* Make your language have a lot of keywords. Enough to make memorizing them ALL 
unlikely, requiring constant visits to your documentation
* Make sure said keywords are many of the obvious words programmers would use 
in their applications (map, object, bytes, dir, etc)
* Design your syntax so that you can’t disambiguate them contextually between 
bind and reference
* Be sure to use it in a late bound language where no warnings will be provided 
about the mistake you’re making at authorship time, deferring the educational 
experience to sundry run times

In my examples column of this bad practice, I’d put Python of course. :)

I do like Python, and I accept it for what it is, so no one needs to jump 
forward as a Holy Python See to convert me to the truth. I also know that with 
most other languages, that first slide wouldn’t need to be one of the prominent 
“worst practices” slide.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python Peewee Query Example Needed

2015-02-16 Thread Travis VanDame
I'm new to python and peewee and was looking for an example on how to query a 
mysql table with a datetime column only returning rows that are 30 days old.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Peewee Query Example Needed

2015-02-16 Thread Travis VanDame
On Monday, February 16, 2015 at 12:35:00 PM UTC-6, Travis VanDame wrote:
 I'm new to python and peewee and was looking for an example on how to query a 
 mysql table with a datetime column only returning rows that are 30 days old.

Well this is what I've come up with

   @classmethod
def get_archive_xml(cls, day_count):
return cls.select().where(cls.created + 
datetime.timedelta(days=int(day_count)) = datetime.date.today())
-- 
https://mail.python.org/mailman/listinfo/python-list


pymongo and attribute dictionaries

2015-02-04 Thread Travis Griggs
I really like pymongo. And I really like Python. But one thing my fingers 
really get tired of typing is

someDoc[‘_’id’]

This just does not roll of the fingers well. Too many “reach for modifier keys” 
in a row. I would rather use

someDoc._id

Googling shows that I’m not the first to want to do this in the general sense 
(e.g. 
http://stackoverflow.com/questions/4984647/accessing-dict-keys-like-an-attribute-in-python).

Arguments aside of whether this should or shouldn’t be done, I want to know how 
I might solve this with Python. Consider it an academic pursuit.

The problem I have is not how to do the AttributeDictionary subclass, there are 
plenty of those examples. The problem is that the pymongo APIs already return 
dictionaries. In a language (Smalltalk, Objective-C, Ruby) that supports class 
extensions, that would be my first tool of choice to solve this problem. I’d 
just extend Dictionary to behave the way I want and be done with it. I can’t do 
that in Python though. I guess I could make my own module that subclasses the 
relevant pymongo classes, and do super() calling implementations of all of the 
relevant methods, coercing the return type. That is a maintenance headache 
though.

What are my options, if any?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pymongo and attribute dictionaries

2015-02-04 Thread Travis Griggs

 On Feb 4, 2015, at 9:22 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 
 On Wed, Feb 4, 2015 at 9:50 AM, Travis Griggs travisgri...@gmail.com wrote:
 I really like pymongo. And I really like Python. But one thing my fingers 
 really get tired of typing is
 
 someDoc[‘_’id’]
 
 This just does not roll of the fingers well. Too many “reach for modifier 
 keys” in a row. I would rather use
 
 someDoc._id
 
 Googling shows that I’m not the first to want to do this in the general 
 sense (e.g. 
 http://stackoverflow.com/questions/4984647/accessing-dict-keys-like-an-attribute-in-python).
 
 Arguments aside of whether this should or shouldn’t be done, I want to know 
 how I might solve this with Python. Consider it an academic pursuit.
 
 The problem I have is not how to do the AttributeDictionary subclass, there 
 are plenty of those examples. The problem is that the pymongo APIs already 
 return dictionaries. In a language (Smalltalk, Objective-C, Ruby) that 
 supports class extensions, that would be my first tool of choice to solve 
 this problem. I’d just extend Dictionary to behave the way I want and be 
 done with it. I can’t do that in Python though. I guess I could make my own 
 module that subclasses the relevant pymongo classes, and do super() calling 
 implementations of all of the relevant methods, coercing the return type. 
 That is a maintenance headache though.
 
 What are my options, if any?
 
 You could construct the AttributeDictionary by copying the dict
 returned from pymongo. The question then is whether the copying would
 be too expensive or not.
 
 Alternately, you could just wrap the dictionaries returned by pymongo
 in an object. Something like this should be all you need:
 
 class AttrDictWrapper(object):
def __init__(self, the_dict):
self.__dict__ = the_dict
 
 d = AttrDictWrapper({'spam': 42, 'ham': False})
 d.spam
 42
 d.ham
 False
 

Yes, that is clever. So if you wanted to minimize the amount of typing you had 
to do at all of your pymongo API call sites, what strategy would you use to 
keep that relatively terse?

Is the following the right approach to take?

class Doc(object):
def __init__(self, target):
self.__dict__ = target

and then something like

for doc in client.db.radios.find({’_id': {’$regex’: ‘^[ABC]'}}):
pprint(doc)

changes to

for doc in ((Doc(d) for d in client.db.radios.find({’_id': {’$regex’: 
‘^[ABC]'}})):
pprint(doc)

Are there other approaches? Feel free to impress me with evil abuses in the 
interest of academic enrichment...

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


Re: Cairo module

2015-02-03 Thread Travis Griggs

 On Feb 3, 2015, at 1:00 PM, Poul Riis prii...@gmail.com wrote:
 
 I just tried the Cairo Python module.
 I ran the test file below.
 It works perfectly but instead of saving the resulting image as a file I want 
 to see it displayed directly on the screen.
 How can I do that?
 

I have quiet a bit of experience with Cairo (I wrote language bindings for it 
in Smalltalk and had the time of my life with it there); I have no experience 
with the pycairo bindings.

 
 import math
 import cairo
 
 WIDTH, HEIGHT = 256, 256
 
 surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, WIDTH, HEIGHT)

This is your basic problem right here. And ImageSurface is for creating an 
Image (sometimes called a raster graphic or bitmap). If you want to display 
directly to your screen, you need to create a surface that binds to your 
screen’s display functionality. There is one for each main operating system:

Win32Surface
XLibSurface
QuartzSurface (I see that this is missing from the pycairo documentation, but 
it is in the cairo documentation, and the pycairo.c file at least has some 
reference to it)

Allocating one of these involves getting handles (and other information) for a 
given window on screen of your host OS and creating the surface from it.


 ctx = cairo.Context (surface)
 
 ctx.scale (WIDTH, HEIGHT) # Normalizing the canvas
 
 pat = cairo.LinearGradient (0.0, 0.0, 0.0, 1.0)
 pat.add_color_stop_rgba (1, 0.7, 0, 0, 0.5) # First stop, 50% opacity
 pat.add_color_stop_rgba (0, 0.9, 0.7, 0.2, 1) # Last stop, 100% opacity
 
 ctx.rectangle (0, 0, 1, 1) # Rectangle(x0, y0, x1, y1)
 ctx.set_source (pat)
 ctx.fill ()
 
 ctx.translate (0.1, 0.1) # Changing the current transformation matrix
 
 ctx.move_to (0, 0)
 ctx.arc (0.2, 0.1, 0.1, -math.pi/2, 0) # Arc(cx, cy, radius, start_angle, 
 stop_angle)
 ctx.line_to (0.5, 0.1) # Line to (x,y)
 ctx.curve_to (0.5, 0.2, 0.5, 0.4, 0.2, 0.8) # Curve(x1, y1, x2, y2, x3, y3)
 ctx.close_path ()
 
 ctx.set_source_rgb (0.3, 0.2, 0.5) # Solid color
 ctx.set_line_width (0.02)
 ctx.stroke ()
 
 surface.write_to_png (example.png) # Output to PNG 
 -- 
 https://mail.python.org/mailman/listinfo/python-list

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


Re: Is there a cairo like surface for the screen without the window hassle

2015-02-03 Thread Travis Griggs

 On Feb 2, 2015, at 5:20 AM, Antoon Pardon antoon.par...@rece.vub.ac.be 
 wrote:
 
 I need to have a program construct a number of designs. Of course I can 
 directly
 use a pfd surface and later use a pdf viewer to check. But that becomes rather
 cumbersome fast. But if I use a cairo-surface for on the screen I suddenly 
 have
 to cope with expose events and all such things I am not really interested in.
 
 So does someone know of a package that provides a cairo like surface but that
 would take care of the events in a rather straight forward matter, so that my
 program could make it's design in a window on the screen just as if it is
 designing it in a pdf file.
 

For the most part, you cannot draw directly to the screen with Cairo. Some OSes 
kind of allow out, but they won’t repaint it for you. Any viewing software that 
will auto detect file updates and reload would do the trick. For example, I 
know that preview on OS X will automatically reload a png file that I write. 
Cairo can generate png output. Just open preview on the file, and then have the 
program rewrite the same file.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue22536] subprocess should include filename in FileNotFoundError exception

2014-11-29 Thread Travis Thieman

Travis Thieman added the comment:

Thank you all for the helpful comments. A revised attempt is attached as 
-2.patch, with improved behavior around using cwd if the child is never called 
and orig_executable if it is. I opted not to fix the issue with the redundancy 
in the error message as I agree that should be handled as a separate issue.

--
Added file: 
http://bugs.python.org/file37322/22536-subprocess-exception-filename-2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22536
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22864] Add filter to multiprocessing.Pool

2014-11-15 Thread Travis Thieman

Travis Thieman added the comment:

Why is it insufficient to run a synchronous 'filter' over the list returned by 
'Pool.map'? These functional constructs are inherently composable, and we 
should favor composing simple implementations of each rather than implementing 
special cases of them throughout the stdlib.

I think there's a clear reason for 'map' to be parallelizable because the 
function you're applying over the iterable could be quite expensive. 'filter' 
would only benefit from this if the comparison you're running is expensive, 
which seems like an unlikely and ill-advised use case. You can also rewrite 
your expensive 'filter' as a 'map' if you really need to.

--
nosy: +travis.thieman

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22864
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22536] subprocess should include filename in FileNotFoundError exception

2014-11-15 Thread Travis Thieman

Travis Thieman added the comment:

The attached patch includes the first element in args in _execute_child to the 
OSError exception subclass. This correctly populates the 'filename' field on 
the resulting exception. A test is also included that fails without the patch.

--
keywords: +patch
nosy: +travis.thieman
Added file: 
http://bugs.python.org/file37202/22536-subprocess-exception-filename.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22536
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: FYI: Micro Python running on kickstarter pyBoard project, now shipping

2014-10-23 Thread Travis Griggs

 On Oct 23, 2014, at 2:11 PM, sohcahto...@gmail.com wrote:
 
 On Thursday, October 23, 2014 10:07:26 AM UTC-7, jkn wrote:
 Hi all
I haven't heard in mentioned here, but since I saw one of the boards 
 today thought I'd pass on the news:
 
 The Kickstarter 'MicroPython' project, which has a tiny 'pyboard' (only a 
 couple of sq.inches in size) with a processor running 'a complete re-write 
 of the Python (version 3.4) programming language so that it fits and runs on 
 a microcontroller' is now shipping.
 
https://micropython.org/
 
 Looks nice; I have no connection but will be getting one myself to play 
 with...
 
Cheers
J^n
 
 
 Is there any particular reason to get one of these when I can get a Raspberry 
 Pi which is faster, has more memory, and a bundle of other features?
 
 I mean, the idea seems cool and all, but I'm trying to understand why I would 
 want to spend the ~$45 on something like that when a ~$35 Raspberry Pi will 
 do everything and more, and do it faster.

Power Consumption.

I don’t know (looked quick, but didn’t find anything fast enough) the exact 
numbers, but the Pi is meant to be plugged in to something, or chew through 
batteries quickly. If your IoT device fits in that space and you need all that 
periphery, that’s great. The Pyboard is running a STM32F405RG (low power contex 
M4). So I’m betting various children of mine, that it can go a whole lot longer 
on the same bit of power. Coin cell operation for long periods is probable.

I think you look at the $45 as a development board. The site says you can get 
access to just about everything, so there’s nothing to keep you from 
prototyping your killer pythonic IoT gadget with these, then doing your own 
tiny board, populating them with the same chip that you can get from DigiKey 
for $7 a piece in quantity. Can’t really do that with the Pi.

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


Re: Toggle

2014-10-08 Thread Travis Griggs

On Oct 8, 2014, at 9:57 PM, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:

 Seymore4Head wrote:
 I want to toggle between color=Red and color=Blue


Don’t forget polymorphic dispatch…

class Red(object):
def toggle(self):
return Blue()

class Blue(object):
def toggle(self):
return Red()


Blue().toggle().toggle().toggle().toggle().toggle() :)

--
Travis Griggs
Objologist
Some of them wanted to sell me snake oil and I'm not necessarily going to 
dismiss all of these, as I have never found a rusty snake. --Terry Pratchett

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


Re: How to show a dictionary sorted on a value within its data?

2014-10-01 Thread Travis Griggs


Sent from my iPhone

 On Oct 1, 2014, at 04:12, Peter Otten __pete...@web.de wrote:
 
 `lambda` is just a fancy way to define a function inline

Not sure fancy is the correct adjective; more like syntactic tartness (a less 
sweet version of syntactic sugar).

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


Python stdout goes where under systemd? (Was: Example of python service running under systemd?)

2014-09-12 Thread Travis Griggs
Thanks all for the help/advice. I’m getting there.

To experiment/learn, I made a simple python program (/Foo/cyclic.py):
 
#!/usr/bin/env python3

import time

while True:
time.sleep(5)   
with open('sound', 'r') as file:
currentValue = file.read()
otherValue = 'tick' if currentValue == 'tock' else 'tock'
with open('sound', 'w') as file:
file.write(otherValue)
print(currentValue, '-', otherValue)

Run from the command line, this tick-tocks nicely, both outputting, as well as 
updating the ‘/Foo/sound’ file on a 5 second period.

I then created a simple .service file:

[Unit]
Description=Foo for learning service
After=network-online.target

[Service]
Type=simple
ExecStart=/Foo/cyclic.py
WorkingDirectory=/Foo
StandardOutput=journal

[Install]
WantedBy=multi-user.target

I chose to be “explicit” with some of the default options (Type and 
StandardOutput).
I finally executed:

systemctl --system daemon-reload
systemctl enable foo
systemctl start foo

It seems to work. Almost. The file is being updated regularly (watch cat 
/Foo/sound shows the change happening). But I can’t seem to find the output 
from my print() statement. journalctl -f doesn’t show anything. Nor does tail 
-f /var/log/syslog or any of the others. It just seems to be going nowhere? Is 
there something I need to do special to get the print() output going somewhere 
logable?

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


Re: Python stdout goes where under systemd? (Was: Example of python service running under systemd?)

2014-09-12 Thread Travis Griggs

On Sep 12, 2014, at 12:05 PM, Travis Griggs travisgri...@gmail.com wrote:

 Thanks all for the help/advice. I’m getting there.
 
 To experiment/learn, I made a simple python program (/Foo/cyclic.py):
 
#!/usr/bin/env python3
 
import time
 
while True:
time.sleep(5)  
with open('sound', 'r') as file:
currentValue = file.read()
otherValue = 'tick' if currentValue == 'tock' else 'tock'
with open('sound', 'w') as file:
file.write(otherValue)
print(currentValue, '-', otherValue)
 
 Run from the command line, this tick-tocks nicely, both outputting, as well 
 as updating the ‘/Foo/sound’ file on a 5 second period.
 
 I then created a simple .service file:
 
[Unit]
Description=Foo for learning service
After=network-online.target
 
[Service]
Type=simple
ExecStart=/Foo/cyclic.py
WorkingDirectory=/Foo
StandardOutput=journal
 
[Install]
WantedBy=multi-user.target
 
 I chose to be “explicit” with some of the default options (Type and 
 StandardOutput).
 I finally executed:
 
systemctl --system daemon-reload
systemctl enable foo
systemctl start foo
 
 It seems to work. Almost. The file is being updated regularly (watch cat 
 /Foo/sound shows the change happening). But I can’t seem to find the output 
 from my print() statement. journalctl -f doesn’t show anything. Nor does tail 
 -f /var/log/syslog or any of the others. It just seems to be going nowhere? 
 Is there something I need to do special to get the print() output going 
 somewhere logable?
 

Arghhh… I’ll answer my own question here. I wasn’t patient enough, when I 
checked after lunch, I found I had a mountain of tick/tock entries in 
journalctl -f. Python print() is buffered, so it wasn’t showing up except in 
huge blocks. Changed the .service file to start with -u and everything works as 
expected now.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newer Debian versions of python on older Debian distros?

2014-09-11 Thread Travis Griggs
On Sep 8, 2014, at 5:06 PM, Chris Angelico ros...@gmail.com wrote:

 Alternatively, you could just run Debian Jessie. I have a few Jessie
 systems on the network, with a Python 3.4 IIRC, and there've been no
 stability problems lately. Both options are pretty easy.

In the end, we were able to get jessie running on this little board (it’s an 
Atmel Xplained SAMA5D3 which boasts one of the lowest linux power 
consumptions). And that solved our problems.
-- 
https://mail.python.org/mailman/listinfo/python-list


Example of python service running under systemd?

2014-09-11 Thread Travis Griggs
I’ve been reading lots of systemd docs. And blogs. Etc. At this point, I think 
I would benefit from learning by example…

Does anyone have an example .service file that they use to launch a long 
running service written as a python program?

If there is any example of what you changed to your python program itself, that 
to would be really instructional for me.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Example of python service running under systemd?

2014-09-11 Thread Travis Griggs

On Sep 11, 2014, at 11:18 AM, Chris “Kwpolska” Warrick kwpol...@gmail.com 
wrote:

 Depends what you want. 

Mine is not a web service. My main.py looks like this:

#!/usr/bin/env python3

import cycle
import pushTelemetry
from threading import Thread

def main():
Thread(target=pushTelemetry.udpLoop).start()
Thread(target=cycle.cycleLoop).start()

if __name__ == '__main__':
main()

It basically creates two threads, one which does some local processing and 
control, the other which periodically does reporting via udp packets. I use the 
dual threads because they both work with a shared serial port at times, so I 
have to synchronize access through that.

What I want is to have this startup, after my board has it’s networking layer 
up and running (and hopefully a valid ip address by then), and to just keep 
running forever
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Example of python service running under systemd?

2014-09-11 Thread Travis Griggs

On Sep 11, 2014, at 2:29 PM, Ervin Hegedüs airw...@gmail.com wrote:

 Hi Travis,
 
 On Thu, Sep 11, 2014 at 02:06:48PM -0700, Travis Griggs wrote:
 
 On Sep 11, 2014, at 11:18 AM, Chris “Kwpolska” Warrick kwpol...@gmail.com 
 wrote:
 
 Depends what you want. 
 
 Mine is not a web service. My main.py looks like this:
 
 #!/usr/bin/env python3
 
 import cycle
 import pushTelemetry
 from threading import Thread
 
 def main():
Thread(target=pushTelemetry.udpLoop).start()
Thread(target=cycle.cycleLoop).start()
 
 if __name__ == '__main__':
main()
 
 It basically creates two threads, one which does some local processing and 
 control, the other which periodically does reporting via udp packets. I use 
 the dual threads because they both work with a shared serial port at times, 
 so I have to synchronize access through that.
 
 What I want is to have this startup, after my board has it’s networking 
 layer up and running (and hopefully a valid ip address by then), and to just 
 keep running forever
 
 may be you think about the fork(), eg:
 
 if __name__ == __main__:
...other codes, eg. drop root privileges, ...
...check arguments...
try:
  pid = os.fork()
  if pid  0:
  #print Daemon started (pid: %d) % (pid)
  sys.exit(0)
except OSError, e:
  print sys.stderr, fork #1 failed: %d (%s) % (e.errno, e.strerror)
  sys.exit(1)
 
os.chdir(/)
os.setsid()
os.umask(0)
 
# do second fork
try:
  pid = os.fork()
  if pid  0:
  #print Daemon started (pid: %d) % (pid)
  sys.exit(0)
except OSError, e:
  print sys.stderr, fork #2 failed: %d (%s) % (e.errno, e.strerror)
  sys.exit(1)
 
main()

OK, I’m probably going to show my naivety about something simple here…

I thought a “fork” essentially created a memory copy of the original process 
and let it go off running. The problem is, in the bowels of the code executing 
in those loops, I access a single instance of a threading.RLock, so that I can 
avoid both threads trying to do transactions with a single serial port at the 
same time. If I end up with two copies of the base process, unhooked from their 
parent, does that RLock still remain valid between the two? I thought since 
they were complete different copies of the same memory, they would no longer be 
coordinated.

Is this a day where I discover something new?
-- 
https://mail.python.org/mailman/listinfo/python-list


Newer Debian versions of python on older Debian distros?

2014-09-08 Thread Travis Griggs
(I realize that this may be seen as off topic for as a general python question, 
but given my historical experience with the Debian community’s predilection to 
answer all questions with a grumpy “go read the very very very very large and 
ever shifting fine manual”, I’m hoping for better luck here.)

Does anyone have experience with using newer versions of python debian packages 
(in particular, python3 and python3-bson-ext from ‘testing’) on older stable 
versions (‘wheezy’ in this case)? If someone’s figured out how to do this 
easily, I’d love to hear the recipe!

TIA


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


Halfway point between interactive and daemon?

2014-08-22 Thread Travis Griggs
I have a python3 program that performs a long running service on a semi 
embedded linux device. I've been in the prototyping stage.  I just run it from 
the command line and use print() statements to let me know the thing is making 
acceptable process.

At some point, I need to properly daemonize it. Write an init script, find a 
logging framework/module, batton all the hatches down, so to speak.

I’m curious if there’s a technique one could use to get half way there. 
Basically, with minimal modifications, I’d like to get it running at startup. 
So I can put a line like this in rc.local

nohup python3 myMain.py 21  /var/log/mylog.log 

Then I can “check” on it when I need to with a tail -f /var/log/mylog.log. But 
then I have the problem of managing the log size. And also I either have to 
wait for stdout to flush, or insert sys.stdout.flush() after any of my 
print()’s.

I haven’t done a lot of these daemon processes (and this is my first with 
python), so I was curious what those with experience do here.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: proposed syntax for multiline anony-functions (hopefully?)

2014-08-22 Thread Travis Griggs

On Aug 21, 2014, at 12:55 AM, icefap...@gmail.com wrote:

 Hi, just wanting to do a shot in the dark,but maybe this syntax is Pythonic 
 (in a we-are-all-grown-ups fashion, ahem)enough to get its way into the 
 language
 this is what yours truly thinks: don't we all know that : means the next 
 token must be an indent (mostly)? and doesn't the ( and its alikes, [ and } 
 begin an space-insensitive lexing context? so all we need is having an 
 space-sensitivity-stack and the corresponding ( counting stack and this 
 way we could match opening and closing () and pop the 
 space-sensitivity-stack whenever the ( counting stack gets a 0 at the top:
snip

Those more pythonista than me have weighed in on the particulars. I’ll offer 
some more general thoughts.

While I dwell in the land of pythonistas, I’m a an expat from the Island of 
Smalltalk. I live happily in Pythonville and will probably never return to the 
shrinking island, I do miss Smalltalk’s block closures. I don’t miss them *too* 
much, because things like comprehensions as well as the large library of 
functional like modules, covers many of the use cases. But I do miss their 
simple elegance.

I do not like the python lambda. For two reasons.

One: In a language that sought to be approachable by simple people (i.e. non 
computer science graduates who would use it in addition to their 
scientific/education background), I can’t believe they threw in a 6 character  
phonetic description of a greek character to imply “fragment of code expression 
to be executed in a removed context”. Show a subset of keyword.kwlist to a 
non-comp-sci guy and tell me if when they see the ‘lambda’ betwixt the others, 
they don’t stop and think “huh, one of these is not like the others”.

Two: The reason that this subject circles regularity, because they used a 
keyword, it can only be used as a literal creator for a single line expression. 
So we keep coming back to “how can we do multiple expressions with a 
lambda/closure”.

For the unaware, the Smaltalk syntax for a literal block closure was a pair of 
[ ]. First of all, I liked that the characters actually looked like a “block” 
with the corners. I liked that it did not use parentheses. Parentheses are 
pretty loaded already, and it helped the brain pick out the differences 
instantly. I don’t like the OP’s proposal because I don’t think (def()) is 
distinct from normal grouping () statements. And I liked how terse they are. 
Two characters and you had a block. They are *everywhere* in the library. 
Compare that with how often you find ‘lambda’ in the python standard modules. I 
used to joke about the irony, that no language did more with functional 
closures than the all-objects-all-the-time Smalltalk, and that CLOS had a more 
robust object model than Smalltalk.

To me, for a multiple-expression (multi line or not) literal closure syntax to 
succeed, it must a) denote both the start and stop (not a leading keyword), b) 
be extremely terse so that the cost of creating closures is reduced c) not be 
confused with other common literal denotation so it can be quickly recognized 
when reading close (so [ and { are out for example, because of lists and 
dictionaries, and using   would cause complete confusion because it’s hard at 
a glance to differentiate from a comparison operand).

Personally, I don’t think the desire to use lines as statement boundaries 
(something I like a lot) and at the same time to tersely pack multiple 
statements into a deferred code fragment, are reconcilable. And I don’t think 
there’s critical mass desire for them. So this subject will continue to 
resurface regularly. But I thought I’d chime in with a “foreigners” perspective.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: TypeError: 'bytes' object is not callable error while trying to converting to bytes.

2014-08-05 Thread Travis Griggs


 On Aug 4, 2014, at 22:57, Chris Angelico ros...@gmail.com wrote:
 
 On Tue, Aug 5, 2014 at 3:47 PM, Satish ML satishmlwiz...@gmail.com wrote:
 bytes = file.read()
 
 You've just shadowed the built-in type 'bytes' with your own 'bytes'.
 Pick a different name for this, and you'll be fine. 'data' would work.

Until python4 introduces the 'data' built in. :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP8 and 4 spaces

2014-07-05 Thread Travis Griggs

 On Jul 4, 2014, at 11:29, Lie Ryan lie.1...@gmail.com wrote:
 
 On 04/07/14 07:55, Gregory Ewing wrote:
 Steven D'Aprano wrote:
 
 That's exactly the problem with tabs - whatever you think your code
 looks like with tabs, other people will see quite different picture.
 
 Why do you consider this a problem?
 
 It's a problem if you try to use tabs for lining things
 up in a tabular fashion in your source code.
 
 The solution is not to use tabs for that -- only use
 tabs for indentation, and use spaces for everything
 else. Or, as PEP 8 suggests, don't try to line things
 up in the first place.
 
 PEP8 suggests using this style of method invocation:
 
obj.method(foo,
   bar,
   baz)
 
 which is an effect impossible to do correctly with tabs alone. If you want to 
 follow this style strictly, you end up having to either mix tabs and spaces, 
 or just use spaces, or as I prefer it, avoid the issue altogether:
 
obj.method(
foo,
bar,
baz,
)

Ok, here's irony. I'm looking at that thinking what the heck is he talking 
about?!?. And then my brain catches up. My mail reader is of course modern 
and does not use a mono space font. So the value of the along ed indent is lost 
anyway. But wasn't that what spaces were supposed to give us over tabs, some 
separation from the trading betwixt different editors? Chuckle.

Travis Griggs

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


Re: OT: This Swift thing

2014-06-06 Thread Travis Griggs


 On Jun 5, 2014, at 1:14, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote:
 
 Swift's memory management is similar to python's (ref. counting). Which
 makes me think that a subset of python with the same type safety would
 be an instant success.

Except that while you don't need to regularly worry about cycles in python, you 
do in swift. Which means you get to think constantly about direct and indirect 
cycles, figure out where to put weak stuff, when to use a local to keep a weak 
property alive until it finds it's strong home, etc.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-06 Thread Travis Griggs

On Jun 4, 2014, at 4:01 AM, Tim Chase python.l...@tim.thechases.com wrote:

 If you use UTF-8 for everything

It seems to me, that increasingly other libraries (C, etc), use utf8 as the 
preferred string interchange format. It’s universal, not prone to endian 
issues, etc. So one *advantage* you gain for using utf8 internally, is any time 
you need to hand a string to an external thing, it’s just ready. An app that 
reserves its internal string processing to streaming based ones but has to to 
hand strings to external libraries a lot (e.g. cairo) might actually benefit 
using utf8 internally, because a) it’s not doing the linear search for the odd 
character address and b) it no longer needs to decode/encode every time it 
sends or receives a string to an external library.

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


Re: IDE for python

2014-05-29 Thread Travis Griggs


 On May 28, 2014, at 3:43, Sameer Rathoud sameer.rath...@gmail.com wrote:
 
 Hello everyone,
 
 I am new to python.
 
 I am currently using python 3.3
 
 With python I got IDLE, but I am not very comfortable with this.
 
 Please suggest, if we have any free ide for python development.
 -- 
 https://mail.python.org/mailman/listinfo/python-list

I use either vim or textwrangler for simple one file scripts. For larger things 
with multiple files and/or classes, I like pycharm best ( free community 
edition ). I tried both pydev and wing before that.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How keep Python 3 moving forward

2014-05-24 Thread Travis Griggs


Sent from my iPhone

 On May 24, 2014, at 7:35, blindanagram no...@nowhere.net wrote:
 
 On 24/05/2014 08:13, wxjmfa...@gmail.com wrote:
 Le vendredi 23 mai 2014 22:16:10 UTC+2, Mark Lawrence a écrit :
 An article by Brett Cannon that I thought might be of interest 
 
 http://nothingbutsnark.svbtle.com/my-view-on-the-current-state-of-python-3
 
 
 
 -- 
 
 My fellow Pythonistas, ask not what our language can do for you, ask 
 
 what you can do for our language.
 
 
 
 Mark Lawrence
 
 
 
 ---
 
 This email is free from viruses and malware because avast! Antivirus 
 protection is active.
 
 http://www.avast.com
 
 =
 =
 
 Quote:
  And with Python 3.4 I really have not heard anyone complain that they 
 wouldn't like to use Python 3 instead of Python 2. 
 
 Or the devs do not wish to listen.
 
 Python 3 will never work.
 
 It works for me.

Works for me too. I do python3 exclusively. If the library/tool I need is 
python 2 only, I figure it's obvious it's in maintenance mode only and find 
something else.
-- 
https://mail.python.org/mailman/listinfo/python-list


Why does isoformat() optionally not print the fractional seconds?

2014-04-22 Thread Travis Griggs
Python(3) let me down today. Better to be explicit, and all that, didn’t pan 
out for me.

I have time series data being recorded in a mongo database (I love pymongo). I 
have an iOS app that consumes the data. Since JSON doesn’t have a time format, 
I have to stringify the times when transmitting between the two. To parse it on 
the obj-c side, I use 

NSDateFormatter *parser = [NSDateFormatter new];
parser = [NSTimeZone timeZoneWithAbbreviation:@GMT];
[parser setDateFormat:@-MM-dd'T'HH:mm:ss.S”];
NSDate *date = [parser dateFromString: thatJsonString];

Which was working swimmingly, until I started getting occasional and infrequent 
nil dates at times. I thought I had a storage issue or something with my REST 
api, or the server, or something. But it was simply now and then again, why 
1000’s of data points, I managed to get 0 milliseconds from time to time, which 
resulted in the isoformat() I was using to suddenly leave off the .S part of 
the string. And since the parse then failed, the iOS side decided it wasn’t 
valid and returned a nil.

Haven’t decided where/how I’ll work around it yet, but the isoformat() seemed 
unpythonic to me today.

Thanks for hearing me whine.

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


Re: test

2014-03-15 Thread Travis Griggs


 On Mar 15, 2014, at 14:24, Mark H Harris harrismh...@gmail.com wrote:
 
 test

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


Re: Functions help

2014-02-23 Thread Travis Griggs


 On Feb 23, 2014, at 17:09, Mark Lawrence breamore...@yahoo.co.uk wrote:
 
 For the benefit of newbies, besides the obvious indentation error above, the 
 underscore basically acts as a dummy variable.  I'll let the language lawyers 
 give a very detailed, precise description :)

You mean a dummy name binding, right? If we say variable we might confuse 
those newly arrived pilgrims from other language kingdom.



(If you squint hard, I think there's some facetious tags in there :) )
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Remove comma from tuples in python.

2014-02-21 Thread Travis Griggs

On Feb 21, 2014, at 6:32 AM, Roy Smith r...@panix.com wrote:

 In article mailman.7230.1392992078.18130.python-l...@python.org,
 Peter Otten __pete...@web.de wrote:
 
 
 [x*x for (x,) in lst]
 
 [paraphrasing...] can be better written as:
 
 [x*x for [x] in items]
 
 I'm torn between, Yes, the second form is distinctly easier to read 
 and, If you think the second form is easier to read, you're admitting 
 you're not really fluent in Python”.

I’ve used the comma form with struct.unpack() frequently:

count, = struct.unpack(‘!I’, self.packet)

That’s after I don’t use it and end up scratching my head for a while and 
finally remember that unpack returns a tuple regardless of how many things I 
unpack from it. It’s just natural if you’re doing lots of single unpacks to 
think it returns a single value. Either way, I much prefer it to:

count = struct.unpack(‘!I’, self.packet)[0]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can global variable be passed into Python function?

2014-02-21 Thread Travis Griggs
On Feb 21, 2014, at 4:13 AM, Ned Batchelder n...@nedbatchelder.com wrote:

 Man, do I hate this idea that Python has no variables.  It has variables 
 (names associated with values, and the values can change over the course of 
 the program), they just don't work the same as C or Fortran variables. In 
 fact, they work exactly the same as Javascript or Ruby variables.

Thank you!

+11

I get tired of the “Python doesn’t have variables” line.

What makes Python 
variables/bindings/references/aliases/namedvalues/slots/bucketsofstuff 
surprising to new arrivals from other language kingdoms, is that accessing is 
pragmatically implicit (walks the scope tree for you) and assignment may 
require explicitness. IOW, for some “variables”, you have to do something 
explicit to make the variable you want to refer to, vary. Some might say there 
is a lack of symmetry. Pros and cons.

Personally, I don’t care. It’s one of those lessons you just learn as you go.
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   >