Re: numpy.allclose()

2015-01-18 Thread Ian Kelly
On Sat, Jan 17, 2015 at 8:09 PM, Steven D'Aprano
 wrote:
> I'm guessing that can only have come from the mindset of C/C++ programmers,
> where this sort of thing is considered acceptable:

Maybe. The journal reference in the second link I posted dates the
practice back to at least 1975, a time predating K&R C, when it was
most notable as the language that Unix was written in. I wouldn't be
surprised if this actually originated from Fortran.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2015-01-18 Thread Jason Friedman
>
>
> Password maximum age is the wrong solution to a few problems, and is
> itself a problem. Don't do it.
>
> Bruce Schneier (mostly) agrees with you:
https://www.schneier.com/blog/archives/2010/11/changing_passwo.html.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2015-01-18 Thread Michael Torrie
On 01/17/2015 05:04 PM, Chris Angelico wrote:
> Related to that is another reason I've heard: if your password is
> figured out by some means other than hash theft [1], there's a maximum
> of N days to make use of it. But let's face it, if someone gets hold
> of one of your accounts, it won't take long to do serious damage. Even
> if it's not a high-profile target like email or banking, a service
> with your password known by someone else is a problem *now*, not
> "after a month of research" or something.
> 
> Password maximum age is the wrong solution to a few problems, and is
> itself a problem. Don't do it.

Most password policies are the wrong solution.  They don't seem to
increase the time to guess the password given the hash, and they
certainly don't physically secure anything, as passwords that have to be
changed often and to bizarre notions of upper case, lower case, digits,
non-alphanumeric characters, are guaranteed to be written down and
pasted to the monitor.

Like many of you I use a password manager these days.  It's pretty
slick.  But really it shows the absurdity of the situation.  Instead of
passwords we should all just use private/public keypairs and store the
private keys in a digital wallet.  Forget this password garbage with
it's 50-70 bits of entropy.  Let's go for 2048-bit keys and be done with
it, if we're going to require the use of password managers.

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


Re: Hello World

2015-01-18 Thread Chris Angelico
On Sun, Jan 18, 2015 at 1:13 PM, Michael Torrie  wrote:
> Like many of you I use a password manager these days.  It's pretty
> slick.  But really it shows the absurdity of the situation.  Instead of
> passwords we should all just use private/public keypairs and store the
> private keys in a digital wallet.  Forget this password garbage with
> it's 50-70 bits of entropy.  Let's go for 2048-bit keys and be done with
> it, if we're going to require the use of password managers.

Easy way to do a lot of that is to layer most things on top of SSH. I
can pull/push git repositories using my SSH keypairs, I can access the
local network mounts that way, all sorts of things can be done with a
system that's already deployed. It's easy to put your own service on
top of SSH too. Want simplicity? Passwords are fine. Want security?
Push the encryption and authentication down to a lower layer, and save
yourself the trouble.

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


Re: Hello World

2015-01-18 Thread Marko Rauhamaa
Michael Torrie :

> Most password policies are the wrong solution.

I believe passwords themselves are the wrong solution. I believe in a
physical, government-issue object capable of challenge-response. It can
then be beefed up with extra measures depending on the need.


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


Re: numpy.allclose()

2015-01-18 Thread Steven D'Aprano
Ian Kelly wrote:

> On Sat, Jan 17, 2015 at 8:09 PM, Steven D'Aprano
>  wrote:
>> I'm guessing that can only have come from the mindset of C/C++
>> programmers, where this sort of thing is considered acceptable:
> 
> Maybe. The journal reference in the second link I posted dates the
> practice back to at least 1975, a time predating K&R C, when it was
> most notable as the language that Unix was written in. I wouldn't be
> surprised if this actually originated from Fortran.

Ah, the good old days, when computer designers built machines where 1.0*X
could overflow and X-0.0 could underflow.




-- 
Steven

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


[Annonce] Une introduction à Python 3 - nouvelle version

2015-01-18 Thread Laurent Pointal
[updated book in french]

Bonjour,

L'ouvrage d'introduction à la programmation avec Python3 de B.Cordeau et 
L.Pointal a été mis à jour en version 1.618. Outre des améliorations dans la 
mise en page, les modifications suivantes ont été réalisées:

* Tous les dessins ont été refaits en utilisant le module LaTeX TikZ
* Changement de la présentation des scripts et codes interprétés Python
* Paragraphe 5.2.1 : corrections paramètres/arguments
* Ajout, paragraphe 6, d'une partie “Python scientifique”
* Ajout, paragraphe 8.3.4, d'un exemple d'interface graphique
* Ajout, paragraphe 9.1.4, de “La récursivité terminale”
* Quelques mots, paragraphe 9.2.3, sur le “duck tiping” et les annotations
* Réécriture de l'annexe C : “Jeux de caractères et encodage”
* La table des matières détaillée est déplacée en fin de document
* Un “Sommaire” est ajouté en début de document
* Déplacement du glossaire en fin de document et ajout de liens aux entrées
* Ajout de l'Abrégé Dense
* Et aussi tout plein d'améliorations et de corrections typos

L'ouvrage est distribué suivant la licence Creative Commons BY-NC-SA-3.0. 
Il est disponible en version PDF, avec ses sources, sur la page: 
http://perso.limsi.fr/pointal/python:courspython3

Bonne lecture.

B.Cordeau & L.Pointal
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2015-01-18 Thread Roy Smith
In article <[email protected]>,
 Steven D'Aprano  wrote:

> You know that two-factor authentication doesn't offer any real security
> against Man In The Middle attacks?

The fact that TFA doesn't solve all problems doesn't change the fact 
that it solves some of them.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2015-01-18 Thread Michael Ströder
Steven D'Aprano wrote:
> Mark Lawrence wrote:
> 
>> Bah humbug, this has reminded me of doing secure work whereby each
>> individual had two passwords, both of which had to be changed every
>> thirty days, and rules were enforced so you couldn't just increment the
>> number at the end of a word or similar.
> 
> I hate and despise systems that force you to arbitrarily change a good
> strong password after N days for no good reason.
> 
> The utterly bad reason often given by people who don't understand
> probability is that if hackers try to guess your password by brute-force,
> changing the password regularly will make it harder for them. That's simply
> wrong, and is based on a misunderstanding of probability.

But there's a probability > 0 that one of the systems where an admin has to
use his/her password was hacked and that passwords gets stolen there. It's
hard to find out in case of skilled hackers.

=> have more than one account for different security areas and have password
aging in place.

Ciao, Michael.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2015-01-18 Thread Michael Ströder
Michael Torrie wrote:
> Like many of you I use a password manager these days.  It's pretty
> slick.  But really it shows the absurdity of the situation.  Instead of
> passwords we should all just use private/public keypairs and store the
> private keys in a digital wallet.  Forget this password garbage with
> it's 50-70 bits of entropy.  Let's go for 2048-bit keys and be done with
> it, if we're going to require the use of password managers.

Yes, and that's easy e.g. with SSH. And in theory it's easy with SSL/TLS. But
support for client certs in browsers really suck (try to change the login once
you've chosen a client cert without closing the browser).

Ciao, Michael.

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


Re: Hello World

2015-01-18 Thread Michael Ströder
Marko Rauhamaa wrote:
> I believe in a
> physical, government-issue object

Did you forget the smiley? Or where were you during the last 1,5 years?

Ciao, Michael.

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


Re: Hello World

2015-01-18 Thread Michael Ströder
Chris Angelico wrote:
> Want security?
> Push the encryption and authentication down to a lower layer, and save
> yourself the trouble.

Yes. And now for the next level: How to prevent unauthorized machines to
connect to your network…

Ciao, Michael.

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


Re: Hello World

2015-01-18 Thread Chris Angelico
On Mon, Jan 19, 2015 at 12:35 AM, Michael Ströder  wrote:
> Chris Angelico wrote:
>> Want security?
>> Push the encryption and authentication down to a lower layer, and save
>> yourself the trouble.
>
> Yes. And now for the next level: How to prevent unauthorized machines to
> connect to your network…

Extremely difficult, and in many cases quite unnecessary. No, you let
them on the network, and then make sure that won't hurt you more than
you're prepared to accept. For instance, someone could join my wifi
network - all they need is the WPA2 PSK, which is well known around
the place - and use/abuse our internet connection; but they couldn't
access my PostgreSQL databases, because the firewall doesn't permit
access to port 5432.

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


Re: Hello World

2015-01-18 Thread Michael Ströder
Chris Angelico wrote:
> On Mon, Jan 19, 2015 at 12:35 AM, Michael Ströder  
> wrote:
>> Chris Angelico wrote:
>>> Want security?
>>> Push the encryption and authentication down to a lower layer, and save
>>> yourself the trouble.
>>
>> Yes. And now for the next level: How to prevent unauthorized machines to
>> connect to your network…
> 
> Extremely difficult, and in many cases quite unnecessary. No, you let
> them on the network, and then make sure that won't hurt you more than
> you're prepared to accept.

Somewhat true…

> For instance, someone could join my wifi
> network - all they need is the WPA2 PSK, which is well known around
> the place - and use/abuse our internet connection; but they couldn't
> access my PostgreSQL databases, because the firewall doesn't permit
> access to port 5432.

…but your firewall relies on authenticity of IP addresses. Fail!

Ciao, Michael.

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


Re: Hello World

2015-01-18 Thread Marko Rauhamaa
Michael Ströder :

> Marko Rauhamaa wrote:
>> I believe in a
>> physical, government-issue object
> 
> Did you forget the smiley? Or where were you during the last 1,5 years?

You can juggle the issues all you want. In the end, there's no escaping
the governments' underwriting role. The TLS "chain of trust" we have
today is a joke and can be spoofed easily not only by governments but
really by anybody.

Authentication is still separate from privacy, which could be secured
from the governments if there were a will.


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


Re: Hello World

2015-01-18 Thread Chris Angelico
On Sun, Jan 18, 2015 at 9:03 PM, Marko Rauhamaa  wrote:
> Michael Torrie :
>
>> Most password policies are the wrong solution.
>
> I believe passwords themselves are the wrong solution. I believe in a
> physical, government-issue object capable of challenge-response. It can
> then be beefed up with extra measures depending on the need.

I can't tell whether you're serious or not. Do you actually trust
"government-issue" more than anything else, or is your tongue firmly
in your cheek?

Also, which government?

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


Trying to parse matchup.io (lxml, SGMLParser, urlparse)

2015-01-18 Thread Jerry Rocteur
Hi,

I'm trying to parse https://matchup.io/players/rocteur/friends

The body source I'm interested in contains blocks exactly like this



https://matchup-io.s3.amazonaws.com/uploads/player/avatar/7651/7651_profile_150_square.jpeg";
/>

mizucci0
Mizuho



29,646

steps


35,315

steps


818.7

Miles



I wanted to do it Python as I'm learning and I looked at the different
modules but it isn't easy for me to work out the best way to do this
as most tutorials I see use complicated classes and I just want to
parse this one paragraph at a time (as I would do in Perl) and print

1 mizuho 26648 35315
2 xx  9 9
3 xx 9 9

etc. (in the above case I'm ignoring 818.7 and Miles.

The best way I found so far is this:

from lxml import html
import requests
page = requests.get("https://matchup.io/players/rocteur/friends/week/";)
tree = html.fromstring(page.text)
a = tree.xpath('//span/text()')
b = tree.xpath('//td/text()')

And the manipulating indices

e.g.
print "%s %s %s %s" % (a[usern], a[users], b[tots], b[weekb])
tots += 4
weekb += 4
usern += 2
users += 2

But it isn't very scientific ;-)

Which module would you use and how would you suggest is the best way to do it ?

Thanks very much in advance, I haven't done a lot of HTML parsing.. I
would much prefer using WebServices and an API but unfortunately they
don't have it.
-- 
Jerry Rocteur
-- 
https://mail.python.org/mailman/listinfo/python-list


How to use Pycharm to display the stack and heap python?

2015-01-18 Thread Jo Barton
I am new to programming. Difficult for me to understand code using 
http://www.pythontutor.com/visualize.html#. How to use Pycharm to display the 
stack and heap python?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to use Pycharm to display the stack and heap python?

2015-01-18 Thread Mark Lawrence

On 18/01/2015 16:45, Jo Barton wrote:

I am new to programming. Difficult for me to understand code using 
http://www.pythontutor.com/visualize.html#. How to use Pycharm to display the 
stack and heap python?



Hello and welcome :)

As you are new to programming please abandon all thoughts of looking at 
the stack and heap with Pycharm or any other tool.  Instead concentrate 
on writing code that can be easily tested at the interactive prompt.  As 
a beginner you might also be more comfortable on the tutor mailing list 
https://mail.python.org/mailman/listinfo/tutor


--
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


Re: Hello World

2015-01-18 Thread Chris Angelico
On Mon, Jan 19, 2015 at 2:48 AM, Michael Ströder  wrote:
>> For instance, someone could join my wifi
>> network - all they need is the WPA2 PSK, which is well known around
>> the place - and use/abuse our internet connection; but they couldn't
>> access my PostgreSQL databases, because the firewall doesn't permit
>> access to port 5432.
>
> …but your firewall relies on authenticity of IP addresses. Fail!

No; I have two completely separate networks. If you're on the one that
anyone can easily get onto, it doesn't matter what your IP is, you do
not get access to certain ports on computers on the other side of the
firewall.

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


Formatting string with accented characters for printing

2015-01-18 Thread Jerry Rocteur
Hi,

When I try and format output when there are accented characters the
output does not look right.

e.g.

27 Angie Dickons   67,638
28 Anne MÉRESSE 64,825

So the strings containing accented characters print one less than
those that don't.

I've tried both:

print '{0:2} {1:25} {2} '.format( cnt, nam[num].encode('utf-8'),
steps[ind1])
print "%3d %-25s %-7s" % ( cnt, nam[num].encode('utf-8'), steps[ind1])

I've searched but I can't see a solution..

I guess it is the way I'm printing nam[num].encode('utf-8') perhaps I
have to convert it first ?

Can someone please help.

Thanks

-- 
Jerry Rocteur

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


Re: Trying to parse matchup.io (lxml, SGMLParser, urlparse)

2015-01-18 Thread Peter Otten
Jerry Rocteur wrote:

> Hi,
> 
> I'm trying to parse https://matchup.io/players/rocteur/friends
> 
> The body source I'm interested in contains blocks exactly like this
> 
> 
> 
>  src="https://matchup-io.s3.amazonaws.com/uploads/player/avatar/7651/7651_profile_150_square.jpeg";
> />
> 
> mizucci0
> Mizuho
> 
> 
> 
> 29,646
> 
> steps
> 
> 
> 35,315
> 
> steps
> 
> 
> 818.7
> 
> Miles
> 
> 
> 
> I wanted to do it Python as I'm learning and I looked at the different
> modules but it isn't easy for me to work out the best way to do this
> as most tutorials I see use complicated classes and I just want to
> parse this one paragraph at a time (as I would do in Perl) and print
> 
> 1 mizuho 26648 35315
> 2 xx  9 9
> 3 xx 9 9
> 
> etc. (in the above case I'm ignoring 818.7 and Miles.
> 
> The best way I found so far is this:
> 
> from lxml import html
> import requests
> page = requests.get("https://matchup.io/players/rocteur/friends/week/";)
> tree = html.fromstring(page.text)
> a = tree.xpath('//span/text()')
> b = tree.xpath('//td/text()')
> 
> And the manipulating indices
> 
> e.g.
> print "%s %s %s %s" % (a[usern], a[users], b[tots], b[weekb])
> tots += 4
> weekb += 4
> usern += 2
> users += 2
> 
> But it isn't very scientific ;-)

In my experience scraping data from a web page never is. The trick is to not 
waste too much time on your script once you have it working. The next 
overhaul of the scraped page is already on the way, and yes, it will heavily  
use javascript ;)

> Which module would you use and how would you suggest is the best way to do
> it ?

I think lxml is a good choice. Is there something with an API you prefer in 
Perl?

> Thanks very much in advance, I haven't done a lot of HTML parsing.. I
> would much prefer using WebServices and an API but unfortunately they
> don't have it.

PS: Here's my take:

import requests
import lxml.html

def get_html():
return 
requests.get("https://matchup.io/players/rocteur/friends/week/";).text

def fix(value):
return value.text.strip().replace(",", "")

tree = lxml.html.fromstring(get_html())
for friend in tree.xpath('//tr[@class="friend"]'):
values = friend.xpath('.//td[@class="delta-alt"]')
print(
friend.xpath('.//div/span[2]/text()')[0],
fix(values[0]),
fix(values[1])
)


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


Re: Formatting string with accented characters for printing

2015-01-18 Thread Chris Angelico
On Mon, Jan 19, 2015 at 3:04 AM, Jerry Rocteur  wrote:
>
> I've tried both:
>
> print '{0:2} {1:25} {2} '.format( cnt, nam[num].encode('utf-8'),
> steps[ind1])
> print "%3d %-25s %-7s" % ( cnt, nam[num].encode('utf-8'), steps[ind1])
>
> I've searched but I can't see a solution..
>
> I guess it is the way I'm printing nam[num].encode('utf-8') perhaps I
> have to convert it first ?

Do the formatting on a Unicode string, and then encode the entire
string at the end. Or, better still, just work entirely with Unicode
all the way; if you switch to Python 3.4 (or anything else in the 3.x
line), print() takes Unicode strings. This kind of thing becomes easy.

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


Re: Formatting string with accented characters for printing

2015-01-18 Thread Peter Otten
Jerry Rocteur wrote:

> When I try and format output when there are accented characters the
> output does not look right.
> 
> e.g.
> 
> 27 Angie Dickons   67,638
> 28 Anne MÉRESSE 64,825
> 
> So the strings containing accented characters print one less than
> those that don't.
> 
> I've tried both:
> 
> print '{0:2} {1:25} {2} '.format( cnt, nam[num].encode('utf-8'),
> steps[ind1])
> print "%3d %-25s %-7s" % ( cnt, nam[num].encode('utf-8'), steps[ind1])
> 
> I've searched but I can't see a solution..
> 
> I guess it is the way I'm printing nam[num].encode('utf-8') perhaps I
> have to convert it first ?

If you have a byte string (the standard in Python 2) you have to decode(), 
i. e. convert it to unicode) before you format it. Compare:

>>> names = "Angie Dickons", "Anne Méresse"
>>> for name in names:
... print "|{:20}|".format(name)
... 
|Angie Dickons   |
|Anne Méresse   |
>>> for name in names:
... name = name.decode("utf-8")
... print u"|{:20}|".format(name)
... 
|Angie Dickons   |
|Anne Méresse|

The best approach is to convert your data to unicode as soon as you read it 
and perform all string operations with unicode. This also avoids breaking 
characters:

>>> print "Méresse"[:2]
M�  
  
>>> print u"Méresse"[:2]
Mé

There are still problems (e. g. with narrow builds), and the best way to 
avoid a few string-related inconviences is to switch to Python 3.

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


Re: Hello World

2015-01-18 Thread Michael Ströder
Marko Rauhamaa wrote:
> Michael Ströder :
> 
>> Marko Rauhamaa wrote:
>>> I believe in a
>>> physical, government-issue object
>> 
>> Did you forget the smiley? Or where were you during the last 1,5 years?
> 
> You can juggle the issues all you want. In the end, there's no escaping
> the governments' underwriting role. The TLS "chain of trust" we have
> today is a joke and can be spoofed easily not only by governments but
> really by anybody.

That's why I'm internally using my own private CA and limit the trust stores
of various services to this CA.

> Authentication is still separate from privacy,

Not true because there's no authorization without authentication.

Ciao, Michael.
-- 
https://mail.python.org/mailman/listinfo/python-list


Attribute error

2015-01-18 Thread Mahendra Prajapati
Hello,
I'm facing this problem with python class, while practising the python 
programming language.It creates an attribute error. I use windows 7 OS. i don't 
why.I just need to know why it gives such an error.please let me know.
Regards -- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2015-01-18 Thread Marko Rauhamaa
Chris Angelico :
> On Sun, Jan 18, 2015 at 9:03 PM, Marko Rauhamaa  wrote:
>> I believe passwords themselves are the wrong solution. I believe in a
>> physical, government-issue object capable of challenge-response. It
>> can then be beefed up with extra measures depending on the need.
>
> I can't tell whether you're serious or not. Do you actually trust
> "government-issue" more than anything else, or is your tongue firmly
> in your cheek?

I'm serious.

> Also, which government?

For example, the State of Finland (the place where I happen to reside).
Then, you would know you would be dealing with someone who is holding a
physical ID guaranteed by the Finnish government. After all, that's how
passports work; passports are trusted everywhere in the world.

That would be better than anything we have right now. As far as I know,
a system like that is in use in Estonia. In principle, an analogous
system is also there in Finland, but it is barely used yet (chicken and
egg). The practical online authentication in Finland is provided by
private banks. The private solution is effective but it costs businesses
money to use making it unavailable for individuals and nonprofits.


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


Re: Attribute error

2015-01-18 Thread Chris Angelico
On Mon, Jan 19, 2015 at 7:50 AM, Mahendra Prajapati
 wrote:
> I'm facing this problem with python class, while practising the python
> programming language.It creates an attribute error.
>  I use windows 7 OS. i don't why.
> I just need to know why it gives such an error.
> please let me know.

It'd be easier to help you if you post your code and the entire
exception, from the beginning of the traceback to the message. Armed
with that, we'll be better able to advise!

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


Re: Attribute error

2015-01-18 Thread Denis McMahon
On Sun, 18 Jan 2015 20:50:49 +, Mahendra Prajapati wrote:

> Hello,
> I'm facing this problem with python class, while practising the python
> programming language.It creates an attribute error. I use windows 7 OS.
> i don't why.I just need to know why it gives such an error.please let me
> know.
> Regards

The python docs https://docs.python.org/2/library/exceptions.html say the 
following about AttributeError:

exception AttributeError

Raised when an attribute reference (see Attribute references) or 
assignment fails. (When an object does not support attribute references 
or attribute assignments at all, TypeError is raised.)

Given your description of the problem, the best guess I can make is that 
you are trying to reference a non existent attribute, possibly because 
you have mistyped the name of the attribute you are trying to access.

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Attribute error

2015-01-18 Thread Steven D'Aprano
Mahendra Prajapati wrote:

> Hello,
> I'm facing this problem with python class, while practising the python
> programming language.It creates an attribute error. I use windows 7 OS. i
> don't why.I just need to know why it gives such an error.please let me
> know. Regards

An attribute error is a bug in your code. Fix the bug.

It might be a spelling error:

s = "Hello World!"
s.uper()  # Oops, I meant "upper"

or it might be that you have the wrong object:

alist = [2, 4, 1]
alist = alist.sort()  # Oops, replaces alist with None
alist.index(2)  # None has no index method.

Either way, it is a bug in your code that needs to be fixed.




-- 
Steven

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


multiprocessing.Queue & vim python interpreter

2015-01-18 Thread unknown3000
Hi,

I am experimenting on a fork of vim-plug for managing vim plugins. I wanted to 
add parallel update support for python since ruby isn't nearly as common. I've 
come across a weird bug that only seems to happen when I'm inside vim, I'm 
wondering if someone could tell me why. 

This problem can be reproduced by sourcing a vim file with the following 
snippet. Then execute the command PyCrash.
command! -nargs=0 PyCrash call s:py_crash()
function! s:py_crash()
python << EOF
import multiprocessing as multi
queue = multi.Queue()
queue.put('a')
queue.close()
EOF
endfunction

This prints to messages the following:
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/queues.py", line 266, in _feed
send(obj)
IOError: [Errno 32] Broken pipe

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


Re: Attribute error

2015-01-18 Thread Rustom Mody
On Monday, January 19, 2015 at 5:02:01 AM UTC+5:30, Steven D'Aprano wrote:
> Mahendra Prajapati wrote:
> 
> > Hello,
> > I'm facing this problem with python class, while practising the python
> > programming language.It creates an attribute error. I use windows 7 OS. i
> > don't why.I just need to know why it gives such an error.please let me
> > know. Regards
> 
> An attribute error is a bug in your code. Fix the bug.
> 
> It might be a spelling error:
> 
> s = "Hello World!"
> s.uper()  # Oops, I meant "upper"
> 
> or it might be that you have the wrong object:
> 
> alist = [2, 4, 1]
> alist = alist.sort()  # Oops, replaces alist with None
> alist.index(2)  # None has no index method.
> 
> Either way, it is a bug in your code that needs to be fixed.

Most often it is because you got lost in a maze of dots. ie
x.y.attr works
but you wrote
x.attr
or
a.y.z.attr

Your tools for figuring out (apart from following what Chris suggested)

1. Use the interpreter
2. Use help
3. Use dir
4. Use type

Like so
>>> l=[1,2]
>>> d={1:2}
>>> dir(d)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', 
'__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', 
'__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', 
'__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', 
'__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 
'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 
'keys', 'pop', 'popitem', 'setdefault', 'update', 'values', 'viewitems', 
'viewkeys', 'viewvalues']
>>> type(l)


>>> help(l)
[Not shown]
>>> help(l.append)
[Not shown]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to "wow" someone new to Python

2015-01-18 Thread alex23

On 17/01/2015 1:03 AM, Chris Angelico wrote:

Scenario: You're introducing someone to Python for the first time.
S/he may have some previous programming experience, or may be new to
the whole idea of giving a computer instructions. You have a couple of
minutes to show off how awesome Python is. What do you do?


When demoing to people with a reasonable amount of experience, I've 
found they're often impressed by showing them list comprehensions, then 
generators, then chained generators.


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