Re: usage of functools.partial in in parallelism

2016-08-01 Thread Michael Selik
On Sun, Jul 31, 2016 at 5:47 AM Sivan Greenberg  wrote:

> That's exactly the answer I was looking for. Thanks.
>
> I got used too much I guess to solving problems the OOP way, e.g. my code
> wraps the session.get invocation with a class to pack together the
> arguments and data and also took care of parallelism using gevent, from
> within the class.
>
> While a bit more verbose (or god forbid..unpythonic?) I find it much nore
> readable in my taste and easier to pass on to the next code maintainer in
> the heritage.
>

You might benefit from watching the talk "Stop Writing Classes"
https://www.youtube.com/watch?v=o9pEzgHorH0
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why not allow empty code blocks?

2016-08-01 Thread bart4858
On Monday, 1 August 2016 01:22:02 UTC+1, Chris Angelico  wrote:
> On Mon, Aug 1, 2016 at 10:11 AM,   wrote:

> > (128MB or 128KB? In the 1980s we were all running in 64KB to 640KB of 
> > memory. 128MB might be what a well-endowed mainframe might have had!)
> 
> Yes, and we didn't have Python then. When I had a computer with 640KB
> of memory, my options were (1) BASIC or (2) 8086 assembly language,
> using DEBUG.EXE and its mini-assembler. Later on (much much later), I
> added C to the available languages, but it was tedious and annoying,
> because one tiny change meant minutes of compilation.

This wasn't my experience. I used my own tools and designed them to always be 
quick enough in use that compilation speed was never really an issue. Not even 
on 8-bit machines.

I was also happily running my interpreters within 640KB (less than that too 
depending on customers' machines).

So that 128MB limit, or *two hundred* times as much memory, was a hardly a 
limitation!

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


Re: Why not allow empty code blocks?

2016-08-01 Thread bart4858
On Monday, 1 August 2016 01:33:37 UTC+1, Chris Angelico  wrote:
> On Mon, Aug 1, 2016 at 10:21 AM,   wrote:

> > However I do 'drive' as I've been programming for decades. And I can have 
> > an opinion about a model of car that I don't normally drive. An opinion 
> > which you might well not get from someone who drives that model for a 
> > living.
> >
> 
> So've I, but I don't try to tell the Scheme folks that they need to
> change the language. You can have an opinion - but it doesn't make it
> worth anything.

OK. But I both drive, and build my own cars!

You think that my nearly 30 years' experience of designing interpreted 
languages and writing fast bytecode interpreters doesn't make my opinions have 
any more merit, that's fine.

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


Re: Why not allow empty code blocks?

2016-08-01 Thread alister
On Mon, 01 Aug 2016 09:49:46 +1000, Chris Angelico wrote:

> On Mon, Aug 1, 2016 at 9:43 AM,   wrote:
>> On Sunday, 31 July 2016 21:01:52 UTC+1, Michael Torrie  wrote:
>>
>>> That said, I wish he'd stop posting his arguments here on this list as
>>> he clearly doesn't use Python for anything, and hasn't used Python for
>>> any real amount of coding.  He has no vested interest in Python so why
>>> should his opinions matter to us?
>>
>> What's using Python got to do with it? If I needed to write Python as a
>> job, then I'd just get on with it. I probably wouldn't have time to
>> post on here!
>>
>> I don't so can discuss it from a different perspective.
> 
> I should get into Parliament and start passing laws about cars. I'd have
> a valuable perspective on it, since I never drive.
> 
> ChrisA

Based on my experience of driving laws & road traffic planning that is a 
mandatory requirement.



-- 
My BIOLOGICAL ALARM CLOCK just went off ... It has noiseless DOZE
FUNCTION and full kitchen!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why not allow empty code blocks?

2016-08-01 Thread alister
On Mon, 01 Aug 2016 01:05:53 -0700, bart4858 wrote:

> On Monday, 1 August 2016 01:33:37 UTC+1, Chris Angelico  wrote:
>> On Mon, Aug 1, 2016 at 10:21 AM,   wrote:
> 
>> > However I do 'drive' as I've been programming for decades. And I can
>> > have an opinion about a model of car that I don't normally drive. An
>> > opinion which you might well not get from someone who drives that
>> > model for a living.
>> >
>> >
>> So've I, but I don't try to tell the Scheme folks that they need to
>> change the language. You can have an opinion - but it doesn't make it
>> worth anything.
> 
> OK. But I both drive, and build my own cars!
> 
> You think that my nearly 30 years' experience of designing interpreted
> languages and writing fast bytecode interpreters doesn't make my
> opinions have any more merit, that's fine.

Actually the more you make these claims the more I think you are 
suffering from NIH (Not Invented Here) syndrome.

there is another poster on the F1 group who initially made comments along 
the lines "Maybe Ferrari should employ me" at first they were taken as 
tongue in cheek until it became apparent he actually believed them.

without any significant user base for any of your invented Languages I 
would suggest they are nothing more than toys* & instead of thinking "my 
designs are much better" you would be better to use the approach "that's 
not how I would have done it what, do they know that I am missing"


* to be fare even a toy language is beyond my own meagre abilities.

-- 
Worst Month of 1981 for Downhill Skiing:
August.  The lift lines are the shortest, though.
-- Steve Rubenstein
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why not allow empty code blocks?

2016-08-01 Thread Steven D'Aprano
On Monday 01 August 2016 18:05, [email protected] wrote:

> You think that my nearly 30 years' experience of designing interpreted
> languages and writing fast bytecode interpreters doesn't make my opinions
> have any more merit, that's fine.


If you are the only one who has ever seen or used these fast bytecode 
interpreters, then they might as well not exist, in which case, no, your 
opinions have no merit.

No offense intended Bart, but for all we know every single one of your 
benchmarks are faked, your interpreters are buggy pieces of garbage, and for 
all your self-promotion, your code wouldn't survive more than six seconds of 
peer review.


-- 
Steve

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


Re: Why not allow empty code blocks?

2016-08-01 Thread bart4858
On Monday, 1 August 2016 11:12:30 UTC+1, Steven D'Aprano  wrote:
> On Monday 01 August 2016 18:05, [email protected] wrote:
> 
> > You think that my nearly 30 years' experience of designing interpreted
> > languages and writing fast bytecode interpreters doesn't make my opinions
> > have any more merit, that's fine.
> 
> If you are the only one who has ever seen or used these fast bytecode 
> interpreters, then they might as well not exist, in which case, no, your 
> opinions have no merit.
> 
> No offense intended Bart, but for all we know every single one of your 
> benchmarks are faked, your interpreters are buggy pieces of garbage, and for 
> all your self-promotion, your code wouldn't survive more than six seconds of 
> peer review.

Sure. I can't pretend the implementations are wonderful. But I think the ideas 
are good and they would make fine little languages when seriously implementated.

Not that it bothers me because I've sold $millions of software implemented 100% 
in these 'toy' languages (and versions from 20+ years ago too).

(If you want to try something out, go to:

https://github.com/bartg/langs

Download the interpreter pcc32.exe (a Windows binary, but I remember it seemed 
to work under 'wine' in Linux). And test program jpeg.bc (a binary bytecode 
file).

Run as pcc32 jpeg file.jpg (or as wine pcc32 jpeg file.jpg). If it works, the 
image will be displayed.

The sourcecode for jpeg.bc (its main module) is in jpeg.q. (jpeg.m is a 
separate static language version.) I don't have the Python version to hand, but 
that has been posted in the past (and which you have already commented on!).

There is also qq.bc, a bytecode compiler. Run as pcc32 qq filename.q, but I 
haven't provided libraries so only simple programs can be compiled.

(Note that pcc32.exe is not accelerated; that version is 2-3 times faster on 
this test.)

I'm working at the moment on a version that works like Python, directly on 
source code rather than precompiled bytecode. But it needs to be fast enough so 
I'm aiming for a 1M lines per second compilation speed; I've managed 
0.8-0.9Mpls so far on real applications.)

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


Re: Why not allow empty code blocks?

2016-08-01 Thread bart4858
On Monday, 1 August 2016 10:50:20 UTC+1, alister  wrote:


> Actually the more you make these claims the more I think you are 
> suffering from NIH (Not Invented Here) syndrome.

That's not surprising. I started out developing hardware such as microprocessor 
boards and video displays. My languages started as streamlined tools that I 
needed for my job.

Commercial products at the time were poor Chris pointed out (and also 
expensive).

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


use import *

2016-08-01 Thread Ganesh Pal
Hi Team ,

I am a Linux user on python 2,6 . I have a very simple question

I was going the zen of python by Tim peters and found an example  that
demonstrates Explicit is better than implicit

"""Load the cat, dog, and mouse models so we can edit instances of them."""
def load():
from menagerie.cat.models import *
from menagerie.dog.models import *
from menagerie.mouse.models import *
#---
def load():
from menagerie.models import cat as cat_models
from menagerie.models import dog as dog_models
from menagerie.models import mouse as mouse_models
#---
print 'Explicit is better than implicit.'


I had a question on the above example

1. I haven't used " from menagerie.cat.models import *  is it a good
programming practice to use  import * ?   if answer is "NO " then  are
there situation where you are forced to use import *


Regards,

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


Re: Why not allow empty code blocks?

2016-08-01 Thread Gordon Levi
"D'Arcy J.M. Cain"  wrote:

>On Sun, 31 Jul 2016 11:53:47 -0400
>"D'Arcy J.M. Cain"  wrote:
>> On Mon, 01 Aug 2016 00:25:58 +1000
>> On the other hand I have no throwaway accounts.  Every address I use
>> is a primary one.  I have all sorts of methods to block spam.  None of
>> those methods involves moving my spam problem to someone else.
>
>For example...
>
>: Host or domain name not found. Name service
>error for name=address.invalid type=: Host not found
>
>So I have to examine every address I reply to or deal with the bounce
>message later.  Way to move your spam problem to someone else.

.invalid is specified in RFC 2606 for exactly that purpose. If you
don't notice that the address is invalid a server very close to you,
probably your SMTP server, will tell you. In contrast, your valid
email address will become the target of many spam emails even if you
manage to block them. It will also be used as the source of spam so
somebody at vex.net may be fooled into believing that they are
receiving a proper email.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: use import *

2016-08-01 Thread Ian Kelly
On Mon, Aug 1, 2016 at 9:31 AM, Ganesh Pal  wrote:
> Hi Team ,
>
> I am a Linux user on python 2,6 . I have a very simple question
>
> I was going the zen of python by Tim peters and found an example  that
> demonstrates Explicit is better than implicit
>
> """Load the cat, dog, and mouse models so we can edit instances of them."""
> def load():
> from menagerie.cat.models import *
> from menagerie.dog.models import *
> from menagerie.mouse.models import *
> #---
> def load():
> from menagerie.models import cat as cat_models
> from menagerie.models import dog as dog_models
> from menagerie.models import mouse as mouse_models
> #---
> print 'Explicit is better than implicit.'

These aren't equivalent. The first implies the existence of the
package "menagerie.cat.models" while the second implies the existence
of "menagerie.models.cat".

> I had a question on the above example
>
> 1. I haven't used " from menagerie.cat.models import *  is it a good
> programming practice to use  import * ?   if answer is "NO " then  are
> there situation where you are forced to use import *

Generally, no. It can be convenient for use in the interactive
interpreter or in toy programs where code health is unimportant. If
you use it in real work, then you end up in situations where you can't
tell just from looking at the source what names are actually being
imported.
-- 
https://mail.python.org/mailman/listinfo/python-list


Using valid emails

2016-08-01 Thread D'Arcy J.M. Cain
Time to change the subject.

On Tue, 02 Aug 2016 01:30:47 +1000
Gordon Levi  wrote:
> "D'Arcy J.M. Cain"  wrote:
> >: Host or domain name not found. Name service
> >error for name=address.invalid type=: Host not found
> >
> >So I have to examine every address I reply to or deal with the bounce
> >message later.  Way to move your spam problem to someone else.  
> 
> .invalid is specified in RFC 2606 for exactly that purpose. If you
> don't notice that the address is invalid a server very close to you,

Sure so either I have to stop and examine the address or else deal with
the bounce from my SMTP server.  Isn't that what I said?

> probably your SMTP server, will tell you. In contrast, your valid
> email address will become the target of many spam emails even if you
> manage to block them. It will also be used as the source of spam so
> somebody at vex.net may be fooled into believing that they are
> receiving a proper email.

I'm a little insulted that you think that I would ever allow someone to
send mail to Vex.Net pretending to be from Vex.Net.  That's just too
easy to detect and block.  Try it.

-- 
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:[email protected]
VoIP: sip:[email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using valid emails

2016-08-01 Thread Chris Angelico
On Tue, Aug 2, 2016 at 2:05 AM, D'Arcy J.M. Cain  wrote:
>> probably your SMTP server, will tell you. In contrast, your valid
>> email address will become the target of many spam emails even if you
>> manage to block them. It will also be used as the source of spam so
>> somebody at vex.net may be fooled into believing that they are
>> receiving a proper email.
>
> I'm a little insulted that you think that I would ever allow someone to
> send mail to Vex.Net pretending to be from Vex.Net.  That's just too
> easy to detect and block.  Try it.

vex.net. 10800 IN TXT "v=spf1 mx -all"
vex.net. 10800 IN MX 10 mail.vex.net.
mail.vex.net. 10800 IN A 98.158.139.68

So, if you're not sending mail from 98.158.139.68 and you claim to be
vex.net, you should be blocked.

Unfortunately, a lot of domains don't have SPF records, or have very
convoluted ones (check out gmail.com's SPF for instance).

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


Re: Can math.atan2 return INF?

2016-08-01 Thread Ian Kelly
On Sun, Jul 31, 2016 at 10:05 PM, Rustom Mody  wrote:
> All starts with the disorder in the middle-east and a whole lot of arbitrary 
> lines
> drawn there
> [Going backward in time]
> - A line drawn in space called ‘Israel’
> - Based on a line drawn in time called the ‘Exodus of Moses’

I'm no expert but I believe that Zionism was based upon the idea of
Negation of the Diaspora, not Exodus.

> - Based on the supremely authoritative history-record called ‘The Bible’
>   (or Torah depending on the speaker)
>
> Leaving aside the first and the third, why specifically the Exodus as a 
> definer?
> Before Canaan they were in Egypt, so Israel=Egypt is equally legitimate
> And before…before… they were in Eden.
> Why not set Israel up in Eden?

Since the Exodus story has it that the Israelites were slaves in Egypt
(despite the utter lack of archaeological evidence that they were ever
there en masse), placing Israel in Egypt would seem rather insulting.

> May it just be the (in)convenient fact that knocking the Palestinians out of
> their homes is easier than removing Mr. God from Eden?

Fun historical fact: the land of Palestine was so named by the Roman
Emperor Hadrian after he kicked the Jews out of their homes and forced
them to leave. The name was a Romanization of the ancient land of
Philistia, home of the Philistines, despite that they were long gone
by this point. So the entire existence of Palestine is basically one
big fat Roman middle finger to the Jews.

Not that any of this is meant to condone any of the violence in the Middle East.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: use import *

2016-08-01 Thread Chris Angelico
On Tue, Aug 2, 2016 at 1:31 AM, Ganesh Pal  wrote:
> I am a Linux user on python 2,6 . I have a very simple question
>
> I was going the zen of python by Tim peters and found an example  that
> demonstrates Explicit is better than implicit
>
> """Load the cat, dog, and mouse models so we can edit instances of them."""
> def load():
> from menagerie.cat.models import *
> from menagerie.dog.models import *
> from menagerie.mouse.models import *
> #---
> def load():
> from menagerie.models import cat as cat_models
> from menagerie.models import dog as dog_models
> from menagerie.models import mouse as mouse_models
> #---
> print 'Explicit is better than implicit.'
>
>
> I had a question on the above example
>
> 1. I haven't used " from menagerie.cat.models import *  is it a good
> programming practice to use  import * ?   if answer is "NO " then  are
> there situation where you are forced to use import *
>

Specifically to that example? No it's never a good idea to do a
star-import inside a function. It's completely illegal in Python 3.
Normally, you'll want to do your imports at module level, and not with
the star.

There are a very few places where a star import is the best thing to
do, and they're usually because of a tight binding between the two
modules. For example, it's common for __init__.py to say "from
.something import *", to make a package's module's contents available
in the package itself. Also, a Python module with a C accelerator will
often start or end by star-importing from the accelerator (eg ast.py
"from _ast import *"). If you're not doing something like that, there
are only a handful of modules that are really designed with
star-imports in mind (eg tkinter, stat), and even then, I personally
don't recommend it.

The downside of a star-import is that it breaks the common pattern
that the first use of a name is its definition. If you see, somewhere
in a program, "conn = psycopg2.connect(...)", you can go up to the top
of the program to find "import psycopg2" and know that it's a module -
even if you don't recognize the name (since it's a third-party one),
you can know that it's a module. Similarly, if you see "conn =
connect(...)", you can go up to the top - but then it depends on
whether the program author wrote "from psycopg2 import connect" or
"from psycopg2 import *". In the latter case, you have to *guess* that
the name "connect" might have come from there.

So, my recommendation is: Use "import *" only when you control both
ends of something. Otherwise, be explicit.

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


Re: SOAP and Zeep

2016-08-01 Thread Nicolas Évrard
* Ethan Furman  [2016-07-29 19:54 +0200]: 

Greetings!

I may have a need in the immediate future to work with SOAP and WSDL
services, and a quick search turned up Zeep
(http://docs.python-zeep.org/en/latest/) -- does anyone have any
experience with it?
Or any other libraries that can be recommended?


We used zeep to communicate with SOAP webservices.
We choose it over suds because it supports python3.

I also happen to have a bug, and the maintainer quickly accepted my
patch, so according to me it's a good choice.

--
(°> Nicolas Évrard
( ) Liège
`¯
--
https://mail.python.org/mailman/listinfo/python-list


Re: use import *

2016-08-01 Thread Thomas 'PointedEars' Lahn
Ganesh Pal wrote:

> is it a good programming practice to use [from … ] import * ? 

No; but it is not as harmful as one would think either.



> if answer is "NO " then  are there situation where you are forced to use
> import *

No.

-- 
PointedEars

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


Re: Using valid emails

2016-08-01 Thread D'Arcy J.M. Cain
On Tue, 2 Aug 2016 02:22:50 +1000
Chris Angelico  wrote:
> > I'm a little insulted that you think that I would ever allow
> > someone to send mail to Vex.Net pretending to be from Vex.Net.
> > That's just too easy to detect and block.  Try it.  
> 
> vex.net. 10800 IN TXT "v=spf1 mx -all"
> vex.net. 10800 IN MX 10 mail.vex.net.
> mail.vex.net. 10800 IN A 98.158.139.68
> 
> So, if you're not sending mail from 98.158.139.68 and you claim to be
> vex.net, you should be blocked.

Exactly.  I also have a further check.  If you try to send me email
pretending to be from Vex.Net you get a "5xx Yah Right" error.

> Unfortunately, a lot of domains don't have SPF records, or have very
> convoluted ones (check out gmail.com's SPF for instance).

I can only fix my little corner of the Internet.

-- 
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:[email protected]
VoIP: sip:[email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Using valid emails

2016-08-01 Thread D'Arcy J.M. Cain
On Sun, 31 Jul 2016 14:01:26 -0600
Michael Torrie  wrote:
> > So I have to examine every address I reply to or deal with the
> > bounce message later.  Way to move your spam problem to someone
> > else.  
> 
> I've never had this problem.  I use the mailing list side of things
> and I reply to the list and I don't have bounce issues.  Besides

Fine for you.  I actually prefer to have people explicitly reply to me
(and the list) because then it winds up in my INBOX instead of the
Python list folder.  If I am busy I might skim over the Python folder
but I always read my INBOX.  The mail will stand out better.

If I preferred everything in my Python folder I would just change the
filter order.  The idea is that as much as possible everyone should be
able to get everything that they want.

> that, he's not using email; he's using usenet which has never
> required a valid email address, real or fake.  To demand he use a
> real email address is as silly as that guy that lambasts people on
> this list for not using real names.

That's really not the same thing at all.  In fact, I don't even care if
the address even works, as long as it doesn't bounce.  If I didn't want
to get replies I would use [email protected] which gets silently dropped and
the address suggests that it will not be delivered.

But I absolutely don't care if someone uses a fake name.  I agree that
such a restriction would be silly not to mention totally unenforceable.

> That said, I wish he'd stop posting his arguments here on this list as
> he clearly doesn't use Python for anything, and hasn't used Python for
> any real amount of coding.  He has no vested interest in Python so why
> should his opinions matter to us?

Agreed.  That's why I have stopped talking to and listening to him.

> As for spam, I hardly think spambots trolling Usenet are as effective
> these days as they once were.  And most people's anti-spam filters are
> pretty good.  Besides that, those of us posting to the mailing list
> side of things get our real email addresses copied out into Usenet
> and I haven't noticed any change in spam levels.

Ditto.

-- 
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:[email protected]
VoIP: sip:[email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using valid emails

2016-08-01 Thread Michael Torrie
On 08/01/2016 10:32 AM, D'Arcy J.M. Cain wrote:
> On Sun, 31 Jul 2016 14:01:26 -0600
> Michael Torrie  wrote:
>>> So I have to examine every address I reply to or deal with the
>>> bounce message later.  Way to move your spam problem to someone
>>> else.  
>>
>> I've never had this problem.  I use the mailing list side of things
>> and I reply to the list and I don't have bounce issues.  Besides
> 
> Fine for you.  I actually prefer to have people explicitly reply to me
> (and the list) because then it winds up in my INBOX instead of the
> Python list folder.  If I am busy I might skim over the Python folder
> but I always read my INBOX.  The mail will stand out better.

That's not something I would ever want, nor I suspect people who are
participating in a lot of e-mail lists. To each his own.

But more importantly, this just isn't how Usenet works.  You may be
using the e-mail gateway, but not everyone is. People coming from Usenet
are always going to be replying to the list in general, because as I
said before Usenet doesn't care about valid email addresses.  You can
complain all you want, but you're unlikely to have replies going to your
email inbox *and* the list folks reply from Usenet.  I myself will
almost never reply intentionally to the person and also the list.
Duplicated emails just annoy people. And they screw up Gmail's filters
on my own account.  Of course that's mainly because Gmail is pretty
stupid when it comes to dealing with mailing lists and they refuse to
fix it.

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


Re: Why not allow empty code blocks?

2016-08-01 Thread Marko Rauhamaa
Gordon Levi :
> In contrast, your valid email address will become the target of many
> spam emails even if you manage to block them. It will also be used as
> the source of spam so somebody at vex.net may be fooled into believing
> that they are receiving a proper email.

Spammers aren't going to cow me into submission. This is my internet,
not theirs.

Anyway, SPF can prevent sender address spoofing effectively.


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


Re: Using valid emails

2016-08-01 Thread Marko Rauhamaa
Chris Angelico :

> Unfortunately, a lot of domains don't have SPF records, or have very
> convoluted ones (check out gmail.com's SPF for instance).

That's their problem.


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


Re: Using valid emails

2016-08-01 Thread D'Arcy J.M. Cain
On Mon, 1 Aug 2016 12:38:27 -0600
Michael Torrie  wrote:
> That's not something I would ever want, nor I suspect people who are
> participating in a lot of e-mail lists. To each his own.

Exactly my point.  Make the general case something that allows each
person to control their own experience.

> But more importantly, this just isn't how Usenet works.  You may be

I have ranted against gatewaying Usenet and email lists in the past.
No one listened then.  I don't suppose anyone would listen now.

At least I was able to filter out Google groups where most of the
garbage was coming from.

:0 Hir
* ^List-Id:.*python-list.python.org
* ^From:.*@gmail.com 
* ^Newsgroups:.*
/dev/null

-- 
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:[email protected]
VoIP: sip:[email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why not allow empty code blocks?

2016-08-01 Thread bartc
On Monday, 1 August 2016 11:12:30 UTC+1, Steven D'Aprano  wrote:
> On Monday 01 August 2016 18:05, [email protected] wrote:

> No offense intended Bart, but for all we know every single one of your 
> benchmarks are faked, your interpreters are buggy pieces of garbage, and for 
> all your self-promotion

I missed this comment earlier on, but I can't really let it go.

I never promote any actual product of mine, but I might bring in ideas from 
them to illustrate a point or a different way of doing things (although that 
usually falls on deaf as the language is already perfect. As is C, funnily 
enough.)

Only a couple of times have links been given (after creating them to make it 
possible) when people have accused me of making things up! But I'm not selling 
anything.

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


Re: Is it possible to draw a BUTTON?

2016-08-01 Thread Rick Johnson
On Thursday, July 28, 2016 at 11:32:19 PM UTC-5, [email protected] wrote:
> Yes, Rick's code works great. Well, could you go a little
> further?

No, i think we've gone far enough. Just FYI, Rick doesn't do
homework for free *OR* for a fee. Now, it's time for *YOU*
to step u.! If you want more help, you'll first have to
prove that our offerings so far have not fallen on deaf ears.

Here are two indispensable sites for learning Tkinter:

  http://effbot.org/tkinterbook/
  
  http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html

I will not write the code for you, but i will give you a
basic outline to follow.

  (Step 1): Learn how to display an image on the Tkinter
  canvas.

  (Step 2): In the handler that is bound to the mouse press
  event, display the image where ever you want.

  Note: If you want the image to be displayed whilst the
  mouse button is held down, and then hidden when the mouse
  button is released, you'll have to bind the events
  "" for the press, and  for the
  release -- where "N" is the number 1,2 or 3. Look at
  Christian's code for more details.

PS: If you're having trouble, please don't expect us to
solve multiple problems at once, instead, try to focus on
one step of the problem at a time. If you're going to be a
programmer, learning to break down large complex problems
into smaller, more manageable chunks, will be paramount to
your success. After you get all the "chunks" working, then
you can assemble them into a working program. Since the
interpreted nature of Python allows you to easily test small
"chunks of code" on the command line and see the results, be
sure to take advantage of this ability!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: use import *

2016-08-01 Thread Lawrence D’Oliveiro
On Tuesday, August 2, 2016 at 3:32:11 AM UTC+12, Ganesh Pal wrote:

> is it a good programming practice to use  import * ?

No. Think of the module you’re importing as a can, and each of the names it 
defines as a worm. So you when you do “from «module» import *”, it’s like 
emptying all the worms in the can onto the floor, and letting them crawl all 
over your program, polluting your global namespace.

Now imagine you change your mind, and want to get all the worms back into the 
can, because people reading your program (yourself included) cannot be sure 
where each name is coming from.

Not a pleasant process. So the wise programmer avoids getting into this 
situation.

Yes, it can be annoying to have to write module names over and over. Python 
lets you use alternative names, e.g.

import long_module_name as lmn

then you say “lmn.«name»” instead of “long_module_name.«name»”.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python and open office

2016-08-01 Thread Lawrence D’Oliveiro
On Thursday, July 28, 2016 at 4:29:34 AM UTC+12, Crane Ugly wrote:

> I try to create some scripts that will help me to open and manipulate
> OpenOffice documents.

Have you looked at odfpy ?
-- 
https://mail.python.org/mailman/listinfo/python-list


ctypes Usage Note

2016-08-01 Thread Lawrence D’Oliveiro
Sometimes people load a library with ctypes like this:

libc = ctypes.cdll.LoadLibrary("libc.so")

Don’t do that. Do this instead:

libc = ctypes.cdll.LoadLibrary("libc.so.6")

What’s the difference? The difference is that the unversioned library comes 
from the “development” package, while the versioned one comes from the 
“runtime” package. Users of your Python binding should only need to have the 
runtime package installed to run scripts that use it, not the development 
package.

So: always load the explicitly-versioned library name.

I thnk this recommendation should be part of the official ctypes docs 
, don’t you?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: `exec`-based routine crashes app upon migration from 3.4.3 to python 3.5.2.

2016-08-01 Thread Lawrence D’Oliveiro
On Friday, July 29, 2016 at 6:25:51 AM UTC+12, Enjoys Math wrote:

> exec('obj = ' + objType + '(self)', None, _locals)
> obj = _locals['obj']

Why? Why not just

obj = objType(self)

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


Re: usage of functools.partial in in parallelism

2016-08-01 Thread Michael Torrie
On 08/01/2016 01:13 AM, Michael Selik wrote:
> You might benefit from watching the talk "Stop Writing Classes"
> https://www.youtube.com/watch?v=o9pEzgHorH0

Great talk! Thanks for posting that.

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


Re: usage of functools.partial in in parallelism

2016-08-01 Thread Steven D'Aprano
On Tuesday 02 August 2016 13:14, Michael Torrie wrote:

> On 08/01/2016 01:13 AM, Michael Selik wrote:
>> You might benefit from watching the talk "Stop Writing Classes"
>> https://www.youtube.com/watch?v=o9pEzgHorH0
> 
> Great talk! Thanks for posting that.


It is a great talk, but for a counter-view:

http://lucumr.pocoo.org/2013/2/13/moar-classes/



Remember: moderation in all things, except for moderation.



-- 
Steve

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


Re: `exec`-based routine crashes app upon migration from 3.4.3 to python 3.5.2.

2016-08-01 Thread eryk sun
On Tue, Aug 2, 2016 at 1:45 AM, Lawrence D’Oliveiro
 wrote:
> On Friday, July 29, 2016 at 6:25:51 AM UTC+12, Enjoys Math wrote:
>
>> exec('obj = ' + objType + '(self)', None, _locals)
>> obj = _locals['obj']
>
> Why? Why not just
>
> obj = objType(self)

I think you meant to use `globals()[objType](self)`, as was already
suggested by Chris Angelico. The value of objType appears to be the
type's name, maybe from marshaled data.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ctypes Usage Note

2016-08-01 Thread eryk sun
On Tue, Aug 2, 2016 at 1:41 AM, Lawrence D’Oliveiro
 wrote:
>
> Don’t do that. Do this instead:
>
> libc = ctypes.cdll.LoadLibrary("libc.so.6")

I recommend using ctypes.CDLL instead. ctypes.cdll is pretty much
pointless on Unix systems (and a potential problem on Windows due to
cached function pointers). It also doesn't allow passing the mode,
handle, and use_errno parameters.

As to the library name, you may instead want to use find_library for
Unix shared libraries:

>>> ctypes.util.find_library('c')
'libc.so.6'
>>> ctypes.util.find_library('python3.5m')
'libpython3.5m.so.1.0'

It's pretty much pointless on Windows since it just searches PATH for
the given name. It doesn't match how Windows LoadLibrary(Ex) really
works, which allows precise control over exactly what gets searched
via AddDllDirectory, SetDefaultDllDirectories, and activation contexts
(i.e. ActivateActCtx). Plus find_library('c') no longer even works in
3.5+ on Windows (it returns None) because the CRT has been split into
API sets (currently all mapped to ucrtbase.dll, but presumably that
can change with servicing).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ctypes Usage Note

2016-08-01 Thread Lawrence D’Oliveiro
On Tuesday, August 2, 2016 at 5:18:14 PM UTC+12, eryk sun wrote:

> I recommend using ctypes.CDLL instead. ctypes.cdll is pretty much
> pointless on Unix systems (and a potential problem on Windows due to
> cached function pointers). It also doesn't allow passing the mode,
> handle, and use_errno parameters.

None of which I currently care about.
-- 
https://mail.python.org/mailman/listinfo/python-list