[issue18835] Add aligned memory variants to the suite of PyMem functions/macros

2015-01-15 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Due to the realloc() problem, I'm thinking that the best course for Numpy would 
be to use its own allocator wrapper like Nathaniel outligned.
Also, Numpy wants calloc() for faster allocation of zeroed arrays...

--

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



Re: [OT] Re: MySQL connections

2015-01-15 Thread Jacob Kruger
- Original Message - 
From: Dennis Lee Bieber wlfr...@ix.netcom.com

To: python-list@python.org
Sent: Thursday, January 15, 2015 4:22 PM
Subject: Re: [OT] Re: MySQL connections



On Thu, 15 Jan 2015 13:48:34 +0200, Jacob Kruger ja...@blindza.co.za
declaimed the following:


Agree with that, but, like said in prior e-mail, just get windows error
message popping up, mentioning - no track trace, since it's python
terminating:


Python is fairly good about dumping a stack trace when the error is
something detectable by Python.

Issue is it just kills python, so no error message from python being 
rendered/displayed.


Jacob Kruger
Blind Biker
Skype: BlindZA
Roger Wilco wants to welcome you...to the space janitor's closet...

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


[issue23245] urllib2: urlopen() gets exception(kwargs bug?)

2015-01-15 Thread Douman

Douman added the comment:

I made additional experiments and now i'm confused
When i tried to execute urlopen in python interpeter it worked fine.
But it fails for me when i attempt to do so via some helper function in search 
engine of qBittorent it throw exception

https://github.com/qbittorrent/qBittorrent/blob/master/src/searchengine/nova/helpers.py

What is curious... all exceptions should be passed without notices, but for 
some reason python does throw exception even though all are catched and passed

--
Added file: http://bugs.python.org/file37715/callstack_urllib2_full

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



Re: Opening the file in writing mode

2015-01-15 Thread Mark Lawrence

On 15/01/2015 11:36, Adnan Sadzak wrote:


On Thu, Jan 15, 2015 at 12:19 PM, Abdul Abdul abdul.s...@gmail.com


Would the two of you please stop top posting, thank you.  Either 
intersperse your answers, snipping stuff that you're not replying to, or 
post at the bottom, in order to make your replies readable.  Thanks in 
anticipation.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Comparisons and sorting of a numeric class....

2015-01-15 Thread Rob Gaddi
On Wed, 14 Jan 2015 23:23:54 -0800
Andrew Robinson andr...@r3dsolutions.com wrote:

 
  Boolean algebra has two values: true and false, or 1 and 0, or humpty
  and dumpty, or whatever you like to call them.
 You're speaking to an Electrical engineer.  I know there are 10 kinds of 
 people, those who know binary and those who don't.  But you're way off 
 base if you think most industrial quality code for manipulating boolean 
 logic uses (or even can be restricted to use) only two values and still 
 accomplish their tasks correctly and within a finite amount of time.
 

[snip]

Absolutely it does and can.  You store anything that's non-boolean in a
non-boolean value, and keep it as fuzzy as you like.  But at the end of
the day, an if statement has no kinda.  You do, or you don't.  1 or
0.  And so you must ultimately resolve to a Boolean decision.

 
  Can you name any other language that *does* allow subclassing of
  booleans or creation of new boolean values?
 Yes. Several off the top of my head -- and I have mentioned these 
 before.  They generally come with the extra subclasses pre-created and 
 the user doesn't get to create the classes, but only use them; none the 
 less -- they have more than two values with which to do logic equations 
 with.
 
 VHDL, Verilog, HDL, Silos III, and there are IEEE variants also.
 C/C++ historically allowed you to do it with instances included, 
 although I am not sure it still does.
 

Incorrect, at least in VHDL.  If I've got signal x : boolean;, then x
is defined on the range (true, false).  I can ask VHDL if x then; ...;
end if;

What you're talking about is not at all a subclass of boolean, it's a
std_logic.  It's a separate enumerated type, with a set of resolution
rules defined in a function the source of which is available in
std_logic_1164.vhd.  And according to the strict rules of VHDL (up
until VHDL2008 decided to forfeit some purity for simplicity's), you
can't simply have:

signal x: std_logic
...
if x then

You have to ask

if x = '1'
or
if (x = '1') or (x = 'H')

Because you are comparing one value of an enumerated type against
others, the result of that '=' operation being, in fact, a boolean,
defined again on the range (true, false).

 [snip]
 
 We've discovered that we live in a quantum-mechanical universe -- yet 
 people still don't grasp the pragmatic issue that basic logic can be 
 indeterminate at least some of the time ?!
 

But actions can't be. You're not asking the software about it's
feelings, you're telling it to follow a defined sequence of
instructions.  Do this, or don't do this.

 I don't know what you mean about composition vs. sub-classing.
 Would you care to show an example of how it would solve the problem and 
 still allow hierarchical sorting ?
 
 I don't see how you can get pre-existing python functions (like sort, 
 max, and min) to accept a complex bool value and have that value 
 automatically revert to a True or False in an intelligent manner without 
 overloading the operators defined in some class -- somewhere -- to 
 operate on the data the class contains.
 
 How do you intend to achieve that with this -- composition -- thing you 
 mentioned ?
 
 

You'd do it something like this.

class _clogic(object):
Represents 'continuous' logic.  For any given instance,
there is a threshold value between 0 and 1 that delineates True from
False, with 0 being entirely False and 1 being entirely True.


def __init__(self, value, threshold=0.5):
self.value = value
self.threshold = threshold

def __bool__(self):
return value  threshold
__nonzero__ = __bool__

def __eq__(self, other):
if other in (True, False):
return bool(self) == other

try:
return self.value == other.value
except AttributeError:
return self.value == other

def __and__(self, other):
return self.__class__(
min(self.value, other.value),
self.threshold)

def __or__(self, other):
return self.__class__(
max(self.value, other.value),
self.threshold)

No need to subclass bool, you just use the __bool__ (or __nonzero__)
methods to say Alright, well when you do finally have to make a
decision on this thing, here's how you make it.  And obviously, you can
add on as many additional data members to carry additional information
as your heart desires.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue20160] broken ctypes calling convention on MSVC / 64-bit Windows (large structs)

2015-01-15 Thread mattip

mattip added the comment:

it seems the problem is that the bundled libffi version in 
Modules/_ctypes/libffi needs updating. The fix for aarch64 is a simple 
one-liner (tested on 2.7 in a aarch64 vm), for both HEAD and 2.7 (attached), 
but perhaps a better fix would be to update the bundled libffi?

--
Added file: http://bugs.python.org/file37716/libffi.patch

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



[issue11835] python (x64) ctypes incorrectly pass structures parameter

2015-01-15 Thread mattip

mattip added the comment:

This is a duplicate of issue 20160, and has been fixed. Can someone mark it as 
a duplicate and close it?

--
nosy: +mattip

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



[issue18986] Add a case-insensitive case-preserving dict

2015-01-15 Thread STINNER Victor

STINNER Victor added the comment:

The API is simple and well defined, the addition is small, I don't understand 
what is the problem with this enhancement.

--

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Mark Lawrence

On 15/01/2015 06:39, Ian Kelly wrote:

On Wed, Jan 14, 2015 at 11:06 PM, Steven D'Aprano st...@pearwood.info wrote:

I have a function, which I put into an expression like this:

def func(a, b=None):
 global spam
 import math
 spam = [a, b]*3
 print spam
 del spam


value = [1, hello, int, func]
del func

How would I use lambdak to write that as an expression

value = [1, hello, int, ??? ]

without the intermediate def?



# Untested, but seems like this should work.

value = [1, hello, int, given_(lambda a, b=None:
 import_(math, lambda math:
 import_(operator, lambda operator:
 do_(lambda: operator.setitem(globals(), 'spam', [a, b]*3), lambda:
 print_(globals()['spam'], lambda:
 do_(lambda: operator.delitem(globals(), 'spam')))]


To the OP: I note that although import_ is used in the examples, it's
not found in the list of functions in the README.



Just what I've been looking for, highly readable, higly maintainable 
Python code.  Please put this up as an Activestate recipe so it's 
preserved for prosperity, so that the entire world can see its 
asthetically pleasing properties.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Rustom Mody
On Thursday, January 15, 2015 at 11:25:11 AM UTC+5:30, Yawar Amin wrote:
 Hi all,
 
 First off, to each reader--if you believe that 'multi-line' lambdas are
 no good and we can just use functions, decorators, c. to accomplish
 everything in Python, advance warning: this post will annoy you.
 
 Now, the crux of my message. I have implemented what I believe is a
 fairly robust, if ugly-looking, native Python module made up of
 combinator functions which compose together to form function expressions
 (well, callable expressions).
 
 I've seen a lot of discussions on possibly introducing syntax support
 for multi-line lambdas in some future version, but I've never seen
 anyone say, here's a way you can do this in Python _today._ So I believe
 lambdak fits in that niche.
 
 https://github.com/yawaramin/lambdak
 
 Would anyone care to try it out? I would be happy to answer questions
 whenever I can.

Looked at your suggestions...
And then got distracted by your other project
https://github.com/yawaramin/vim-cute-python

Reminded me of what I had written some months ago along similar lines
http://blog.languager.org/2014/04/unicoded-python.html

At that time this was not suggested quite seriously.
Now I see that this can be realized at least partially
and on a personal level.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Comparisons and sorting of a numeric class....

2015-01-15 Thread Ian Kelly
On Thu, Jan 15, 2015 at 12:23 AM, Andrew Robinson
andr...@r3dsolutions.com wrote:
 Can you name any other language that *does* allow subclassing of
 booleans or creation of new boolean values?

 Yes. Several off the top of my head -- and I have mentioned these before.
 They generally come with the extra subclasses pre-created and the user
 doesn't get to create the classes, but only use them; none the less -- they
 have more than two values with which to do logic equations with.

 VHDL, Verilog, HDL, Silos III, and there are IEEE variants also.
 C/C++ historically allowed you to do it with instances included, although I
 am not sure it still does.

Sorry, let me rehprase my question. Of course there will be
special-purpose languages that allow you to do interesting things with
the logic values and operators. Can you name any other
*general-purpose* language that allows subclassing of booleans or
creation of new boolean values? If not, it seems rather unfair to
single out Python and marvel that this isn't allowed when it's
actually quite normal to disallow it. Unless you care to provide an
example, I am fairly sure your claim of C/C++ is wrong. The bool type
in C++ is a primitive type, none of which can be inherited from. C
doesn't even have a bool type; at most you have macros for true and
false to 1 and 0, so the booleans there are just ordinary integers.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23018] Add version info to python

2015-01-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3f7e483cebef by Steve Dower in branch 'default':
Issue 23018: Add version info to python[w].exe
https://hg.python.org/cpython/rev/3f7e483cebef

--
nosy: +python-dev

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



[issue23160] Respect the environment variable SVNROOT in external-common.bat

2015-01-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 294501835890 by Steve Dower in branch '2.7':
Closes #23160: Respect the environment variable SVNROOT in external-common.bat 
(patch by anselm.kruis)
https://hg.python.org/cpython/rev/294501835890

--
nosy: +python-dev
resolution:  - fixed
stage: patch review - resolved
status: open - closed

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



[issue23018] Add version info to python

2015-01-15 Thread Steve Dower

Changes by Steve Dower steve.do...@microsoft.com:


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

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



[issue23152] fstat64 required on Windows

2015-01-15 Thread Steve Dower

Steve Dower added the comment:

Victor, I've been testing your patch and it's mostly good (a few obscure errors 
you'd never find without a compiler), but I think we also need to update the 
win32_xstat functions in posixmodule.c, since they all try and use the same 
struct.

I don't know how familiar you are with the posixmodule functions, so I can 
study up on them if needed. It's probably due for some simplifications anyway, 
since we can now assume that Vista's APIs are always available. I think a lot 
of the functionality there is now in fileutils.c too, so we don't need so much 
duplicated code.

--

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



[issue23160] Respect the environment variable SVNROOT in external-common.bat

2015-01-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 45e2c95bb802 by Steve Dower in branch '3.4':
Closes #23160: Respect the environment variable SVNROOT in external-common.bat 
(patch by anselm.kruis)
https://hg.python.org/cpython/rev/45e2c95bb802

--

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Skip Montanaro
On Thu, Jan 15, 2015 at 8:29 AM, Steven D'Aprano 
steve+comp.lang.pyt...@pearwood.info wrote:

 Now I shall try very hard to forget I ever saw it.


There are some things, no matter how hard you try, which cannot be
unseen. :-)

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


[issue20160] broken ctypes calling convention on MSVC / 64-bit Windows (large structs)

2015-01-15 Thread Robert Kuska

Robert Kuska added the comment:

FYI The bug was found in libffi. I have tried and rebuilt python also with 
*bundled libffi* with the *same result* (=test failure). There is more info in 
the bugzilla mentioned in my previous post along with the libffi patch.

--

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



[issue23245] urllib2: urlopen() gets exception(kwargs bug?)

2015-01-15 Thread Douman

Douman added the comment:

Yes, i checked what is http_class. It is passed as httplib.HTTPSConnection
Before submitting this issue i checked httplib.py in my installation of py2 and 
there https://hg.python.org/cpython/file/2.7/Lib/httplib.py

HTTPSConnection has argument context.

Btw, it would be nice to update comments in urllib2 so that it would be more 
accurate

--

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



Re: How to terminate the function that runs every n seconds

2015-01-15 Thread Marko Rauhamaa
Marko Rauhamaa ma...@pacujo.net:
 Dennis Lee Bieber wlfr...@ix.netcom.com:
  My response to that then is: design the thread's I/O so that it
 is not blocking... On Linux, maybe a timed select(); Windows? short
 sleeps around a non-blocking check for available data... (if console
 I/O, msvcrt.kbhit(); otherwise may need some other library function to
 put a time-out on the I/O)

 Ah, polling, the fig leaf that covers embarrassing design constraints
 all over the world.

And to provide something constructive, I should add:

Polling is occasionally the right way forward (consider the Linux
kernel's NAPI, for example). However, it is usually bad because:

 * it consumes resources when there is no need: the CPU wakes up from
   the power-saving mode, the hard disk spins unnecessarily; the battery
   that should be good for several years, dies in the middle of the
   winter

 * it is not reactive enough as you must wait patiently for the polling
   interval to expire.


Since you brought up select(), a better choice is right under your nose:
multiplexing. Have your program block and be prepared for any possible
stimulus. However, once you do that, you realize you lose the naive
simplicity of threads. Thus we arrive at the conclusion: asynchronous
programming and processes are usually a better design choice than
threads.


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


Re: MySQL connections

2015-01-15 Thread Jacob Kruger
- Original Message - 
From: Chris Angelico ros...@gmail.com

Cc: python-list@python.org
Sent: Thursday, January 15, 2015 2:33 PM
Subject: Re: MySQL connections


On Thu, Jan 15, 2015 at 10:59 PM, Jacob Kruger ja...@blindza.co.za 
wrote:

Tried generating .exe with both cx_freeze, and pyInstaller, and the code
itself, and both versions of executable generate errors, same as running 
it
from command line - only difference is the source of the error mentioned 
in
error message then varies from a2m.exe and python.exe , and even if 
compile

it on machine where all works, and then copy .exe back to this primary
machine, then get same error - think it must relate to something else on
this machine, but can't track it down.


Okay. Ignore the .exe versions, and just work with what happens when
you run the .py files. If it fails as part of a .py file, post the
failing file.


If you want to check it out, have attached the full code file - might be a 
bit messy/large - but, effectively, right at bottom, launch an instance of 
the class a2m, passing through arguments, and then from within __init__ call 
convertProcess function, which then initiates process, harvesting sort of 
rendition/version of structure out of MS access database file, makes call to 
convertSQL to generate structural SQL script, and save it to a file, which 
then calls convertData function to generate insert statements to populate 
database, and then that makes a call to convertExport, if you passed a 
command line argument in requesting mysql, and that's the current issue 
function - have stripped most of actual functionality out of it, since am 
just testing, so the first 16 lines of that function are what's relevant at 
moment - think shouldn't rely on any other self. objects/attributes as such 
either, unless step-through process is an issue.


And, tried cleaning it up a bit - replaced tab indentation character with 
double spaces, but, code might not look perfect/be perfectly clean as of 
yet.


Jacob Kruger
Blind Biker
Skype: BlindZA
Roger Wilco wants to welcome you...to the space janitor's closet... 

import pypyodbc, os, sys
import copy, warnings
import pymysql, time, pickle
from unidecode import unidecode

def sTimeDiffFormat(i_time1, i_time2):
 i_total_time = i_time2 - i_time1 if i_time2  i_time1 else i_time1 - i_time2
 i_total_time = int(i_total_time)
 #time.strftime(%H:%M:%S, time.gmtime(i_total_time))
 i_hours = 0
 i_minutes = 0
 if i_total_time = 3600:
   i_hours = int(i_total_time / 3600)
   i_total_time = i_total_time - (i_hours * 3600)
 if i_total_time  60:
   i_minutes = int(i_total_time/60)
   i_total_time = i_total_time - (i_minutes * 60)
 s_out = 
 if i_hours  0: s_out = {0} hours .format(i_hours)
 if i_minutes  0: s_out = s_out + {0} minutes .format(i_minutes)
 s_out = s_out + {0} seconds.format(i_total_time)
 return s_out
 #end of sTimeDiffFormat

class a2m():
 s_mdb = 
 s_mdb_pass = 
 s_mdb_conn = 
 bl_mdb_conn = False
 d_db_tables = {}
 cn_mdb = None
 s_structure_sql = 
 d_db_data = {}
 l_field_types = []
 s_target = 
 s_target_value = 
 s_sql_struct_file = 
 s_sql_data_file = 
 
 def __init__(self, s_mdb, s_mdb_pass, s_target, s_target_value):

   self.s_mdb = str(s_mdb) if len(str(s_mdb))  0 else 
   self.s_mdb_pass = str(s_mdb_pass) if len(str(s_mdb_pass))  0 else 
   if self.s_mdb_pass == #: self.s_mdb_pass = 
   self.s_target = str(s_target) if len(str(s_target))0 else 
   self.s_target_value = str(s_target_value) if len(str(s_target_value))0 else 

   self.s_mdb_conn = 
   self.bl_mdb_conn = False
   if self.s_mdb !=  and self.s_target !=  and self.s_target_value != :
 self.convertProcess()
 #end of __init__
 
 def shiftID(self, l_columns):

   if l_columns.count(ID)0:
 l_columns.remove(ID)
 l_columns.insert(0, ID)
   return l_columns
 #end of shiftID

 def dictDBStructure(self, cur):
   d_out = {}
   cur_tables = cur.tables(tableType=table).fetchall()
   s_tables = 
   for l_table in cur_tables:
 s_tables += str(l_table[2]) + |
   l_tables = s_tables.split(|)
   if len(l_tables)  1: l_tables.pop(len(l_tables)-1)
   for s_table in l_tables:
 d_out[s_table] = {}
 #s_columns = 
 #INTEGER, SMALLINT, VARCHAR, LONGCHAR, CURRENCY, BIT, DATETIME, COUNTER?
 for col in cur.columns(table=s_table):
   s_col_name = str(col.get(column_name))
   s_col_type = str(col.get(type_name))
   i_col_size = int(col.get(column_size))
   if list(d_out[s_table].keys()).count(s_col_name)  1:
 d_out[s_table][s_col_name] = {column_name: s_col_name, column_type: 
s_col_type, column_size: i_col_size}
   return d_out
#end of dictDBStructure

 def pullDataTypes(self, evt):
   if len(self.s_mdb)  0:
 s_path = self.s_mdb
 s_pwd = self.DialogInput(title=Password, label=Password (if required):, 
value=)
 if len(s_pwd)  0: s_pwd =  pwd={0};.format(s_pwd)
 self.s_mdb_conn = Driver=Microsoft Access Driver (*.mdb, *.accdb); + s_pwd + 
 DBQ= + s_path
 try:
   self.cn_mdb 

[issue17546] Document the circumstances where the locals() dict get updated

2015-01-15 Thread R. David Murray

R. David Murray added the comment:

Yeah, the question of thread-safety in regards to what we are talking about 
here also occurred to me.  That is, the wording makes one wonder if locals is 
thread safe or not.  I don't see your suggested wording as making it clearer, 
though.

The problem is that it *is* underspecified.

So I think the correct description of the current under-specification is that 
locals() returns a copy of the current locals namespace.  If you modify the 
thing returned by locals it may or may not update the local namespace.  If you 
modify the local namespace (by doing x = y or its equivalents) the change may 
or may not be reflected in the object that was returned by locals().

Now, how do we boil that down?  Or do we just say it more or less that way?

--

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



[issue23245] urllib2: urlopen() gets exception(kwargs bug?)

2015-01-15 Thread Douman

Douman added the comment:

It seems to be this one
https://hg.python.org/cpython/rev/1882157b298a

--

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



[issue23219] asyncio: cancelling wait_for(task, timeout) must also cancel the task

2015-01-15 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
stage: resolved - 

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



[issue23219] asyncio: cancelling wait_for(task, timeout) must also cancel the task

2015-01-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8adf1896712d by Victor Stinner in branch '3.4':
Closes #23219: cancelling asyncio.wait_for() now cancels the task
https://hg.python.org/cpython/rev/8adf1896712d

--
nosy: +python-dev
resolution:  - fixed
stage:  - resolved
status: open - closed

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



[issue20160] broken ctypes calling convention on MSVC / 64-bit Windows (large structs)

2015-01-15 Thread Steve Dower

Steve Dower added the comment:

You're running on Fedora, not Windows, so this is not the right issue. You 
should open a new one and probably post on python-dev to get some attention 
(since there's no useful nosy lists right now and ctypes has no maintainer).

--

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Chris Angelico
On Fri, Jan 16, 2015 at 1:24 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Marko Rauhamaa wrote:

 Corollary: Make sure the complete definition of every function can be
 seen at once without scrolling.

 Problem: I like to view code on a smartphone with a 4x4 pixel screen, and
 the scroll bars obscure the text.

 Solution: Change the editor to a 1pt font.

Problem: You have a smartphone with a 4x4 pixel screen.

Solution: Utilize hammer, then get a laptop.

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


[issue23245] urllib2: urlopen() gets exception(kwargs bug?)

2015-01-15 Thread Douman

Douman added the comment:

Btw, i also tried to replace **kwargs with usual argument and it didn't throw 
exception

--

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



[issue23245] urllib2: urlopen() gets exception(kwargs bug?)

2015-01-15 Thread Douman

Douman added the comment:

Also according to documentation this class was specifically updated with 
context in 2.7.9
I guess then there should commit related to adding of context to 
HTTPSConnection

--

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



[issue1602] windows console doesn't print or input Unicode

2015-01-15 Thread Drekin

Drekin added the comment:

File redirection has nothing to do with win-unicode-console and this issue. 
When stdout is redirected, it is not a tty so win-unicode-console doesn't 
replace the stream object, which is the right thing to do. You got 
UnicodeEncodeError because Python creates sys.stdout with encoding based on 
your locale. In my case it is cp1250 which cannot encode whole Unicode. You can 
control the encoding used by setting PYTHONIOENCODING environment variable. For 
example, if you have a script producer.py, which prints some Unicode 
characters, and consumer.py, which just does print(input()), then py 
producer.py | py consumer.py shows that redirection works (when 
PYTHONIOENCODING is set e.g. to utf-8).

--

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



Re: class-based class decorator

2015-01-15 Thread Albert-Jan Roskam


- Original Message -

 From: Jean-Michel Pichavant jeanmic...@sequans.com
 To: Albert-Jan Roskam fo...@yahoo.com
 Cc: Python python-list@python.org
 Sent: Tuesday, January 13, 2015 5:37 PM
 Subject: Re: class-based class decorator
 
 - Original Message -
  From: Albert-Jan Roskam fo...@yahoo.com
   From: Jean-Michel Pichavant jeanmic...@sequans.com
   I don't really understand how you successfuly manage positional
   parameters,
   since the caller may not name them.
   I'm asking because if your intend to check only the keyword
   parameters,
   there's a much simplier solution.
   
   JM
 
 
  Hi,
 
  Can you give an example of where/how my code would fail? I do not
  intend to use *args and **kwargs, if that is what you mean. I am
  interested in hearing a simpler approach, especially if it would
  also solve the messed-up-signature problem that I mentioned.
 
  Thank you!
 
  Albert-Jan
 
 
 In the example you've given you've deprecated only keyword arguments. So 
 I was wondering...
 
 would the following *untested* code work ? :
 
 def check_deprecated_args(deprecated):
   def decorator(func):
 def inner(*args, **kwargs):
   for p in deprecated:
 if p in kwargs:
   print '%s is deprecated' % p
   return func(*args, **kwargs)
 return inner
   return decorator
 


This is indeed a lot simpler than a class-based version, merci bien! And now I 
can also make it work with the signature-preserving decorator package. 
Meanwhile I also found a Python 2 backport for inspect.signature, so positional 
args can also be used. 


Thanks again!

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


[issue23211] test.test_logging.SMTPHandlerTest failing on Snow Leopard

2015-01-15 Thread Ned Deily

Ned Deily added the comment:

Yes, this has the same root cause as the failure in Issue20605 since SMTPServer 
in smtpd.py uses getaddrinfo.  I'm now able to reliably reproduce the failure.  
The system getaddrinfo failure is seen when the OS X 10.6 system's network 
configuration is *not* using the local mdns for its primary domain service 
(which can be checked with scutil --dns); it fails when using an external dns 
as its primary dns service.  At least that's one failure scenario.  In any 
case, this seems to have been fixed in later versions of OS X, the problem 
appears to be unique to getaddrinfo (gethostbyname works OK), and it's only 
this one test.  I'm tempted to just close this as won't fix; on the other 
hand, it's easy enough to change this test to use '127.0.0.0' instead of 
'localhost'; there are precedents for doing that for other reasons (Issue18792, 
for example).  Here's a patch that does so and thus avoids the potential 
problem on 10.6.  I'll apply it if there are no objections.

--
keywords: +patch
nosy: +vinay.sajip
stage:  - patch review
versions: +Python 3.4
Added file: http://bugs.python.org/file37717/issue23211.patch

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



[issue20132] Many incremental codecs don’t handle fragmented data

2015-01-15 Thread Martin Panter

Martin Panter added the comment:

I opened Issue 23231 about fixing iterencode() and iterdecode() in the general 
case. I added a patch to Issue 13881 to fix StreamWriter for zlib and bz2, and 
to fix StreamWriter.writelines() in general.

I am adding a patch here to clarify the StreamReader API and fix the 
StreamReader for the zlib-codec.

Plan of other things to do:

bz2 StreamReader: Should be implemented similar to the zlib patch above, after 
Issue 15955 is resolved and we have a max_length parameter to use. Or could be 
based on Bz2File now.

hex decoder: Shouldn’t be too hard to hack a stateful IncrementalDecoder that 
saves the leftover digit if given an odd number of digits. Create a generic 
codecs._IncrementalStreamReader class that uses an IncrementalDecoder and 
buffers unread decoded data, similar to my _IncrementalStreamWriter for Issue 
13881.

base64 encoder: IncrementalEncoder could encode in base64.MAXBINSIZE chunks

base64 decoder: IncrementalDecoder could strip non-alphabet characters using 
regular expressions, decode in multiples of four characters

quopri encoder: would require new implementation or major refactoring of quopri 
module

quopri decoder: check for incomplete trailing escape codes (=, =single hex 
digit, =\r) and newlines (\r)

uu encoder: write header and trailer via uu module; encode using b2a_uu()

uu decoder: factor out header parsing from uu module; buffer and decode line by 
line based on encoded length

unicode-escape, raw-unicode-escape: Stateful decoding would probably require a 
new -Stateful() function at the C level, though it might be easy to build from 
the existing implementation. I suggest documenting that stateful decoding is 
not supported for the time being.

utf-7: As Walter said, proper stateful codec is not supported by the C API, 
despite PyUnicode_DecodeUTF7Stateful(); doing so would probably require 
significant changes. I suggest documenting a warning for stateful mode 
(including with TextIOWrapper) about suboptimal encoding and unlimited data 
buffering for the time being.

punycode, unicode_internal: According to test_codecs.py, these also don’t work 
in stateful mode. Not sure on the details though.

--
keywords: +patch
Added file: http://bugs.python.org/file37718/zlib-reader.patch

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



[issue20132] Many incremental codecs don’t handle fragmented data

2015-01-15 Thread Martin Panter

Martin Panter added the comment:

My “master plan” is basically to make most of the bytes-to-bytes codecs work as 
documented in the incremental (stateful) modes. I’m less interested in fixing 
the text codecs, and the quopri and uu codecs might be too hard, so I was going 
to propose some documentation warnings for those.

If you have a suggestion on how to go about this better, let me know.

With my doc change to StreamReader, I wanted to document the different modes 
that I saw in the base codecs.StreamReader.read() implementation:

* read() or read(-1) reads everything
* read(size) returns an arbitrary amount of data
* read(size, chars) returns exactly *chars* length of data (unless EOF or 
similar)

Previously the case of read(-1, chars) was ambiguous. Also I did not find the 
description “an approximate maximum number of decoded bytes” very helpful, 
considering more than this maximum was read if necessary to get enough *chars*.

Regarding the end-of-stream behaviour, I made an assumption but I now realize 
it was wrong. Experimenting with the UTF-8 codec shows that its 
StreamReader.read() keeps returning  when the underlying stream returns no 
data. But if it was in the middle of a multi-byte sequence, no “end of data” 
error is raised, and the multi-byte sequence can be completed if the underlying 
stream later returns more data. I think the lack of end-of-data checking should 
be documented.

The different cases of ValueError and UnicodeError that you describe make 
sense. I think the various references to ValueError and UnicodeError should be 
updated (or replaced with pointers) to match.

--

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



[issue20132] Many incremental codecs don’t handle fragmented data

2015-01-15 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 15.01.2015 23:46, Martin Panter wrote:
 
 I opened Issue 23231 about fixing iterencode() and iterdecode() in the 
 general case. I added a patch to Issue 13881 to fix StreamWriter for zlib and 
 bz2, and to fix StreamWriter.writelines() in general.
 
 I am adding a patch here to clarify the StreamReader API and fix the 
 StreamReader for the zlib-codec.

Martin, I must be missing some context: what's your master plan with
all these codec patches and open tickets ?

They are very hard to follow and you're making design changes which
need more review and discussion than can easily be done on a few tickets.

Regarding the patch:

The doc patch seems to just change ordering of sentences and paragraphs.
Without additional explanation, it's difficult to determine whether
you are changing semantics or not.

The strict error change is not correct. Most codecs raise a UnicodeError
(which is a ValueError subclass) and code expects codecs that work
on Unicode to return a UnicodeError, not a ValueError. Only codecs that
do not work on Unicode are allowed to raise ValueErrors.

--

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



[issue13881] Stream encoder for zlib_codec doesn't use the incremental encoder

2015-01-15 Thread Martin Panter

Martin Panter added the comment:

Sorry, I changed the name of the attribute and forgot to update the doc string. 
Its new name was _Encoder.

Your description was fairly accurate. I am adding patch v3, with an expanded 
the doc string. Hopefully that explains it a bit better. Since it is just 
implementing the documented StreamWriter API, I only added brief descriptions 
of the methods pointing back to the StreamWriter methods.

--
Added file: http://bugs.python.org/file37719/zlib-bz2-writer.v3.patch

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



[issue20132] Many incremental codecs don’t handle fragmented data

2015-01-15 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

This addition is wrong as well:

The *stream* argument must be a file-like object open for reading
-   text or binary data, as appropriate for the specific codec.
+   text or binary data, as appropriate for the specific codec. This stream is
+   assumed to have ended as soon as a read from it returns no data.

Where did you get this idea from ?

--

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



[issue23243] asyncio: emit ResourceWarning warnings if transports/event loops are not explicitly closed

2015-01-15 Thread STINNER Victor

STINNER Victor added the comment:

 Some ResourceWarning are still emited on SSL server tests.

Attached server_close.patch is a work-in-process patch to fix this issue on 
Linux.

If I understood correctly, there are two issues:

- SelectorEventLoop._accept_connection() doesn't care of the creation of the 
transport failed
- SSLProtocol.eof_received() does not notify the waiter that EOF was received

So an application cannot control SSL incoming connections which fail during the 
handshake? Control: log errors, do something with the socket, etc.

See also the STARTTLS feature request:
https://code.google.com/p/tulip/issues/detail?id=79

--
Added file: http://bugs.python.org/file37720/server_close.patch

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



[issue22685] memory leak: no transport for pipes by create_subprocess_exec/shell

2015-01-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 992ce0dcfb29 by Victor Stinner in branch '3.4':
Issue #22685: Fix test_pause_reading() of asyncio/test_subprocess
https://hg.python.org/cpython/rev/992ce0dcfb29

--

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Steven D'Aprano
Yawar Amin wrote:

 To the responders in the 'beauty of the code' subthread: yes, I realise
 that lambdak is not Pythonic, and it will make angels cry, and all that.
 My view is you should actually be happy that it looks like this. If
 anyone ever asks about multi-line lambdas again, you can point to
 lambdak and say, 'See! This is what happens if you try to go against
 Pythonic style.' And then you can shrug your head in disgust if they
 continue to use it anyway.


:-)


-- 
Steven

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Steven D'Aprano
Rustom Mody wrote:

 Let there be a hundred different versions, then people will
 begin to clamor against the non-necessity of the penury-of-ASCII:
 
 http://blog.languager.org/2015/01/unicode-and-universe.html

Almost 30 years ago, Apple's Hypertalk language allowed, and encouraged, the
use of certain non-ASCII symbols. You could use ≤ ≥ and ≠ for
less-or-equal, greater-or-equal, and not-equal comparisons; you could use ÷
for division; and you could define a square root function using √ as the
name. You could even define ∞ = 'INF' and do floating point operations on
it.

Apple could get away with this back in the 80s because they controlled the
platform including keyboard mappings, and they could guarantee that key
combinations such as Option-/ would generate the ÷ character and that any
reasonable font would include a glyph for it.

Alas and alack, 30 years on and we have to live with the down-side of
multicultural computers. Any modern Linux system is almost sure to be fully
Unicode compatible with a UTF-8 filesystem -- *almost* sure. But we have to
interoperate with Windows machines still stuck in the Dark Ages of code
pages; Java that insists that Unicode == UTF-16 (and support for the
supplementary multilingual planes is weak); there is a plethora of fonts
but Unicode support is extremely variable; many of us are using US
keyboards and there's no well-known or standard input method for Unicode
characters; and while Apple only had to support somewhat fewer than 256
characters, Unicode has tens of thousands.

Before Unicode can take off for programming syntax, we need to solve at
least four problems:

- we need a good selection of decent programmer's fonts with 
  extensive support for Unicode especially mathematical symbols;

- we need a platform-independent input method that will allow 
  programmers to enter these symbols without moving their hands 
  off the keyboard;

- and some way to make the existence of these symbols easily 
  discoverable, e.g. for most of us, ~ is easily discoverable 
  because we can see it on the keyboard, but the same doesn't
  apply for ≈

- we have to be confident that moving source code from one 
  machine to another (Windows - Linux or visa versa) won't
  corrupt the file. That means UTF-8 everywhere.

I live in hope, but I am not confident that these issues will be solved in
my lifetime. One of the ten most popular programming languages, PHP,
doesn't even support Unicode even as a data type. What hope do we have?



-- 
Steven

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


Re: [OT] Re: MySQL connections

2015-01-15 Thread Jacob Kruger
- Original Message -  functions. When was the last time those 
systems had Windows Update and

reboots performed?


Daily basis.

Think, in line with your other message, will just try rewrite code - and, 
issue relating to structure etc. is left over from when pulled it out of 
wxPython implementation - you're right that should have just redone that 
part of it ;)


Jacob Kruger
Blind Biker
Skype: BlindZA
Roger Wilco wants to welcome you...to the space janitor's closet...

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Rustom Mody
On Friday, January 16, 2015 at 9:46:30 AM UTC+5:30, Steven D'Aprano wrote:
 Rustom Mody wrote:
 
  Let there be a hundred different versions, then people will
  begin to clamor against the non-necessity of the penury-of-ASCII:
  
  http://blog.languager.org/2015/01/unicode-and-universe.html
 
 Almost 30 years ago, Apple's Hypertalk language allowed, and encouraged, the
 use of certain non-ASCII symbols. You could use ≤ ≥ and ≠ for
 less-or-equal, greater-or-equal, and not-equal comparisons; you could use ÷
 for division; and you could define a square root function using √ as the
 name. You could even define ∞ = 'INF' and do floating point operations on
 it.

Good stuff!

 
 Apple could get away with this back in the 80s because they controlled the
 platform including keyboard mappings, and they could guarantee that key
 combinations such as Option-/ would generate the ÷ character and that any
 reasonable font would include a glyph for it.

APL went much further, 60 years ago.  And IBM could get away with it
for similar monopolistic reasons

 
 Alas and alack, 30 years on and we have to live with the down-side of
 multicultural computers. Any modern Linux system is almost sure to be fully
 Unicode compatible with a UTF-8 filesystem -- *almost* sure. But we have to
 interoperate with Windows machines still stuck in the Dark Ages of code
 pages; Java that insists that Unicode == UTF-16 (and support for the
 supplementary multilingual planes is weak); there is a plethora of fonts
 but Unicode support is extremely variable; many of us are using US
 keyboards and there's no well-known or standard input method for Unicode
 characters; and while Apple only had to support somewhat fewer than 256
 characters, Unicode has tens of thousands.

No direct experience but my impression is that windows is almost as
unicode-compliant as linux:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd317752%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/dd374081%28v=vs.85%29.aspx

Yeah SMP support may be problematic. Anyways...
1. BMP alone is a 256-fold expansion over ASCII
2. SMP support all round is spotty. MySQL?? Blogger is messing my posts etc
3. For almost all the cases we're talking of BMP is enough and to spare

 
 Before Unicode can take off for programming syntax, we need to solve at
 least four problems:
 
 - we have to be confident that moving source code from one 
   machine to another (Windows - Linux or visa versa) won't
   corrupt the file. That means UTF-8 everywhere.

Ok

 - we need a good selection of decent programmer's fonts with 
   extensive support for Unicode especially mathematical symbols;

I guess so

 
 - we need a platform-independent input method that will allow 
   programmers to enter these symbols without moving their hands 
   off the keyboard;

I dont see why.  I use laptops and desktops having different layouts.
Fumble a bit but not too much.
Others probably use much more way out devices eg android phones.

Likewise I dont see why input-methods need to match/be platform independent. As 
long as they work.

eg Some cars have European controls – wiper on left, lights on right.
Or American – the other way round.
When changing I fumble a bit but not so much its an issue

 
 - and some way to make the existence of these symbols easily 
   discoverable, e.g. for most of us, ~ is easily discoverable 
   because we can see it on the keyboard, but the same doesn't
   apply for ≈

I believe this is the nub of the matter.

Discoverability of 1 million characters is a very different matter from
discoverability of a few hundred.

eg 

1. Beginning programmers do search-and-peck typing – they need to
discover the US-104 (or whatever) keyboard
2. Beginning vi-users need to find the controls of the dragon with two modes
— one in which it beeps and one in which it corrupts the file
3. Beginning python programmers need to discover the difference
between typing at the command-prompt at the REPL and into a file… and
a dozen other things before python begins to look barely friendly

In the same way typing a ≤ ≥ ≠ on a stock keyboard may require some
learning/acclimatization/setup.

- Using a suitable editor mode it needs to be exactly the same as the ASCII
=, =, != 
- With compose key setup its just a character more – the above preceded
by the compose key [right-win, ALtGr, Menu, whatever]

 
 
 I live in hope, but I am not confident that these issues will be solved in
 my lifetime. One of the ten most popular programming languages, PHP,
 doesn't even support Unicode even as a data type. What hope do we have?

Using, canvassing, clamoring, bugging (with bug-reports) is our toolset :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Comparisons and sorting of a numeric class....

2015-01-15 Thread Ian Kelly
On Thu, Jan 15, 2015 at 6:45 PM, Andrew Robinson
andr...@r3dsolutions.com wrote:
 Then I look at python development historically and look at the built in
 class's return values for compares; and I notice; they have over time become
 more and more tied to the 'type' bool.  I expect sometime in the future that
 python may implement an actual type check on all comparison operators so
 they can not be used to return anything but a bool.

Let's see what the documentation says about this:


A rich comparison method may return the singleton NotImplemented if it
does not implement the operation for a given pair of arguments. By
convention, False and True are returned for a successful comparison.
However, these methods can return any value, so if the comparison
operator is used in a Boolean context (e.g., in the condition of an if
statement), Python will call bool() on the value to determine if the
result is true or false.


https://docs.python.org/3/reference/datamodel.html#object.__lt__

So the docs explicitly promise that comparison methods can return any
value. Changing this would break backward compatibility (in particular
it would break a lot of DSLs), so it's not going to happen any time
soon, and you have nothing to worry about here.

 (eg:  I already noticed
 a type check on the return value of len() so that I can't return infinity,
 even when a method clearly is returning an infinitely long iterator -- such
 as a method computing PI dynamically.  That suggests to me that there is
 significant risk in python of having type checking on all __xx__ methods in
 the future. )  This inspection is what points me foremost to saying that
 very likely, I am going to want a bool or subtye of it (if possible) as a
 return type as self defense against future changes in Python -- although at
 present, I can still get away with returning other types if bool turns out
 to be impossible.

I suspect the reason __len__ must return an int is largely historical.
Back before __iter__ existed, the way Python did iteration was by
calling __len__ and then calling __getitem__ for each index between 0
and the result. Obviously for this to work, the result had to be an
int, and infinite iterators didn't exist in this era either.

Nowadays, that sort of iteration is non-standard, but Python will
still fall back on it if __iter__ isn't defined.

 So, your first alternative is the most at risk of future problems due to
 constraints likely to be placed on comparison return types ; and as I don't
 want to do much maintenance on my library in the future -- I don't think
 that is a very good choice for making my library with.

Except that the risk you describe is fictitious.

 One example: It can also be a union.

 I don't understand what you think this means. I know what *I* think it
 means, but subclass = union doesn't make sense to me, so wonder what
 you think it means.


 It's a fringe use-case in Python that I don't think many people use/know
 about.  I was just being thorough in listing it.

 I haven't seen it used in actual python code myself -- but I know from the
 literature I've read on Python that it is occasionally used in a manner
 analogous to that of C/C++.

 In C/C++ unions are a datatype that allow two (or more) different types of
 data to be defined as held by one object, but only one of them is allowed to
 be initialized at a time because their location in computer memory which
 overlaps.  C places no restrictions on the compatibility of the datatypes --
 which is different than Python, but Python has a similar ability.

 In Python, when multiple inheritance is invoked -- it does some kind of
 check on the base types for compatibility; but still appears to be able / or
 simply does overlap the allocated memory for the different base types; eg:
 according to several sources I have read (at least on C-python internals).

 So one can semantically instantiate a subclass of one subtype without
 semantically instantiating the other.

 ALl I know about it is what I have seen it in Python literature -- and I
 tested the examples I was shown to see if they still work, and they do --
 and noted that at least at one time Guido apparently thought it was a good
 idea ; but I haven't pursued it beyond that.

Do you have a link? I have no idea what you're referring to, and I
suspect that you're confused. You can't do multiple inheritance from
types that would internally have overlapping memory.  For example:

 class Foo(list, dict): pass
...
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: multiple bases have instance lay-out conflict

 I'm getting the message that the reason Guido though this was important was
 because the historical meaning of bool is more important than the idea that
 metastability is an issue to be dealt with at the same time as the data
 value -- like electrical engineers do regularly.

Maybe because Python wasn't written for electrical engineers. It's a
general purpose boolean 

Factories and Builders [was Re: lambdak...]

2015-01-15 Thread Steven D'Aprano
Roy Smith wrote:

 The ebb and flow of technology has recently brought me someplace I never
 thought I'd be.  Java-land.  And what I've discovered is that factories
 are so last year.  Apparently builders are the new thing.


I've never really understand why abstract factory, factory method
and builder are considered different design patterns. They're variants on
the same idea.

class Spam:
def create(self, a, b, c, d):
if a == fast:
theclass = FastClass
elif a == steady:
theclass = SteadyClass
obj = theclass(b, c, d)
# obj.extra_stuff = self.get_stuff()
return obj


As I understand it, if FastClass and SteadyClass are subclasses of Spam,
then this is the Factory Method design pattern, but if they are independent
classes unrelated to Spam, then it is the Abstract Factory design pattern.
But if I uncomment out the obj.extra_stuff line, it becomes a Builder.



-- 
Steven

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Ian Kelly
On Thu, Jan 15, 2015 at 9:00 PM, Chris Angelico ros...@gmail.com wrote:
 My first response was going to be Well, you can always add another
 layer of indirection to try to solve your problem, but then I went
 and looked up builders on Wikipedia. Now I'm confused. What can you do
 with a builder that you can't do with a constructor?

In Java you have to write a separate constructor for every conceivable
combination of arguments. If there are a lot of optional arguments,
that's an exponentially large number of constructors. The builder
pattern provides a solution to that problem.

In Python you just have one initializer with defaults for the optional
arguments, so it's not an issue.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Ethan Furman
On 01/15/2015 09:29 PM, Ian Kelly wrote:
 
 In Python you just have one initializer with defaults for the optional
 arguments, so it's not an issue.

What, Python makes it easy?  That must be a mistake somewhere!  ;)

--
~Ethan~



signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Comparisons and sorting of a numeric class....

2015-01-15 Thread Chris Angelico
On Fri, Jan 16, 2015 at 12:45 PM, Andrew Robinson
andr...@r3dsolutions.com wrote:
 I don't have a setting on my email to turn off html.  Sorry. Can't help.

 You are using Thunderbird. You certainly do have such a setting.

 It's nice to know that you read and believe what you see in an email header.
 Note: Headers are sometimes modified by sysadmins who actually care about
 security.

 PPS: If there is a way to turn off HTML in this email program -- it is not
 obvious -- and I have looked.
 I've done my best not to push any HTML enhancement buttons...

You do have another option: Change email programs. Or lean on whoever
is in charge of this one, saying that it's failing in a significant
way.

Also, what security do your sysadmins gain by lying about mail
clients? Stripping the header would gain just as much. Lying just
makes your network uncooperative at best, and possibly will be seen as
malicious. If you're using a mail client with known vulnerabilities,
*FIX THAT*, don't try to hide behind a fallacious header. Otherwise
it's not security, it's laziness.

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


Re: Comparisons and sorting of a numeric class....

2015-01-15 Thread Steven D'Aprano
Andrew Robinson wrote:

[...much about bools...]

I'll get back to that shortly, but for now I just want to make a couple of
comments about your HTML email.

 [...]
 I don't have a setting on my email to turn off html.  Sorry. Can't help.
 You are using Thunderbird. You certainly do have such a setting.

 It's nice to know that you read and believe what you see in an email
 header. Note: Headers are sometimes modified by sysadmins who actually
 care about security.

No they're not. They're modified by sysadmins who like to give the false
impression that they care about security. Also who don't care about your
privacy. (I wouldn't trust a sys admin who modified the headers my mail
program set. I would wonder what else he is modifying behind my back.)

Faking the Useragent header is as useful for security as removing the badge
off a Toyota and replacing it with a Ford badge. Even if you can come up
with some conceivable set of circumstances where you are more secure (what
if a terrorist with a grudge against Toyota sees your car and is
sufficiently enraged to blow it up???), it's just security theatre.

To quote Whitfield Diffie: 

The secret to strong security: less reliance on secrets.

If the security of your email program depends on people being misinformed
about which email program you have, then you have no little or no security.


 PPS: If there is a way to turn off HTML in this email program -- it is
 not obvious -- and I have looked.
 I've done my best not to push any HTML enhancement buttons...

Despite your belief that you are unable to disable HTML in your email, I can
tell you that out of the twelve posts I have received from you so far,
eight have no HTML (including this one of yours which I am replying to). So
you can disable it -- the only trick is to work out what you are doing, or
not doing, to avoid triggering it.

(If you are using Thunderbird, it gives you extensive control over when HTML
mail is set. Apart from being able to disable it completely, you can set
certain domains to only receive plain text emails. Look under Preferences
or Settings or whatever it's called now -- you're an engineer. I'm sure
you'll work it out.)



-- 
Steven

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


[issue11835] python (x64) ctypes incorrectly pass structures parameter

2015-01-15 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
resolution:  - duplicate
stage:  - resolved
status: open - closed
superseder:  - broken ctypes calling convention on MSVC / 64-bit Windows 
(large structs)

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



[issue20898] Missing 507 response description

2015-01-15 Thread Demian Brecht

Demian Brecht added the comment:

Ping. Would be nice to get this change in before 3.5.0a1.

--

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



Re: Comparisons and sorting of a numeric class....

2015-01-15 Thread Andrew Robinson


On 01/15/2015 12:41 AM, Steven D'Aprano wrote:

On Wed, 14 Jan 2015 23:23:54 -0800, Andrew Robinson wrote:

[...]

A subclass is generally backward compatible in any event -- as it is
built upon a class, so that one can almost always revert to the base
class's meaning when desired -- but subclassing allows extended meanings
to be carried.  eg: A subclass of bool is a bool -- but it can be MORE
than a bool in many ways.

You don't have to explain the benefits of subclassing here.

I'm still trying to understand why you think you *need* to use a bool
subclass. I can think of multiple alternatives:

- don't use True and False at all, create your own multi-valued
   truth values ReallyTrue, MaybeTrue, SittingOnTheFence, ProbablyFalse,
   CertainlyFalse (or whatever names you choose to give them);

- use delegation to proxy True and False;

- write a class to handle the PossiblyTrue and PossiblyFalse cases,
   and use True and False for the True and False cases;

There may be other alternatives, but what problem are you solving that
you think

 class MyBool(bool): ...

is the only solution?

That's a unfair question that has multiple overlapping answers.
Especially since I never said subclassing bool is the 'only' solution; I 
have indicated it's a far better solution than many.


So -- I'll just walk you through my thought processes and you will see 
what I consider problems:


Start with the concept that as an engineer, I have spent well over 
twenty years on and off dealing with boolean values that are very often 
mixed indistinguishably with 'don't care' or 'tri-state' or 'metastable 
states'.   A metastable state *is* going to be True or False once the 
metastability resolves by some condition of measurement/timing/etc.; but 
that value can not be known in advance.   eg: similar to the idea that 
there is early and late binding in programming Sometimes there is a 
very good reason to delay making a final decision until the last 
possible moment; and it is good to have a default value defined if no 
decision is made at all.


So -- From my perspective, Guido making Python go from an open ended and 
permissive use of anything goes as a return value that can handle 
metastable states -- into to a historical version of 'logic' being 
having *only* two values in a very puritanical sense, is rather -- well 
-- disappointing.  It makes me wonder -- what hit the fan?!  Is it 
lemmings syndrome ? a fight ? no idea  and is there any hope of 
recovery or a work around ?


eg: To me -- (as an engineer) undefined *IS* equivalent in useage to an 
acutal logic value, just as infinity is a floating point value that is 
returned as a 'float'.  You COULD/CAN separate the two values from each 
other -- but always with penalties.  They generally share an OOP 'is' 
relationship with respect to how and when they are used. (inf) 'IS' a 
float value and -- uncertain -- 'IS' a logic value.


That is why I automatically thought before I ever started writing on 
this list (and you are challenging me to change...) -- that 'uncertain' 
should share the same type (or at least subtype) as Bool.  
Mathematicians can argue all they want that 'infinity' is not a float 
value, and uncertain is not a True or False.  And they are/will be 
technically right -- But as a practical matter -- I think programmers 
have demonstrated over the years that good code can handle 'infinity' 
most efficiently by considering it a value rather than an exception.  
And I think the same kind of considerations very very likely apply to 
Truth values returned from comparisons found in statistics, quantum 
mechanics, computer logic design, and several other fields that I am 
less familiar with.


So -- let's look at the examples you gave:


- don't use True and False at all, create your own multi-valued
   truth values ReallyTrue, MaybeTrue, SittingOnTheFence, ProbablyFalse,
   CertainlyFalse (or whatever names you choose to give them);


OK.  So -- what do I think about when I see your suggestion:

First I need to note where my booleans come from -- although I've never 
called it multi-valued logic... so jargon drift is an issue... though 
you're not wrong, please note the idea of muti-value is mildly misleading.


The return values I'm concerned about come from a decimal value after a 
comparison with another decimal value.

eg:

a = magicFloat( '2.15623423423(1)' )
b = magicFloat('3()')

myTruthObject = ab

Then I look at python development historically and look at the built in 
class's return values for compares; and I notice; they have over time 
become more and more tied to the 'type' bool.  I expect sometime in the 
future that python may implement an actual type check on all comparison 
operators so they can not be used to return anything but a bool.  (eg:  
I already noticed a type check on the return value of len() so that I 
can't return infinity, even when a method clearly is returning an 
infinitely long iterator -- such as a method 

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Michael Torrie
On 01/15/2015 06:34 PM, Roy Smith wrote:
 The ebb and flow of technology has recently brought me someplace I never 
 thought I'd be.  Java-land.  And what I've discovered is that factories 
 are so last year.  Apparently builders are the new thing.

It's never clear to me whether all these fancy design patterns are to
make up for a deficient language, or whether some people just get their
kicks from layer upon layer of abstraction.  Certainly it's this sort of
thing that turns me right off of Java.

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Yawar Amin
On Thursday, January 15, 2015 at 1:40:09 AM UTC-5, Ian wrote:
 On Wed, Jan 14, 2015 at 11:06 PM, Steven D'Aprano
 steve@... wrote:
 [...]
  def func(a, b=None):
  global spam
  import math
  spam = [a, b]*3
  print spam
  del spam
 
  value = [1, hello, int, func]
  del func
 [...]
 # Untested, but seems like this should work.
 [...]
 To the OP: I note that although import_ is used in the examples, it's
 not found in the list of functions in the README.

Thanks Ian. I'll update the readme soon. It's still a little behind the
actual code.

Steve, here is your example translated, about as simple as I can make
it:

from lambdak import *

value = [
  1,
  hello,
  int,
  given_(lambda a, b = None:
import_(math, lambda math:
given_(lambda globs = globals(), spam = spam:

assign_(spam, [a, b] * 3, globs, lambda:
print_(get_(spam, globs), lambda:
del_(spam, globs))
]

value[3](1)
del value[3]

The problem with globals is that a Python module can't easily manipulate
the globals of its caller modules. Here you can see I had to work around
the issue by just creating a few functions[1] which generically work
with dicts and then explicitly passing in the globals dict on each call.
I don't see any other reasonable way to do it. I would welcome being
proven wrong here.

To the responders in the 'beauty of the code' subthread: yes, I realise
that lambdak is not Pythonic, and it will make angels cry, and all that.
My view is you should actually be _happy_ that it looks like this. If
anyone ever asks about multi-line lambdas again, you can point to
lambdak and say, 'See! This is what happens if you try to go against
Pythonic style.' And then you can shrug your head in disgust if they
continue to use it anyway.

Regards,

Yawar

[1] `assign_`, `get_`, `del_`. I haven't pushed these to the project
repo yet. Will do so after writing up the tests and docs.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Yawar Amin
Hi,

On Thursday, January 15, 2015 at 12:19:31 PM UTC-5, Rustom Mody wrote:
 [...]
 Looked at your suggestions...
 And then got distracted by your other project
 https://github.com/yawaramin/vim-cute-python
 
 Reminded me of what I had written some months ago along similar lines
 http://blog.languager.org/2014/04/unicoded-python.html
 
 At that time this was not suggested quite seriously.
 Now I see that this can be realized at least partially
 and on a personal level.

Glad it was useful. Although let me clarify that I just forked the repo
from the original on GitHub, to publish my custom version. I have more
conservative tastes than the original, so I chose to keep the `in`, `not
in`, `and`, `or`, `not` keywords as is instead of using the symbols. I
did go through your blog post and got a previously-unused symbol out of
it: '÷' to represent '/'.

Regards,

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


[issue23234] refactor subprocess: use new OSError exceptions, factorize stdin.write() code

2015-01-15 Thread Gregory P. Smith

Gregory P. Smith added the comment:

thanks for the cleanup refactoring!

--

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



Best Replica Panerai Radiomir Watches Online

2015-01-15 Thread billwang821
We have high quality Replica Panerai Radiomir watches on sale ,cheapest Replica 
Panerai Radiomir watches for sale.

Panerai RADIOMIR 1940 3 DAYS MARINA MILITARE ACCIAIO PAM00587
http://www.rep8.com/panerai-radiomir-1940-3-days-marina-militare-acciaio-pam00587-p-4812.html

Panerai RADIOMIR S.L.C. 3 DAYS 47 mm Watch PAM00425
http://www.owatchoo.com/panerai-radiomir-s-l-c-3-days-47-mm-watch-pam00425

Panerai Radiomir 8 Days PAM 00346 Replica Watches Pr0347 
http://www.timywatch.com/panerai-radiomir-8-days-pam-00346-replica-watches-pr0347-s189-2399.html

Panerai Radiomir 8 days Ceramica Mens watch PAM00384
http://www.watchdemo.net/panerai-radiomir-8-days-ceramica-mens-watch-pam00384-p-1140.html

Panerai Radiomir Black Seal 45mm Homme Montre PAM00292
http://www.jmontres.net/panerai-radiomir-black-seal-45mm-homme-montre-pam00292-p-1135.html

Panerai Radiomir Chronograph 45mm Homme Montre PAM00288
http://www.watchgoing.net/panerai-radiomir-chronograph-45mm-homme-montre-pam00288-p-1093.html


More cheap Replica Panerai Radiomir Watches
http://www.rep8.com/replica-panerai-c-241.html
http://www.owatchoo.com/replica-panerai
http://www.timywatch.com/panerai-sale-48.html
http://www.watchdemo.net/panerai-watches-c-74.html
http://www.jmontres.net/panerai-replique-74.html
http://www.watchgoing.net/panerai-c-74.html
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23246] distutils fails to locate vcvarsall with Visual C++ Compiler for Python

2015-01-15 Thread Gregory Szorc

Gregory Szorc added the comment:

The first sentence in my original report is ambiguous. I tested with distutils 
on Python 2.7.9. But considering the code in question hasn't changed since 
2011, I think it's safe to say this isn't a regression in CPython.

--

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Roy Smith
In article 87zj9kb2j0@elektro.pacujo.net,
 Marko Rauhamaa ma...@pacujo.net wrote:

 Skip Montanaro skip.montan...@gmail.com:
 
  Beautiful is better than ugly.
 
 Yes, our job is to increase the Harmony of the Universe. Useful
 applications are happy side effects.
 
  Explicit is better than implicit.
 
 Corollary: Constructors are usually preferable to factories.

The ebb and flow of technology has recently brought me someplace I never 
thought I'd be.  Java-land.  And what I've discovered is that factories 
are so last year.  Apparently builders are the new thing.

 Corollary: Make sure the complete definition of every function can be
 seen at once without scrolling.

The problem with that, is I have a 30 inch monitor now.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue20898] Missing 507 response description

2015-01-15 Thread Berker Peksag

Berker Peksag added the comment:

This is mostly a documentation update. Documentation updates can be committed 
anytime. Also, feature freeze for 3.5 will be started by Beta 1, not Alpha 1 
(see PEP 478).

I'll commit the patch this weekend. Thanks!

--

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



[issue3566] httplib persistent connections violate MUST in RFC2616 sec 8.1.4.

2015-01-15 Thread Martin Panter

Martin Panter added the comment:

I believe the BadStatusLine can still happen, depending on the circumstances. 
When I get a chance I will see if I can make a demonstration. In the meantime 
these comments from my persistent connection handler 
https://github.com/vadmium/python-iview/blob/587a198/iview/utils.py#L169 
might be useful:

# If the server closed the connection,
# by calling close() or shutdown(SHUT_WR),
# before receiving a short request (= 1 MB),
# the http.client module raises a BadStatusLine exception.
#
# To produce EPIPE:
# 1. server: close() or shutdown(SHUT_RDWR)
# 2. client: send(large request  1 MB)
#
# ENOTCONN probably not possible with current Python,
# but could be generated on Linux by:
# 1. server: close() or shutdown(SHUT_RDWR)
# 2. client: send(finite data)
# 3. client: shutdown()
# ENOTCONN not covered by ConnectionError even in Python 3.3.
#
# To produce ECONNRESET:
# 1. client: send(finite data)
# 2. server: close() without reading all data
# 3. client: send()

I think these behaviours were from experimenting on Linux with Python 3 
sockets, and reading the man pages.

I think there should be a new documented exception, a subclass of BadStatusLine 
for backwards compatibility. Then user code could catch the new exception, and 
true bad status lines that do not conform to the specification or whatever 
won’t be caught. I agree that the library shouldn’t be doing any special 
retrying of its own, but should make it easy for the caller to do so.

--

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Mark Lawrence

On 16/01/2015 02:48, Rustom Mody wrote:


The more forks the merrier!



When counting them, or more specifically handles, thou shalt not stop 
counting at three, but thou shalt continue to four, and thou shalt not 
continue on to five https://www.youtube.com/watch?v=Cz2-ukrd2VQ


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Rick Johnson
On Wednesday, January 14, 2015 at 11:55:11 PM UTC-6, Yawar Amin wrote:
 First off, to each reader--if you believe that 'multi-
 line' lambdas are no good and we can just use functions,
 decorators, c. to accomplish everything in Python,
 advance warning: this post will annoy you.

Well i'm not religious in that way, but i can tell you that
you'd be hard pressed to find a subject that did *NOT*
annoy someone in this group. Heck, it might even be
something like finding a holy grail if we all agreed!

 Now, the crux of my message. I have implemented what I
 believe is a fairly robust, if ugly-looking, native Python
 module made up of combinator functions which compose
 together to form function expressions (well, callable
 expressions).

Oh my, that's atrocious! (but kudos for trying!). If you
have not already done so, i would suggest you play around
with the Ruby language -- for which anonymous blocks are
quite prevalent.

I myself have lamented the limited power and expressiveness
of Python's anonymous functions. It's almost as though
Python lambda's are barely worth having since they are so
crippled.

Of course the majority will say that is because people
would use them for stupid things... well, i've seen Python
used for stupid things -- how are they going to reconcile
that?. These types of excuses are based purely on religious
or fascist thinking, and nothing more. :-(


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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Mark Lawrence

On 16/01/2015 01:44, Michael Torrie wrote:

On 01/15/2015 06:34 PM, Roy Smith wrote:

The ebb and flow of technology has recently brought me someplace I never
thought I'd be.  Java-land.  And what I've discovered is that factories
are so last year.  Apparently builders are the new thing.


It's never clear to me whether all these fancy design patterns are to
make up for a deficient language, or whether some people just get their
kicks from layer upon layer of abstraction.  Certainly it's this sort of
thing that turns me right off of Java.



If you're interested in patterns in the Python world take a look at Alex 
Martelli's writings on the subject, e.g. http://www.aleax.it/gdd_pydp.pdf


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Comparisons and sorting of a numeric class....

2015-01-15 Thread Mark Lawrence

On 16/01/2015 01:45, Andrew Robinson wrote:




[snipped as far too long to bother anybody with]

I hereby congratulate you on having made it to my Dream Team for having 
written the longest pile of drivel I've read in the 12 ish years I've 
been hanging around here.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Rustom Mody
On Friday, January 16, 2015 at 7:48:20 AM UTC+5:30, Yawar Amin wrote:
 Hi,
 
 On Thursday, January 15, 2015 at 12:19:31 PM UTC-5, Rustom Mody wrote:
  [...]
  Looked at your suggestions...
  And then got distracted by your other project
  https://github.com/yawaramin/vim-cute-python
  
  Reminded me of what I had written some months ago along similar lines
  http://blog.languager.org/2014/04/unicoded-python.html
  
  At that time this was not suggested quite seriously.
  Now I see that this can be realized at least partially
  and on a personal level.
 
 Glad it was useful. Although let me clarify that I just forked the repo
 from the original on GitHub, to publish my custom version. I have more
 conservative tastes than the original, so I chose to keep the `in`, `not
 in`, `and`, `or`, `not` keywords as is instead of using the symbols. I
 did go through your blog post and got a previously-unused symbol out of
 it: '÷' to represent '/'.

The more forks the merrier!

Let there be a hundred different versions, then people will 
begin to clamor against the non-necessity of the penury-of-ASCII:

http://blog.languager.org/2015/01/unicode-and-universe.html
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23246] distutils fails to locate vcvarsall with Visual C++ Compiler for Python

2015-01-15 Thread Gregory Szorc

New submission from Gregory Szorc:

distutils as of Python 2.7.9 is unable to locate vcvarsall.bat if Visual C++ 
Compiler for Python is the only Visual Studio distribution installed.

STR:

1) Do a fresh install of Windows + all updates
2) Install Microsoft Visual C++ Compiler for Python from 
http://www.microsoft.com/en-us/download/details.aspx?id=44266
3) Enter a Visual C++ 2008 command prompt via start menu 
4) Attempt to run any |python.exe setup.py| that contains C extensions
5) Unable to find vcvarsall.bat

Examining the behavior of MSVC for Python's bat scripts and filesystem layout, 
it is different enough from full distributions that it confused distutils.

First, MSVC for Python doesn't appear to set any meaningful registry entries. 
So, the registry checking in msvc9compiler fails to find anything.

Second, the command environment for MSVC for Python doesn't export 
VS90COMNTOOLS, so msvc9compiler has no clue where to go looking for files.

Third, even if VS90COMNTOOLS is set, msvc9compiler isn't able to find 
vcvarsall.bat because it is installed in %installdir%/vcvarsall.bat and not 
%installdir%/VC/vcvarsall.bat, unlike every other Visual Studio AFAICT.

Another concern is that distutils.msvc9compiler.find_vcvarsall() first attempts 
to read from the registry, not the environment. If you are in a MSVC for Python 
command shell and you also have Visual Studio 2008 installed, distutils will 
use vcvarsall.bat from the full Visual Studio installation instead of the 
Python one. I think this is wrong.

The MSVC for Python command prompt does have an environment variable that can 
be used: VCINSTALLDIR. It is set to %installdir%\VC\, which is equivalent to 
~/AppData/Local/Programs/Common/Microsoft/Visual C++ for Python/9.0/VC/ if you 
launch the installer with default options. distutils could be patched to find 
vcvarsall.bat in %VCINSTALLDIR%\..\vcvarsall.bat

Fortunately, a workaround is available:

1) Enter MSVC for Python command prompt
2) SET DISTUTILS_USE_SDK=1
3) SET MSSdk=1
4) python.exe setup.py ...

--
components: Distutils
messages: 234110
nosy: Gregory.Szorc, dstufft, eric.araujo
priority: normal
severity: normal
status: open
title: distutils fails to locate vcvarsall with Visual C++ Compiler for Python
versions: Python 2.7

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Rustom Mody
On Friday, January 16, 2015 at 8:33:14 AM UTC+5:30, Mark Lawrence wrote:
 On 16/01/2015 02:48, Rustom Mody wrote:
 
  The more forks the merrier!
 
 
 When counting them, or more specifically handles, thou shalt not stop 
 counting at three, but thou shalt continue to four, and thou shalt not 
 continue on to five https://www.youtube.com/watch?v=Cz2-ukrd2VQ

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


Re: MySQL connections

2015-01-15 Thread Mark Lawrence

On 15/01/2015 16:40, Jacob Kruger wrote:


If you want to check it out, have attached the full code file - might be
a bit messy/large - but, effectively, right at bottom, launch an
instance of the class a2m, passing through arguments, and then from
within __init__ call convertProcess function, which then initiates
process, harvesting sort of rendition/version of structure out of MS
access database file, makes call to convertSQL to generate structural
SQL script, and save it to a file, which then calls convertData function
to generate insert statements to populate database, and then that makes
a call to convertExport, if you passed a command line argument in
requesting mysql, and that's the current issue function - have stripped
most of actual functionality out of it, since am just testing, so the
first 16 lines of that function are what's relevant at moment - think
shouldn't rely on any other self. objects/attributes as such either,
unless step-through process is an issue.



Can you please provide us with a piece of code based on these guidelines 
http://sscce.org/ as I doubt that too many people are going to wade 
through the now deceased attachment.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


[issue22028] Python 3.4.1 Installer ended prematurely (Windows msi)

2015-01-15 Thread Piotr Dobrogost

Changes by Piotr Dobrogost p...@bugs.python.dobrogost.net:


--
nosy: +piotr.dobrogost

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



MySQL connections

2015-01-15 Thread Jacob Kruger
Development machine is windows7 64 bit machine, now working with either/both 
python 2.7 or 3.4 - test purposes, trying to figure out if this was something 
like a version incompatibility issue, and tried using both XAMPP and WAMP MySQL 
server version 5.0.11 instances thus far.

Now, aside from all other issues relating to character encoding, etc., now down 
to, hopefully, final issue.

Side note is under python 2.7, I use pyodbc to gather data from .mdb file am 
using to test, but under python 3.4, I use pypyodbc for same functionality.

Now, current/actual issue is something can sort of duplicate using both MySQLdb 
version of mysqlclient, as well as pymysql using both python 2.7 and python 
3.4, but, strange thing am trying to figure out is that even if just implement 
a connection object in interpreter of either version, retrieve an instance of a 
cursor object, and do various types of statement executions, no issues, and can 
then close connection, or cursor, or both, and all good/fine/well.

However, if implement similar code - down to just trying to open a connection, 
wait a few seconds, and then close it again, inside a function called from a 
prior function, in the class am implementing in a file called/executed from 
command line, then, the moment I try to close the connection, whether or not 
have done anything with it, that's when I get that python.exe has stopped 
working/responding error message popping up, and python bombs out.

Have no idea how to try track down actual source/cause of issue, since haven't 
found anything obvious in system event logs, nothing appearing in MySQL server 
logs that makes sense/appears relevant, and no matter if I try enclosing the 
connection open/close code inside try except code blocks, nothing happens there 
except that python just stops cooperating at all, and stops working.

Now did try making sure data execution prevention was turned on/off, and that 
if set to second mode then told it to ignore specific applications - added both 
python.exe, and the compiled version of my code to it's exemption list, but, no 
changes there.

This still operates fine on my other dev machine, but, would like to know why 
it's not operating on one specific machine.

Otherwise, will just have to tell guys that, sorry, will only be able to 
generate SQL script text files, and they'll have to stick to the final step of 
then executing those via MySQL console interface, or something, but, would 
really prefer to at the very least, figure/find out what's causing this 
mis-behaviour.

Thoughts/suggestions with regards to how to find out what is happening/what I'm 
doing/handling wrong/incorrectly?

The two current versions of the code - which work fine under interpreter of 
both versions of python are basically the following:

#pymysql version
import pymysql
cn = pymysql.connect(localhost, root, , import_test)
time.sleep(5)
cn.close()

#MySQLdb version
import MySQLdb
cn = MySQLdb.connect(localhost, root, , import_test)
time.sleep(5)
cn.close()
#end code

Stay well (away from this machine ;) )

Jacob Kruger
Blind Biker
Skype: BlindZA
Roger Wilco wants to welcome you...to the space janitor's closet...
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23209] asyncio: break some cycles

2015-01-15 Thread STINNER Victor

STINNER Victor added the comment:

I noticed that _ProactorBasePipeTransport doesn't clear its reference to the 
socket when it is closed. I changed this in the following commit (now merged in 
Python 3.4  3.5):
https://code.google.com/p/tulip/source/detail?r=61ce7def97272ab1a6488545dc392160c2fbe316

--

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



[issue22560] New SSL implementation based on ssl.MemoryBIO

2015-01-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fb3761de0d3c by Victor Stinner in branch '3.4':
Issue #22560: Fix SSLProtocol._on_handshake_complete()
https://hg.python.org/cpython/rev/fb3761de0d3c

--

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



[issue22198] Odd floor-division corner case

2015-01-15 Thread Petr Viktorin

Petr Viktorin added the comment:

ping, is there anything I can do to help push the patch forward?

--

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



Re: How to terminate the function that runs every n seconds

2015-01-15 Thread Marko Rauhamaa
Dennis Lee Bieber wlfr...@ix.netcom.com:

   The main thing to consider is that killing a thread doesn't
 work well in Python. Instead the thread has to check for some signal
 telling it to quit.

Alas, a thread can't check anything because it's blocked by I/O.


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


Stripping in Python

2015-01-15 Thread Abdul Abdul
Hello,

I have a program where I read a line input from the keyboard.

If I remove this portion of code after reading the line, I get an error:

line = line.rstrip()

Why is that? Should stripping be always be used after reading an input in
Python?

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


Re: MySQL connections

2015-01-15 Thread Chris Angelico
On Thu, Jan 15, 2015 at 7:13 PM, Jacob Kruger ja...@blindza.co.za wrote:
 However, if implement similar code - down to just trying to open a
 connection, wait a few seconds, and then close it again, inside a function
 called from a prior function, in the class am implementing in a file
 called/executed from command line, then, the moment I try to close the
 connection, whether or not have done anything with it, that's when I get
 that python.exe has stopped working/responding error message popping up, and
 python bombs out.

You've posted your working versions; can you post a non-working version?

Also, I'm seeing a very small hint here that might indicate a huge
factor that you haven't mentioned. You speak of compiling your
Python code. Do you mean you're turning it into an exe file? If so,
with which tool? Does the code still have problems if you run the
actual Python file?

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


Re: Opening the file in writing mode

2015-01-15 Thread Steven D'Aprano
Abdul Abdul wrote:

 Hello,
 
 In the Python documentation, when opening the file in write mode, it
 mentions the following:
 
 *writing (truncating the file if it already exists)*
 What is meant by truncating here? Is it simply overwriting the file
 already existing?

Not quite. It means that if the file already has content, the content is
erased immediately you open it, not just as you write over the top.

Consider this demo:


fname = 'test'  # caution, this file will be overridden
for mode in ('w', 'r+w'):
# first write a file with known content
with open(fname, 'w') as f:
f.write(hello world\n)
# confirm the file contains what we expect
with open(fname, 'r') as f:
assert f.read() == hello world\n
# now test the mode
with open(fname, mode) as f:
f.write()
with open(fname, 'r') as f:
print (mode, f.read())


The output of running this code will be:

('w', '')
('r+w', 'o world\n')



-- 
Steven

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


Re: Opening the file in writing mode

2015-01-15 Thread Adnan Sadzak
Hi,

in 'w' mode, if file does not exist it will create new one (if You have
permissions to write in specified location).
If file exist, it will 'truncate' it or like it is specified in
documentation *(an existing file with the same name will be erased)*.

I'm not sure what You mean by existing mode? Maybe to open one file twice?
If You open file for reading, then open it again for writing - yes it will
be erased or as You said 'overwrite existing mode'. Is that what You think
about?


Kind regards,
Adnan


On Thu, Jan 15, 2015 at 12:19 PM, Abdul Abdul abdul.s...@gmail.com wrote:

 Hi,

 Thanks for your reply. I just wanted to understand the 'w' mode in Python.
 So, when using it, it will overwrite any existing mode, right?

 Thanks.

 On Thu, Jan 15, 2015 at 12:13 PM, Adnan Sadzak sad...@gmail.com wrote:

 Hi,

 Yes, but You also can open an existing file in 'append' mode.

 Cheers,
 Adnan
 On Jan 15, 2015 12:08 PM, Abdul Abdul abdul.s...@gmail.com wrote:

 Hello,

 In the Python documentation, when opening the file in write mode, it
 mentions the following:

 *writing (truncating the file if it already exists)*
 What is meant by truncating here? Is it simply overwriting the file
 already existing?

 Thanks.

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



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


[OT] Re: MySQL connections

2015-01-15 Thread Peter Otten
Jacob Kruger wrote:

 However, if implement similar code - down to just trying to open a
 connection, wait a few seconds, and then close it again, inside a function
 called from a prior function, in the class am implementing in a file
 called/executed from command line, then, the moment I try to close the
 connection, whether or not have done anything with it, that's when I get
 that python.exe has stopped working/responding error message popping up,
 and python bombs out.

Jacob, your writing style is incredibly long-winded and hard to follow.
Try to build shorter sentences instead of this stream of consciousness, and 
focus on the actual problem.

python bombs out

is not a meaningful problem description. A traceback might be.

That said, I probably cannot help with your particular problem, so feel free 
to ignore me...


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


Re: Opening the file in writing mode

2015-01-15 Thread Abdul Abdul
Hi,

Thanks for your reply. I just wanted to understand the 'w' mode in Python.
So, when using it, it will overwrite any existing mode, right?

Thanks.

On Thu, Jan 15, 2015 at 12:13 PM, Adnan Sadzak sad...@gmail.com wrote:

 Hi,

 Yes, but You also can open an existing file in 'append' mode.

 Cheers,
 Adnan
 On Jan 15, 2015 12:08 PM, Abdul Abdul abdul.s...@gmail.com wrote:

 Hello,

 In the Python documentation, when opening the file in write mode, it
 mentions the following:

 *writing (truncating the file if it already exists)*
 What is meant by truncating here? Is it simply overwriting the file
 already existing?

 Thanks.

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


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


Re: Stripping in Python

2015-01-15 Thread Peter Otten
Abdul Abdul wrote:

 I have a program where I read a line input from the keyboard.
 
 If I remove this portion of code after reading the line, I get an error:
 
 line = line.rstrip()
 
 Why is that? Should stripping be always be used after reading an input in
 Python?

What version of Python are you using? How do you read the line of input?
If you provide a small program that shows the behaviour you describe we can 
probably help you fix it in no time.

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


Opening the file in writing mode

2015-01-15 Thread Abdul Abdul
Hello,

In the Python documentation, when opening the file in write mode, it
mentions the following:

*writing (truncating the file if it already exists)*
What is meant by truncating here? Is it simply overwriting the file
already existing?

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


Re: Opening the file in writing mode

2015-01-15 Thread Adnan Sadzak
Hi,

Yes, but You also can open an existing file in 'append' mode.

Cheers,
Adnan
On Jan 15, 2015 12:08 PM, Abdul Abdul abdul.s...@gmail.com wrote:

 Hello,

 In the Python documentation, when opening the file in write mode, it
 mentions the following:

 *writing (truncating the file if it already exists)*
 What is meant by truncating here? Is it simply overwriting the file
 already existing?

 Thanks.

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


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


[issue22560] New SSL implementation based on ssl.MemoryBIO

2015-01-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3c37825d85d3 by Victor Stinner in branch '3.4':
Issue #22560: Fix typo: call - call_soon
https://hg.python.org/cpython/rev/3c37825d85d3

--

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



[issue22560] New SSL implementation based on ssl.MemoryBIO

2015-01-15 Thread STINNER Victor

STINNER Victor added the comment:

Buildbots are happy. There is no remaining things to do, I close the issue.

--
resolution:  - fixed
status: open - closed

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



Re: Comparisons and sorting of a numeric class....

2015-01-15 Thread Steven D'Aprano
On Wed, 14 Jan 2015 23:23:54 -0800, Andrew Robinson wrote:

[...]
 A subclass is generally backward compatible in any event -- as it is
 built upon a class, so that one can almost always revert to the base
 class's meaning when desired -- but subclassing allows extended meanings
 to be carried.  eg: A subclass of bool is a bool -- but it can be MORE
 than a bool in many ways.

You don't have to explain the benefits of subclassing here.

I'm still trying to understand why you think you *need* to use a bool 
subclass. I can think of multiple alternatives:

- don't use True and False at all, create your own multi-valued 
  truth values ReallyTrue, MaybeTrue, SittingOnTheFence, ProbablyFalse,
  CertainlyFalse (or whatever names you choose to give them);

- use delegation to proxy True and False;

- write a class to handle the PossiblyTrue and PossiblyFalse cases,
  and use True and False for the True and False cases;

There may be other alternatives, but what problem are you solving that 
you think 

class MyBool(bool): ...

is the only solution?



 One example: It can also be a union.

I don't understand what you think this means. I know what *I* think it 
means, but subclass = union doesn't make sense to me, so wonder what 
you think it means.

 So when Guido chose to cut off
 subclassing -- his decision had a wider impact than just the one he
 mentioned; eg: extra *instances* of True and False as if he were
 trying to save memory or something.

*shrug* well maybe he was.


 The reason Guido's action puzzles me is twofold -- first it has been
 standard industry practice to subclass singleton  (or n-ton) objects to
 expand their meaning in new contexts, 

I dispute that. I *strongly* dispute that.

Industry practice, in my experience, is that there is one and only one 
case where you can subclass singleton classes: when you have a factory 
which chooses at runtime which subclass to instantiate, after which you 
can no longer instantiate any of the other subclasses.

E.g. given an *abstract* class Maze, and three *concrete* subclasses 
Labyrinth, OrdinaryMaze, and EnchantedMaze, you can have a factory 
function, or method on Maze:

class Maze:
_the_instance = None
@classmethod
def create(cls, variant='ordinary'):
if cls._the_instance is None:
# Create the Maze singleton
if variant == 'ordinary':
cls._the_instance = OrdinaryMaze()
elif variant == 'labyrinth':
cls._the_instance = Labyrinth()
elif variant == 'enchanted':
cls._the_instance = EnchantedMaze()
return _the_instance


(This is just a sketch of a solution, because the caller can bypass the 
factory and just call the subclasses directly. In Java it is possible to 
write this in such a way that the caller cannot easily do so.)


Why are we limited to a single Maze? Making Maze a singleton in the first 
place was a bad idea. The singleton design pattern is *highly* over-used 
and abused. But that is another story. Let's just assume that the 
designer has good reason to insist that there be only one Maze, perhaps 
it uses some resource which truly is limited to there being one only. If 
that is the case, then allowing the caller to break that invariant by 
subclassing will just lead to horrible bugs. By using a factory and 
controlling access to the subclasses, Maze can keep the singleton 
invariant and allow subclasses.

This is not relevant to bool, since True and False are already 
instantiated.


[...]
 In general -- it's not the goal of subclassing to create more instances
 of the base types

That might not be the goal, but it is the effect. When you instantiate 
the subclass, by definition the instances are also instances of the base 
classes.

 -- but rather to refine meaning in a way that can be
 automatically reverted to the base class value (when appropriate) and to
 signal to users that the type can be passed to functions that require a
 bool because of backward compatibility.

And I am wondering what you think you can extend bools to perform that is 
completely backwards compatible to code that requires bools?

I don't think you can. I think you are engaged on a fool's errand, trying 
to do something impossible *even if subclassing bool were allowed*. But I 
could be wrong. I just don't think you can possibly write code which is 
backwards-compatible with code that expects bools while still extending 
it. People are so prone to write:

if flag is True: ... 
if flag is False: ...


(which is naughty of them, but what are you going to do?)




[...]
 Can you name any other language that *does* allow subclassing of
 booleans or creation of new boolean values?

 Yes. Several off the top of my head -- and I have mentioned these
 before.  They generally come with the extra subclasses pre-created and
 the user doesn't get to create the classes, but only use them; none the
 less -- they have more than two values 

Re: MySQL connections

2015-01-15 Thread Jacob Kruger
And, FWIW, if I compile the 2.7 version on the other machine where it works, in 
both code and compiled forms, and then copy .exe back to the main machine, same 
error message pops up, so must be something to do with machine's configuration, 
etc.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
Roger Wilco wants to welcome you...to the space janitor's closet...

  - Original Message - 
  From: Jacob Kruger 
  To: python-list@python.org 
  Sent: Thursday, January 15, 2015 10:13 AM
  Subject: MySQL connections


  Development machine is windows7 64 bit machine, now working with either/both 
python 2.7 or 3.4 - test purposes, trying to figure out if this was something 
like a version incompatibility issue, and tried using both XAMPP and WAMP MySQL 
server version 5.0.11 instances thus far.

  Now, aside from all other issues relating to character encoding, etc., now 
down to, hopefully, final issue.

  Side note is under python 2.7, I use pyodbc to gather data from .mdb file am 
using to test, but under python 3.4, I use pypyodbc for same functionality.

  Now, current/actual issue is something can sort of duplicate using both 
MySQLdb version of mysqlclient, as well as pymysql using both python 2.7 and 
python 3.4, but, strange thing am trying to figure out is that even if just 
implement a connection object in interpreter of either version, retrieve an 
instance of a cursor object, and do various types of statement executions, no 
issues, and can then close connection, or cursor, or both, and all 
good/fine/well.

  However, if implement similar code - down to just trying to open a 
connection, wait a few seconds, and then close it again, inside a function 
called from a prior function, in the class am implementing in a file 
called/executed from command line, then, the moment I try to close the 
connection, whether or not have done anything with it, that's when I get that 
python.exe has stopped working/responding error message popping up, and python 
bombs out.

  Have no idea how to try track down actual source/cause of issue, since 
haven't found anything obvious in system event logs, nothing appearing in MySQL 
server logs that makes sense/appears relevant, and no matter if I try enclosing 
the connection open/close code inside try except code blocks, nothing happens 
there except that python just stops cooperating at all, and stops working.

  Now did try making sure data execution prevention was turned on/off, and that 
if set to second mode then told it to ignore specific applications - added both 
python.exe, and the compiled version of my code to it's exemption list, but, no 
changes there.

  This still operates fine on my other dev machine, but, would like to know why 
it's not operating on one specific machine.

  Otherwise, will just have to tell guys that, sorry, will only be able to 
generate SQL script text files, and they'll have to stick to the final step of 
then executing those via MySQL console interface, or something, but, would 
really prefer to at the very least, figure/find out what's causing this 
mis-behaviour.

  Thoughts/suggestions with regards to how to find out what is happening/what 
I'm doing/handling wrong/incorrectly?

  The two current versions of the code - which work fine under interpreter of 
both versions of python are basically the following:

  #pymysql version
  import pymysql
  cn = pymysql.connect(localhost, root, , import_test)
  time.sleep(5)
  cn.close()

  #MySQLdb version
  import MySQLdb
  cn = MySQLdb.connect(localhost, root, , import_test)
  time.sleep(5)
  cn.close()
  #end code

  Stay well (away from this machine ;) )

  Jacob Kruger
  Blind Biker
  Skype: BlindZA
  Roger Wilco wants to welcome you...to the space janitor's closet...



--


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


Re: [issue13881] Stream encoder for zlib_codec doesn't use the incremental encoder

2015-01-15 Thread M.-A. Lemburg
On 15.01.2015 05:43, Martin Panter wrote:
 
 New patch that also fixes StreamWriter.writelines() in general for the byte 
 codecs

Could you explain this new undocumented class ?

+class _IncrementalBasedWriter(StreamWriter):
+Generic StreamWriter implementation.
+
+The _EncoderClass attribute must be set to an IncrementalEncoder
+class to use.
+
+
+def __init__(self, stream, errors='strict'):
+super().__init__(stream, errors)
+self._encoder = self._Encoder(errors)
+
+def write(self, object):
+self.stream.write(self._encoder.encode(object))
+
+def reset(self):
+self.stream.write(self._encoder.encode(final=True))
+

Note that the doc-string mentions a non-existing attribute and there
are doc-string missing for the other methods.

The purpose appears to be a StreamWriter which works with
an IncrementalEncoder. A proper name would thus be
IncrementalStreamWriter which provides an .encode()
method which adapts the signature of the incremental encoder
to the one expected for StreamWriters and Codecs.

-- 
Marc-Andre Lemburg
eGenix.com

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



[issue22198] Odd floor-division corner case

2015-01-15 Thread Mark Dickinson

Mark Dickinson added the comment:

The patch is fine; I just need to find time to look at it properly.  That might 
take a week or two.  Sorry for the delay.

--

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



[issue23243] asyncio: emit ResourceWarning warnings if transports/event loops are not explicitly closed

2015-01-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2f13d53f4680 by Victor Stinner in branch '3.4':
Issue #23243: Fix asyncio._UnixWritePipeTransport.close()
https://hg.python.org/cpython/rev/2f13d53f4680

New changeset aef0f9b4e729 by Victor Stinner in branch '3.4':
Issue #23243: Close explicitly event loops in asyncio tests
https://hg.python.org/cpython/rev/aef0f9b4e729

New changeset f9b127188d43 by Victor Stinner in branch '3.4':
Issue #23243: Close explicitly transports in asyncio tests
https://hg.python.org/cpython/rev/f9b127188d43

--
nosy: +python-dev

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



[issue17546] Document the circumstances where the locals() dict get updated

2015-01-15 Thread R. David Murray

R. David Murray added the comment:

Your formulation is more concise, thank you.

I suggest dropping the word 'additionally'.  Also, how it does would be 
better phrased as how it changes, I think.  (It really should be whether and 
how it changes, but in deference to Anatoly's 'advanced English' comment I'm 
willing to let that imprecision slide).

--

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Skip Montanaro
On Thu, Jan 15, 2015 at 7:04 AM, Roy Smith r...@panix.com wrote:

 I don't know which zen this is, but Beauty is important.


Kinda near the front:

% python -m this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
...

:-)

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


Re: [OT] Re: MySQL connections

2015-01-15 Thread Jacob Kruger
- Original Message - 
From: Peter Otten __pete...@web.de

To: python-list@python.org
Sent: Thursday, January 15, 2015 12:40 PM
Subject: [OT] Re: MySQL connections



Jacob Kruger wrote:


However, if implement similar code - down to just trying to open a
connection, wait a few seconds, and then close it again, inside a 
function

called from a prior function, in the class am implementing in a file
called/executed from command line, then, the moment I try to close the
connection, whether or not have done anything with it, that's when I get
that python.exe has stopped working/responding error message popping up,
and python bombs out.


Jacob, your writing style is incredibly long-winded and hard to follow.
Try to build shorter sentences instead of this stream of consciousness, 
and

focus on the actual problem.



Was just trying to make sure included all relevant details ;)


python bombs out

is not a meaningful problem description. A traceback might be.



Agree with that, but, like said in prior e-mail, just get windows error 
message popping up, mentioning - no track trace, since it's python 
terminating:


---error details---
 Problem Event Name: BEX
 Application Name: python.exe
 Fault Module Name: StackHash_0a9e
---end error details---

That term BEX equates to buffer overflow exception, but not sure why this is 
happening - previous suggestion was to do with data execution prevention on 
windows, but, bex apparently also relates to winsock, or something, and 
tried different types of applying DEP - think so anyway.
That said, I probably cannot help with your particular problem, so feel 
free

to ignore me...



No worries - thanks for reply.

Just found following bit of summary of possible combination of 
bex/stackhash - but, still doesn't make sense when at this test stage I'm 
literally just opening and closing connection - might make sense if was 
executing thousands of queries against database before committing them:

---quote---
Buffer overflow is a condition when some process tries to store data beyond 
the capacity of the fixed/available buffer so it tries to overwrite some 
other memory locations, too. And in Windows we have some security feature 
called Data Execution Prevention that is intended to prevent similar 
processes to prevent buffer overflow attacks (that can introduce some 
malicious codes). But in some cases DEP can prevent some legitimate software 
from executing, too. And then you can get a BEX error.

---end quote---

Jacob Kruger
Blind Biker
Skype: BlindZA
Roger Wilco wants to welcome you...to the space janitor's closet...

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


Re: Stripping in Python

2015-01-15 Thread ronnyma
On Thursday, January 15, 2015 at 11:35:11 AM UTC+1, Abdul Abdul wrote:
 Hello,
 
 I have a program where I read a line input from the keyboard.
 
 If I remove this portion of code after reading the line, I get an error:
 
 line = line.rstrip()
 
 Why is that? Should stripping be always be used after reading an input in 
 Python?
 
 Thanks.

You have a displaced apostrophe in line 8 of your code. Sorry for the joke, but 
like Peter Otten says, you need to include more code, Python-version and the 
error message to prove us with context so that we can help you.

Best regards,

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


Re: MySQL connections

2015-01-15 Thread Chris Angelico
On Thu, Jan 15, 2015 at 10:59 PM, Jacob Kruger ja...@blindza.co.za wrote:
 Tried generating .exe with both cx_freeze, and pyInstaller, and the code
 itself, and both versions of executable generate errors, same as running it
 from command line - only difference is the source of the error mentioned in
 error message then varies from a2m.exe and python.exe , and even if compile
 it on machine where all works, and then copy .exe back to this primary
 machine, then get same error - think it must relate to something else on
 this machine, but can't track it down.

Okay. Ignore the .exe versions, and just work with what happens when
you run the .py files. If it fails as part of a .py file, post the
failing file.

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Roy Smith
yawar.a...@gmail.com wrote:

 I have implemented what I believe is a
 fairly robust, if ugly-looking, native Python module 

I don't know which zen this is, but Beauty is important.
-- 
https://mail.python.org/mailman/listinfo/python-list


EuroPython 2015: Come join us from July 20-26 in Bilbao !

2015-01-15 Thread M.-A. Lemburg
We are happy to announce the dates for EuroPython 2015 in Bilbao, Spain,
this year:

   Monday, July 20 - Sunday, July 26


Please mark your calendar. We’d love to meet you all in Bilbao - and hey,
it’s summer, so you might want to combine the conference with a holiday :-)

For updates, please watch our blog at http://blog.europython.eu/.

Enjoy,
—
EuroPython Society (EPS) - http://www.europython-society.org/
Asociación de Ciencias de la Computación Python San Sebastián (ACPySS)
- http://www.pyss.org/


PS: Please help spread the word and forward this email to all your local
lists, user groups, etc. Many thanks !
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How can i use a dictionnary

2015-01-15 Thread brice DORA
Le mardi 13 janvier 2015 14:56:24 UTC, Novocastrian_Nomad a écrit :
 On Tuesday, January 13, 2015 at 2:03:30 AM UTC-7, brice DORA wrote:
  i consume a web service that return a element whose the type is instance. 
  but this element seem be a dictionary but when i want to use it like a 
  dictionary, i got some errors. so this is the element and please someone 
  can tell me how can i use it. tkanks in advance.
  
  
  (tCountryInfo){
 sISOCode = CI
 sName = Côte D'Ivoire (Ivory Coast)
 sCapitalCity = Yamoussoukro
 sPhoneCode = 225
 sContinentCode = AF
 sCurrencyISOCode = XOF
 sCountryFlag = 
  http://www.oorsprong.org/WebSamples.CountryInfo/Images/Côte D'Ivoire.jpg
 Languages = 
(ArrayOftLanguage){
   tLanguage[] = 
  (tLanguage){
 sISOCode = fr
 sName = French
  },
}
   }
 
 This data is not a Python dictionary, nor is it a JSON object.  You will 
 probably need to code your own conversion function to make it a Python 
 dictionary.

thanks for your help but can you give a example that's you tell about my own 
conversion funcion. thanks in advance
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: MySQL connections

2015-01-15 Thread Jacob Kruger
- Original Message - 
From: Chris Angelico ros...@gmail.com




You've posted your working versions; can you post a non-working version?


Problem is that works fine in interpreter, but, not when executing it as 
part of code in file.




Also, I'm seeing a very small hint here that might indicate a huge
factor that you haven't mentioned. You speak of compiling your
Python code. Do you mean you're turning it into an exe file? If so,
with which tool? Does the code still have problems if you run the
actual Python file?


Tried generating .exe with both cx_freeze, and pyInstaller, and the code 
itself, and both versions of executable generate errors, same as running it 
from command line - only difference is the source of the error mentioned in 
error message then varies from a2m.exe and python.exe , and even if compile 
it on machine where all works, and then copy .exe back to this primary 
machine, then get same error - think it must relate to something else on 
this machine, but can't track it down.


Jacob Kruger
Blind Biker
Skype: BlindZA
Roger Wilco wants to welcome you...to the space janitor's closet...

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


  1   2   >