Micropython?

2015-03-13 Thread Paul Rubin
http://www.micropython.org/

Has anyone used this?  Know anything about it?  I don't remember seeing
any mention of it here.  I remember there was a stripped down Python
some years back that didn't work very well, but I think this is
different.  I just came across it by accident.  Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: generator/coroutine terminology

2015-03-13 Thread Steven D'Aprano
Marko Rauhamaa wrote:

> Your 'factory' is a:
> 
> generator
> A function which returns an iterator.
> https://docs.python.org/3/glossary.html>

That glossary entry is misleading, or at least incomplete, and it fails to
match the way "generator" is used by actual Python programmers.

Here is a function which returns an iterator. According to the docs, it's a
generator, but that's simply wrong. In no way, shape or form should it be
considered to be a generator:

def not_a_generator():
return iter([1, 2, 3])


A generator (function) may be a function which returns an iterator, but not
all functions that return iterators are generators, and in some ways
returning an iterator is the *least* interesting part of what makes a
generator a generator.

What distinguishes a generator from a regular function is the use of
`yield`. Any definition which fails to mention that fact is useless.

"Generator" is used to describe both functions with the `yield` statement,
and the return result of calling such functions. Where it is necessary to
distinguish the two, we call the function-with-yield a "generator
function". This terminology comes straight from the PEP introducing
generators:

https://www.python.org/dev/peps/pep-0255/


Such functions-with-yield *are* functions (or methods):

py> def gen():
... yield 1
...
py> type(gen)



but they're a special kind of function, distinguished by a flag on the
__code__ object (also known as func_code in Python 2). The inspect module
has a function to check that flag, which looks like this:

def isgeneratorfunction(object):
return bool((isfunction(object) or ismethod(object)) and
object.func_code.co_flags & CO_GENERATOR)


The result of calling `gen` is an instance of the generator type, that is to
say, an instance of a type which considers its own name to be "generator":

py> x = gen()
py> type(x)


Although this type is built-in, it is not available in the builtins
namespace, but it is bound to the name "GeneratorType" in the types module.
The inspect module has a function for this too:

def isgenerator(object):
return isinstance(object, types.GeneratorType)


For brevity, I've deleted the docstring, but it is very informative to read
it. Run `import inspect; help(inspect.isgenerator)` for more details.


Like many English words, we have two meanings for "generator":

(1) A function containing the `yield` keyword, or "generator-function".

(2) The result of calling such a function, an instance of
types.GeneratorType. PEP 255 calls that a "generator-iterator", but that
name doesn't appear to have caught on anywhere.

If people can cope with the difference between a TV program and a computer
program, they can cope with "generator" having two meanings, especially
since we have ways to disambiguate between the two when needed.

 
> Your 'generator-instance' is an:
> 
> iterator
> An object representing a stream of data.
> https://docs.python.org/3/glossary.html>

Generator instances are iterators, but not all iterators are generator
instances. Generator instances are special: they are subroutines which can
be suspended and resumed, with multiple exit points (each yield is an exit
point). 

Generators are a subset of coroutines, which are a generalization of
generators. Coroutines have multiple entry points and exit points (each
yield is both an entry point and exit point). CPython uses the same
internal mechanism for both, and as far as I know, there is no programmatic
way to distinguish a coroutine from a generator. Or at least no obvious
way -- there's no `inspect.iscoroutine` function that I know of.


> I don't think you should read much into what str(obj) returns. It's not
> much more than a random printable some CPython coder has cooked up in
> the heat of the moment.

I think that is completely wrong. The repr() and str() of generator
instances is hardly "random", it reflects the consensus of the PEP authors
and the Python core developers, in particular the BDFL Guido who approved
the PEP, that the type of object it is should be called "generator".



-- 
Steven

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


Re: Code hosting providers

2015-03-13 Thread Rustom Mody
On Saturday, March 14, 2015 at 9:15:39 AM UTC+5:30, Paul Rubin wrote:
> Mario Figueiredo writes:
> >>Question:  How much money is this group, taken as the whole of the python 
> >>world, spending on remote hosting per month?
> > I'd wager very little, since most options are completely free.
> 
> Oh come on, if you count all forms of hosting, some of us are spending a
> lot (megabucks per month on AWS in some cases I'm sure).  If you just
> mean VCS hosting, the free Github plans are only for FOSS projects.
> Prices of paid plans vary depending on project size etc.  Lots of
> companies pay to use Github for closed source stuff.

Bitbucket will give you closed source repos for upto 5 users collaborating for 
FREE.
I use it the way others (I guess) you dropbox/googledrive etc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code hosting providers

2015-03-13 Thread Paul Rubin
Mario Figueiredo  writes:
>>Question:  How much money is this group, taken as the whole of the python 
>>world, spending on remote hosting per month?
> I'd wager very little, since most options are completely free.

Oh come on, if you count all forms of hosting, some of us are spending a
lot (megabucks per month on AWS in some cases I'm sure).  If you just
mean VCS hosting, the free Github plans are only for FOSS projects.
Prices of paid plans vary depending on project size etc.  Lots of
companies pay to use Github for closed source stuff.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code hosting providers

2015-03-13 Thread Mario Figueiredo
On Fri, 13 Mar 2015 23:13:17 -0400, Gene Heskett 
wrote:
>
>>
>> That's taking things too far. And when people speak of hosting your
>> own server, they don't necessarily mean hosting in your home computer.
>> Speaking for myself, I refuse to collaborate on any project that is
>> hosted on some dude's personal computer.
>
>Chuckle.  1. My finished, running code is copied to at least 200 other 
>users machines because it is useful code. 

I said collaborating, not just downloading your code. By collaborating
I mean forking and branching your project, making pull requests,
merging, opening and closing tickets, etc.


>
>> If you are the sole developer of your project, why not.
>
>Generally I am, unless a circuit board is under construction in our 
>group, in which case I might offer to make a couple of non-plated thru 
>copies if I get to keep one for my time. However, on my small machinery, 
>mechanical etching, while great on the environment as there's  no 
>downright nasty chemistry to dispose of, is also very slow, limited by 
>the 2500 rpms max speed of the spindle, so a busy double sided 4"x8" 
>board is over 8 hours to machine.  That big, I'd also have to make a 
>vacuum pallet, which for a given sized board is about a day.

You aren't talking about software anymore... I don't know why you are
telling me this.

>
>> But if that is 
>> the case, I'd say most project managers are just overkill and the
>> choice of what to choose shouldn't even be considered. Just grab your
>> VCS of choice. Issue tracking can be safely managed in your code with
>> TODO and FIXME. If by any chance you need to work on more than one
>> computer, don't bloody open your ports at home. Just get an usb pen
>> and make a bare repo in there from where you can push/pull.
>
>And if the next box you plug it into has a different first user number, 
>and you don't have a root account handy, how do you access the data, 
>written say on a fedora system, but you need to read it on a debian 
>system. And you are not the first user, and you are not in /etc/sudoers.
>
>Go ahead, I'll wait for you to suss that out. :)

What do you mean? If you have those problems with a bare repo in a usb
pen, you will have those problems with a bare repo anywhere, including
in your computer back at home.

How do you propose to solve any local access previligies by having
your project management system hosted at your home? I don't
understand.

...I'm getting the feeling we are talking of different things.

>What for?  I keep backups using amanda.  Because of that, and despite 
>several hard drive deaths, my email corpus for some mailing lists is now 
>13 yo, and several gigabytes.

Right. You won't ever lose your data. Heard that before.

I'm a bit old too, you know. And I learned the following, back in the
late 80s when I was initiating my computer carreer doing nightly
backups on a ES9000:

"You will never lose your data until you lost it."

>
>Question:  How much money is this group, taken as the whole of the python 
>world, spending on remote hosting per month?

I'd wager very little, since most options are completely free.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code hosting providers

2015-03-13 Thread Gene Heskett


On Friday 13 March 2015 20:48:36 Mario Figueiredo wrote:
> On Fri, 13 Mar 2015 19:38:09 -0400, Gene Heskett 
>
> wrote:
> >Running your own server is a piece of cake, and if I, at 80 yo, can
> > do it, I don't see a single reason you can't do likewise.  The code
> > I write, for what is called a legacy computer, is just one of the
> > things I share at the link in my sig.  That link is actually _this_
> > machine.
>
> That's taking things too far. And when people speak of hosting your
> own server, they don't necessarily mean hosting in your home computer.
> Speaking for myself, I refuse to collaborate on any project that is
> hosted on some dude's personal computer.

Chuckle.  1. My finished, running code is copied to at least 200 other 
users machines because it is useful code. 

2.  If I fall over, there is close to that many copies extant that 
include the src code since that is virtually the only way I have 
released anything in the last 25 years.

> The uptime can never match 
> that of a data center and and if you decide to stream some movies
> while torrenting the latest linux distro, I'm basically screwed.

That is much more of a function of the bandwidth available to me, 10 
megbit dl, 2.5 megbit ul.  I, on SS, do not have the budget for a 
gigabit pipe, and I have serious doubts that level of bandwidth is even 
available locally.

> If you are the sole developer of your project, why not.

Generally I am, unless a circuit board is under construction in our 
group, in which case I might offer to make a couple of non-plated thru 
copies if I get to keep one for my time. However, on my small machinery, 
mechanical etching, while great on the environment as there's  no 
downright nasty chemistry to dispose of, is also very slow, limited by 
the 2500 rpms max speed of the spindle, so a busy double sided 4"x8" 
board is over 8 hours to machine.  That big, I'd also have to make a 
vacuum pallet, which for a given sized board is about a day.

> But if that is 
> the case, I'd say most project managers are just overkill and the
> choice of what to choose shouldn't even be considered. Just grab your
> VCS of choice. Issue tracking can be safely managed in your code with
> TODO and FIXME. If by any chance you need to work on more than one
> computer, don't bloody open your ports at home. Just get an usb pen
> and make a bare repo in there from where you can push/pull.

And if the next box you plug it into has a different first user number, 
and you don't have a root account handy, how do you access the data, 
written say on a fedora system, but you need to read it on a debian 
system. And you are not the first user, and you are not in /etc/sudoers.

Go ahead, I'll wait for you to suss that out. :)

Besides, thats way more trouble than NFS shares or ssh -Y sessions on my 
local network assuming I am the first user and therefore in the sudoers 
file..  And with dd-wrt playing guard dog for the whole system, I don't 
worry about somebody stomping in and doing an rm -Rf /.  No one has in 
well over a decade.

But, while I have done quite a few scripts on this machine, the one my 
legacy code runs on is not accessible from the outside world.  The 
kernel modules to support that are not in any of the several choices of 
specialized bootfiles for it.

> The ability to host your own server means:
>
> 1. Your code hosting provider doesn't lock you in. You can take
>your *full* repository history and host it yourself somewhere
>else outside their domain.
> 2. You will want to host this ASAP on some web hosting provider.

What for?  I keep backups using amanda.  Because of that, and despite 
several hard drive deaths, my email corpus for some mailing lists is now 
13 yo, and several gigabytes.

Question:  How much money is this group, taken as the whole of the python 
world, spending on remote hosting per month?

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Odd ValueError using float

2015-03-13 Thread Chris Angelico
On Sat, Mar 14, 2015 at 1:33 PM, Paul Rubin  wrote:
> emile  writes:
>> *** NameError: name 'val' is not defined
>> (Pdb) l
>> 139 try:
>> 140 val = round(float(decval),1)
>> 141 except:
>> 142 import pdb; pdb.set_trace()
>
> If 'float' or 'round' throw an exception, the assignment to 'val' never
> happens, so 'val' is undefined.  Try examining the value of 'decval' in
> the debugger to see what is making the conversion fail.

That's exactly what the OP did :) Trouble is, it didn't help, because
it sure looked as if decval was the string '4'. My best guess was -
and is - that it's not just a string. We're looking at an SQL
interface routine here, so it may be that there's a string subclass
that length-limits itself, on the assumption that it's going into a
fixed-length database field. Let's see if I can recreate the OP's
situation...

>>> def Char(maxlen):
class CharN(str):
def __repr__(self):
return repr(self[:maxlen])
CharN.__qualname__ = CharN.__name__ = "Char(%d)"%maxlen
return CharN

>>> four = Char(1)('41.703')
>>> four
'4'
>>> int(four)
Traceback (most recent call last):
  File "", line 1, in 
int(four)
ValueError: invalid literal for int() with base 10: '4'

... well, close. Anyway, a string subclass could probably do this by
accident somehow.

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


Re: Code hosting providers

2015-03-13 Thread Paul Rubin
Mario Figueiredo  writes:
> That's taking things too far. And when people speak of hosting your
> own server, they don't necessarily mean hosting in your home computer.
> Speaking for myself, I refuse to collaborate on any project that is
> hosted on some dude's personal computer. 

Meh, you don't necessarily know where it is, but you can get a year of
EC2 VPS for free (https://aws.amazon.com/free/), or for ridiculously
cheap at tons of smaller providers (http://list.lowendserv.net/).  Even
the smallest of such VPS is plenty for a moderate sized Git repo.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Odd ValueError using float

2015-03-13 Thread Paul Rubin
emile  writes:
> *** NameError: name 'val' is not defined
> (Pdb) l
> 139 try:
> 140 val = round(float(decval),1)
> 141 except:
> 142 import pdb; pdb.set_trace()

If 'float' or 'round' throw an exception, the assignment to 'val' never
happens, so 'val' is undefined.  Try examining the value of 'decval' in
the debugger to see what is making the conversion fail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 conversion - embrace the pain

2015-03-13 Thread Chris Angelico
On Sat, Mar 14, 2015 at 10:14 AM, Ned Deily  wrote:
> In article , John Nagle 
> wrote:
>>All the bugs I'm discussing reflect forced package
>> changes or upgrades.  None were voluntary on my part.
>
> You would have run into the SSL certificate issue if you upgraded your
> Python 2 instance to the current Python 2.7.9.

And the same applies to many MANY other upgrades. I was trying to
delve into a VLC issue by compiling the latest version from source
control, but it wouldn't build with the version of
libsomething-or-other that shipped with Debian Wheezy, so I had to
upgrade that... and then it needed a newer Linux kernel as well, I
think, but at that point I accepted building from a couple dozen
commits ago.

If you upgrade your Python from 2.3 to 2.7, you'll find some breakage,
too. Any upgrade can do that. That's why stable OS releases don't just
randomly upgrade you... which is a bit of a pain for people who want
to distribute Python code that will "just work", but it sure is better
than something unexpectedly going belly-up on a live server!

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


Re: The idle gui

2015-03-13 Thread Steven D'Aprano
sohcahto...@gmail.com wrote:


> We need more information than just "It doesn't work".  You wouldn't go to
> a car mechanic and say "It makes a funny noise", would you?  No.

Actually, most likely yes.It's remarkably hard to describe noises, and often
difficult to pin-point where they come from. My wife and I can sit in the
same car, listening to the same noise, and she swears it is coming from the
front left and I'm sure its coming from the rear right. (Invariably she's
correct.)

But at least the car mechanic can jump in the car and take it for a drive.



-- 
Steven

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


Re: Code hosting providers

2015-03-13 Thread Mario Figueiredo
On Fri, 13 Mar 2015 19:38:09 -0400, Gene Heskett 
wrote:

>
>Running your own server is a piece of cake, and if I, at 80 yo, can do 
>it, I don't see a single reason you can't do likewise.  The code I 
>write, for what is called a legacy computer, is just one of the things I 
>share at the link in my sig.  That link is actually _this_ machine.

That's taking things too far. And when people speak of hosting your
own server, they don't necessarily mean hosting in your home computer.
Speaking for myself, I refuse to collaborate on any project that is
hosted on some dude's personal computer. The uptime can never match
that of a data center and and if you decide to stream some movies
while torrenting the latest linux distro, I'm basically screwed.

If you are the sole developer of your project, why not. But if that is
the case, I'd say most project managers are just overkill and the
choice of what to choose shouldn't even be considered. Just grab your
VCS of choice. Issue tracking can be safely managed in your code with
TODO and FIXME. If by any chance you need to work on more than one
computer, don't bloody open your ports at home. Just get an usb pen
and make a bare repo in there from where you can push/pull.

The ability to host your own server means:

1. Your code hosting provider doesn't lock you in. You can take 
   your *full* repository history and host it yourself somewhere 
   else outside their domain.
2. You will want to host this ASAP on some web hosting provider.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: regex help

2015-03-13 Thread Steven D'Aprano
Larry Martell wrote:

> I need to remove all trailing zeros to the right of the decimal point,
> but leave one zero if it's whole number. 


def strip_zero(s):
if '.' not in s:
return s
s = s.rstrip('0')
if s.endswith('.'):
s += '0'
return s


And in use:

py> strip_zero('-10.2500')
'-10.25'
py> strip_zero('123000')
'123000'
py> strip_zero('123000.')
'123000.0'


It doesn't support exponential format:

py> strip_zero('1.230e3')
'1.230e3'

because it isn't clear what you intend to do under those circumstances.


-- 
Steven

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


Re: Pexpect idea - but can I handle curses?

2015-03-13 Thread Skip Montanaro
On Fri, Mar 13, 2015 at 5:47 PM, Christian Gollwitzer 
wrote:

> Why? Do you not have a C compiler?


Sure I do, and I'm not afraid to use it. I realize top is just one
not-terribly-critical tool, but every divergence between my machines and
the "standard" install just makes it that much more difficult for me to
track changes when our IT group *does* move us to a more up-to-date
environment. I develop and build software which runs in a production
environment. I can't afford to diverge more than absolutely necessary.

Let's just let this thread die, shall we? So far, nobody seems interested
in attempting to answer my original question. I thought it might be an
interesting hack if I could make it work. If I plunge in and try it, I will
report back with results.

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


Re: Code hosting providers

2015-03-13 Thread Gene Heskett


On Friday 13 March 2015 17:13:41 Paul Rubin wrote:
> Chris Angelico  writes:
> > In the meantime, I get zero-dollar hosting of my repos, including
> > zip download and such ...  You're welcome to shun them. There is
> > definitely benefit to encouraging a multiplicity of hosting
> > services. But I'm not bothered by the GitHub non-free-ness, because
> > I take a less philosophical and more pragmatic view of things.
>
> But you're making the problem worse for other people too.  For
> example, I can't file a bug against your code or send you a pull
> request, without enrolling in Github myself.

That alone is grounds enough to get the heck out of github.  This is 
classic vendor lockin, or lockout if you don't want to play by githubs 
rules.  A classic demonstration of TANSTAAFL if there ever was one.

The above quoted problem YOU, Chris do not see, but that should be reason 
enough to bail out AND take your code with you before you find yourself 
locked out of your own code.

Running your own server is a piece of cake, and if I, at 80 yo, can do 
it, I don't see a single reason you can't do likewise.  The code I 
write, for what is called a legacy computer, is just one of the things I 
share at the link in my sig.  That link is actually _this_ machine.  
Sure, I blow my own horn a bit, & you have to look at my ugly mug while 
it loads on the front page, but that is the only advertising you will 
ever see on that site.  If I am still breathing regular when the 5 year 
namecheap registration expires, I'll renew it for another 5 years.  I'll 
be approaching 84 yo then.

That namecheap registration, and the electricity to run it are my only 
extra expenses over and above my use of the machine as a web tourer, and 
an email system.  Or as a remote terminal into one of my milling 
machines so I can write gcode and test execute it here in a comfy office 
chair, which beats the hell out of extended periods standing in front of 
the machines own keyboard.  An hour of that at my age is very painfull.

But don't even think of using the std http port 80, thats blocked at your 
isp, precisely to force you to use, and pay for, space on their servers.

Your /etc/services contains a list of ports, and what they are supposed 
to be used for. The 6309 that I use, is the simplified jedec number of a 
cpu chip that can be transplanted into a TRS-80 Color Computer to 
replace its normal 6809, is 10%  faster at the same clock speed, and 
often 4x faster than a 6809 with some of its added instructions.  It was 
not listed in /etc/services, so there was zero reason not to use it as I 
wasn't stepping on any toes to use it.

Surely this group can look at the ascii code for the word python, and 
come up with a port number that is unique AND not in /etc/services.  If 
you all do that, and agree on a common port number you will establish a 
common port number that can be used for python code interchange and even 
broadcasting among the group.  Since thats a 4 byte wide hex number, and 
there's 65536 of them, it shouldn't be that hard to find one that will 
serve the purpose.

But I do also,  have a router running dd-wrt facing the net, my guard dog 
with the big teeth.

It (that number) will in time, become that standard.

> You can get a whole virtual server from Amazon for free that is
> perfectly good for hosting git repos and lots of other things too, or
> you can get them for a few dollars a year in other places if you don't
> want to deal with Amazon.  Github adds some conveniences but I've
> never understood the attraction and mystique around it.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 conversion - embrace the pain

2015-03-13 Thread Ned Deily
In article , John Nagle  
wrote:
>All the bugs I'm discussing reflect forced package
> changes or upgrades.  None were voluntary on my part.

You would have run into the SSL certificate issue if you upgraded your 
Python 2 instance to the current Python 2.7.9.

-- 
 Ned Deily,
 n...@acm.org

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


Re: Python 2 to 3 conversion - embrace the pain

2015-03-13 Thread John Nagle
On 3/13/2015 3:27 PM, INADA Naoki wrote:
> Hi, John.  I'm maintainer of PyMySQL.
> 
> I'm sorry about bug of PyMySQL.  But the bug is completely unrelated
> to Python 3.
> You may encounter the bug on Python 2 too.

   True.  But much of the pain of converting to Python 3
comes from having to switch packages because the Python 2
package didn't make it to Python 3.

   All the bugs I'm discussing reflect forced package
changes or upgrades.  None were voluntary on my part.

John Nagle

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


Re: Pexpect idea - but can I handle curses?

2015-03-13 Thread Christian Gollwitzer
Am 13.03.15 um 18:25 schrieb Skip Montanaro:
> I understand that. Tell that to management though. They were working
> on 13.1 for awhile, but seem to be focused on 13.2 now, though not all
> our internal software works on that.
> 
> I'll give up on hoping I get access to a more modern top anytime soon.

Why? Do you not have a C compiler?

Christian

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


Re: Odd ValueError using float

2015-03-13 Thread emile

On 03/13/2015 03:14 PM, Chris Angelico wrote:

On Sat, Mar 14, 2015 at 9:10 AM, emile  wrote:

(Pdb) decval
'4'
(Pdb) len(decval)
1
(Pdb) int(decval)
*** ValueError: invalid literal for int() with base 10: '41.703'
(Pdb)


Any ideas?


What's type(decval) tell you? I suspect you may have something other
than a string, even though it looks like a string in its repr.


>sigh<   Now it's running again.  Up to 20 minutes ago when I posted it 
continually.


Is-it-time-to-go-pick-grapes-yet?-ly y'rs,

Emile



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


Re: regex help

2015-03-13 Thread Cameron Simpson

On 13Mar2015 12:05, Larry Martell  wrote:

I need to remove all trailing zeros to the right of the decimal point,
but leave one zero if it's whole number. For example, if I have this:

14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.13725490196

I want to end up with:

14S,5.0,4.56862745,3.7272727272727271,3.394736842105263,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.13725490196

I have a regex to remove the zeros:

'0+[,$]', ''

But I can't figure out how to get the 5. to be 5.0.
I've been messing with the negative lookbehind, but I haven't found
one that works for this.


Leaving aside the suggested non-greedy match, you can rephrase this: strip 
trailing zeroes _after_ the first decimal digit. Then you can consider a number 
to be:


 digits
 point
 any digit
 other digits to be right-zero stripped

so:

 (\d+\.\d)(\d*[1-9])?0*\b

and keep .group(1) and .group(2) from the match.

Another way of considering the problem.

Or you could two step it. Strip all trailing zeroes. If the result ends in a 
dot, add a single zero.


Cheers,
Cameron Simpson 

C'mon. Take the plunge. By the time you go through rehab the first time,
you'll be surrounded by the most interesting people, and if it takes years
off of your life, don't sweat it. They'll be the last ones anyway.
   - Vinnie Jordan, alt.peeves
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2 to 3 conversion - embrace the pain

2015-03-13 Thread INADA Naoki
Hi, John.  I'm maintainer of PyMySQL.

I'm sorry about bug of PyMySQL.  But the bug is completely unrelated
to Python 3.
You may encounter the bug on Python 2 too.

I've already made mysqlclient, the fork of MySQLdb supporting Python 3.


On Sat, Mar 14, 2015 at 6:08 AM, John Nagle  wrote:
>   I'm approaching the end of converting a large system from Python 2 to
> Python 3.  Here's why you don't want to do this.
>
>   The language changes aren't that bad, and they're known and
> documented.  It's the package changes that are the problem.
> Discovering and fixing all the new bugs takes a while.
>
>
> BeautifulSoup:
>
> BeautifulSoup 3 has been phased out. I had my own version of
> BeautifulSoup 3, modified for greater robustness.  But that was
> years ago.  So I converted to BeautifulSoup 4, as the documentation
> says to do.
>
> The HTML5parser module is claimed to parse as a browser does, with
> all the error tolerance specified in the HTML5 spec. (The spec
> actually specifies how to handle bad HTML consistently across
> browsers in great detail, and HTML5parser has code in it for that.)
>
> It doesn't deliver on that promise, though. Some sites crash
> BeautifulSoup 4/HTML5parser.  Try "kroger.com", which has HTML with
> .  The parse tree constructed has a bad link,
> and trying to use the parse tree results in exceptions.
> Submitted bug report.  Appears to be another case of
> a known bug.  No workaround at this time.
>
> https://bugs.launchpad.net/beautifulsoup/+bug/1270611
> https://bugs.launchpad.net/beautifulsoup/+bug/1430633
>
>
> PyMySQL:
>
> "Pymysql is a pure Python drop-in replacement for MySQLdb".
> Sounds good.  Then I discover that LOAD DATA LOCAL wasn't
> implemented in the version on PyPi.  It's on Github, though,
> and I got the authors to push that out to PyPi.  It
> works on test cases.  But it doesn't work on a big job,
> because the default size of MySQL packets was set to 16MB.
> This made the LOAD DATA LOCAL code try to send the entire
> file being loaded as one giant MySQL packet.  Unless you
> configure the MySQL server with 16MB buffers, this fails, with
> an obscure "server has gone away" message.  Found the
> problem, came up with a workaround, submitted a bug report,
> and it's being fixed.
>
> https://github.com/PyMySQL/PyMySQL/issues/317
>
>
> SSL:
>
> All the new TLS/SSL support is in Python 3. That's good.
> Unfortunately, using Firefox's set of SSL certs, some
> important sites (such as "verisign.com") don't validate.
> This turned out to be a complex problem involving Verisign
> cross-signing a certificate, which created a certificate
> hierarchy that some versions of OpenSSL can't handle.
> There's now a version of OpenSSL that can handle it, but
> the Python library has to make a call to use it, and
> that's going in but isn't deployed yet.  This bug
> resulted in much finger-pointing between the Python
> and OpenSSL developers, the Mozilla certificate store
> maintainers, and Verisign.  It's now been sorted out,
> but not all the fixes are deployed.  Because "ssl" is
> a core Python module, this will remain broken until the
> next Python release, on both the 2.7 and 3.4 lines.
>
> Also, for no particularly good reason, the exception
> "SSL.CertificateError" is not a subclass of "SSL.Error",
> resulting in a routine exception not being recognized.
>
> Bug reports submitted for both OpenSSL and Python SSL.
> Much discussion.  Problem fixed, but fix is in next
> version of Python.  No workaround at this time.
>
> http://bugs.python.org/issue23476
>
>
> Pickle:
>
> As I just posted recently, CPickle on Python 3.4 seems to
> have a memory corruption bug.  Pure-Python Pickle is fine.
> So a workaround is possible.  Bug report submitted.
>
> http://bugs.python.org/issue23655
>
>
> Converting a large application program to Python 3
> thus required diagnosing four library bugs and filing
> bug reports on all of them.  Workarounds are known
> for two of the problems.  I can't deploy the Python 3
> version on the servers yet.
>
> John Nagle
> --
> https://mail.python.org/mailman/listinfo/python-list



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


Re: Odd ValueError using float

2015-03-13 Thread Chris Angelico
On Sat, Mar 14, 2015 at 9:10 AM, emile  wrote:
> (Pdb) decval
> '4'
> (Pdb) len(decval)
> 1
> (Pdb) int(decval)
> *** ValueError: invalid literal for int() with base 10: '41.703'
> (Pdb)
>
>
> Any ideas?

What's type(decval) tell you? I suspect you may have something other
than a string, even though it looks like a string in its repr.

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


Re: The idle gui

2015-03-13 Thread Mark Lawrence

On 13/03/2015 20:58, lmzent...@gmail.com wrote:

My python program was running for over six weeks. Then the idle gui stopped 
opening. I have reinstalled several times but it doesn't work. Any idea?



Would you please read http://www.catb.org/esr/faqs/smart-questions.html 
and possibly http://sscce.org/ and then repost your question, thank you.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Odd ValueError using float

2015-03-13 Thread emile
On an older WinXP SP2 box with python2.6 that's been running this 
process fine for years, this week we're seeing:


> c:\python26\lib\site-packages\fenx\sql_interface.py(144)normalized()
-> return val
(Pdb) val
*** NameError: name 'val' is not defined
(Pdb) l
139 try:
140 val = round(float(decval),1)
141 except:
142 import pdb; pdb.set_trace()
143 #val = round(float(int(decval)/10**((decval%100)*100)),1)
144  -> return val
145
146
147 def foodList(reference):
148 # return a list of (code,val) tuples for the ingredients of 
the foodlist referenced

149 # local internal use only to create sqlFoodListsByID
(Pdb) decval
'4'
(Pdb) len(decval)
1
(Pdb) int(decval)
*** ValueError: invalid literal for int() with base 10: '41.703'
(Pdb)


Any ideas?

Thanks,

Emile

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


Re: The idle gui

2015-03-13 Thread sohcahtoa82
On Friday, March 13, 2015 at 1:58:44 PM UTC-7, lmze...@gmail.com wrote:
> My python program was running for over six weeks. Then the idle gui stopped 
> opening. I have reinstalled several times but it doesn't work. Any idea?

Not trying to be rude here, but do you really think we'll be able to help you 
when all you say is "It doesn't work"?

What error message do you get?

What exactly isn't working?  Does IDLE not start *AT ALL*?  Or is your Python 
program just not working?

What version of Python/IDLE are you running?

What operating system?

We need more information than just "It doesn't work".  You wouldn't go to a car 
mechanic and say "It makes a funny noise", would you?  No.  You'd say "It makes 
a metallic whining noise, like the brakes of a bus or semi-truck, when I make 
right-turns after going over a bump.  It sounds like its coming from the rear 
driver-side wheel."

Being up-front and describing your problem in detail saves everybody time.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code hosting providers

2015-03-13 Thread Paul Rubin
Ben Finney  writes:
> Also worth watching is Kallithea, a new federated code hosting service ...
> Good hunting in finding a free-software code hosting provider for your
> projects!

Should also put in a mention for Savannah (savannah.gnu.org for GNU
projects and savannah.nongnu.org for non-GNU free software) as the
provider most philosophically committed to free software.  In technical
terms I think it's a fork of an early version of Sourceforge, so it's a
bit old fashioned, but some good projects are there, and I'll probably
use it if the need arises.  It runs several VCS's including Arch,
Bazaar, CVS, Git, Mercurial, and SVN.

Also, if you like the avant-garde, hub.darcs.net might be of interest.
I had an account on patch-tag.com (darcs host) for a while, but it
apparently shut down last year.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code hosting providers

2015-03-13 Thread Paul Rubin
Chris Angelico  writes:
> In the meantime, I get zero-dollar hosting of my repos, including zip
> download and such ...  You're welcome to shun them. There is
> definitely benefit to encouraging a multiplicity of hosting
> services. But I'm not bothered by the GitHub non-free-ness, because I
> take a less philosophical and more pragmatic view of things.

But you're making the problem worse for other people too.  For example,
I can't file a bug against your code or send you a pull request, without
enrolling in Github myself.

You can get a whole virtual server from Amazon for free that is
perfectly good for hosting git repos and lots of other things too, or
you can get them for a few dollars a year in other places if you don't
want to deal with Amazon.  Github adds some conveniences but I've never
understood the attraction and mystique around it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python 2 to 3 conversion - embrace the pain

2015-03-13 Thread John Nagle
  I'm approaching the end of converting a large system from Python 2 to
Python 3.  Here's why you don't want to do this.

  The language changes aren't that bad, and they're known and
documented.  It's the package changes that are the problem.
Discovering and fixing all the new bugs takes a while.


BeautifulSoup:

BeautifulSoup 3 has been phased out. I had my own version of
BeautifulSoup 3, modified for greater robustness.  But that was
years ago.  So I converted to BeautifulSoup 4, as the documentation
says to do.

The HTML5parser module is claimed to parse as a browser does, with
all the error tolerance specified in the HTML5 spec. (The spec
actually specifies how to handle bad HTML consistently across
browsers in great detail, and HTML5parser has code in it for that.)

It doesn't deliver on that promise, though. Some sites crash
BeautifulSoup 4/HTML5parser.  Try "kroger.com", which has HTML with
.  The parse tree constructed has a bad link,
and trying to use the parse tree results in exceptions.
Submitted bug report.  Appears to be another case of
a known bug.  No workaround at this time.

https://bugs.launchpad.net/beautifulsoup/+bug/1270611
https://bugs.launchpad.net/beautifulsoup/+bug/1430633


PyMySQL:

"Pymysql is a pure Python drop-in replacement for MySQLdb".
Sounds good.  Then I discover that LOAD DATA LOCAL wasn't
implemented in the version on PyPi.  It's on Github, though,
and I got the authors to push that out to PyPi.  It
works on test cases.  But it doesn't work on a big job,
because the default size of MySQL packets was set to 16MB.
This made the LOAD DATA LOCAL code try to send the entire
file being loaded as one giant MySQL packet.  Unless you
configure the MySQL server with 16MB buffers, this fails, with
an obscure "server has gone away" message.  Found the
problem, came up with a workaround, submitted a bug report,
and it's being fixed.

https://github.com/PyMySQL/PyMySQL/issues/317


SSL:

All the new TLS/SSL support is in Python 3. That's good.
Unfortunately, using Firefox's set of SSL certs, some
important sites (such as "verisign.com") don't validate.
This turned out to be a complex problem involving Verisign
cross-signing a certificate, which created a certificate
hierarchy that some versions of OpenSSL can't handle.
There's now a version of OpenSSL that can handle it, but
the Python library has to make a call to use it, and
that's going in but isn't deployed yet.  This bug
resulted in much finger-pointing between the Python
and OpenSSL developers, the Mozilla certificate store
maintainers, and Verisign.  It's now been sorted out,
but not all the fixes are deployed.  Because "ssl" is
a core Python module, this will remain broken until the
next Python release, on both the 2.7 and 3.4 lines.

Also, for no particularly good reason, the exception
"SSL.CertificateError" is not a subclass of "SSL.Error",
resulting in a routine exception not being recognized.

Bug reports submitted for both OpenSSL and Python SSL.
Much discussion.  Problem fixed, but fix is in next
version of Python.  No workaround at this time.

http://bugs.python.org/issue23476


Pickle:

As I just posted recently, CPickle on Python 3.4 seems to
have a memory corruption bug.  Pure-Python Pickle is fine.
So a workaround is possible.  Bug report submitted.

http://bugs.python.org/issue23655


Converting a large application program to Python 3
thus required diagnosing four library bugs and filing
bug reports on all of them.  Workarounds are known
for two of the problems.  I can't deploy the Python 3
version on the servers yet.

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


The idle gui

2015-03-13 Thread lmzentman
My python program was running for over six weeks. Then the idle gui stopped 
opening. I have reinstalled several times but it doesn't work. Any idea?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Google Code Shutting Down

2015-03-13 Thread Josh English
Thanks for the discussion. I found my original concern was supposedly about 
sourceforge. PyPi, according to a post over on pypubsub-dev that pip installs 
had anecdotal problems with sourcforge-hosted projects.

I guess I wanted some more anecdotes and opinions before I tried moving 
anything. 

I barely understand the SVN I'm using now, so trying to learn a new VCS is a 
tad daunting for this hobbyist.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: regex help

2015-03-13 Thread Larry Martell
On Fri, Mar 13, 2015 at 1:29 PM, MRAB  wrote:
> On 2015-03-13 16:05, Larry Martell wrote:
>>
>> I need to remove all trailing zeros to the right of the decimal point,
>> but leave one zero if it's whole number. For example, if I have this:
>>
>>
>> 14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.13725490196
>>
>> I want to end up with:
>>
>>
>> 14S,5.0,4.56862745,3.7272727272727271,3.394736842105263,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.13725490196
>>
>> I have a regex to remove the zeros:
>>
>> '0+[,$]', ''
>>
>> But I can't figure out how to get the 5. to be 5.0.
>> I've been messing with the negative lookbehind, but I haven't found
>> one that works for this.
>>
> Search: (\.\d+?)0+\b
> Replace: \1
>
> which is:
>
> re.sub(r'(\.\d+?)0+\b', r'\1', string)

Thanks! That works perfectly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: regex help

2015-03-13 Thread Tim Chase
On 2015-03-13 12:05, Larry Martell wrote:
> I need to remove all trailing zeros to the right of the decimal
> point, but leave one zero if it's whole number. 
> 
> But I can't figure out how to get the 5. to be 5.0.
> I've been messing with the negative lookbehind, but I haven't found
> one that works for this.

You can do it with string-ops, or you can resort to regexp.
Personally, I like the clarity of the string-ops version, but use
what suits you.

-tkc

import re
input = [
'14S',
'5.',
'4.5686274500',
'3.7272727272727271',
'3.3947368421052630',
'5.7307692307692308',
'5.7547169811320753',
'4.9423076923076925',
'5.7884615384615383',
'5.13725490196',
]

output = [
'14S',
'5.0',
'4.56862745',
'3.7272727272727271',
'3.394736842105263',
'5.7307692307692308',
'5.7547169811320753',
'4.9423076923076925',
'5.7884615384615383',
'5.13725490196',
]


def fn1(s):
if '.' in s:
s = s.rstrip('0')
if s.endswith('.'):
s += '0'
return s

def fn2(s):
return re.sub(r'(\.\d+?)0+$', r'\1', s)

for fn in (fn1, fn2):
for i, o in zip(input, output):
v = fn(i)
print "%s: %s -> %s [%s]" % (v == o, i, v, o)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: regex help

2015-03-13 Thread MRAB

On 2015-03-13 16:05, Larry Martell wrote:

I need to remove all trailing zeros to the right of the decimal point,
but leave one zero if it's whole number. For example, if I have this:

14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.13725490196

I want to end up with:

14S,5.0,4.56862745,3.7272727272727271,3.394736842105263,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.13725490196

I have a regex to remove the zeros:

'0+[,$]', ''

But I can't figure out how to get the 5. to be 5.0.
I've been messing with the negative lookbehind, but I haven't found
one that works for this.


Search: (\.\d+?)0+\b
Replace: \1

which is:

re.sub(r'(\.\d+?)0+\b', r'\1', string)

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


Re: Pexpect idea - but can I handle curses?

2015-03-13 Thread Skip Montanaro
On Fri, Mar 13, 2015 at 12:03 PM, Thomas 'PointedEars' Lahn
 wrote:
> “o” is not an option, it is an interaktive keystroke command in (my) top(1).

"o" is also an unrecognized keystroke.

> OpenSUSE 12.2 has reached its end-of-life on 2014-01-27.

I understand that. Tell that to management though. They were working
on 13.1 for awhile, but seem to be focused on 13.2 now, though not all
our internal software works on that.

I'll give up on hoping I get access to a more modern top anytime soon.
Can someone give me some feedback on my harebrained pexpect idea?

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


Re: regex help

2015-03-13 Thread Thomas 'PointedEars' Lahn
Larry Martell wrote:

> I need to remove all trailing zeros to the right of the decimal point,
> but leave one zero if it's whole number. For example, if I have this:
> 
> 
14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.13725490196
> 
> I want to end up with:
> 
> 
14S,5.0,4.56862745,3.7272727272727271,3.394736842105263,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.13725490196
> 
> I have a regex to remove the zeros:
> 
> '0+[,$]', ''
> 
> But I can't figure out how to get the 5. to be 5.0.
> I've been messing with the negative lookbehind, but I haven't found
> one that works for this.

First of all, I find it unlikely that you really want to solve your problem 
with regular expressions.  Google “X-Y problem”.

Second, if you must use regular expressions, the most simple approach is to 
use backreferences.

Third, you need to show the relevant (Python) code.



-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pexpect idea - but can I handle curses?

2015-03-13 Thread Thomas 'PointedEars' Lahn
Skip Montanaro wrote:

> Thomas 'PointedEars' Lahn […] wrote:
>> Yes, it (top(1) from procps-ng 3.3.9) does.  Either run
>>
>>   top -u '!root'
>>
>> or type “o” (for case-insensitive filter), then e.g. “!USER=root” to show
>> processes started by all users except “root”.  RTFM.
> 
> Neither works on what I have available at work (OpenSuSE 12.2). -u only
> accepts a single user name or id in my world. -o doesn't exist at all.

“o” is not an option, it is an interaktive keystroke command in (my) top(1).  
Press “h” for help (I found out this way while reading your posting).

OpenSUSE 12.2 has procps 3.3.3 which does not support “-u '!$USER'” yet; 
however, OpenSUSE 12.2 has reached its end-of-life on 2014-01-27.

> Thanks for the pointer though.

You’re welcome.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: KB 2670838 - The EVIL UPDATE

2015-03-13 Thread David H. Lipman

From: "Skybuck Flying" 


KB 2670838 - The EVIL UPDATE



< snip >



GOODBYE,
  FAILURE TO DO SO PUTS YOUR SYSTEMS AT RISK !


Bye,
  Skybuck. 


I hope you like the taste of shoe leather.

KB2670838 ==> 2013 !

It was not a part of the March '15 Patch tuesday release.


--
Dave
Multi-AV Scanning Tool - http://multi-av.thespykiller.co.uk
http://www.pctipp.ch/downloads/dl/35905.asp
--
https://mail.python.org/mailman/listinfo/python-list


Re: Pexpect idea - but can I handle curses?

2015-03-13 Thread Skip Montanaro
On Fri, Mar 13, 2015 at 10:54 AM, Thomas 'PointedEars' Lahn <
pointede...@web.de> wrote:

> Yes, it (top(1) from procps-ng 3.3.9) does.  Either run
>
>   top -u '!root'
>
> or type “o” (for case-insensitive filter), then e.g. “!USER=root” to show
> processes started by all users except “root”.  RTFM.
>

Neither works on what I have available at work (OpenSuSE 12.2). -u only
accepts a single user name or id in my world. -o doesn't exist at all.

Thanks for the pointer though.

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


regex help

2015-03-13 Thread Larry Martell
I need to remove all trailing zeros to the right of the decimal point,
but leave one zero if it's whole number. For example, if I have this:

14S,5.,4.5686274500,3.7272727272727271,3.3947368421052630,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.13725490196

I want to end up with:

14S,5.0,4.56862745,3.7272727272727271,3.394736842105263,5.7307692307692308,5.7547169811320753,4.9423076923076925,5.7884615384615383,5.13725490196

I have a regex to remove the zeros:

'0+[,$]', ''

But I can't figure out how to get the 5. to be 5.0.
I've been messing with the negative lookbehind, but I haven't found
one that works for this.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pexpect idea - but can I handle curses?

2015-03-13 Thread Thomas 'PointedEars' Lahn
Skip Montanaro wrote:

> I have this tweak I'd like to make to the top command (Linux only is
> fine). Most of the time I want to see just one user or all users. Every
> now and again though, I'd like to see all users except another.  Top 
> doesn't support this functionality,

Yes, it (top(1) from procps-ng 3.3.9) does.  Either run

  top -u '!root'

or type “o” (for case-insensitive filter), then e.g. “!USER=root” to show 
processes started by all users except “root”.  RTFM.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Pexpect idea - but can I handle curses?

2015-03-13 Thread Skip Montanaro
I have this tweak I'd like to make to the top command (Linux only is fine).
Most of the time I want to see just one user or all users. Every now and
again though, I'd like to see all users except another.  Top doesn't
support this functionality, but I thought something like "-u -root" would
be a handy extension. Another would be to watch multiple users, e.g. -u
skip,bob. I thought I could fire up a top command showing all users in a
pseudo tty with a fake huge number of lines, then elide the rows matching
unwanted users. However... I have a feeling I might be fairly seriously
challenged trying to work with top's raw output, as it probably does
something more sophisticated than clear the screen and spit out rows. Will
I be in over my head trying to tweak the output? Hmmm... maybe if I tell
top TERM=dumb?

Anyway, before I get in over my head on the input side, I thought I would
check to see if I'm likely to hit a brick wall on the output side...

Thx,

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


Re: Django-DMARC making it easier to manage DMARC reports - Beta 0.1.3 on PyPI

2015-03-13 Thread Chris Angelico
On Mon, Mar 9, 2015 at 9:16 PM, Alan Hicks  wrote:
> With defending reputations as important as receiving email I'm pleased to
> announce another beta of django-dmarc 0.1.3 is released to PyPI.
> https://pypi.python.org/pypi/django-dmarc
>
> The Django DMARC project aims to help with implementing DMARC "Domain-based
> Message Authentication, Reporting & Conformance" and ongoing monitoring by
> importing feedback reports about messages that pass and/or fail DMARC
> evaluation into a more easily digested format.

Welcome to irony. Your message got dropped into my Gmail spam box
because DMARC is incompatible with mailing lists.

Until that can be resolved, I don't want to deploy either end of DMARC
for any of my domains or mail servers.

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


Re: Code hosting providers

2015-03-13 Thread Chris Angelico
On Fri, Mar 13, 2015 at 7:59 PM, Steven D'Aprano
 wrote:
> If you had said, "Sometimes it's worth using a non-federated service, and
> risking vendor lock-in, because the extra features they provide are just
> that good" then I'd accept that. That makes sense. I don't like it, but
> that's the business model of proprietary services: provide more features,
> and use that to lock people in.
>
> But saying "I host my projects on GitHub because I DON'T use any of the
> features which differentiate GitHub from its federated competitors" makes
> no sense to me. You are actively helping to support a software monoculture,
> and you're not even getting any short-term benefit from it! That's the
> worst of all possible worlds -- selling out the future, for no gain today.

Not quite. It's a matter of priorities. I will make use of their
proprietary features, but they aren't important to me, and if ever I
need to move away from GitHub, I'll just shrug and abandon all of that
ancillary stuff. In the meantime, I get zero-dollar hosting of my
repos, including zip download and such (I'm not sure how many other
hosts have that, but it's a minor convenience rather than anything
crucial), and it's a convenient place to point people.

You're welcome to shun them. There is definitely benefit to
encouraging a multiplicity of hosting services. But I'm not bothered
by the GitHub non-free-ness, because I take a less philosophical and
more pragmatic view of things.

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


Re: generator/coroutine terminology

2015-03-13 Thread Chris Angelico
On Fri, Mar 13, 2015 at 8:12 PM, Rustom Mody  wrote:
> On Friday, March 13, 2015 at 1:53:50 PM UTC+5:30, Chris Angelico wrote:
>> On Fri, Mar 13, 2015 at 4:28 PM, Rustom Mody  wrote:
>> > And even there I would expect generators to close with StopIteration
>> > Whereas I would expect coroutines to close (on close method) with 
>> > GeneratorExit
>> > [Ive not thought all this through properly so may be off the mark]
>>
>> I expect both of them to close with "return".
>
> Nice demo of the same confusing terminology we are talking about.
>
> When I say "expect generators to close" I mean 'generator-instances' ie at 
> runtime
>
> When you say "expect both to close with return" you are talking of 
> program-texts
> ie the 'factory'
>
> [Or I am guilty of the same I am accusing python of]

Well, if you're going to discuss the specifics of terminology, we'd
best figure out what "close" means :)

You spoke of generators closing "with" StopIteration. Does that mean
that, once a generator closes, it raises StopIteration? That's the job
of the next() method, in effect. Or do you mean that raising
StopIteration will terminate the generator? That won't be true
forever, and shouldn't be relied on - just use "return".

If you use the close() method, Python throws a GeneratorExit into your
generator. But unless you have something that catches that, you
shouldn't need to worry about it; all you need to know is that you
call close() and the function cleanly terminates. Like I said, there
are implementation details that don't usually matter.

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


Re: Code hosting providers (was: Google Code Shutting Down)

2015-03-13 Thread Mario Figueiredo
On Fri, 13 Mar 2015 12:37:30 +1100, Ben Finney
 wrote:

>
>Any service which doesn't run their service on free software is one to
>avoid http://mako.cc/writing/hill-free_tools.html>; free software
>projects need free tools to remain that way.
>
>
>GitLab https://about.gitlab.com/> is a good option: they provide
>VCS, file hosting, wiki, issue tracker, code review via merge requests,
>etc. and all of it can be migrated to any other instance of the same
>service.
>

For sure the Communition Edition offers self-hosting. But in face of
Benjamin article above, what is your opinion on its commercial
approach to provide only relevant features through its vendor lock-in
service?

I always wondered what would happen if the developers community
chooses to take its open-source Community edition and fork it into a
EE edition.

Reminds me so much of MySQL and why MariaDB is today a superior
DBMS...

>Also worth watching is Kallithea, a new federated code hosting service
>https://kallithea-scm.org/>. It supports Mercurial and Git for VCS,
>code review, and integrates with existing issue trackers. Because it's
>federated, you won't suffer from vendor lock-in.
>
>Good hunting in finding a free-software code hosting provider for your
>projects!

And Redmine. Kallithea and Redmine seem like two great options. The
only problem with Redmine is that it does not provide any Git workflow
(correc tme if this is not true anymore).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: generator/coroutine terminology

2015-03-13 Thread Marko Rauhamaa
Rustom Mody :

> Nice demo of the same confusing terminology we are talking about.

Why don't you just stick with the terminology of the language
specification? I think your students are going to be more confused if
you try to come up with something better.

> When I say "expect generators to close" I mean 'generator-instances'
> ie at runtime
>
> When you say "expect both to close with return" you are talking of
> program-texts ie the 'factory'
>
> [Or I am guilty of the same I am accusing python of]

Your 'factory' is a:

generator
A function which returns an iterator.
https://docs.python.org/3/glossary.html>

Your 'generator-instance' is an:

iterator
An object representing a stream of data.
https://docs.python.org/3/glossary.html>

I don't think you should read much into what str(obj) returns. It's not
much more than a random printable some CPython coder has cooked up in
the heat of the moment.


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


Re: generator/coroutine terminology

2015-03-13 Thread Rustom Mody
On Friday, March 13, 2015 at 1:53:50 PM UTC+5:30, Chris Angelico wrote:
> On Fri, Mar 13, 2015 at 4:28 PM, Rustom Mody  wrote:
> > And even there I would expect generators to close with StopIteration
> > Whereas I would expect coroutines to close (on close method) with 
> > GeneratorExit
> > [Ive not thought all this through properly so may be off the mark]
> 
> I expect both of them to close with "return".

Nice demo of the same confusing terminology we are talking about.

When I say "expect generators to close" I mean 'generator-instances' ie at 
runtime

When you say "expect both to close with return" you are talking of program-texts
ie the 'factory'

[Or I am guilty of the same I am accusing python of]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code hosting providers

2015-03-13 Thread Steven D'Aprano
Chris Angelico wrote:

> It's worth noting, by the way, that sometimes it's worth using a
> non-federated service. I host most of my projects on GitHub, because
> the git repo is the part that's most important to me. I don't heavily
> use the bug tracker attached to any of those projects, nor the
> gh-pages branch, etc, etc.


That is the complete opposite of making sense.

If you had said, "Sometimes it's worth using a non-federated service, and
risking vendor lock-in, because the extra features they provide are just
that good" then I'd accept that. That makes sense. I don't like it, but
that's the business model of proprietary services: provide more features,
and use that to lock people in.

But saying "I host my projects on GitHub because I DON'T use any of the
features which differentiate GitHub from its federated competitors" makes
no sense to me. You are actively helping to support a software monoculture,
and you're not even getting any short-term benefit from it! That's the
worst of all possible worlds -- selling out the future, for no gain today.

Personally, I won't use Github if I can possibly ignore it. I have ethical
issues with their corporate culture, and I dislike anything which smacks of
a monoculture. The more Github gets treated as synonymous with revision
control, the more I will push back, until I cannot push back any more.


-- 
Steven

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


Re: Google Code Shutting Down

2015-03-13 Thread Steven D'Aprano
Ian Kelly wrote:

> On Thu, Mar 12, 2015 at 4:26 PM, Josh English
>  wrote:
>> I've been hosting Python projects on Google Code, and they're shutting
>> down.
>>
>> Damn.
>>
>> What is the recommended replacement for Code Hosting that works reliably
>> with PyPi and pip?
> 
> Google has been migrating most of its own open source projects to GitHub.

All that tells me is that Google is planning on buying GitHub, at which
point they will continue the process of GitHub lock-in.

http://nedbatchelder.com/blog/201405/github_monoculture.html



-- 
Steven

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


Re: Python3 "pickle" vs. stdin/stdout - unable to get clean byte streams in Python 3

2015-03-13 Thread Steven D'Aprano
John Nagle wrote:

>I'm starting to think that the "cpickle" module, which Python 3
> uses by default, has a problem. After the program has been
> running for a while, I start seeing errors such as
> 
>   File "C:\projects\sitetruth\InfoSiteRating.py", line 200, in scansite
> if len(self.badbusinessinfo) > 0 :  # if bad stuff
> NameError: name 'len' is not defined
> 
> which ought to be impossible in Python, and

"Impossible"?

py> len

py> import __builtin__  # use builtins in Python 3
py> del __builtin__.len
py> len
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'len' is not defined


Why something is deleting builtins len is a mystery. Sounds to me that your
Python installation is borked.


>   File "C:\projects\sitetruth\subprocesscall.py", line 129, in send
> self.writer.dump(args)  # send data
> OSError: [Errno 22] Invalid argument
> 
> from somewhere deep inside CPickle.

Why do you say "deep inside CPickle"? The traceback says 
C:\projects\sitetruth\subprocesscall.py

Is it possible you have accidentally shadowed the CPickle module with
something? What does this say?

import cPickle
print cPickle.__file__

Use _pickle in Python 3.


> I got
> 
>   File "C:\projects\sitetruth\InfoSiteRating.py", line 223, in
> get_rating_text
> (ratingsmalliconurl, ratinglargiconurl, ratingalttext) =
> DetailsPageBuilder.getratingiconinfo(rating)
> NameError: name 'DetailsPageBuilder' is not defined
> (That's an imported module.  It worked earlier in the run.)
> 
> and finally, even after I deleted all .pyc files and all Python
> cache directories:
> 
> Fatal Python error: GC object already tracked
> 
> Current thread 0x1a14 (most recent call first):
>   File "C:\python34\lib\site-packages\pymysql\connections.py", line 411
> in description
>   File "C:\python34\lib\site-packages\pymysql\connections.py", line 1248
> in _get_descriptions
>   File "C:\python34\lib\site-packages\pymysql\connections.py", line 1182
> in _read_result_packet
>   File "C:\python34\lib\site-packages\pymysql\connections.py", line 1132
> in read
>   File "C:\python34\lib\site-packages\pymysql\connections.py", line 929
> in _read_query_result
>   File "C:\python34\lib\site-packages\pymysql\connections.py", line 768
> in query
>   File "C:\python34\lib\site-packages\pymysql\cursors.py", line 282 in
> _query
>   File "C:\python34\lib\site-packages\pymysql\cursors.py", line 134 in
> execute
>   File "C:\projects\sitetruth\domaincacheitem.py", line 128 in select
>   File "C:\projects\sitetruth\domaincache.py", line 30 in search
>   File "C:\projects\sitetruth\ratesite.py", line 31 in ratedomain
>   File "C:\projects\sitetruth\RatingProcess.py", line 68 in call
>   File "C:\projects\sitetruth\subprocesscall.py", line 140 in docall
>   File "C:\projects\sitetruth\subprocesscall.py", line 158 in run
>   File "C:\projects\sitetruth\RatingProcess.py", line 89 in main
>   File "C:\projects\sitetruth\RatingProcess.py", line 95 in 
> 
> That's a definite memory error.
>
> So something is corrupting memory.  Probably CPickle.


> All my code is in Python. Every library module came in via "pip", into a
> clean Python 3.4.3 (32 bit) installation on Win7/x86-64.
> Currently installed packages:
> 
> beautifulsoup4 (4.3.2)
> dnspython3 (1.12.0)
> html5lib (0.999)
> pip (6.0.8)
> PyMySQL (0.6.6)
> pyparsing (2.0.3)
> setuptools (12.0.5)
> six (1.9.0)
> 
> And it works fine with Python 2.7.9.
> 
> Is there some way to force the use of the pure Python pickle module?

Try renaming the _pickle module. This works on Linux:

mv /usr/local/lib/python3.3/lib-dynload/_pickle.cpython-33m.so 
/usr/local/lib/python3.3/lib-dynload/_pickle.cpython-33m.so~


> My guess is that there's something about reusing "pickle" instances
> that botches memory uses in CPython 3's C code for "cpickle".

How are you reusing instances?


-- 
Steven

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


Re: Code hosting providers

2015-03-13 Thread Chris Angelico
On Fri, Mar 13, 2015 at 4:17 PM, Paul Rubin  wrote:
> Thanks for that informative post: I've been uncomfortable with the reach
> of Github and you've done a good job explaining the reasons.
>
> I personally use self-hosted git repositories on cheap VPS servers which
> is easy to do, but doesn't supply issue tracking.  I know various
> projects that use either Trac or Bugzilla but I haven't tried operating
> those.

It's worth noting, by the way, that sometimes it's worth using a
non-federated service. I host most of my projects on GitHub, because
the git repo is the part that's most important to me. I don't heavily
use the bug tracker attached to any of those projects, nor the
gh-pages branch, etc, etc. If ever I need to move off GitHub, the loss
of my tracker history is almost entirely non-significant. But if
someone goes looking at my repo there, and wants to raise an issue,
I'm quite happy to have that come through the tracker - which means
that, technically, I am using that non-federated service. It's not
something to fear, just something to be aware of.

With the example of moving emails around, the hard part usually isn't
SMTP and co, but moving your email history. Can you download all your
emails in a convenient format for unloading into your new host, or do
you get a proprietary .PST file that you have to somehow deal with?
I'm not speaking from any sort of experience here, of course. It's not
like I've had to deal with several people who decided not to move to
an open system because it would be too hard to move their data. No, of
course not. That never happens.

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


Re: My emails are getting bounced?

2015-03-13 Thread Tim Golden
On 12/03/2015 22:03, Zachary Ware wrote:
> On Thu, Mar 12, 2015 at 4:56 PM, Ryan Gonzalez  wrote:
>> I'm posting this here because I have no clue who the heck the mailing list
>> manager is.
>>
>> I got this message:
>>
>> Your membership in the mailing list Python-ideas has been disabled due
>> to excessive bounces The last bounce received from you was dated
>> 12-Mar-2015.  You will not get any more messages from this list until
>> you re-enable your membership.  You will receive 3 more reminders like
>> this before your membership in the list is deleted.
> 
> I just got the same and sent a mail to python-ideas-ow...@python.org.
> I suspect the problem is that Gmail is bounces any message coming
> through the list from an @yahoo.com address; I've been having to
> not-spam every message from Andrew Barnett this week.
> 

Only slightly ironically, I had to approve that email to python-list
(not sure why; I just waved it through).

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


Re: generator/coroutine terminology

2015-03-13 Thread Chris Angelico
On Fri, Mar 13, 2015 at 4:28 PM, Rustom Mody  wrote:
> And even there I would expect generators to close with StopIteration
> Whereas I would expect coroutines to close (on close method) with 
> GeneratorExit
> [Ive not thought all this through properly so may be off the mark]

I expect both of them to close with "return". You can throw
GeneratorExit into a generator, but that's an implementation detail
more than anything else (same as the throwing of SystemExist is, and
for the same reason). When any iterator is exhausted, next() will
raise StopIteration rather than returning something; if you're simply
iterating over a generator, you can treat StopIteration as an
implementation detail too:

def squares_up_to(top):
for n in range(top):
if n*n > top: return
yield n*n

for sq in squares_up_to(50):
print(sq)

You don't need to be concerned about all those little details of
resuming and stack frames and so on. You definitely don't need to
worry about strange interactions around a "with" block inside the
generator - you can confidently trust that everything will behave
correctly. As it happens, this notion of "behaving correctly" is
largely implemented using exceptions, but if it were implemented with
a bunch of special cases in the CPython source code, it wouldn't
matter.

Write idiomatic source code and don't worry about the details. Learn
how things work if you're curious, but it's seldom going to matter.

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


Re: My emails are getting bounced?

2015-03-13 Thread Zachary Ware
On Thu, Mar 12, 2015 at 4:56 PM, Ryan Gonzalez  wrote:
> I'm posting this here because I have no clue who the heck the mailing list
> manager is.
>
> I got this message:
>
> Your membership in the mailing list Python-ideas has been disabled due
> to excessive bounces The last bounce received from you was dated
> 12-Mar-2015.  You will not get any more messages from this list until
> you re-enable your membership.  You will receive 3 more reminders like
> this before your membership in the list is deleted.

I just got the same and sent a mail to python-ideas-ow...@python.org.
I suspect the problem is that Gmail is bounces any message coming
through the list from an @yahoo.com address; I've been having to
not-spam every message from Andrew Barnett this week.

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