[issue26867] test_ssl test_options fails on ubuntu 16.04

2016-04-27 Thread Xiang Zhang

Xiang Zhang added the comment:

>From the source code (get from apt-get source) of openssl-1.0.2g, I find

SSL_CTX_clear_options(ctx, op):
  op &= ~SSL_OP_NO_SSLv3
  return (ctx->options &= ~op)
SSL_CTX_set_options(ctx, op):
  op |= SSL_OP_NO_SSLv3
  return (ctx->options |= op)

which differs from the official code repos:

SSL_CTX_clear_options(ctx, op):
  return (ctx->options &= ~op)
SSL_CTX_set_options(ctx, op):
  return (ctx->options |= op)

This difference is introduced by debian-specific patch:

 case SSL_CTRL_OPTIONS:
+larg|=SSL_OP_NO_SSLv3;
 return (ctx->options |= larg);
 case SSL_CTRL_CLEAR_OPTIONS:
+larg&=~SSL_OP_NO_SSLv3;
 return (ctx->options &= ~larg);

--

___
Python tracker 

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



[issue26873] xmlrpclib raises when trying to convert an int to string when unicode is available

2016-04-27 Thread Nathan Williams

Nathan Williams added the comment:

I have attached the response.
As it is coming from our UMS, I had to redact a few values, but that shouldn't 
matter.

For reference, they were the host name of my email address, and the hashes of 
passwords etc.
Our UMS is a bit too chatty!

--
Added file: http://bugs.python.org/file42636/pybug.txt

___
Python tracker 

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



Re: Pythonic style

2016-04-27 Thread Steven D'Aprano
On Thursday 28 April 2016 13:23, Ben Finney wrote:

> Christopher Reimer  writes:
> 
>> In short,  my original code before I turned it into a separate
>> dictionary. *sigh*
> 
> No, I think that misses the points that were being made. The discussion
> you're talking about was *not* to say “attribute access is better than
> dictionary access”, or vice versa. Each is good for its purpose.
> 
> Rather, the discussion was to drive home the point that in Python those
> are *two distinct concepts*, and you need to not conflate them.
> 
> If you want items in a mapping, explicitly use a Python ‘dict’ instance.
> If you want attributes that describe an object, explicitly use
> attributes of that object. Deliberately choose which one makes more
> sense.


Think of it like this: attribute access is for accessing parts of a thing:

dog.tail
car.engine
cup.handle

or one of a small number of fixed fields from a record:

employment_record.start_date
employee.salary
autopsy.cause_of_death
person.title


Mappings (dicts) are for recording a potentially unlimited number of 
distinct records with arbitrary keys, especially since the keys don't have 
to be valid identifiers:

employees['Fred Smith']
students['Joanna McTavish']
prisoners[12345]
catalog['Widgets']['GMH-12345']
dictionary['update']


While Python allows you to write code to use attribute syntax for item 
access, doing so is a category mistake and leads to semantic confusion and 
potential bugs:

employees.Fred_Smith
students.Joanna_McTavish
prisoners.P12345
parts.widgets.GMH_12345
dictionary.update


The last example shows how mixing up these two distinct concepts can lead to 
problems. Should dictionary.update refer to the update method, or the entry 
for the word "update"?



-- 
Steve

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


Re: Python Madlibs.py code and error message

2016-04-27 Thread Ben Finney
Stephen Hansen  writes:

> The error message means there's a mismatch between the number of
> formatting instructions (ie, %s) and arguments passed to formatting. I
> leave it to you to count and find what's missing or extra, because I'm
> seriously not going to do that :)

Better: when you have many semantically-different values, use named (not
positional) parameters in the format string.

Some simple format string examples:

"First, thou shalt count to {0}" # References first positional argument
"Bring me a {}"  # Implicitly references the first 
positional argument
"From {} to {}"  # Same as "From {0} to {1}"
"My quest is {name}" # References keyword argument 'name'
[…]



By using names, you will not need to count positional arguments; and
when there's an error, the error will state the name, making it easier
to debug.

Also feasible with ‘%’ syntax. But, if you're writing new code, you may
as well use the more powerful ‘str.format’ described at that URL.

-- 
 \   “To have the choice between proprietary software packages, is |
  `\  being able to choose your master. Freedom means not having a |
_o__)master.” —Richard M. Stallman, 2007-05-16 |
Ben Finney

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


Re: Pythonic style

2016-04-27 Thread Rustom Mody
On Thursday, April 28, 2016 at 9:26:21 AM UTC+5:30, Chris Angelico wrote:
> My rule of thumb is: Dunders are for defining, not for calling. It's
> not a hard-and-fast rule, but it'll get you through 99%+ of
> situations.

Neat and clever.
Should get in the docs somewhere
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Madlibs.py code and error message

2016-04-27 Thread Stephen Hansen
On Wed, Apr 27, 2016, at 10:01 PM, Cai Gengyang wrote:
> I changed it to all lowercase, this time I get a different error message
> though (a TypeError message) 

The error message means there's a mismatch between the number of
formatting instructions (ie, %s) and arguments passed to formatting. I
leave it to you to count and find what's missing or extra, because I'm
seriously not going to do that :)

-- 
Stephen Hansen
  m e @ i x o k a i . i o
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue18551] child_exec() doesn't check return value of fcntl()

2016-04-27 Thread Berker Peksag

Berker Peksag added the comment:

There is one fcntl call in Modules/_posixsubprocess.c now and its return value 
is checked

local_max_fd = fcntl(0, F_MAXFD);
if (local_max_fd >= 0)

Closing this as 'out of date'.

--
nosy: +berker.peksag
resolution:  -> out of date
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

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



[issue26867] test_ssl test_options fails on ubuntu 16.04

2016-04-27 Thread Xiang Zhang

Xiang Zhang added the comment:

After some test, I think the reason causing this error is due to 
SSL_CTX_clear_options. 

With OPENSSL_VERSION_NUMBER 268443775, SSL_CTX_clear_options(self->ctx, 
2248147967) returns 33554432, where SSL_CTX_get_options returns 2248147967. 
From the manpage of SSL_CTX_clear_options, it seems it should return 0.

--

___
Python tracker 

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



Re: Python Madlibs.py code and error message

2016-04-27 Thread Cai Gengyang
I changed it to all lowercase, this time I get a different error message though 
(a TypeError message) 


# This program does the following ... writes a Mad Libs story 

# Author: Cai Gengyang 

print "Mad Libs is starting!" 

name = raw_input("Enter a name: ") 

adjective1 = raw_input("Enter an adjective: ") 

adjective2 = raw_input("Enter a second adjective: ") 

adjective3 = raw_input("Enter a third adjective: ") 

verb1 = raw_input("Enter a verb: ") 

verb2 = raw_input("Enter a second verb: ") 

verb3 = raw_input("Enter a third verb: ") 

noun1 = raw_input("Enter a noun: ") 

noun2 = raw_input("Enter a noun: ") 

noun3 = raw_input("Enter a noun: ") 

noun4 = raw_input("Enter a noun: ") 

animal = raw_input("Enter an animal: ") 

food = raw_input("Enter a food: ") 

fruit = raw_input("Enter a fruit: ") 

number = raw_input("Enter a number: ") 

superhero_name = raw_input("Enter a superhero_name: ") 

country = raw_input("Enter a country: ") 

dessert = raw_input("Enter a dessert: ") 

year = raw_input("Enter a year: ") 


#The template for the story 

STORY = "This morning I woke up and felt %s because _ was going to finally %s 
over the big _ %s. On the other side of the %s were many %ss protesting to keep 
%s in stores. The crowd began to _ to the rythym of the %s, which made all of 
the %ss very _. %s tried to _ into the sewers and found %s rats. Needing help, 
%s quickly called %s. %s appeared and saved %s by flying to %s and dropping _ 
into a puddle of %s. %s then fell asleep and woke up in the year _, in a world 
where %ss ruled the world." 

print STORY % (adjective1, name, verb1, adjective2, noun1, noun2, animal, food, 
verb2, noun3, fruit, adjective3, name, verb3, number, name , superhero_name, 
superhero_name, name, country, name, dessert, name, year, noun4) 


Terminal Output : 

$ python Madlibs.py 

Mad Libs is starting! 

Enter a name: andrew 

Enter an adjective: beautiful   

Enter a second adjective: honest 

Enter a third adjective: pretty

Enter a verb: hit 

Enter a second verb: run 

Enter a third verb: fire

Enter a noun: honesty

Enter a noun: love

Enter a noun: peace

Enter a noun: wisdom

Enter an animal: elephant 

Enter a food: burger   

Enter a fruit: watermelon 

Enter a number: 1985 

Enter a superhero_name: batman 

Enter a country: america 

Enter a dessert: icekachang 

Enter a year: 1982 

Traceback (most recent call last):   

File "Madlibs.py", line 34, in  

print STORY % (adjective1, name, 

verb1, adjective2, noun1, noun2, an 

imal, food, verb2, noun3, fruit, adj 

ective3, name, verb3, number, name , 

superhero_name, superhero_name, nam   

e, country, name, dessert, name, yea 

r, noun4) 

TypeError: not all arguments converted during string formatting











On Thursday, April 28, 2016 at 12:50:28 PM UTC+8, Gregory Ewing wrote:
> Cai Gengyang wrote:
> 
> > adjective1 = raw_input("Enter an adjective: ")
> > 
> > NameError: name 'Adjective1' is not defined
> 
> Python is case-sensitive. You've spelled it "adjective1" in one
> place and "Adjective1" in another. You need to be consistent.
> 
> -- 
> Greg

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


Re: Python Madlibs.py code and error message

2016-04-27 Thread Stephen Hansen
On Wed, Apr 27, 2016, at 09:37 PM, Cai Gengyang wrote:
> print STORY % (Adjective1, name, Verb1, Adjective2, Noun1, Noun2, animal,
> food, Verb2, Noun3, fruit, Adjective3, name, Verb3, number, name ,
> superhero_name, superhero_name, name, country, name, dessert, name, year,
> Noun4)

Python is case-sensitive. "Adjective1" and "adjective1" are separate
things. In your code you're reading into "adjective1".

-- 
Stephen Hansen
  m e @ i x o k a i . i o
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Madlibs.py code and error message

2016-04-27 Thread Gregory Ewing

Cai Gengyang wrote:


adjective1 = raw_input("Enter an adjective: ")

NameError: name 'Adjective1' is not defined


Python is case-sensitive. You've spelled it "adjective1" in one
place and "Adjective1" in another. You need to be consistent.

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


[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2016-04-27 Thread Richard PALO

Richard PALO added the comment:

[fingers not yet warmed up] that is '/opt/local/lib/libmagic.so'

--

___
Python tracker 

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



[issue1145257] shutil.copystat() may fail...

2016-04-27 Thread Berker Peksag

Changes by Berker Peksag :


--
resolution: accepted -> out of date
stage: test needed -> resolved
status: open -> closed

___
Python tracker 

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



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2016-04-27 Thread Richard PALO

Richard PALO added the comment:

An example:

richard@omnis:/home/richard$ python2.7
Python 2.7.11 (default, Apr 27 2016, 04:35:25) 
[GCC 4.9.3] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> from ctypes.util import find_library
>>> find_library('magic')
>>> cdll.LoadLibrary('libmagic.so')


Finally, as you can see above, LoadLibrary() works fine to load 
'/opt/local/libmagic.so' because of the runpath in the python binary, but 
find_library() does not because the runpath is ignored.

This should probably be considered as 'unexpected' behaviour.

--

___
Python tracker 

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



Python Madlibs.py code and error message

2016-04-27 Thread Cai Gengyang
Python Madlibs.py code and error message --- Anyone can help? I keep getting 
stuck here ...




# This program does the following ... writes a Mad Libs story

# Author: Cai Gengyang

print "Mad Libs is starting!"

name = raw_input("Enter a name: ")

adjective1 = raw_input("Enter an adjective: ")

adjective2 = raw_input("Enter a second adjective: ")

adjective3 = raw_input("Enter a third adjective: ")

verb1 = raw_input("Enter a verb: ")

verb2 = raw_input("Enter a second verb: ")

verb3 = raw_input("Enter a third verb: ")

noun1 = raw_input("Enter a noun: ")

noun2 = raw_input("Enter a noun: ")

noun3 = raw_input("Enter a noun: ")

noun4 = raw_input("Enter a noun: ")

animal = raw_input("Enter an animal: ")

food = raw_input("Enter a food: ")

fruit = raw_input("Enter a fruit: ")

number = raw_input("Enter a number: ")

superhero_name = raw_input("Enter a superhero_name: ")

country = raw_input("Enter a country: ")

dessert = raw_input("Enter a dessert: ")

year = raw_input("Enter a year: ")


#The template for the story

STORY = "This morning I woke up and felt %s because _ was going to finally %s 
over the big _ %s. On the other side of the %s were many %ss protesting to keep 
%s in stores. The crowd began to _ to the rythym of the %s, which made all of 
the %ss very _. %s tried to _ into the sewers and found %s rats. Needing help, 
%s quickly called %s. %s appeared and saved %s by flying to %s and dropping _ 
into a puddle of %s. %s then fell asleep and woke up in the year _, in a world 
where %ss ruled the world."

print STORY % (Adjective1, name, Verb1, Adjective2, Noun1, Noun2, animal, food, 
Verb2, Noun3, fruit, Adjective3, name, Verb3, number, name , superhero_name, 
superhero_name, name, country, name, dessert, name, year, Noun4)


Terminal Output :

$ python Madlibs.py 

Mad Libs is starting! 

Enter a name: Cai Gengyang  

Enter an adjective: beautiful  

Enter a second adjective: honest

Enter a third adjective: huge

Enter a verb: hit 

Enter a second verb: run 

Enter a third verb: jump 

Enter a noun: anger 

Enter a noun: belief

Enter a noun: wealth

Enter a noun: regret 

Enter an animal: elephant

Enter a food: burger  

Enter a fruit: watermelon 

Enter a number: 6

Enter a superhero_name: batman 

Enter a country: America 

Enter a dessert: icekachang 

Enter a year: 1984

Traceback (most recent call last):   

File "Madlibs.py", line 34, in  

print STORY % (Adjective1, name,

Verb1, Adjective2, Noun1, Noun2, an 

imal, food, Verb2, Noun3, fruit, Adj

ective3, name, Verb3, number, name ,

superhero_name, superhero_name, nam   

e, country, name, dessert, name, yea 

r, Noun4) 

NameError: name 'Adjective1' is not 

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


[issue26873] xmlrpclib raises when trying to convert an int to string when unicode is available

2016-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Could you provide a response of your server (pass verbose=True to ServerProxy)?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue25461] Unclear language (the word ineffective) in the documentation for os.walk

2016-04-27 Thread Luiz Poleto

Luiz Poleto added the comment:

The change to os.rst is already committed so I modified the patch to remove it 
and keep only the change to os.py, which looks good and ready to be committed.

--
Added file: http://bugs.python.org/file42635/issue25461.patch

___
Python tracker 

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



[issue20453] json.load() error message changed in 3.4

2016-04-27 Thread Berker Peksag

Berker Peksag added the comment:

3.4 is in security-fix-only mode and 3.5+ has better error messages thanks to 
JSONDecodeError (07af9847dbec). Closing this as 'out of date'.

--
nosy: +berker.peksag
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Michael Torrie
On 04/27/2016 10:06 PM, Christopher Reimer wrote:
> On 4/27/2016 8:52 PM, Michael Torrie wrote:
>>   In fact if it were me I would save game state to some kind of ini file,
>> which would mean manually going through each object and writing out the
>> relevant data to the ini file using the right syntax. And then reverse
>> the process when restoring from a file.  XML could be another format
>> used for your file, if you're into that kind of thing.
> 
> Funny that you should mention the ini file. I wrote a ConfigParser class 
> for my const['whatever'] variable. It wouldn't take much to use that in 
> the meantime until I get a handle on pickle.

I'm not sure pickle is the way to go anyway.  Especially for your
purposes. Definitely you could make a ConfigParser that could read and
write your object instances.

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


[issue20447] doctest.debug_script: insecure use of /tmp

2016-04-27 Thread Berker Peksag

Berker Peksag added the comment:

3.1 is now EOL: 
https://docs.python.org/devguide/index.html#status-of-python-branches

--
nosy: +berker.peksag
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer

On 4/27/2016 8:52 PM, Michael Torrie wrote:

  In fact if it were me I would save game state to some kind of ini file,
which would mean manually going through each object and writing out the
relevant data to the ini file using the right syntax. And then reverse
the process when restoring from a file.  XML could be another format
used for your file, if you're into that kind of thing.


Funny that you should mention the ini file. I wrote a ConfigParser class 
for my const['whatever'] variable. It wouldn't take much to use that in 
the meantime until I get a handle on pickle.


Thank you,

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


Re: Pythonic style

2016-04-27 Thread Christopher Reimer

On 4/27/2016 8:52 PM, Ethan Furman wrote:


The point Ben was trying to make is this:  you should never* call 
__dunder__ methods in normal code; there is no need to do so:


- use len(), not __len__()
- use next(), not __next__()
- use some_instance.an_attribute, not 
some_instance.__dict__['an_attribute']




DOH! I need a doughnut. :)

Thank you,

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


Re: Pythonic style

2016-04-27 Thread Christopher Reimer

On 4/27/2016 8:23 PM, Ben Finney wrote:

If you want items in a mapping, explicitly use a Python ‘dict’ instance.
If you want attributes that describe an object, explicitly use
attributes of that object. Deliberately choose which one makes more
sense.


Okay, that makes sense.

Thank you,

Chris R.

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


Re: Pythonic style

2016-04-27 Thread Chris Angelico
On Thu, Apr 28, 2016 at 1:52 PM, Ethan Furman  wrote:
>
> The point Ben was trying to make is this:  you should never* call __dunder__
> methods in normal code; there is no need to do so:
>
> - use len(), not __len__()
> - use next(), not __next__()
> - use some_instance.an_attribute, not some_instance.__dict__['an_attribute']
>
> --
> ~Ethan~
>
> * Okay, maybe /almost/ never.  About the only time you need to is when
> giving your classes special methods, such as __add__ or __repr__.

My rule of thumb is: Dunders are for defining, not for calling. It's
not a hard-and-fast rule, but it'll get you through 99%+ of
situations.

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


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer

On 4/27/2016 8:05 PM, Ethan Furman wrote:
I ripped out the fetch_state because that will take more work -- you 
can't pass a Pawn's saved state in to Piece and get the results you 
want.  pickle is worth looking at for saving/restoring.


The original idea was to pass a Pawn dictionary to the constructor of 
the Pawn object. The Piece object will throw a NotImplementedError if 
called directly. I guess I'll have to look at pickle sooner rather than 
later.



Also, your code will give the same notation to Kings and Knights.


Good catch. I knew I was forgetting something. I overrode variable in 
the Knight class to produce the correct notation.


Thank you,

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


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Michael Torrie
On 04/27/2016 08:49 PM, Christopher Reimer wrote:
> On 4/27/2016 7:00 PM, Michael Torrie wrote:
>> I am guessing that the reason you are storing state as it's own 
>> dictionary is so that you can pass the state itself to the constructor? 
> 
> Someone said it was bad to store the object itself to file (my original 
> plan) and that I should use a dictionary instead. This is my 
> implementation of that idea. However, saving and loading data is far 
> down my to do list.

Pickle should be able to serialize an object that stores state as
attributes, as that's what objects normally do.

But you could also serialize and save the objects yourself manually too.
 In fact if it were me I would save game state to some kind of ini file,
which would mean manually going through each object and writing out the
relevant data to the ini file using the right syntax. And then reverse
the process when restoring from a file.  XML could be another format
used for your file, if you're into that kind of thing.


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


Re: Pythonic style

2016-04-27 Thread Ethan Furman

On 04/27/2016 08:07 PM, Christopher Reimer wrote:

On 4/27/2016 7:07 PM, Ben Finney wrote:

>> Ian Kelly wrote:


 self.__dict__ = {'key', 'value'}

is essentially equivalent to:

 self.key = value

>>

I would say the latter is more Pythonic, because it:

>>
>> [snip]
>>

* Uses the built-in mechanisms of Python (don't invoke magic attributes,
   instead use the system that makes use of them behind the scenes).


In short,  my original code before I turned it into a separate
dictionary. *sigh*


No.

The point Ben was trying to make is this:  you should never* call 
__dunder__ methods in normal code; there is no need to do so:


- use len(), not __len__()
- use next(), not __next__()
- use some_instance.an_attribute, not some_instance.__dict__['an_attribute']

--
~Ethan~

* Okay, maybe /almost/ never.  About the only time you need to is when 
giving your classes special methods, such as __add__ or __repr__.

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


Re: Pythonic style

2016-04-27 Thread Ben Finney
Christopher Reimer  writes:

> In short,  my original code before I turned it into a separate
> dictionary. *sigh*

No, I think that misses the points that were being made. The discussion
you're talking about was *not* to say “attribute access is better than
dictionary access”, or vice versa. Each is good for its purpose.

Rather, the discussion was to drive home the point that in Python those
are *two distinct concepts*, and you need to not conflate them.

If you want items in a mapping, explicitly use a Python ‘dict’ instance.
If you want attributes that describe an object, explicitly use
attributes of that object. Deliberately choose which one makes more
sense.

-- 
 \ “The double standard that exempts religious activities from |
  `\   almost all standards of accountability should be dismantled |
_o__)   once and for all.” —Daniel Dennett, 2010-01-12 |
Ben Finney

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


Re: Pythonic style (was: Differences between Class(Object) and Class(Dict) for dictionary usage?)

2016-04-27 Thread Christopher Reimer

On 4/27/2016 7:07 PM, Ben Finney wrote:

I would say the latter is more Pythonic, because it:

* Better conveys the intention (“set the value of the ‘self.key’
   attribute”).

* Uses the built-in mechanisms of Python (don't invoke magic attributes,
   instead use the system that makes use of them behind the scenes).

* Expresses that intention more concisely (fewer terms).

* Expresses that intention more clearly (less syntactic noise).


In short,  my original code before I turned it into a separate 
dictionary. *sigh*


Thank you,

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


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Ethan Furman

On 04/27/2016 06:12 PM, Christopher Reimer wrote:


After considering the feedback I got for sanity checking my code, I've
decided to simplify the base class for the chess pieces (see code
below). All the variables are stored inside a dictionary with most
values accessible through properties. A custom dictionary can be loaded
through the constructor and or saved out through the fetch_state method.
The subclasses only have to implement the is_move_valid method, which is
different for each type of chess piece.


Much better.

Here's my take on it:

class Piece(object):
def __init__(self, color, position):
 self._color = color
 self._first_move = True
 self._initial_position = position
 self._move_count = 0
 self._name = color.title() + ' ' + self.__class__.__name__
 self._notation = color.title()[:1] + self.__class__.__name__[:1]
 self._position = position

@property
def color(self):
return self._color

def is_move_valid(self, new_position, board_state):
raise NotImplementedError

@property
def move_count(self):
return self._move_count

@property
def name(self):
return self._name

@property
def notation(self):
return self._notation

@property
def position(self):
return self._position

@position.setter
def position(self, position):
self._position = position
if self._first_move:
self._first_move = False
self._move_count += 1

Now all the attributes are, well, attributes of the instance (that's 
what instances are for).


I ripped out the fetch_state because that will take more work -- you 
can't pass a Pawn's saved state in to Piece and get the results you 
want.  pickle is worth looking at for saving/restoring.


Also, your code will give the same notation to Kings and Knights.

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


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer

On 4/27/2016 7:00 PM, Michael Torrie wrote:
I am guessing that the reason you are storing state as it's own 
dictionary is so that you can pass the state itself to the constructor? 


Someone said it was bad to store the object itself to file (my original 
plan) and that I should use a dictionary instead. This is my 
implementation of that idea. However, saving and loading data is far 
down my to do list.


I know you've stated reasons for doing things the way you have, but 
this self._state dict smells a bit funny, especially where you have 
self._state = state, which means that several instances could have the 
exact same state object at the same time and strikes me as mildly 
un-pythonic and very confusing. "State" is what instances themselves 
are supposed to track by design. I recommend you use this feature 
rather than duplicating it with your own error-prone dict handling. 


So far the code is working as designed for new chess pieces (see below).

Thank you,

Chris R.

Rook('white', (1, 1)) @ 2106251742008
Knight('white', (1, 2)) @ 2106251755648
Bishop('white', (1, 3)) @ 2106251755760
Queen('white', (1, 4)) @ 2106251755872
King('white', (1, 5)) @ 2106251755984
Bishop('white', (1, 6)) @ 2106251756096
Knight('white', (1, 7)) @ 2106251756208
Rook('white', (1, 8)) @ 2106251756320
Pawn('white', (2, 1)) @ 2106251756432
Pawn('white', (2, 2)) @ 2106251756544
Pawn('white', (2, 3)) @ 2106251756656
Pawn('white', (2, 4)) @ 2106251756768
Pawn('white', (2, 5)) @ 2106251756880
Pawn('white', (2, 6)) @ 2106251756992
Pawn('white', (2, 7)) @ 2106251757104
Pawn('white', (2, 8)) @ 2106251757216
Pawn('black', (7, 1)) @ 2106251742288
Pawn('black', (7, 2)) @ 2106251742400
Pawn('black', (7, 3)) @ 2106251742512
Pawn('black', (7, 4)) @ 2106251742624
Pawn('black', (7, 5)) @ 2106251742736
Pawn('black', (7, 6)) @ 2106251742848
Pawn('black', (7, 7)) @ 2106251742960
Pawn('black', (7, 8)) @ 2106251743072
Rook('black', (8, 1)) @ 2106251743184
Knight('black', (8, 2)) @ 2106251742120
Bishop('black', (8, 3)) @ 2106251740608
Queen('black', (8, 4)) @ 2106251740496
King('black', (8, 5)) @ 2106251740832
Bishop('black', (8, 6)) @ 2106251741672
Knight('black', (8, 7)) @ 2106251741784
Rook('black', (8, 8)) @ 2106251741896

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


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer via Python-list

On 4/26/2016 8:56 PM, Random832 wrote:
what exactly do you mean by property decorators? If you're just 
accessing them in a dictionary what's the benefit over having the 
values be simple attributes rather than properties?


After considering the feedback I got for sanity checking my code, I've 
decided to simplify the base class for the chess pieces (see code 
below). All the variables are stored inside a dictionary with most 
values accessible through properties. A custom dictionary can be loaded 
through the constructor and or saved out through the fetch_state method. 
The subclasses only have to implement the is_move_valid method, which is 
different for each type of chess piece.


Thank you,

Chris R.



class Piece(object):
def __init__(self, color, position, state=None):
if state is None:
self._state = {
'class': self.__class__.__name__,
'color': color,
'first_move': True,
'initial_position': position,
'move_count': 0,
'name': color.title() + ' ' + self.__class__.__name__,
'notation': color.title()[:1] + 
self.__class__.__name__[:1],

'position': position
}
else:
self._state = state

@property
def color(self):
return self._state['color']

def fetch_state(self):
return self._state

def is_move_valid(self, new_position, board_state):
raise NotImplementedError

@property
def move_count(self):
return self._state['move_count']

@property
def name(self):
return self._state['name']

@property
def notation(self):
return self._state['notation']

@property
def position(self):
return self._state['position']

@position.setter
def position(self, position):
self._state['position'] = position
if self._state['first_move']:
self._state['first_move'] = False
self._state['move_count'] += 1

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


Pythonic style (was: Differences between Class(Object) and Class(Dict) for dictionary usage?)

2016-04-27 Thread Ben Finney
Christopher Reimer  writes:

> On 4/27/2016 7:33 AM, Ian Kelly wrote:
>
> >  self.__dict__ = {'key', 'value'}
> >
> >  self.key = value
>
> Which expression is Pythonic?

(Note that assignment is not an expression in Python; assigment is a
statement.)

> I've seen both used in various examples on the Internet.

I would say the latter is more Pythonic, because it:

* Better conveys the intention (“set the value of the ‘self.key’
  attribute”).

* Uses the built-in mechanisms of Python (don't invoke magic attributes,
  instead use the system that makes use of them behind the scenes).

* Expresses that intention more concisely (fewer terms).

* Expresses that intention more clearly (less syntactic noise).

-- 
 \“Nothing so needs reforming as other people's habits.” —Mark |
  `\   Twain, _Pudd'n'head Wilson_ |
_o__)  |
Ben Finney

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


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Michael Torrie
On 04/27/2016 07:12 PM, Christopher Reimer wrote:
> class Piece(object):
>  def __init__(self, color, position, state=None):
>  if state is None:
>  self._state = {
>  'class': self.__class__.__name__,
>  'color': color,
>  'first_move': True,
>  'initial_position': position,
>  'move_count': 0,
>  'name': color.title() + ' ' + self.__class__.__name__,
>  'notation': color.title()[:1] + 
> self.__class__.__name__[:1],
>  'position': position
>  }

I am guessing that the reason you are storing state as it's own
dictionary is so that you can pass the state itself to the constructor?

>  else:
>  self._state = state

I'm not sure why you are storing the class name in self._state above,
but keep in mind that this part of the constructor will just reference
whatever was in the passed-in state object, whether it's right or wrong.
 So the value of self._state.class and self._state.notation may or may
not be right, compared to what is set in the previous section if None is
passed in.  Also self._state = state means that the state object passed
will be the self._state object.  Not a copy, but the exact same object.
 So multiple instances could have the exact object as self._state.  Not
sure if this is what you intended or not.

Personally I would ditch the self._state dictionary entirely and store
the state directly as instance attributes.  self.color, self.first_move,
etc.  For the constructor if you want to duplicate another object's
state, just pass the entire object as an argument and copy the
attributes manually, rather than passing around the state dict.

I know you've stated reasons for doing things the way you have, but this
self._state dict smells a bit funny, especially where you have
self._state = state, which means that several instances could have the
exact same state object at the same time and strikes me as mildly
un-pythonic and very confusing.  "State" is what instances themselves
are supposed to track by design.  I recommend you use this feature
rather than duplicating it with your own error-prone dict handling.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26873] xmlrpclib raises when trying to convert an int to string when unicode is available

2016-04-27 Thread Nathan Williams

New submission from Nathan Williams:

I am using xmlrpclib against an internal xmlrpc server.
One of the responses returns integer values, and it raises an exception in 
"_stringify"

The code for _stringify is (xmlrpclib.py:180 in python2.7):

if unicode:
def _stringify(string):
# convert to 7-bit ascii if possible
try:
return string.encode("ascii")
except UnicodeError:
return string
else:
def _stringify(string):
return string


So when "unicode" is available, .encode is called on the parameter (which are 
the returned objects from the server) which fails for ints.

Without the unicode path it works fine, proven with the following monkey-patch:
xmlrpclib._stringify = lambda s: s

I am using the above patch as a workaround, but a fix to the library should be 
straightforward, simply checking for AttributeError in the except clause would 
solve it while retaining the existing functionality.


The traceback:

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request
return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1387, in _parse_response
p.feed(response)
  File "/usr/lib/python2.6/xmlrpclib.py", line 601, in feed
self._parser.Parse(data, 0)
  File "/usr/lib/python2.6/xmlrpclib.py", line 868, in end
return f(self, join(self._data, ""))
  File "/usr/lib/python2.6/xmlrpclib.py", line 935, in end_struct
dict[_stringify(items[i])] = items[i+1]
  File "/usr/lib/python2.6/xmlrpclib.py", line 176, in _stringify
return string.encode("ascii")
AttributeError: 'int' object has no attribute 'encode'

--
components: Library (Lib)
messages: 264407
nosy: Nathan Williams
priority: normal
severity: normal
status: open
title: xmlrpclib raises when trying to convert an int to string when unicode is 
available
type: crash
versions: Python 2.7

___
Python tracker 

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



[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-04-27 Thread Martin Panter

Martin Panter added the comment:

I don’t know anything about AIX specific stuff, but I left some general 
comments in the code review.

Is there any chance that AIX people would be relying on the current behaviour 
that I understand uses _findSoname_ldconfig() and _findLib_gcc()?

Is this new functionality covered by the test suite? E.g. in 
/Lib/ctypes/test/test_find.py, there are tests that call find_library() for GL, 
GLU, and gle. Are those libraries common on AIX?

As discussed in Issue 9998, it seems a lot of people use find_library() to help 
convert a build-time library name to a run-time shared library name that can be 
passed to CDLL() or LoadLibrary(). E.g. on Linux:

>>> find_library("python2.7")  # As used in cc . . . -lpython2.7
'libpython2.7.so.1.0'
>>> cdll.LoadLibrary("libpython2.7.so.1.0")


Does your patch support this kind of use case?

--

___
Python tracker 

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



Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer

On 4/27/2016 7:33 AM, Ian Kelly wrote:


This class definition looks muddled. Because Test2 inherits from dict,
the object referred to by "self" will be a dict, and self.__dict__ is
actually a *different* dict, containing the attributes of self. The
line:

 self.__dict__ = {'key', 'value'}

is essentially equivalent to:

 self.key = value

and will be regardless of whether you inherit from object or dict. If
you find this distinction confusing, then I recommend not inheriting
from dict.


Which expression is Pythonic? I've seen both used in various examples on 
the Internet.


Thank you,

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


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer

On 4/27/2016 7:24 AM, Ian Kelly wrote:
Some other great questions to ask yourself are "do I really want 
len(my_object) to return the number of items in this dict" and "do I 
really want list(my_object) to return all the keys in this dict"? If 
the answer to all those is yes, then it's probably fair to say that 
your object is-a dict and should be modeled as such.


These questions are more useful for me to consider. For my chess piece 
base class, the answer is no.


Thank you,

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


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Christopher Reimer

On 4/26/2016 8:56 PM, Random832 wrote:
what exactly do you mean by property decorators? If you're just 
accessing them in a dictionary what's the benefit over having the 
values be simple attributes rather than properties?


After considering the feedback I got for sanity checking my code, I've 
decided to simplify the base class for the chess pieces (see code 
below). All the variables are stored inside a dictionary with most 
values accessible through properties. A custom dictionary can be loaded 
through the constructor and or saved out through the fetch_state method. 
The subclasses only have to implement the is_move_valid method, which is 
different for each type of chess piece.


Thank you,

Chris R.



class Piece(object):
def __init__(self, color, position, state=None):
if state is None:
self._state = {
'class': self.__class__.__name__,
'color': color,
'first_move': True,
'initial_position': position,
'move_count': 0,
'name': color.title() + ' ' + self.__class__.__name__,
'notation': color.title()[:1] + 
self.__class__.__name__[:1],

'position': position
}
else:
self._state = state

@property
def color(self):
return self._state['color']

def fetch_state(self):
return self._state

def is_move_valid(self, new_position, board_state):
raise NotImplementedError

@property
def move_count(self):
return self._state['move_count']

@property
def name(self):
return self._state['name']

@property
def notation(self):
return self._state['notation']

@property
def position(self):
return self._state['position']

@position.setter
def position(self, position):
self._state['position'] = position
if self._state['first_move']:
self._state['first_move'] = False
self._state['move_count'] += 1
--
https://mail.python.org/mailman/listinfo/python-list


Big World, Big Data, Big Mind : Spark | Scala | Python

2016-04-27 Thread Apporva Jain
Become proficient in both Scala and python to implement programming skills on 
Apache spark and have independent understanding of all three platforms


Objectives:
Understand the difference between Apache Spark and Hadoop
Learn Scala and its programming implementation
Implement Spark on a cluster
Write Spark Applications using Python, Java and Scala
Understand Module 4-RDD and its operation
Learn common Spark Algorithms
Define and explain Spark Streaming
Execute Pattern Matching in Scala
Understand Scala Java Interoperability
Understand the purpose, importance and Installation of Python
Get expertise in Python core Data types, Regular Expressions, Looping, and 
object Oriented Programming
Master the concepts of File Operations, Functions, Special methods of defining 
a Class and SQLite in Python
Take a quick overview on Panda
Learn how to manage Hadoop File System
Get an understanding on Server logs, Pig script and Work Flow Editor
Work on a detailed Project on Web Logging in Python and Implement everything 
you learnt on a live Project
Work on Minor and Major Projects applying programming techniques of Scala to 
run on Spark applications


Start learning Spark | Scala | Python from basics to advance levels.
https://goo.gl/4SEsJR
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python path and append

2016-04-27 Thread Stephen Hansen
On Tue, Apr 26, 2016, at 07:56 PM, Seymore4Head wrote:
> On Tue, 26 Apr 2016 11:53:57 +1000, Steven D'Aprano
>  wrote:
> 
> >On Tue, 26 Apr 2016 08:04 am, Seymore4Head wrote:
> >
> >> BTW I was trying to use a line like yours that used an output file
> >> that didn't exist and was getting an error.  I assume that import os
> >> fixes that.
> >
> >
> >Why would you assume that?
> >
> >
> >"Doctor, I have a problem with my arm, but I won't tell you what. I assume
> >that if I take cough drops that will fix it."
> 
> OK.  Dumb question acknowledged.
> 
> I got an error when I tried to write to a non existent file.  I
> "incorrectly" assumed wrong.  That is going to be a common theme.

Oh, he wasn't saying it was a dumb question. He was complaining you said
you were "getting an error". That's not a dumb question, that's a
useless report of a problem. If you don't say what exactly the error is,
we can't help you.

If you want help, the two best things to do are:
  1) Show actual code. 
  2) Show actual, complete tracebacks. 

Having a nice description of what you expect to happen is often nice
too, especially if its doing something "wrong" and not giving an obvious
traceback. Seeing specifically what the wrong behavior is, and you
explaining why you think its wrong, can be invaluable. 

-- 
Stephen Hansen
  m e @ i x o k a i . i o
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python(x,y) 64 bit

2016-04-27 Thread Stephen Hansen
On Wed, Apr 27, 2016, at 04:25 PM, Pierre wrote:
> I did check and it looks like the Python(x,y) 64 distribution I
> downloaded uses a 32 bit Python.
> The question is if there is ANY Python(x,y) 64 distribution that uses the
> 64 bit python version.
> I looked it up online and could not find anything related to this issue

I don't know anything about Python(x,y), but from their website it looks
like it doesn't offer 64-bit python. 

Note, Python(x,y) is not affiliated with Python itself.

That said, perhaps you should check out
https://www.continuum.io/downloads which is the Anaconda scientific
distribution, which I know does offer 64-bit Python support.

---
Stephen Hansen
  m e @ i x o k a i . i o

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


[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-04-27 Thread Martin Panter

Changes by Martin Panter :


Added file: http://bugs.python.org/file42634/python.Lib.ctypes.160317.patch

___
Python tracker 

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



[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-04-27 Thread Martin Panter

Changes by Martin Panter :


Removed file: http://bugs.python.org/file42633/python.Lib.ctypes.160309.patch

___
Python tracker 

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



[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-04-27 Thread Martin Panter

Martin Panter added the comment:

I notice the patch is against Python 2, and uses Python 2 specific syntax. I am 
unsure if this kind of change is acceptable for 2.7, or if it would have to 
only go into 3.6. Hopefully this version of the patch will notify the review 
system that it is against Python 2.

--
stage:  -> patch review
Added file: http://bugs.python.org/file42633/python.Lib.ctypes.160309.patch

___
Python tracker 

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



Re: Python(x,y) 64 bit

2016-04-27 Thread Pierre
On Wednesday, April 27, 2016 at 11:17:32 AM UTC-4, Zachary Ware wrote:
> Hi Pierre,
> 
> On Wed, Apr 27, 2016 at 6:23 AM, Pierre  wrote:
> > Hello,
> >
> > I installed Python(x,y) 64 bit version and ran it using a library that 
> > requires Python 64 bit.
> > I got an error which indicated that I am using Python 32 bit.
> >
> > So, is the python used by Python(x,y) 64 bit, using Python 64 or 32 bit?
> 
> You can check by doing `python -c "import sys;print(sys.maxsize ==
> 2**63-1)"`.  You'll get True for 64-bit, False for 32-bit.  There's a
> possibility that you've gotten a misleading error message, though.
> What version of Python(x,y) are you using, and what library?
> 
> -- 
> Zach

Zach,

I did check and it looks like the Python(x,y) 64 distribution I downloaded uses 
a 32 bit Python.
The question is if there is ANY Python(x,y) 64 distribution that uses the 64 
bit python version.
I looked it up online and could not find anything related to this issue
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Stefan Krah

Stefan Krah added the comment:

It seems that the patch also introduces a segfault if PyLong_FromSsize_t() 
returns NULL.

--
nosy: +skrah

___
Python tracker 

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



[issue26872] Default ConfigParser in python is not able to load values habing percent in them

2016-04-27 Thread sorin

sorin added the comment:

Here is one example of failure caused by this 
https://gist.github.com/ssbarnea/b373062dd45de92735c7482b2735c5fb

--

___
Python tracker 

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



[issue26872] Default ConfigParser in python is not able to load values habing percent in them

2016-04-27 Thread sorin

New submission from sorin:

The ConfigParser issue with % (percent) is taking huge proportions because it 
does have serious implications downstream. One such example is the fact that in 
breaks virtualenv in such way the if you create a virtual env in a path that 
contains percent at some point you will endup with a virtualenv where you can 
install only about 50% of existing python packages (serious ones like numpy or 
pandas will fail to install or even to perform a simple python setup.py 
egg_info on them).

This is related to distutils which is trying to use the ConfigParser to load 
the python PATH (which now contains the percent). 

Switching to RawConfigParser does resolve the problem but this seems like an 
almost impossible attempt because the huge number of occurrences in the wild.

You will find the that only class that is able to load a value with percent 
inside is RawConfigParser and I don't think that this is normal.

Here is some code I created to exemplify the defective behaviour:
https://github.com/ssbarnea/test-configparser/blob/master/tests/test-configparser.py#L21

The code is executed by Travis with multiple version of python, see one result 
example: https://travis-ci.org/ssbarnea/test-configparser/jobs/126145032

My personal impression is that the decision to process the % (percent) and to 
change the behaviour between Python 2 and 3 was a very unfortunate one. Ini/Cfg 
file specification does not specify the percent as an escape character. 
Introduction of the %(VAR) feature sounds more like bug than a feature in this 
case.

--
components: Distutils
messages: 264402
nosy: dstufft, eric.araujo, sorin
priority: normal
severity: normal
status: open
title: Default ConfigParser in python is not able to load values habing percent 
in them
type: compile error
versions: Python 3.4, Python 3.5

___
Python tracker 

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



[issue25788] fileinput.hook_encoded has no way to pass arguments to codecs

2016-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Committed with some changes. Thank you for your contribution Joseph.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue25788] fileinput.hook_encoded has no way to pass arguments to codecs

2016-04-27 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8ab8f5259f09 by Serhiy Storchaka in branch 'default':
Issue #25788: fileinput.hook_encoded() now supports an "errors" argument
https://hg.python.org/cpython/rev/8ab8f5259f09

--
nosy: +python-dev

___
Python tracker 

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



[issue26348] activate.fish sets VENV prompt incorrectly

2016-04-27 Thread Dan McCombs

Dan McCombs added the comment:

Thanks Brett.

--

___
Python tracker 

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



[issue26348] activate.fish sets VENV prompt incorrectly

2016-04-27 Thread Brett Cannon

Brett Cannon added the comment:

I'll revert the two commits then and close both this and #26664 when I have a 
chance.

--

___
Python tracker 

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



[issue26348] activate.fish sets VENV prompt incorrectly

2016-04-27 Thread Dan McCombs

Dan McCombs added the comment:

Yes, reverting cfc66e37eb8e and 0f1ac94d2f98 should resolve #26664.

--

___
Python tracker 

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



[issue26348] activate.fish sets VENV prompt incorrectly

2016-04-27 Thread Brett Cannon

Brett Cannon added the comment:

So just to be clear, cfc66e37eb8e and 0f1ac94d2f98 should be reverted? No other 
changes?

And will this fix issue #26664 or affect it in any way?

--
assignee:  -> brett.cannon
status: closed -> open

___
Python tracker 

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



[issue26664] find a bug in activate.fish of venv of cpython3.6

2016-04-27 Thread Brett Cannon

Changes by Brett Cannon :


--
assignee:  -> brett.cannon

___
Python tracker 

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



[issue26348] activate.fish sets VENV prompt incorrectly

2016-04-27 Thread Dan McCombs

Dan McCombs added the comment:

I somehow missed the comment on 2016-04-01, I apologize for being late to look 
at this.

Xiang is right, this patch should be reverted.

It looks like the issue reported was originally brought on by an activate.fish 
being used from a Python after the patch in commit 7f913c6ada03 was added, but 
the running version of Python did not include the patch, so that the 
placeholder was not being swapped out. In that case, updating the script to 
include $ and use the variable fixed the problem, but when the patch in 
7f913c6ada03 is also included it causes the placeholder to be swapped to a name 
wrapped in parenthesis preceded by $ at the time the venv is created causing a 
syntax error in fish.

Since the patch in commit 7f913c6ada03 swaps that place holder and handles 
doing so in the other activate scripts as well, the patch that was part of this 
issue (cfc66e37eb8e) is not needed and should be reverted.

Here's the commit adding that placeholder for context:

https://hg.python.org/cpython/rev/7f913c6ada03

--

___
Python tracker 

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



Re: Importerror: cannot import name httpshandler linux

2016-04-27 Thread Wildman via Python-list
On Wed, 27 Apr 2016 10:13:45 -0700, bharadwajsrivatsa wrote:

> I tried installing Python 2.7.11 on HP-UX which already has all
> the build and run time dependencies installed on it such as
> openssl, libffi, etc. But after installing python , I tried
> installing some open source packages using pip. But pip thows the error:
> Importerror: cannot import name httpshandler linux.
> 
>  PLease help me out to resolve this.

Try installing the libssl-dev package.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Stefan Krah

Changes by Stefan Krah :


--
nosy:  -skrah

___
Python tracker 

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



[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Stefan Krah

Stefan Krah added the comment:

Your definition of correctness is very odd. The "leaks" you are talking
about are single references in case of a module initialization failure,
in which case you are likely to have much bigger problems.


Please take _decimal out of this patch, it's a waste of time.

--

___
Python tracker 

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



[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Idiomatic code is

if (PyModule_AddObject(module, "name", create_new_object()) < 0)
goto error;

If you already have a reference and need to use it later:

obj = create_new_object();
... /* use obj */
Py_INCREF();
if (PyModule_AddObject(module, "name", create_new_object()) < 0)
goto error;
... /* use obj */
Py_DECREF(obj);

error:
Py_XDECREF(obj);

Many current code use above idioms, but it doesn't work as expected.

It is almost impossible to write correct code with current behavior. And 
_decimal.c is not an exception, it has leaks.

--

___
Python tracker 

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



[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-04-27 Thread David Edelsohn

David Edelsohn added the comment:

The most recent patch seems to follow AIX semantics correctly.

--

___
Python tracker 

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



[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-04-27 Thread Michael Felt

Michael Felt added the comment:

These are very different issues. However, this patch may resolve both!

ldconfig (-p if I recall) lists where (shared) libraries have been installed 
(imho, this is a GNU tool approach) - whereas AIX would use dump -H to find 
library paths embedded in a program and/or shared library.

Until this patch, to use shared libraries on AIX the members of an archive 
needed to be extracted from the .a archive, and for 64-bit members, a separate 
directory (e.g. /usr/lib64) is needed. With this patch find_library() (actually 
cdll.LoadLibrary() can load members from either both .so and .a libraries, as 
is normal for AIX.

So, in a way, this would also solve https://bugs.python.org/issue21826 as 
ldconfig is no longer needed (nor called) on AIX.

p.s. As it is well longer than a month - I would appreciate that someone 
actually look at the patch and tell me how it can be improved! :)

--

___
Python tracker 

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



[issue25243] decouple string-to-boolean logic from ConfigParser.getboolean and offer as separate function

2016-04-27 Thread Joshua Bronson

Joshua Bronson added the comment:

Though come to think of it, the issue you raised with using "from" in the 
method name wouldn't apply here, since the static method is on the bool class, 
and the method does return bool.

--

___
Python tracker 

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



[issue25243] decouple string-to-boolean logic from ConfigParser.getboolean and offer as separate function

2016-04-27 Thread Joshua Bronson

Joshua Bronson added the comment:

Actually, looks like the version of the patch I attached did use the name 
`bool.from_config_str`, sorry about that -- I'll attach a new patch renaming 
this to `bool.parse_config_str` if there is interest in further consideration.

--

___
Python tracker 

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



[issue26868] Incorrect check for return value of PyModule_AddObject in _csv.c

2016-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

As for Modules/_csv.c, I think it is better to change the behavior of 
PyModule_AddObject() (issue26871). This will fix similar issues in all modules.

--
dependencies: +Change weird behavior of PyModule_AddObject()

___
Python tracker 

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



[issue25243] decouple string-to-boolean logic from ConfigParser.getboolean and offer as separate function

2016-04-27 Thread Joshua Bronson

Joshua Bronson added the comment:

Hi Raymond, I'm a bit confused by your comment. The patch I attached to my 
previous message adds the static method `bool.parse_config_str`. So there's no 
need to `import configparser` to use this, and "from" is no longer included in 
the proposed method name. Could you please take a look at my previous message, 
if you missed it, and reopen this if appropriate?

--

___
Python tracker 

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



[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Stefan Krah

Stefan Krah added the comment:

I think the current behavior is good for error handling by goto,
which is common for module initialization.

Please don't change this.

--
nosy: +skrah

___
Python tracker 

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



[issue26348] activate.fish sets VENV prompt incorrectly

2016-04-27 Thread Xiang Zhang

Xiang Zhang added the comment:

The original behaviour is right. __VENV_PROMPT__ is meant to be a placeholder, 
not a variable interpreted by shell. I think this patch should be reverted. 
Related issue is #26664.

--
nosy: +xiang.zhang

___
Python tracker 

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



[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

PyModule_AddObject() has weird and counterintuitive behavior. It steals a 
reference only on success. The caller is responsible to decref it on error. 
This behavior was not documented and inconsistent with the behavior of other 
functions stealing a reference (PyList_SetItem() and PyTuple_SetItem()). Seems 
most developers don't use this function correctly, since only in few places in 
the stdlib a reference is decrefed explicitly after PyModule_AddObject() 
failure.

This weird behavior was first reported in issue1782, and changing it was 
proposed. Related bugs in PyModule_AddIntConstant() and 
PyModule_AddStringConstant() were fixed, but the behavior of 
PyModule_AddObject() was not changed and not documented.

This issue is opened for gradual changing the behavior of PyModule_AddObject(). 
Proposed patch introduces new macros PY_MODULE_ADDOBJECT_CLEAN that controls 
the behavior of PyModule_AddObject() as PY_SSIZE_T_CLEAN controls the behavior 
of PyArg_Parse* functions. If the macro is defined before including "Python.h", 
PyModule_AddObject() steals a reference unconditionally.  Otherwise it steals a 
reference only on success, and the caller is responsible for decref'ing it on 
error (current behavior). This needs minimal changes to source code if 
PyModule_AddObject() was used incorrectly (i.e. as documented), and keep the 
code that explicitly decref a reference after PyModule_AddObject() working 
correctly.

Use of PyModule_AddObject() without defining PY_MODULE_ADDOBJECT_CLEAN is 
declared deprecated (or we can defer this to 3.7). In the distant future (after 
dropping the support of 2.7) the old behavior will be dropped.

See also a discussion on Python-Dev: 
http://comments.gmane.org/gmane.comp.python.devel/157545 .

--
components: Extension Modules, Interpreter Core
files: pymodule_addobject.patch
keywords: patch
messages: 264384
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Change weird behavior of PyModule_AddObject()
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file42632/pymodule_addobject.patch

___
Python tracker 

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



[issue26664] find a bug in activate.fish of venv of cpython3.6

2016-04-27 Thread Xiang Zhang

Xiang Zhang added the comment:

The patch introduced by issue26348 should be reverted. The __VENV_PROMPT__ is 
meant to be a placeholder. For example, when you create a virtual environment 
named venv-test, the __VENV_PROPMT__ will be replace by (venv-test). If the 
patch is applied, it will be $(venv-test), treated as an expression and then 
cause a failure.

--
nosy: +xiang.zhang

___
Python tracker 

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



[issue26869] unittest longMessage docs

2016-04-27 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Replace existing description with

"This class attribute determines what happens when a custom failure message is 
passed as the msg argument to an assertXYY call that fails.  If True, the 
default, the custom message is appended to the end of the standard failure 
message.  If False, the custom message replaces the standard message.

The standard failure message for each *assert method* contains useful 
information about the objects involved.  For example the message from 
assertEqual shows the repr of the two unequal objects.  It is usually easier to 
augment rather than replace this message

The class setting can be overridden in individual test methods by assigning an 
instance attribute, self.longMessage, to True or False before calling the 
assert methods.

New in version 3.1."

--
nosy: +terry.reedy
stage:  -> needs patch
type:  -> behavior
versions: +Python 3.5

___
Python tracker 

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



[issue26866] Inconsistent environment in Windows using "Open With"

2016-04-27 Thread Tom Middleton

Tom Middleton added the comment:

I agree with your assessment Steve. I don't see there being a good fix to this. 
I also think it would be a bad idea to have the launcher change the current 
working directory.
Example:
c:\foo\> python d:\scripts\bar.py myfile
(where myfile is in c:\foo\)

A kludge work around in a script is something like this:
import os

if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))


I also don't think it makes sense to counteract what seems to be a Windows 
issue in python (or the launcher of which I am less familiar with). I was 
hoping it was going to be a simple registry setting or something like that 
which could be handled in the install process.


Eryk, you are correct, it was poor coding that led to the issue. I don't think 
I was clear in my initial post that I realize that opening a file and assuming 
the directory of the script is the cwd is not good practice. I was commenting 
that it is inconsistent between launching methods. I was launching a script 
that was attempting to write a log file using the logging module with a 
relative path filename. It was a gotcha because it worked fine on my desktop 
and it wasn't working when a colleague ran it from "Open with". I've since 
improved my methodology so the issue is moot for that regard.
However, it is still interesting that there is an inconsistency in Windows in 
those methods of execution. FWIW I also tested it out with perl and as I 
expected, got the same results of working directories.

Also please note that I am working in Python 2.7, there is no py launcher as 
there is in 3. I am not certain what inconsistencies may occur between calling 
py.exe v. python.exe.

--

___
Python tracker 

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



Importerror: cannot import name httpshandler linux

2016-04-27 Thread bharadwajsrivatsa
I tried installing Python 2.7.11 on HP-UX which already has all the build and 
run time dependencies installed on it such as openssl, libffi, etc. But after 
installing python , I tried installing some open source packages using pip. But 
pip thows the error:
Importerror: cannot import name httpshandler linux.

 PLease help me out to resolve this.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26866] Inconsistent environment in Windows using "Open With"

2016-04-27 Thread Steve Dower

Steve Dower added the comment:

Wouldn't be surprised to see differences between Win7 and Win10 - the "current 
working directory" concept has essentially been deprecated in Windows for a 
while (at least through the GUI).

Registering a system file association is something we could do for the 
launcher, but that'd be about it. I'm not sure it'd gain that much. Would be 
very interesting to collect data on who double clicks .py files vs. running 
them from another program or a console.

--

___
Python tracker 

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



[issue25788] fileinput.hook_encoded has no way to pass arguments to codecs

2016-04-27 Thread Joseph Hackman

Joseph Hackman added the comment:

Updated documentation in fileinput.rst, Doc/whatsnew/3.6.rst, Misc/NEWS and 
Misc/ACKS.

Thank you so much Serhiy for taking the time to review!

--
Added file: http://bugs.python.org/file42631/issue25788-3.patch

___
Python tracker 

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



Re: Howw to prevent the duplication of any value in a column within a CSV file (python)

2016-04-27 Thread darnold via Python-list

potential_passengers = ['bob','john','sue','wendy','chris','bob','jen','wendy']
accepted_passengers = set()

for name in potential_passengers:
print('checking on {}...'.format(name))
if name not in accepted_passengers:
accepted_passengers.add(name)
print('welcome aboard, {}!'.format(name))
else:
print('i am sorry, we have already accepted a {}.'.format(name))
print()


HTH,
Don 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to create a dictionary from csv file?

2016-04-27 Thread Sibylle Koczian

Am 27.04.2016 um 11:31 schrieb Peter Otten:

Sibylle Koczian wrote:


And if the csv module is used anyway, why not simply read into a
DictReader?


How would that help with looking up 3.5 by "apple" given the OP's sample
data

banana,4.0
apple,3.5
orange,3.0



Quite right, it wouldn't. Misread the problem, sorry.



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


urgent requirement DB2 with AIX or LINUX@ Foster City,CA

2016-04-27 Thread durganaveen . usit
This is Naveen from SAGE IT INC.
Hope you are doing great. Please send me your updated resume if you're 
interested for this position

Title: DB2 with AIX or LINUX
Location: Foster City, CA
Duration: 12+ Months

 

Job Description

Strong DB2 LUW V10 (AIX/LINUX) expertise combined with sharp conceptual and 
analytical thinking!
Working knowledge of Hadoop is a big plus.
 
The successful candidate should have a working experience with Large 
(multi-terabytes) systems on DB2. 
Working experience with hadoop and Oracle-based systems as it pertains to the 
Datawarehousing environment is big plus.
 
Should have hands-on advanced trouble-shooting and performance tuning 
knowledge/experience; understand and be able to define different DB2 
partitioning strategies; be able to provide 3rd and 4th level support.
 
The responsibilities will include but they will not be limited to
 
* Requirement gathering and performing capacity planning, database 
physical design, architecture and configuration of large infrastructures, 
developing complex shell scripts, preparing specifications and defining
best practices and standards.
* Provide database expertise to other Global Engineering and 
Application teams; represent DB Engineering in project planning, sizing, design 
and defining backup/recovery strategies.
* The successful candidate should be adaptive to the Visa's agile 
environment!
* Experience with IBM DB2 for LUW Database Editions 9.x and 10.x
* Must have experience in administrating DB2 LUW in DPF (Partitioning) 
envrionment.
* Experience in IBM DB2 applicances like ISAS is preferred.
* Experience in shell scripting (.ksh,.bash) in AIX and Linux platforms.
* Experience IBM DB2 for LUW backup and recovery processes
* Experience in troubleshooting and supporting DB2 for LUW database 
instances.
* Experience in multiple methods of data movement technologies like 
Import, Export, and Ingest.
* Experience in DB2 LUW performance tuning methodologies.
* Knowledge of DB2 for LUW high availability and DR solutions

Thanks& Regards
Durga Naveen
SageIT IT Solutions INC
cnav...@sageitinc.net 
972-996-0650 Extn 349
www.sageitinc.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python(x,y) 64 bit

2016-04-27 Thread Zachary Ware
Hi Pierre,

On Wed, Apr 27, 2016 at 6:23 AM, Pierre  wrote:
> Hello,
>
> I installed Python(x,y) 64 bit version and ran it using a library that 
> requires Python 64 bit.
> I got an error which indicated that I am using Python 32 bit.
>
> So, is the python used by Python(x,y) 64 bit, using Python 64 or 32 bit?

You can check by doing `python -c "import sys;print(sys.maxsize ==
2**63-1)"`.  You'll get True for 64-bit, False for 32-bit.  There's a
possibility that you've gotten a misleading error message, though.
What version of Python(x,y) are you using, and what library?

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


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Ian Kelly
On Tue, Apr 26, 2016 at 9:43 PM, Christopher Reimer
 wrote:
> class Test2(dict):
> def __init__(self):
> self.__dict__ = {'key', 'value'}

This class definition looks muddled. Because Test2 inherits from dict,
the object referred to by "self" will be a dict, and self.__dict__ is
actually a *different* dict, containing the attributes of self. The
line:

self.__dict__ = {'key', 'value'}

is essentially equivalent to:

self.key = value

and will be regardless of whether you inherit from object or dict. If
you find this distinction confusing, then I recommend not inheriting
from dict.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Ian Kelly
On Tue, Apr 26, 2016 at 11:31 PM, Ethan Furman  wrote:
> On 04/26/2016 08:43 PM, Christopher Reimer wrote:
>
>> If I'm using a dictionary to store variables for an object, and
>> accessing the variable values from dictionary via property decorators,
>> would it be better to derive the class from object or dict?
>>
>>  class Test1(object):
>>  def __init__(self):
>>  self.state = {'key': 'value'}
>>
>> Or:
>>
>>  class Test2(dict):
>>  def __init__(self):
>>  self.__dict__ = {'key', 'value'}
>>
>> I haven't seen a good pro/con discussion on the Internet for using one
>> over the other. I played with both in my code. Doesn't seem to make a
>> great difference either way. Using object seems to be the most simplest
>> approach.
>
>
> Using a dict gets you a bunch of methods for free: keys(), values(),
> items(), get(), etc., etc..

You get those for free either way; in the first case you just have use
self.state.keys() instead of self.keys().

The question boils down to composition versus inheritance, and the
prevailing wisdom is to prefer composition. For me the discerning test
is "do the things that are in this dict make sense as items contained
by my object?" If the answer is yes, then go ahead and subclass from
dict. More often, the answer is no.

Some other great questions to ask yourself are "do I really want
len(my_object) to return the number of items in this dict" and "do I
really want list(my_object) to return all the keys in this dict"? If
the answer to all those is yes, then it's probably fair to say that
your object is-a dict and should be modeled as such.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26870] Unexpected call to readline's add_history in call_readline

2016-04-27 Thread Tyler Crompton

Tyler Crompton added the comment:

I agree about the documentation. It would only take a few minutes to do.

In regard to your inquiry about the second solution, more or less, yes. I left 
that one a bit ambiguous since there are many ways to skin that cat. But in 
retrospect, I probably shouldn't have included that potential solution since 
it'd be a bit goofy and wouldn't necessarily be much different (in terms of 
code conciseness) than the third workaround that I mentioned.

As for your suggestion about the fourth solution, I like that idea. I feel that 
it's actually more similar to the fifth solution than the fourth, but I feel 
that we're getting close to coming up with something that should be easy and 
effective.

Lastly, in regard to the fifth solution, yes. But I see what you're saying 
about the downside. Yeah, that would be rather annoying. For a moment, I 
thought that it could fall back to standard IO in the absence of 
Readline/libedit, but that would be a bit misleading for a function in the 
readline module. Besides, input already does that anyway.

I would imagine that in the vast majority of cases of using such a new 
function, the developer would fallback to input, because they'd likely 
prioritize getting the content from the user over ensuring Readline/libedit 
functionality. Since we already have a function that automatically does that, I 
think your suggestion to add a function to the readline module to 
enable/disable automatic history addition would be ideal. I'd be reluctant to 
use a global Python variable since it would be out of uniform with the rest of 
the members (i.e., functions) of the module.

I like the idea of adding a set_auto_history(flag=True|False) or something to 
that effect.

--

___
Python tracker 

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



[issue26855] add platform.android_ver() for android

2016-04-27 Thread Chi Hsuan Yen

Chi Hsuan Yen added the comment:

I have a WIP patch. [1] It's based on Shiz's patch [2].

[1] 
https://github.com/yan12125/python3-android/blob/cpython-hg/mk/python/android-misc.patch
[2] 
https://github.com/rave-engine/python3-android/blob/9bb6420317922c07df405315eea040f9301f7eca/mk/python/3.4.3/python-3.4.3-android-misc.patch

--

___
Python tracker 

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



Re: Howw to prevent the duplication of any value in a column within a CSV file (python)

2016-04-27 Thread Andrew Ongko
On Apr 27, 2016 7:25 PM, "Adam Davis"  wrote:
>
> On Wednesday, 27 April 2016 07:37:42 UTC+1, Chris Angelico  wrote:
> > On Wed, Apr 27, 2016 at 4:26 PM, Adam Davis 
wrote:
> > > I understand what you're saying! But where you say: " the_set =
set()", what would go within the set brackets?
> >
> > Nothing. The empty parentheses mean "call this with no arguments", and
> > when you call the set constructor like that, you get back an empty
> > set.
> >
> > ChrisA
>
> Thanks Chris. Where Ian says 'the_set.add(item)', what would be put
within item in terms of my codes function/aim?

item is name in your case. Since it's the one you care about existing or
not.

It would be like:
Read from csv,
For each row, the_set.add(name)

Now that you have the_set in memory, whenever you want to check whether a
particular name has taken the quiz, just do:

if name in the_set:
# forbid
else:
# allow

Regards,
Andrew
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Howw to prevent the duplication of any value in a column within a CSV file (python)

2016-04-27 Thread Adam Davis
On Wednesday, 27 April 2016 07:37:42 UTC+1, Chris Angelico  wrote:
> On Wed, Apr 27, 2016 at 4:26 PM, Adam Davis  wrote:
> > I understand what you're saying! But where you say: " the_set = set()", 
> > what would go within the set brackets?
> 
> Nothing. The empty parentheses mean "call this with no arguments", and
> when you call the set constructor like that, you get back an empty
> set.
> 
> ChrisA

Thanks Chris. Where Ian says 'the_set.add(item)', what would be put within item 
in terms of my codes function/aim? 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Basic Concepts

2016-04-27 Thread Steven D'Aprano
On Wed, 27 Apr 2016 07:29 pm, Smith wrote:

> Fill in the blanks to declare a variable, add 5 to it and print its value:
> 
>  >>> x = 4
>  >>> x_ = 5
>  >>> print_
> 
> 
> Any suggestion ?


Okay, you have a variable x with the value of 4:

x = 4


How do you think you would print the value of x?

Hint: here I print the value of z instead:

print z



-- 
Steven

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


[issue26855] add platform.android_ver() for android

2016-04-27 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

Some screenshots showing different file contents:

 * 
http://www1-lw.xda-cdn.com/files/2013/12/tweak-your-samsung-galaxy-s3s-performance-with-these-build-prop-android-hacks.w654.jpg
 * 
http://media.apcmag.com/wp-content/uploads/sites/20/2014/04/buildprop-text-file.jpg
 * http://i.imgur.com/hZXQaX9.png

I think exposing `codename` and `incremental` may also make sense to get a 
complete picture.

`ro.product` also has a lot of useful entries which could be used for some of 
the other platform APIs such as uname().

--

___
Python tracker 

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



[issue26868] Incorrect check for return value of PyModule_AddObject in _csv.c

2016-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Added comments on Rietveld.

--

___
Python tracker 

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



[issue26855] add platform.android_ver() for android

2016-04-27 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

If the file is guaranteed to exist on most modern Android platforms, this 
sounds like a good approach.

Perhaps you could add support to fallback to running getprop instead, if the 
file doesn't exist or cannot be parsed ?!

--
nosy: +lemburg

___
Python tracker 

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



[issue26855] add platform.android_ver() for android

2016-04-27 Thread Chi Hsuan Yen

Chi Hsuan Yen added the comment:

Isn't this macro used in compile time? I thought android_ver() aims to check 
runtime versions.

--

___
Python tracker 

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



Python(x,y) 64 bit

2016-04-27 Thread Pierre
Hello,

I installed Python(x,y) 64 bit version and ran it using a library that requires 
Python 64 bit. 
I got an error which indicated that I am using Python 32 bit.

So, is the python used by Python(x,y) 64 bit, using Python 64 or 32 bit?

Thanks



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


Re: Basic Concepts

2016-04-27 Thread alister
On Wed, 27 Apr 2016 11:29:12 +0200, Smith wrote:

> Fill in the blanks to declare a variable, add 5 to it and print its
> value:
> 
>  >>> x = 4 x_ = 5 print_
> 
> 
> Any suggestion ?
> 
> Thanks

2 suggestions:-

1) Stay awake during your class so that you can complete basic homework 
assignments.

2) Try reading the online python tutorial which covers this type of basic 
operation (& much more).


assistance with homework can be obtained her but only if you have made 
some effort, posted your code and given some explanation of why you think 
it is not working.
even then you will get suggestions to steer you in the right direction 
rather than working code. 


-- 
The more a man is imbued with the ordered regularity of all events, the 
firmer
becomes his conviction that there is no room left by the side of this 
ordered
regularity for causes of a different nature.  For him neither the rule of
human nor the rule of divine will exists as an independent cause of 
natural
events.  To be sure, the doctrine of a personal God interfering with 
natural
events could never be refuted, in the real sense, by science, for this
doctrine can always take refuge in those domains in which scientific 
knowledge
has not yet been able to set foot.

But I am persuaded that such behavior on the part of the representatives
of religion would not only be unworthy but also fatal.  For a doctrine 
which 
is able to maintain itself not in clear light, but only in the dark, will
of necessity lose its effect on mankind, with incalculable harm to human
progress.  In their struggle for the ethical good, teachers of religion
must have the stature to give up the doctrine of a personal God, that is, 
give up that source of fear and hope which in the past placed such vast
powers in the hands of priests.  In their labors they will have to avail
themselves of those forces which are capable of cultivating the Good, the 
True, and the Beautiful in humanity itself.  This is, to be sure, a more
difficult but an incomparably more worthy task.
- Albert Einstein
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26864] urllib.request no_proxy check differs from curl

2016-04-27 Thread Martin Panter

Martin Panter added the comment:

This version looks okay to me, thanks.

--

___
Python tracker 

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



[issue26826] Expose new copy_file_range() syscal in os module and use it to improve shutils.copy()

2016-04-27 Thread Martin Panter

Martin Panter added the comment:

FYI Martin Panter and vadmium are both me :)

I’m not a big fan or expert on configure.ac and Autoconf, but I guess in this 
case it is the simplest solution. Maybe look at some of the existing 
AC_CHECK_DECL and AC_COMPILE_IFELSE invocations. I guess you need to see if 
__NR_copy_file_range is available.

In the earlier patches, there were four space characters at the start of the 
file. In the 2016-04-27 09:16 patch, there is a completely empty line (after 
+#endif /* HAVE_COPY_FILE_RANGE */), which may also be interfering.

FWIW, I don’t think you have to have the posix_ prefix on your function if you 
don’t want it. It is a static function, so the naming is fairly unrestricted.

About changing copyfileobj(), here are some test cases which may help explain 
the compatibility problems:

# Transcoding a file to a different character encoding
with open("input.txt", "rt", encoding="latin-1") as input, \
open("utf8.txt", "wt", encoding="utf-8") as output:
shutil.copyfileobj(input, output)

# Input is a BufferedReader and may hold extra buffered data
with open("data", "rb") as input, open("output", "wb") as output:
header = input.read(100)  # Actually reads more bytes from OS
process_header(header)
copyfileobj(input, output)  # Copy starting from offset 100

--

___
Python tracker 

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



[issue16353] add function to os module for getting path to default shell

2016-04-27 Thread Roman Evstifeev

Changes by Roman Evstifeev :


--
nosy: +Roman.Evstifeev

___
Python tracker 

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



[issue16255] subrocess.Popen needs /bin/sh but Android only has /system/bin/sh

2016-04-27 Thread Roman Evstifeev

Changes by Roman Evstifeev :


--
nosy: +Roman.Evstifeev

___
Python tracker 

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



[issue17905] Add check for locale.h

2016-04-27 Thread Roman Evstifeev

Changes by Roman Evstifeev :


--
nosy: +Roman.Evstifeev

___
Python tracker 

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



[issue22747] Interpreter fails in initialize on systems where HAVE_LANGINFO_H is undefined

2016-04-27 Thread Roman Evstifeev

Changes by Roman Evstifeev :


--
nosy: +Roman.Evstifeev

___
Python tracker 

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



newsreader pan could not find my post

2016-04-27 Thread ldompeling
Hello,

I post a message in comp.lang python, but with caching new articles in the 
newsreader pan I don't see my article.

How can I contact the administrater or this group.

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


  1   2   >