[issue26614] False/0 and True/1 collision when used as dict keys?

2016-03-22 Thread nickeubank

New submission from nickeubank:

Found an odd behavior I'd never known about today, not sure if it's a bug or 
known. Python 3.4.4 (anaconda)

True, False, 0, 1 can all be used as dictionary keys.

But

Apparently True and 1 hash to the same item and False and 0 hash to the same 
item, so they can easily overwrite (which I spent a while banging my head over 
today). In other words:

In[1]:
d = {True: 'a', False: 'b'}
d[0] = 'z'
d[False]

Out[1]:
    'z'

--
messages: 262232
nosy: nickeubank
priority: normal
severity: normal
status: open
title: False/0 and True/1 collision when used as dict keys?
versions: Python 3.4

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



[issue26605] Feature request: string method `to_file`

2016-03-21 Thread nickeubank

nickeubank added the comment:

Seems like existence of a method in the stdlib (or at least in the pathlib part 
of the stdlib) suggests issues with text encoding can be overcome. 

IMHO I would suggest most people have no idea about that method (I've been 
doing python for years and this has always been a personal frustration, and 
I've asked several others for better options and no one had one to offer),  and 
it seems like it would make much more sense as a string method. If someone has 
a string they want to save to disk, I can't imagine anyone looking in the Path 
library. 

I respect the desire to avoid bloat -- the context manager or open/close idiom 
has just felt unnecessarily complicated (dare I say unpythonic?) for a common 
task. 

Also, I think it's one that data scientists use a lot when they generate 
outputs to pull into LaTeX documents.

--

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



[issue26605] Feature request: string method `to_file`

2016-03-21 Thread nickeubank

New submission from nickeubank:

As a social scientists trying to help other social scientists move from 
language like R, Stata, and Matlab into Python, one of the behaviors I've found 
unnecessarily difficult to explain is the "file.open()/file.close()" idiom (or, 
alternatively, context managers). In normal operating systems, and many high 
level languages, saving is a one-step operation. 

I understand there are situations where an open file handle is useful, but it 
seems a simple `to_file` method on strings (essentially wrapping a 
context-manager) would be really nice, as it would save users from learning 
this idiom. 

Any chance it's feasible? Sadly, I have no real C skills so can't implement 
myself. :(

--
components: IO
messages: 262141
nosy: nickeubank
priority: normal
severity: normal
status: open
title: Feature request: string method `to_file`
type: enhancement

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