Re: Automation query... Plz help

2018-01-30 Thread Prahallad Achar
Luckily application supports headless automation now question is how to
> invoke those jar using python.

On 29 Jan 2018 10:45 pm, "Prahallad Achar"  wrote:

Thanks for the kind response.
Sure.. Definitely I shall ask development team for the same.

Regards
Prahallad

On 29 Jan 2018 7:48 pm, "Steven D'Aprano"  wrote:

> On Mon, 29 Jan 2018 17:50:46 +0530, Prahallad Achar wrote:
>
> > No.. Not at all.
> >
> > Its CTP application.. Which is basically transport planner for networks
>
> If you want to know whether CTP can be run headless, you should ask the
> CTP support team or software maintainer, not Python forums.
>
> Do you have a support contract for this software? You could ask the help
> desk.
>
>
> --
> Steve
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


2.6.7: Does socket.gethostbyaddr truncate?

2018-01-30 Thread Antoon Pardon
I am using python 2.6.7 to do a little network programming, but it seems I don't
get all the results.

When I call socket.gethostbyaddr(IP) entry [1] of the result is a list of 34 
addresses.

However when I use: dig -x IP I get a list of 46 addresses.

Am I using the wrong function? Is this a bug? If the latter, is there a work 
around?

-- 
Antoon Pardon.

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


Re: Where has the practice of sending screen shots as source code come from?

2018-01-30 Thread Rustom Mody
On Tuesday, January 30, 2018 at 1:02:12 PM UTC+5:30, Steven D'Aprano wrote:
> On Mon, 29 Jan 2018 21:32:11 -0800, Rustom Mody wrote:
> 
> > On Sunday, January 28, 2018 at 8:37:11 PM UTC+5:30, Steven D'Aprano
> > wrote:
> >> I'm seeing this annoying practice more and more often. Even for trivial
> >> pieces of text, a few lines, people post screenshots instead of copying
> >> the code.
> >> 
> >> Where has this meme come from? It seems to be one which inconveniences
> >> *everyone* involved:
> > 
> > Have you heard of the “Dutch Reach¨?
> > http://www.telegraph.co.uk/travel/news/the-dutch-reach-how-opening-car-
> door-like-the-dutch-could-save-lives-cycling/
> 
> Ah, yes, the Dutch Reach. That would be like the French Pox (which isn't 
> French), the Spanish Flu (that didn't start in Spain), the Jerusalem 
> artichoke (which is neither an artichoke nor from Jerusalem), and the 
> turkey (the bird, which has nothing to do with Turkey, the country).
> 
> This technique is neither taught nor commonly used used by the Dutch: 
> apparently some Americans decided that because the Netherlands has a lot 
> of cyclists, they'll say its Dutch.

reference please But before we wander far afield OT please also read below
> 
> https://en.wikipedia.org/wiki/Dooring
> 
> So let me see if I understand the logic... 
> 
> Rather than teach people to *explicitly* check their mirror to make sure 
> it is safe before opening the car door, teach them a difficult, awkward 
> maneuver which they're guaranteed to stop using the second the driving 
> test is over, that merely points their head more-or-less vaguely in the 
> right direction to *maybe* notice on-coming cyclists *if and only if* 
> they're actually paying attention.

You have interpreted my example/analogy/allegory in the opposite sense from the 
intention.  The example is really far OT for this list so let me back up the abc
hierarchy:


> 
> I can see this falls under the problem solving technique, "We must do 
> something, this is something, therefore we must do it!"

…to wit: Small changes of convenience expecially when habitualized can yield 
large benefits
In this (OT) case using the 'wrong hand' can save lives

If this example does not work for you lets not labour it but find others that 
do!

> 
> The sorts of people who can't remember to check their mirror before 
> opening the car door aren't the sort who will remember to use this 
> awkward technique. And for those who can remember to do so, it is simpler 
> and more effective to explicitly check your mirror (as the Dutch actually 
> do).
> 
> 
> > Presumably it goes beyond the 'inconvenience' of images-instead-of-text
> > to the saving-of-lives…
> 
> I have no idea what connection you think is between this and emailing 
> pictures of source code in place of source code.

There is this slippery slope:
1. Action A is suboptimal (only makes sense wrt action B)
2. Action A is silly
3. You are doing a silly action A
4. You are silly for doing action A
5. You are silly
6. You are  

How close you are to 6 is for you to say
What I want to say is I'd like to be closer to 1

Text is a highly stylized unnatural medium
Its an extreme digitization of something (do you remember?) called handwriting…
At least I remember… being an unwilling school boy… using something called 
fountain pens… filled with something called ink… that for some reason had 
greater affinity for our school uniforms than for our notebooks

That people who have not been cultured in a certain way can do aggravating 
things
like talking with pics instead of text — I wont dispute
That people who have gone from the nature to nurture process conveniently forget
this process is more aggravating
-- 
https://mail.python.org/mailman/listinfo/python-list


[OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Steven D'Aprano
On Tue, 30 Jan 2018 05:48:15 -0800, Rustom Mody wrote:

[...]
>> Ah, yes, the Dutch Reach. That would be like the French Pox (which
>> isn't French), the Spanish Flu (that didn't start in Spain), the
>> Jerusalem artichoke (which is neither an artichoke nor from Jerusalem),
>> and the turkey (the bird, which has nothing to do with Turkey, the
>> country).
>> 
>> This technique is neither taught nor commonly used used by the Dutch:
>> apparently some Americans decided that because the Netherlands has a
>> lot of cyclists, they'll say its Dutch.
> 
> reference please

The onus should be on those who claim that the technique actually is used 
by the Dutch. Anecdotally, the Dutch people I've spoken to on the 
Internet had no idea that this technique even existed.

(I happened to know about this because this week's "QI" on the BBC 
happened to mention it, and that show is very popular among the Dutch. 
There's been quite a number of comments on Reddit from Dutch people 
complaining about the QI Elves' lack of fact checking regarding this, as 
well as machine vision.)

Even the organisation who invented the term acknowledge that lots of 
people, *especially* Dutch people, take issue with their claim that the 
technique is required by Dutch law, is taught in Dutch schools, and is 
routinely practiced by the Dutch.

Their answer? To paraphrase their rambling explanation here:

https://www.dutchreach.org/is-the-dutch-reach-really-dutch/

Trust us, it was required by NL law decades ago but isn't
any longer now, it was never given a name and so even though
it is really commonplace and everyone in NL does it, nobody
remembers doing it. And besides, its only young Dutch people
who say that nobody uses this technique there, what do they
know? Old people use it all the time.

(Not a direct quote.)

Yeah, colour me skeptical that this actually ever was a commonplace 
practice in the NL, or anywhere else for that matter.

There's an easy way to find out whether this is commonplace in the NLs. 
Look at Dutch movies and television. How do the characters open their car 
doors?

By the way, anyone who actually has a car: I encourage you to sit in 
driver's seat of your car and try out this "Dutch Reach" maneuver for 
yourself. If you do, you will probably have the same experience that I 
did when I tried it:

It is awkward and clumsy to reach across and open the door with your 
opposite hand, but most importantly, doing so does NOT cause your upper 
body to twist around enough to automatically look behind the car for on-
coming cyclists. I estimate that my head and upper torso rotated no more 
than about 30 degree from "straight ahead".

This effectively and completely undermines the supposed claim that this 
technique makes it *automatic* to look behind you for on-coming cyclists. 
That simply isn't the case. Whether you use the arm closest or furthest 
from the door, you still need to make a conscious effort to either look 
over your shoulder (where your view will be obstructed by the car pillar 
by the door), or consciously check your side mirror.

Guess which one is both easier and more effective?


-- 
Steve

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


Re: [OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Matt Wheeler
On Tue, 30 Jan 2018 at 15:39 Steven D'Aprano <
[email protected]> wrote:

> This effectively and completely undermines the supposed claim that this
> technique makes it *automatic* to look behind you for on-coming cyclists.
> That simply isn't the case. Whether you use the arm closest or furthest
> from the door, you still need to make a conscious effort to either look
> over your shoulder (where your view will be obstructed by the car pillar
> by the door), or consciously check your side mirror.
>

Checking the side mirrors isn't particularly helpful advice if you're
sitting in any seat other than the driver's seat, however.
-- 

--
Matt Wheeler
http://funkyh.at
-- 
https://mail.python.org/mailman/listinfo/python-list


Import statements and multiprocessing

2018-01-30 Thread Nicholas Cole
Dear List,

I have a strange problem on python 3.6.1

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

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

from .some_file_in_the_package import *

line at the top.

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

def some_function():
from .some_file_in_the_package import ThisObject

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

With the explicit import statements everything works as expected.

What could be going wrong?

Best wishes,

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


[OT] Text as digitization [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Steven D'Aprano
On Tue, 30 Jan 2018 05:48:15 -0800, Rustom Mody wrote:

> Text is a highly stylized unnatural medium

Hmmm. I think it is no more "unnatural" than whale songs or the extremely 
formalised dancing rituals of birds or any other animal communication.

Our species just takes this communication to a higher level of 
information content -- but that's a matter of degree, not kind.

But okay, for the sake of the argument, it's highly stylised (like formal 
logic, mathematical reasoning, filling in your tax return, and Kabuki 
theatre). How is that relevant?

We're talking about *programmers* here -- if they can't cope with the 
highly stylised textual medium in which they work, they're going to 
really struggle to, you know, actually program.

And as for being unnatural -- that would be like electric lights, 
antibiotics, eyeglasses, and dentistry. Still not seeing the downside 
here. The natural state of humanity is to spend the majority of your life 
being cold and hungry, hot and hungry, or terrified, before dying young.


> Its an extreme digitization
> of something (do you remember?) called handwriting… 

Of course I remember handwriting. I still use handwriting.

Typed text has evolved from handwriting, via printing. What's your point?


> That people who have not been cultured in a certain way can do
> aggravating things like talking with pics instead of text — I wont
> dispute That people who have gone from the nature to nurture process
> conveniently forget this process is more aggravating

I'm sorry, I don't understand this paragraph.


-- 
Steve

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


Re: [OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Steven D'Aprano
On Tue, 30 Jan 2018 15:48:29 +, Matt Wheeler wrote:

> Checking the side mirrors isn't particularly helpful advice if you're
> sitting in any seat other than the driver's seat, however.

That's a fair point.

But it really only applies to those sitting on the driver's side in the 
back seat. On the passenger's side, you open the door towards the curb, 
out of the way of both cyclists and on-coming traffic.

For the minority of passengers sitting in the rear on the driver's side, 
you just have to be extra careful about opening the door and stepping out 
into the road, not just for the sake of cyclists, but also for the sake 
of not being side-swiped by a car or truck as you step into the road.



-- 
Steve

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


Re: [OT] Text as digitization [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Chris Angelico
On Wed, Jan 31, 2018 at 3:09 AM, Steven D'Aprano
 wrote:
> On Tue, 30 Jan 2018 05:48:15 -0800, Rustom Mody wrote:
>
>> Text is a highly stylized unnatural medium
> [chomp]
>
>> That people who have not been cultured in a certain way can do
>> aggravating things like talking with pics instead of text — I wont
>> dispute That people who have gone from the nature to nurture process
>> conveniently forget this process is more aggravating
>
> I'm sorry, I don't understand this paragraph.

I think that paragraph is his demonstration that text can, if properly
crafted, be as useless as an image.

*ducking for cover*

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


Re: Import statements and multiprocessing

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

[...]
> The function I am passing to map calls a function in another file within
> the same model.  And that file has a
> 
> from .some_file_in_the_package import *
> 
> line at the top.
> 
> However, in each function called in that file, I seem to need to put an
> explicit important statement buried within the function in order for the
> code to work:
> 
> def some_function():
> from .some_file_in_the_package import ThisObject
> 
> It is as if in the worker processes created by Pool.map() the from .
> import * directive is being completely ignored.

[...]
> What could be going wrong?

I would say you're probably misinterpreting the nature of the problem. 
Import * isn't a directive that can be ignored.

Can you show us a *simplified* demonstration? A minimal sample program 
which we can run that demonstrates the issue?

Here's an expensive function for you to call:


import time

def process(value):
time.sleep(3)
return value+1



And a data set to process:

data = [1, 2, 3, 4]


Can you put them in a minimal package, show us how you would import them, 
and call worker processes with them? We ought to be able to copy the code 
and run it ourselves to see the issue first hand. See 

http://sscce.org/

for further details.


-- 
Steve

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


Re: [OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Grant Edwards
On 2018-01-30, Steven D'Aprano  wrote:
> On Tue, 30 Jan 2018 15:48:29 +, Matt Wheeler wrote:
>
>> Checking the side mirrors isn't particularly helpful advice if you're
>> sitting in any seat other than the driver's seat, however.
>
> That's a fair point.
>
> But it really only applies to those sitting on the driver's side in the 
> back seat. On the passenger's side, you open the door towards the curb, 
> out of the way of both cyclists and on-coming traffic.

Unless the bike lane is between the "parallel parking lane" and the
curb[*], in which case it's the passenger side doors that are used to
catch bicycles rather than the driver's side doors.

[*] This seems to be increasingly common here in the Minneapolis /
St. Paul area

-- 
Grant Edwards   grant.b.edwardsYow! People humiliating
  at   a salami!
  gmail.com

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


Re: Import statements and multiprocessing

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

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

[snip]

I find it extremely odd.

File A:

the multiprocessing code and the map function.

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

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


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

In single process code this seems to work perfectly.

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

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


Re: Import statements and multiprocessing

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

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

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

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

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

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


Re: Where has the practice of sending screen shots as source code come from?

2018-01-30 Thread alister via Python-list
On Tue, 30 Jan 2018 07:28:58 +, Steven D'Aprano wrote:

> On Mon, 29 Jan 2018 21:32:11 -0800, Rustom Mody wrote:
> 
>> On Sunday, January 28, 2018 at 8:37:11 PM UTC+5:30, Steven D'Aprano
>> wrote:
>>> I'm seeing this annoying practice more and more often. Even for
>>> trivial pieces of text, a few lines, people post screenshots instead
>>> of copying the code.
>>> 
>>> Where has this meme come from? It seems to be one which inconveniences
>>> *everyone* involved:
>> 
>> Have you heard of the “Dutch Reach¨?
>> http://www.telegraph.co.uk/travel/news/the-dutch-reach-how-opening-car-
> door-like-the-dutch-could-save-lives-cycling/
> 
> Ah, yes, the Dutch Reach. That would be like the French Pox (which isn't
> French), the Spanish Flu (that didn't start in Spain), the Jerusalem
> artichoke (which is neither an artichoke nor from Jerusalem), and the
> turkey (the bird, which has nothing to do with Turkey, the country).
> 
> This technique is neither taught nor commonly used used by the Dutch:
> apparently some Americans decided that because the Netherlands has a lot
> of cyclists, they'll say its Dutch.
> 
The British TV show QI seemed to think this is actually part of the Dutch 
driving test although they have been known to make mistakes

> https://en.wikipedia.org/wiki/Dooring
> 
> So let me see if I understand the logic...
> 
> Rather than teach people to *explicitly* check their mirror to make sure
> it is safe before opening the car door, teach them a difficult, awkward
> maneuver which they're guaranteed to stop using the second the driving
> test is over, that merely points their head more-or-less vaguely in the
> right direction to *maybe* notice on-coming cyclists *if and only if*
> they're actually paying attention.
> 
> I can see this falls under the problem solving technique, "We must do
> something, this is something, therefore we must do it!"
> 
on this I can agree with you.
Personally I tend to "crack" the door a little & then look down the road 
Before opening fully. i am pretty sure I also (at least subconsciously) 
check the mirror.
Then again many* cyclists tend to be in the blind spot, dressed in dark 
clothing & have no lights & ride with zero regard to the rules of the 
road.

> The sorts of people who can't remember to check their mirror before
> opening the car door aren't the sort who will remember to use this
> awkward technique. And for those who can remember to do so, it is
> simpler and more effective to explicitly check your mirror (as the Dutch
> actually do).
> 
> 
>> Presumably it goes beyond the 'inconvenience' of images-instead-of-text
>> to the saving-of-lives…
> 
> I have no idea what connection you think is between this and emailing
> pictures of source code in place of source code.

* not all, some do appear have a desire to live.



-- 
The pollution's at that awkward stage.  Too thick to navigate and too
thin to cultivate.
-- Doug Sneyd
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] Text as digitization [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Grant Edwards
On 2018-01-30, Steven D'Aprano  wrote:

> We're talking about *programmers* here -- if they can't cope with the 
> highly stylised textual medium in which they work, they're going to 
> really struggle to, you know, actually program.

Well, to be fair, many of them do (struggle to actually program, that
is).

Spend any time at all reading PHP forums and you'll despair for
humanity.  Not only are they trying to build airports and radios out
of bamboo and twine, they don't even know how to split cane or tie a
knot.

-- 
Grant Edwards   grant.b.edwardsYow! WHO sees a BEACH BUNNY
  at   sobbing on a SHAG RUG?!
  gmail.com

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


Re: 2.6.7: Does socket.gethostbyaddr truncate?

2018-01-30 Thread Dan Stromberg
dig -x should return a single PTR in all cases, shouldn't it?

What IP are you using?

2.6 is very old.  You probably should move to at Least 2.7, and plan a
move to 3.x.

On Tue, Jan 30, 2018 at 4:05 AM, Antoon Pardon  wrote:
> I am using python 2.6.7 to do a little network programming, but it seems I 
> don't
> get all the results.
>
> When I call socket.gethostbyaddr(IP) entry [1] of the result is a list of 34 
> addresses.
>
> However when I use: dig -x IP I get a list of 46 addresses.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-30 Thread Rhodri James

On 30/01/18 16:47, alister via Python-list wrote:

The British TV show QI seemed to think this is actually part of the Dutch
driving test although they have been known to make mistakes


It has to be noted that the QI Elves did not do particularly well in 
Only Connect...


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread MRAB

On 2018-01-30 15:39, Steven D'Aprano wrote:

On Tue, 30 Jan 2018 05:48:15 -0800, Rustom Mody wrote:

[...]

Ah, yes, the Dutch Reach. That would be like the French Pox (which
isn't French), the Spanish Flu (that didn't start in Spain), the
Jerusalem artichoke (which is neither an artichoke nor from Jerusalem),
and the turkey (the bird, which has nothing to do with Turkey, the
country).

This technique is neither taught nor commonly used used by the Dutch:
apparently some Americans decided that because the Netherlands has a
lot of cyclists, they'll say its Dutch.


reference please


The onus should be on those who claim that the technique actually is used
by the Dutch. Anecdotally, the Dutch people I've spoken to on the
Internet had no idea that this technique even existed.


Do we know of anyone who's Dutch and frequents a Python newsgroup? :-)

[snip]
--
https://mail.python.org/mailman/listinfo/python-list


Re: checksum problem

2018-01-30 Thread Peter Pearson
On Tue, 30 Jan 2018 11:24:07 +0100, jak  wrote:
> Hello everybody,
> I'm using python 2.7.14 and calculating the checksum with the sha1 
> algorithm and this happens: the checksum is wrong until I read the whole 
> file in one shot. Here is a test program:
>
> import hashlib
>
> def Checksum(fname, blocks):
>  m = hashlib.sha1()
>  print "sha1 block size: " + str(m.block_size * blocks)
>  with open(fname, "rb") as fh:
>  for data in fh.read(m.block_size * blocks):
>  m.update(data)
>  return m.hexdigest()
>
> def main():
>  for b in range(10, 260, 10):
>  print str(b) + ': ' + 
> Checksum("d:/upload_688df390ea0bd728fdbeb8972ae5f7be.zip", b)
>
> if __name__ == '__main__':
>  main()
>
> and this is the result output:
>
> sha1 block size: 640
> 10: bf09de3479b2861695fb8b7cb18133729ef00205
> sha1 block size: 1280
> 20: 71a5499e4034fdcf0eb0c5d960c8765a8b1f032d
> .
> .
> .
> sha1 block size: 12160
> 190: 956d017b7ed734a7b4bfdb02519662830dab4fbe
> sha1 block size: 12800
> 200: 1b2febe05b70f58350cbb87df67024ace43b76e5
> sha1 block size: 13440
> 210: 93832713edb40cf4216bbfec3c659842fbec6ae4
> sha1 block size: 14080
> 220: 93832713edb40cf4216bbfec3c659842fbec6ae4
> .
> .
> .
>
> the file size is 13038 bytes and its checksum is 
> 93832713edb40cf4216bbfec3c659842fbec6ae4
>
> Why do I get these results? What am I doing wrong?
>
> Thanks to everyone in advance.

I believe your "for data in fh.read" loop just reads the first block of
the file and loops over the bytes in that block (calling m.update once
for each byte, probably the least efficient approach imaginable),
omitting the remainder of the file.  That's why you start getting the
right answer when the first block is big enough to encompass the whole
file.

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Import statements and multiprocessing

2018-01-30 Thread Terry Reedy

On 1/30/2018 10:54 AM, Nicholas Cole wrote:


I have a strange problem on python 3.6.1

[involving multiprocessing]

I think the first thing you should do is upgrade to 3.6.4 to get all the 
bugfixes since 3.6.4. I am pretty sure there have been some for 
multiprocessing itself. *Then* see if you still have a problem.


--
Terry Jan Reedy

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


Re: checksum problem

2018-01-30 Thread Chris Angelico
On Wed, Jan 31, 2018 at 6:21 AM, Peter Pearson
 wrote:
> On Tue, 30 Jan 2018 11:24:07 +0100, jak  wrote:
>>  with open(fname, "rb") as fh:
>>  for data in fh.read(m.block_size * blocks):
>>  m.update(data)
>>  return m.hexdigest()
>>
>
> I believe your "for data in fh.read" loop just reads the first block of
> the file and loops over the bytes in that block (calling m.update once
> for each byte, probably the least efficient approach imaginable),
> omitting the remainder of the file.  That's why you start getting the
> right answer when the first block is big enough to encompass the whole
> file.

Correct analysis.

Generally, if you want to read a file in chunks, the easiest way is this:

while "moar data":
data = fh.read(block_size)
if not data: break
m.update(data)

That should get you the correct result regardless of your block size,
and then you can tweak the block size to toy with performance.

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


PyPy support breaking CPython compatibility?

2018-01-30 Thread Etienne Robillard

Hi,

I managed to patch Schevo and Durus to run under PyPy 5.9. However, I'm 
afraid the changes is breaking Python 2.7 compatibility.


I'm not sure how I should distribute my changes to the respective projects.

Since I decided to use more PyPy in my Django projects, should I drop 
Python 2.7 support and release the experimental code on PyPi ?



What do you think?

Etienne


--
Etienne Robillard
[email protected]
https://www.isotopesoftware.ca/

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


Re: [OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Ian Kelly
On Tue, Jan 30, 2018 at 9:24 AM, Grant Edwards
 wrote:
> On 2018-01-30, Steven D'Aprano  wrote:
>> On Tue, 30 Jan 2018 15:48:29 +, Matt Wheeler wrote:
>>
>>> Checking the side mirrors isn't particularly helpful advice if you're
>>> sitting in any seat other than the driver's seat, however.
>>
>> That's a fair point.
>>
>> But it really only applies to those sitting on the driver's side in the
>> back seat. On the passenger's side, you open the door towards the curb,
>> out of the way of both cyclists and on-coming traffic.
>
> Unless the bike lane is between the "parallel parking lane" and the
> curb[*], in which case it's the passenger side doors that are used to
> catch bicycles rather than the driver's side doors.
>
> [*] This seems to be increasingly common here in the Minneapolis /
> St. Paul area

This seems like it would tend to make the "dooring" problem worse,
since people are not generally accustomed to using caution when
opening their door toward the curb rather than the street.

Also, I just wanted to add that if you're going to use the side mirror
then you need to watch it for a couple of seconds rather than a quick
glance. Most people's mirrors are not particularly well adjusted to
capture the car's blind spot, which is exactly where an oncoming
cyclist would be. A blind spot that can fit an entire car inside of it
is enormous compared to the size of a bicycle.
-- 
https://mail.python.org/mailman/listinfo/python-list


[UDEMY] complete python course 13 hour long course

2018-01-30 Thread Muhammad Waqas
link as follow:
https://www.udemy.com/complete-package-of-python-course-mastery-in-python-course/?couponCode=PYTHONFORUM
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-30 Thread Peter Pearson
On Mon, 29 Jan 2018 14:46:59 -0500, Dennis Lee Bieber wrote:
> On 29 Jan 2018 17:26:32 GMT, Peter Pearson 
> declaimed the following:
>
>>
>>In 1964, the IBM exhibit at the World's Fair in New York demonstrated
>>a system that read dates that visitors wrote by hand.  (You were
>>supposed to write your date of birth, and the system then printed
>>the New York Times's headline for that date.)
>
>   Was it somehow scanning dates from paper or cards, or was it using some
> sort of touch sensor input (pressure tablet, or a pen in a harness with
> position sensors).
>
>   The first would be OCR proper, while the second is what many PDAs (and
> some tablets) rely upon. The second provides actually stroke vector
> information on how the characters are formed, which is more reliable than
> just seeing pixel transitions and trying to match characters to them.

We wrote our dates of birth on paper or punch cards (I forget which)
with an ordinary pen.  We handed the papers (or cards) to someone who
fed them into a machine, which printed slips of paper that were handed
to us as we exited.  According to the promotional displays, our writing
was examined optically; one poster showed a scan path that resembled
an extremely prolate cycloid following along the handwritten line.

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyPy support breaking CPython compatibility?

2018-01-30 Thread Chris Angelico
On Wed, Jan 31, 2018 at 6:35 AM, Etienne Robillard  wrote:
> Hi,
>
> I managed to patch Schevo and Durus to run under PyPy 5.9. However, I'm
> afraid the changes is breaking Python 2.7 compatibility.
>
> I'm not sure how I should distribute my changes to the respective projects.
>
> Since I decided to use more PyPy in my Django projects, should I drop Python
> 2.7 support and release the experimental code on PyPi ?
>
>
> What do you think?

First off, what's your status on Python 3? When you say "PyPy 5.9",
are you referring to the one that's compatible with Python 3.5 or the
one that's compatible with Python 2.7?

If you're supporting Python 3, I don't think there's any problem with
saying "Python 2.7 support ceases as of Schevo v4.0, so if you need Py
2.7 use Schevo 3.x". (It's not as if the old versions will suddenly
cease working or anything.)

On the other hand, if you're looking at two different Python 2.7
interpreters, you'll be narrowing your potential userbase
significantly by dropping CPython support. Maybe that's not an issue
for you (hey, I've "released" code that depends on features in
unreleased versions of Python - the intended userbase is basically
just me, even though the code's open source and published), but it's
definitely a consideration.

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


Re: PyPy support breaking CPython compatibility?

2018-01-30 Thread Etienne Robillard

Hi Chris,


Le 2018-01-30 à 14:53, Chris Angelico a écrit :

If you're supporting Python 3, I don't think there's any problem with
saying "Python 2.7 support ceases as of Schevo v4.0, so if you need Py
2.7 use Schevo 3.x". (It's not as if the old versions will suddenly
cease working or anything.)


Fair enough. I'll gladly release libschevo and libdurus 4.0 very soon. :)

Thank you,

Etienne

--
Etienne Robillard
[email protected]
https://www.isotopesoftware.ca/

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


Re: PyPy support breaking CPython compatibility?

2018-01-30 Thread Ned Batchelder

On 1/30/18 2:35 PM, Etienne Robillard wrote:

Hi,

I managed to patch Schevo and Durus to run under PyPy 5.9. However, 
I'm afraid the changes is breaking Python 2.7 compatibility.


I'm curious what you had to change for PyPy? (Unless it's a Py2/Py3 
thing as Chris mentions.)


I'm not sure how I should distribute my changes to the respective 
projects.


You should make pull requests to the projects so they can incorporate 
the changes.


--Ned.


Since I decided to use more PyPy in my Django projects, should I drop 
Python 2.7 support and release the experimental code on PyPi ?



What do you think?

Etienne




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


Re: Where has the practice of sending screen shots as source code come from?

2018-01-30 Thread Jugurtha Hadjar

On 01/29/2018 03:48 PM, alister via Python-list wrote:

On Mon, 29 Jan 2018 15:20:06 +0100, Jugurtha Hadjar wrote:


On 01/28/2018 04:43 PM, Skip Montanaro wrote:

I've never been a Windows user, but at my current job, Windows is core
to just about everything, so I am forced to use it for a lot of stuff
(Outlook, SQL Server, Excel, etc).

I was hired at a startup which made a good impression on me and I was
eager to start working. I checked in for my first day, signed the
paperwork, then the CTO showed me around and told me "Here's your
laptop, you can install Windows and I'll check in with you later". Life
started draining out of my body and my mind was racing in all directions
before he even finished his sentence. I felt tricked: I was hired based
on a test and the file I've received was a *.tar.gz* and it made me
happy because I assumed they were a NIX shop..

I was considering how I should go about quitting gracefully. I have
stopped using Windows in 2008 for psychological reasons for it made me
really anxious, irritable, angry, and tense to the point of abusing
hardware with low kicks and punches which was not very healthy or sane.
It was only when I switched OS that this behavior stopped. There was no
way I would be going back to my bully.

The CTO then said "Sorry.. I meant Ubuntu." and seeing my pale face, he
said in a reassuring tone "Don't be afraid, there are no Windows
machines here." which brought me back to life.

I hope to be as brave as you some day.

Any Vacancies
whatever they do I am sure I can learn :-)





We're hiring all the good (technical and human side) people we can 
find/afford. It's a small startup that helps its clients improve 
business using machine learning. We're in Algiers, Algeria and Paris, 
France.



--
~ Jugurtha Hadjar,

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


Re: PyPy support breaking CPython compatibility?

2018-01-30 Thread Etienne Robillard

Hi Ned,


Le 2018-01-30 à 15:14, Ned Batchelder a écrit :
I'm curious what you had to change for PyPy? (Unless it's a Py2/Py3 
thing as Chris mentions.) 


Please take a look at the changesets:

https://bitbucket.org/tkadm30/libschevo/commits/745d1aeab5c6ee0d336790cf13d16f327e10c2f8
https://bitbucket.org/tkadm30/libdurus/commits/875636e9b6caa840fd50ca87d69217d87fc06f43

In short, it seems PyPy automagically adds a __weakref__ attribute to 
__slots__, causing the CPython interpreter to raise a TypeError...



Cheers,

Etienne

--
Etienne Robillard
[email protected]
https://www.isotopesoftware.ca/

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


Re: PyPy support breaking CPython compatibility?

2018-01-30 Thread Chris Angelico
On Wed, Jan 31, 2018 at 7:58 AM, Etienne Robillard  wrote:
> Hi Ned,
>
>
> Le 2018-01-30 à 15:14, Ned Batchelder a écrit :
>>
>> I'm curious what you had to change for PyPy? (Unless it's a Py2/Py3 thing
>> as Chris mentions.)
>
>
> Please take a look at the changesets:
>
> https://bitbucket.org/tkadm30/libschevo/commits/745d1aeab5c6ee0d336790cf13d16f327e10c2f8
> https://bitbucket.org/tkadm30/libdurus/commits/875636e9b6caa840fd50ca87d69217d87fc06f43
>
> In short, it seems PyPy automagically adds a __weakref__ attribute to
> __slots__, causing the CPython interpreter to raise a TypeError...
>

I'm confused by this:

-if os.environ.get('SCHEVO_OPTIMIZE', '1') == '1':
+if os.environ.get('SCHEVO_OPTIMIZE', '1') == True:

BTW, this part you should probably consider doing differently:

-except schevo.error.SchemaFileIOError:
+except schevo.error.SchemaFileIOError, ex:
+print ex

The comma version is only needed on really old versions of Python
(2.4? something like that), and won't work on Python 3. Unless support
for ancient Pythons is important to you, I recommend using the "except
type as name:" syntax, which works on 2.7 and on 3.x.

But the weakref situation is curious. Can you show a minimal test-case
for the difference? Might be something that one interpreter or the
other needs to update.

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


Re: PyPy support breaking CPython compatibility?

2018-01-30 Thread Ned Batchelder

On 1/30/18 4:08 PM, Chris Angelico wrote:

On Wed, Jan 31, 2018 at 7:58 AM, Etienne Robillard  wrote:

Hi Ned,


Le 2018-01-30 à 15:14, Ned Batchelder a écrit :

I'm curious what you had to change for PyPy? (Unless it's a Py2/Py3 thing
as Chris mentions.)

Please take a look at the changesets:

https://bitbucket.org/tkadm30/libschevo/commits/745d1aeab5c6ee0d336790cf13d16f327e10c2f8
https://bitbucket.org/tkadm30/libdurus/commits/875636e9b6caa840fd50ca87d69217d87fc06f43

In short, it seems PyPy automagically adds a __weakref__ attribute to
__slots__, causing the CPython interpreter to raise a TypeError...


I'm confused by this:

-if os.environ.get('SCHEVO_OPTIMIZE', '1') == '1':
+if os.environ.get('SCHEVO_OPTIMIZE', '1') == True:

I was also curious about this: when does os.environ.get return anything 
but a string?


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


Re: Where has the practice of sending screen shots as source code come from?

2018-01-30 Thread Gregory Ewing

On Mon, 29 Jan 2018 22:41:36 + (UTC), Steven D'Aprano
 declaimed the following:

Its the component of the router that actually handles the 
telecommunications side of things. Legend has it that once upon a time 
they were a stand alone device.


Even more distant legend suggests that modems existed before
the concept of a router was even thought of. Hard to imagine,
I know!

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


Re: [OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Grant Edwards
On 2018-01-30, Ian Kelly  wrote:
>
>> Unless the bike lane is between the "parallel parking lane" and the
>> curb[*], in which case it's the passenger side doors that are used to
>> catch bicycles rather than the driver's side doors.
>>
>> [*] This seems to be increasingly common here in the Minneapolis /
>> St. Paul area
>
> This seems like it would tend to make the "dooring" problem worse,
> since people are not generally accustomed to using caution when
> opening their door toward the curb rather than the street.

That may be mitigated by the high percentage of cars in US cities that
have no passengers.

-- 
Grant Edwards   grant.b.edwardsYow! Hello.  Just walk
  at   along and try NOT to think
  gmail.comabout your INTESTINES being
   almost FORTY YARDS LONG!!

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


Re: [OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Steven D'Aprano
On Tue, 30 Jan 2018 09:39:26 -0700, Ian Kelly wrote:

> Also, I just wanted to add that if you're going to use the side mirror
> then you need to watch it for a couple of seconds rather than a quick
> glance. Most people's mirrors are not particularly well adjusted to
> capture the car's blind spot, which is exactly where an oncoming cyclist
> would be. A blind spot that can fit an entire car inside of it is
> enormous compared to the size of a bicycle.

How slow is the bike travelling that it takes a couple of seconds to 
cross the length of a car? If they're travelling that slowly, they're not 
so much going to collide with the door as gently nudge it.

Of course you should do more than a quick glance, it should be a proper 
look[1], but surely in a couple of seconds a cyclist could easily travel 
three or four car lengths.




[1] You're not just looking out for cyclists, but traffic, since you're 
stepping out into traffic yourself and presumably would prefer not to 
have some wayward car take your door off, and you with it.



-- 
Steve

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


Re: Automation query... Plz help

2018-01-30 Thread Steven D'Aprano
On Tue, 30 Jan 2018 16:00:43 +0530, Prahallad Achar wrote:

> Luckily application supports headless automation now question is how to
> invoke those jar using python.

I can see two approaches:

(1) Calling the jar directly from Python.

I don't think you can do that from CPython, but you might be able to do 
it from Jython. (Jython is Python implemented in Java, and is designed to 
allow Java and Python code to call each other). Or there might be some 
third-party library that runs under CPython which allows you to do so.


(2) Call the jar as an external process, in whatever way you would call a 
jar from an external application.

Have you tried googling?

https://duckduckgo.com/html/?q=call%20a%20jar%20from%20python


(I think this is the limit of any help I can give -- I know nothing about 
jars except that they are some sort of Java code.)



-- 
Steve

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


Re: Automation query... Plz help

2018-01-30 Thread Prahallad Achar
Thank you.
Indeed I did a search but couldn't find a right approach.

Jython! Yes.. It supports to call jar file.

As you said... Application support team has to modify few things on
application side where object creation should be public rather protected

On 31 Jan 2018 7:12 am, "Steven D'Aprano" <
[email protected]> wrote:

> On Tue, 30 Jan 2018 16:00:43 +0530, Prahallad Achar wrote:
>
> > Luckily application supports headless automation now question is how to
> > invoke those jar using python.
>
> I can see two approaches:
>
> (1) Calling the jar directly from Python.
>
> I don't think you can do that from CPython, but you might be able to do
> it from Jython. (Jython is Python implemented in Java, and is designed to
> allow Java and Python code to call each other). Or there might be some
> third-party library that runs under CPython which allows you to do so.
>
>
> (2) Call the jar as an external process, in whatever way you would call a
> jar from an external application.
>
> Have you tried googling?
>
> https://duckduckgo.com/html/?q=call%20a%20jar%20from%20python
>
>
> (I think this is the limit of any help I can give -- I know nothing about
> jars except that they are some sort of Java code.)
>
>
>
> --
> Steve
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Package containing C sources

2018-01-30 Thread Victor Porton
I am going to create a Python wrapper around a generally useful C library. 
So the wrapper needs to contain some C code to glue them together.

Can I upload a package containing C sources to PyPi?

If not, what is the proper way to distribute it?

-- 
Victor Porton - http://portonvictor.org
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Package containing C sources (Posting On Python-List Prohibited)

2018-01-30 Thread Victor Porton
Lawrence D’Oliveiro wrote:

> On Wednesday, January 31, 2018 at 6:13:00 PM UTC+13, Victor Porton wrote:
>> I am going to create a Python wrapper around a generally useful C
>> library. So the wrapper needs to contain some C code to glue them
>> together.
> 
> Not necessarily. It’s often possible to implement such a wrapper entirely
> in Python, using ctypes .

But if I will find that I need C code, do I need to package it separately?

So I would get three packages: the C library, the C wrapper for Python, and 
the Python code.

Can this be done with just two packages: the C library and C wrapper and 
Python in one package?

-- 
Victor Porton - http://portonvictor.org
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Package containing C sources

2018-01-30 Thread dieter
Victor Porton  writes:

> I am going to create a Python wrapper around a generally useful C library. 
> So the wrapper needs to contain some C code to glue them together.
>
> Can I upload a package containing C sources to PyPi?

You can.

This is documented in "https://docs.python.org/2/extending/building.html";
(for Python 2; likely, it works in the same way for Python 3).


Note: I use "setuptools" (a "distutils" extension)
rather than the base "distutils" -- essentially, because it facilitates
the inclusion of non Python files in a distribution.
I do not know whether the base "distutils" automatically includes
the sources of C extensions (likely it does); "setuptools" provides
a way to include everything under control of a versioning system
(which I rely upon to not miss important files).

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