Re: help with SUDS

2013-09-24 Thread dieter
Ismar Sehic i.she...@gmail.com writes:

 hello, i'm trying to make a wrapper for making xml requests to hotelbeds.com 
 site.
 ...
   File /usr/lib/python2.6/urllib2.py, line 1172, in http_open
 return self.do_open(httplib.HTTPConnection, req)
   File /usr/lib/python2.6/urllib2.py, line 1147, in do_open
 raise URLError(err)
 urllib2.URLError: urlopen error [Errno 110] Connection timed out

This indicates a problem of the service you are contacting:
suds tries to open a connection to the service url defined
in the WSDL, but it does not get a response within a reasonable
time frame.

The problem might be temporary (a temporary overload of the
corresponding service) - or they may be some error in the
WSDL - or some firewall may interfere with your request - or ...

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


Re: Functional Programming and python

2013-09-24 Thread Jussi Piitulainen
Vito De Tullio writes:

 rusi wrote:
 
  [Not everything said there is correct; eg python supports currying
  better [than haskell which is surprising considering that
  Haskell's surname is [Curry!]
 
 AFAIK python does not support currying at all (if not via some
 decorators or something like that).

I suppose rusi means functools.partial:

   from functools import partial
   trip = lambda x,y,z: (x,y,z)
   partial(trip,'a','b')('c')
  ('a', 'b', 'c')

It also supports keyword arguments.

 Instead every function in haskell implicitly support currying...
 so... how does no support is better than full support?

Yes. I'm satisfied that Python does, but what can be seen as a
shortcoming in Haskell? Just curious.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Functional Programming and python

2013-09-24 Thread rusi
On Monday, September 23, 2013 11:54:53 PM UTC+5:30, Vito De Tullio wrote:
 rusi wrote:
 
  [Not everything said there is correct; eg python supports currying better
  [than haskell which is surprising considering that Haskell's surname is
  [Curry!]
 
 
 AFAIK python does not support currying at all (if not via some decorators or 
 something like that).
 
 
 Instead every function in haskell implicitly support currying... so... how 
 does no support is better than full support?

Without resorting to lambdas/new-functions:
 With functools.partial one can freeze any subset of a function(callable's) 
 parameters.
 
 In Haskell one can only freeze the first parameter or at most with a right 
section the second
-- 
https://mail.python.org/mailman/listinfo/python-list


combine pictures

2013-09-24 Thread andypu
hello, i have a picture and i want to merge it with an other picture which is 
half transparent and the first picture will shine through it, has python the 
library's to do this?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Functional Programming and python

2013-09-24 Thread Jussi Piitulainen
rusi writes:

 Without resorting to lambdas/new-functions:
  With functools.partial one can freeze any subset of a
  function(callable's) parameters.

  In Haskell one can only freeze the first parameter or at most with
  a right section the second

You have an f of type A - B - C - D - E in Haskell, you can freeze
the first three parameters by calling it with three arguments. These
are equivalent:

f a b c d
(f a b c) d
(f a b) c d
(f a) b c d

So it's any initial sequence of arguments, not just the first.

And I thought such types were preferred over A * B * C * D - E in
Haskell, so you tend to get this for free. Not sure of the syntax here
- it's been long since I did anything at all with Haskell.

A difference seems to be that in Python, a call can refer to named
parameters. This gives functools.partial some power over Haskell.

Another difference is that the value of functools.partial is always a
function that needs to be called with the remaining arguments, even if
there are none. Both the creation and the evaluation of the curried
functions just happens in Haskell.

(I also think that the word currying used to refer to what Haskell
does and it's an extension to use it to mean any partial evaluation.)
-- 
https://mail.python.org/mailman/listinfo/python-list


How to login to a website using Python 3.x?

2013-09-24 Thread Osumo Clement
 Hi. I am new to Python. I am making a script where logging in to a website is 
the first step.. I am using Python 3.3 All of the help I have seen online uses 
urllib2 which in Python 3 aint there. I will greatly appreciate any help
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to login to a website using Python 3.x?

2013-09-24 Thread Mark Lawrence

On 24/09/2013 09:09, Osumo Clement wrote:

  Hi. I am new to Python. I am making a script where logging in to a website is 
the first step.. I am using Python 3.3 All of the help I have seen online uses 
urllib2 which in Python 3 aint there. I will greatly appreciate any help



urllib2 has been renamed in Python 3 see 
http://www.python.org/dev/peps/pep-3108/#urllib-package


--
Cheers.

Mark Lawrence

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


Re: combine pictures

2013-09-24 Thread Terry Reedy

On 9/24/2013 3:40 AM, and...@zoho.com wrote:

hello, i have a picture and i want to merge it with an other picture which is 
half transparent and the first picture will shine through it, has python the 
library's to do this?


Searching 'python image library' might lead one to
https://pypi.python.org/pypi/Pillow/2.1.0


--
Terry Jan Reedy

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


removing BOM prepended by codecs?

2013-09-24 Thread J. Bagg
I'm having trouble with the BOM that is now prepended to codecs files. 
The files have to be read by java servlets which expect a clean file 
without any BOM.


Is there a way to stop the BOM being written?

It is seriously messing up my work as the servlets do not expect it to 
be there. I could delete it but that means another delay in retrieving 
the data. My work is a bibliographic system and I'm writing a new search 
engine in Python to replace an ancient one in C.


I'm working on Linux with a locale of en_GB.UTF8

--
Dr Janet Bagg
CSAC, Dept of Anthropology,
University of Kent, UK
--
https://mail.python.org/mailman/listinfo/python-list


Re: python IDE and function definition

2013-09-24 Thread Fabio Zadrozny
On Mon, Sep 23, 2013 at 8:20 PM, Neil Hodgson nhodg...@iinet.net.au wrote:

 Chris Friesen:


  where I could highlight the stop and ask it to go to the definition.
 (Where the definition is in a different file.)

 I'm running into issues where my current IDE (I'm playing with Komodo)
 can't seem to locate the definition, I suspect because it's too ambiguous.


 Some IDEs allow you to help them understand the context by adding type
 information. Here's some documentation for Wing IDE that uses an isinstance
 assertion:
 http://www.wingware.com/doc/**edit/helping-wing-analyze-codehttp://www.wingware.com/doc/edit/helping-wing-analyze-code


Just to note, PyDev can also use the assert isinstance as well as
docstrings (http://pydev.org/manual_adv_type_hints.html) for type hinting.

Cheers,

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


Re: removing BOM prepended by codecs?

2013-09-24 Thread Steven D'Aprano
On Tue, 24 Sep 2013 10:42:22 +0100, J. Bagg wrote:

 I'm having trouble with the BOM that is now prepended to codecs files.
 The files have to be read by java servlets which expect a clean file
 without any BOM.
 
 Is there a way to stop the BOM being written?

Of course there is :-) but first we need to know how you are writing it 
in the first place.

If you are dealing with existing files, which already contain a BOM, you 
may need to open the files and re-save them without the BOM.

If you are dealing with temporary files you're creating programmatically, 
it depends how you're creating them. My guess is that you're doing 
something like this:

f = open(some file, w, encoding=UTF-16)  # or UTF-32
f.write(data)
f.close()

or similar. Both the UTF-16 and UTF-32 codecs write BOMs. To avoid that, 
you should use UTF-16-BE or UTF-16-LE (Big Endian or Little Endian), as 
appropriate to your platform.

If you're getting a UTF-8 BOM, that's seriously weird. The standard UTF-8 
codec doesn't write a BOM. (Strictly speaking, it's not a Byte Order 
Mark, but a Signature.) Unless you're using encoding='UTF-8-sig', I can't 
guess how you're getting a UTF-8 BOM.

If you're doing something else, well, you'll have to explain what you're 
doing before we can tell you how to stop doing it :-)


 I'm working on Linux with a locale of en_GB.UTF8

The locale only sets the default encoding used by the OS, not that used 
by Python. Python 2 defaults to ASCII; Python 3 defaults to UTF-8.


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


Re: removing BOM prepended by codecs?

2013-09-24 Thread Peter Otten
J. Bagg wrote:

 I'm having trouble with the BOM that is now prepended to codecs files.
 The files have to be read by java servlets which expect a clean file
 without any BOM.
 
 Is there a way to stop the BOM being written?

I think if you specify the byte order explicitly with UTF-16-LE or 
UTF-16-BE no BOM is written.


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


Re: Making it a MultiThread!

2013-09-24 Thread Piet van Oostrum
stas poritskiy stascr...@gmail.com writes:

 Thanks for getting back to me, so i assume it is OK to have a very
 very long file? The sample code i posted here is basically the
 barebones of the main app.
 so, combining the GUI-file(gui.py) with main code is acceptable?
 Separating them into modules was initially the attempt to keep things
 in order.

Keeping things in separate modules is still OK. Just don't use circular
imports. Keeping the logic of your applcation and the GUI in separate
files is usually a good idea. And make sure the dependencies between the
modules are simple. Very, very long files usually are not a good idea.

Also you imported multiprocessing through anothe module. This obscures
the structure of the application, and is unnecesary. You should only
access a module through another module if you add a layer of abstraction
that makes it easier or more powerful.
-- 
Piet van Oostrum p...@vanoostrum.org
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to send an anonymous mail via Python script

2013-09-24 Thread Alister
On Sat, 21 Sep 2013 20:41:25 +1000, Chris Angelico wrote:

 On Sat, Sep 21, 2013 at 8:15 PM, Νίκος nikos.gr...@gmail.com wrote:
 On 21/9/2013 1:04 μμ, Chris Angelico wrote:

 On Sat, Sep 21, 2013 at 7:58 PM, Νίκος nikos.gr...@gmail.com wrote:

 Can you please tell me what alternation must be made in order to send
 this anonymously?

 that is my question. There must be a way.


 No, there isn't. The nearest you could come to anonymous mail would be
 sending via a botnet (to hide your IP address) and forging the from
 address. So unless you *want* your mail to be flagged as spam and
 detested by the entire world, NO THERE IS NO WAY to send it
 anonymously.

 ChrisA

 How about an anonymous remailer then?
 
 I'm going to spell this out for the benefit of anyone else who's reading
 this, because I know Nikos won't take any notice. This is a gross
 oversimplification, but I'm trying to condense everything into a single
 email.
 
snip

To put it even more simply
If you have a legitimate reason to send me emails then you have no 
legitimate reason to withhold your true Identity.

if you do I will assume you are a crook.

if you are asking for advise on how to achieve this I will assume you 
want to be a crook and will not provide any assistance.

-- 
No man would listen to you talk if he didn't know it was his turn next.
-- E.W. Howe
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: combine pictures

2013-09-24 Thread Roy Smith
In article mailman.288.1380016922.18130.python-l...@python.org,
 Terry Reedy tjre...@udel.edu wrote:

 On 9/24/2013 3:40 AM, and...@zoho.com wrote:
  hello, i have a picture and i want to merge it with an other picture which 
  is half transparent and the first picture will shine through it, has python 
  the library's to do this?
 
 Searching 'python image library' might lead one to
 https://pypi.python.org/pypi/Pillow/2.1.0

It might also lead one to

http://www.pythonware.com/products/pil/

That being said, I've had Evaluate Pillow as possible PIL replacement 
on my todo list for a while :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Functional Programming and python

2013-09-24 Thread rusi
On Tuesday, September 24, 2013 1:12:51 PM UTC+5:30, Jussi Piitulainen wrote:
 rusi writes:
 
  Without resorting to lambdas/new-functions:
   With functools.partial one can freeze any subset of a
   function(callable's) parameters.
 
 
   In Haskell one can only freeze the first parameter or at most with
   a right section the second
 
 You have an f of type A - B - C - D - E in Haskell, you can freeze
 the first three parameters by calling it with three arguments. These
 are equivalent:
 
 f a b c d
 (f a b c) d
 (f a b) c d
 (f a) b c d
 
 So it's any initial sequence of arguments, not just the first.

Agreed. I missed that.

However as n increases there are n initial sequences (Haskell) whereas there 
are 2^n possible subsets (Python) (2^n - 1 if we remove the fully saturated 
case). So I would argue that Python syntax gives more flexibility in this 
direction than Haskell.  Add the further feature of **args and its even more

 
 (I also think that the word currying used to refer to what Haskell
 does and it's an extension to use it to mean any partial evaluation.)

Hmm… Seems this is a contentious issue
http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_application

which links to this LtU post that I find neat:

---
If I have a function f:(x,y)-z, I can't apply it to only one of its arguments. 
I can curry it, turning it into a function g:x-(y-z) ... and I can apply g to 
only one of the original arguments. But turning f into g and applying g to some 
x are technically different things.

I suspect the confusion arises because originally currying was a technique to 
model multiple-argument functions in a single-argument framework and was a 
meta-operation. In ML-like languages, the functions are typically already 
curried, so the only operation you see being done is partial application.
---
from http://lambda-the-ultimate.org/node/2266

-
Anyways thanks for that Ive added it to my 'lost-booty' list
http://blog.languager.org/2012/10/functional-programming-lost-booty.html#curry
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to send an anonymous mail via Python script

2013-09-24 Thread Steven D'Aprano
On Tue, 24 Sep 2013 11:36:16 +, Alister wrote:

 To put it even more simply
 If you have a legitimate reason to send me emails then you have no
 legitimate reason to withhold your true Identity.

Dear Alister,

Forgive this anonymous email, but I don't wish to get fired from my job 
and sued for breaking the confidentiality agreement I signed, but 
somebody needs to speak out about this matter. You need to know that the 
company I work for, Acme Ltd, is illegally dumping radioactive waste in 
the street where you live in the form of extremely fine powder which 
blows all over the street, into your home and garden. Attached is the 
evidence for this, proving that knowledge of this dumping goes all the 
way to the company board. I suggest you talk to your lawyer before your 
children develop mutant superpowers, or possibly cancer, whichever 
happens first.


Whistleblower laws are useless. Sometimes people need to remain 
anonymous. Even when whistleblower laws have teeth, sometimes it's just 
better to keep your identity unknown.

However, in the specific case of Nikos, I cannot imagine any legitimate 
reason for him to be sending anonymous emails to his website users. I've 
asked him to explain, but he hasn't. I can only conclude that he is 
intending to send spam, or otherwise act unethically or even criminally. 
Even if I knew how to write an anonymous mail server, I wouldn't help him.



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


Re: How to send an anonymous mail via Python script

2013-09-24 Thread Chris Angelico
On Tue, Sep 24, 2013 at 10:29 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Tue, 24 Sep 2013 11:36:16 +, Alister wrote:

 To put it even more simply
 If you have a legitimate reason to send me emails then you have no
 legitimate reason to withhold your true Identity.

 Dear Alister,

 Forgive this anonymous email, but I don't wish to get fired from my job
 and sued for breaking the confidentiality agreement I signed, but
 somebody needs to speak out about this matter.

There are definitely the odd times when a person needs anonymity. I do
not know of any times when an email-sending *computer* does. To send
your whistleblower email, I would recommend an HTTPS connection to
some free webmail service, or some sort of bouncer, or something - but
that bouncer can identify itself honestly to the receiver.

Same goes for other situations. I received your email, not from
pearwood.info, but from python.org - courtesy of Mailman. It's not
being sneaky about it, but the 'from' header is quite different from
the mail's actual origin. What I want to know here, primarily, is the
identity of the server who's giving me the message - ie python.org -
and MTAs will be adding tracking headers that identify that server.

(The concepts here are somewhat clouded by the c.l.py gateway, but
pick any other mailing list as your example and it'll be correct.)

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


removing BOM prepended by codecs?

2013-09-24 Thread J. Bagg

I'm using:

outputfile = codecs.open (fn, 'w+', 'utf-8', errors='strict')

to write as I know that the files are unicode compliant. I run the raw 
files that are delivered through a Python script to check the unicode 
and report problem characters which are then edited. The files use a 
whole variety of languages from Sanskrit to Cyrillic and more obscure 
ones too.


I'll probably have to remove it in the servlet as we have standardised 
on utf-8. This was done some years ago when utf-16 was rare (apart from 
Macs).


J



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


xml parsing as YML parser does does

2013-09-24 Thread bab mis
Hi ,
Here is an example how i do yml parsing and a proper pythonic object returns , 
is it possible in XML, tried lxml,dom, but there is no straight forward 
solution:

[root@linux-source pyrun]# cat x.yml
#Section for specifying test process information

Test: 

commoninfo: 
buildhome   : /root/linuxbuilds

 
Project:
default:

test_parameters:
svnuser: vmbuild
suite  : sanity
username   : root


Commands :
-   name   : generalcheck of destination
action : generalcheck

-   name   : retrieve source from svn
action : retsource
params : src=x,src1=y
[root@linux-source pyrun]



[root@linux-source pyrun]# cat a.py 
import yaml
fd = open(x.yml)
data = fd.read()
fd.close()
ydata = yaml.safe_load(data)
import pprint
pprint.pprint( ydata )

===


[root@linux-source pyrun]# python a.py 
{'Test': {'Project': {'default': {'Commands': [{'action': 'generalcheck',
'name': 'generalcheck of 
destination'},
   {'action': 'retsource',
'name': 'retrieve source from 
svn',
'params': 'src=x,src1=y'}],
  'test_parameters': {
  'suite': 'sanity',
  'svnuser': 'vmbuild',
  'username': 'root'}}},
  'commoninfo': {'buildhome': '/root/linuxbuilds'}}}
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: removing BOM prepended by codecs?

2013-09-24 Thread Tim Golden
On 24/09/2013 14:01, J. Bagg wrote:
 I'm using:
 
 outputfile = codecs.open (fn, 'w+', 'utf-8', errors='strict')

Well for the life of me I can't make that produce a BOM on 2.7 or 3.4.
In other words:

code
import codecs
with codecs.open(temp.txt, w+, utf-8, errors=strict) as f:
  f.write(abc)

with open(temp.txt, rb) as f:
  assert f.read()[:3] == babc

/code

works without any assertion failures on 2.7 and 3.4, both running on
Win7 and on 2.7 and 3.3 running on Linux.

Have I misunderstood your situation?

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


Re: removing BOM prepended by codecs?

2013-09-24 Thread Dave Angel
On 24/9/2013 09:01, J. Bagg wrote:

Why would you start a new thread?  just do a Reply-List (or Reply-All
and remove the extra names) to the appropriate message on the existing
thread.

 I'm using:

 outputfile = codecs.open (fn, 'w+', 'utf-8', errors='strict')

That won't be adding a BOM.  It appends to an existing file, which
already may have a BOM in it.  Or conceivably you have a BOM in your
unicode string that you're passing to write() method.


 to write as I know that the files are unicode compliant. I run the raw 
 files that are delivered through a Python script to check the unicode 
 and report problem characters which are then edited. The files use a 
 whole variety of languages from Sanskrit to Cyrillic and more obscure 
 ones too.

it'd be much nicere to remove it when writing the file.
-- 
DaveA


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


Re: What's the best way to extract 2 values from a CSV file from each row systematically?

2013-09-24 Thread Alex Lee
Thanks for the help guys! I'll definitely read up on the csv module 
documentation.

Tim, that's incredibly helpful, thanks a lot! :) My CSV file doesn't have 
headers, but I'm sure I can just as easily add it in manually.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: combine pictures

2013-09-24 Thread andypu
Oh i thaught maybe python comes with something native, bevore i install 
something new i think i might better look into if kivy can do the job - thats 
allready installed...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Functional Programming and python

2013-09-24 Thread Jussi Piitulainen
rusi writes:
 On Tuesday, September 24, 2013 1:12:51 PM UTC+5:30, Jussi Piitulainen wrote:
  rusi writes:
  
   Without resorting to lambdas/new-functions:
With functools.partial one can freeze any subset of a
function(callable's) parameters.
  
In Haskell one can only freeze the first parameter or at most
with a right section the second
  
  You have an f of type A - B - C - D - E in Haskell, you can
  freeze the first three parameters by calling it with three
  arguments. These are equivalent:
  
  f a b c d
  (f a b c) d
  (f a b) c d
  (f a) b c d
  
  So it's any initial sequence of arguments, not just the first.
 
 Agreed. I missed that.

Ok.

 However as n increases there are n initial sequences (Haskell)
 whereas there are 2^n possible subsets (Python) (2^n - 1 if we
 remove the fully saturated case). So I would argue that Python
 syntax gives more flexibility in this direction than Haskell.

Strictly speaking and in principle, yes. I'm not sure how important
this is in practice: the positional parameter list should be short
anyway, Haskell does have the special mechanism for the second, and
there is always the fully general mechanism (lambda) in both languages
(and in another language I use that has neither built-in currying nor
keyword parameters :).

I agree that the ability to identify arguments by name gives a useful
amount of quite practical power, and I see that functools.partial uses
it nicely. So, no real disagreement on this from me.

Would the type system get in the way of providing some analogous
function in Haskell? I don't know.

 Add the further feature of **args and its even more

  (I also think that the word currying used to refer to what
  Haskell does and it's an extension to use it to mean any partial
  evaluation.)
 
 Hmm[] Seems this is a contentious issue
 http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_application
 
 which links to this LtU post that I find neat:

[snip]

Thanks. I don't think I have anything useful to add, though.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with python functions?

2013-09-24 Thread Denis McMahon
On Mon, 23 Sep 2013 19:40:47 -0700, kjakupak wrote:

 Not sure if we've gotten that far in class, considering I don't know how
 to go about doing that.

Which bit aren't you sure about?

(a) adding a same unit conversion to the units conversion program? 
(Actually, this bit isn't needed after all, you can avoid it with a test 
in comp.)

(b) calling temp from comp to establish a common unit?

(c) comparing the returned value of the call to temp with the other temp 
in comp

Question, given the original temp function as previously described by 
yourself, what does the following function f which takes the same params 
as comp do:

def f( t1, u1, t2, u2 ):
if u1 == u2:
return t2
else:
return temp( t2, u2, u1 )

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to send an anonymous mail via Python script

2013-09-24 Thread Alister
On Tue, 24 Sep 2013 12:29:14 +, Steven D'Aprano wrote:

 On Tue, 24 Sep 2013 11:36:16 +, Alister wrote:
 
 To put it even more simply If you have a legitimate reason to send me
 emails then you have no legitimate reason to withhold your true
 Identity.
 
 Dear Alister,
snip 
 
 Whistleblower laws are useless. Sometimes people need to remain
 anonymous. Even when whistleblower laws have teeth, sometimes it's just
 better to keep your identity unknown.


That would be acceptable as an email to me as a company/gvt. officer.
emails to me as an individual have no justification in remaining anonymous
 
 However, in the specific case of Nikos, I cannot imagine any legitimate
 reason for him to be sending anonymous emails to his website users. I've
 asked him to explain, but he hasn't. I can only conclude that he is
 intending to send spam, or otherwise act unethically or even criminally.
 Even if I knew how to write an anonymous mail server, I wouldn't help
 him.

indeed, I have given Nikos the benefit of the doubt  even tried to help 
him once when the question seemed within my limited abilities but without 
further information on the purpose I will not be helping with this one.#




-- 
unfair competition, n.:
Selling cheaper than we do.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with python functions?

2013-09-24 Thread Denis McMahon
On Tue, 24 Sep 2013 03:15:23 +, Steven D'Aprano wrote:

 You don't have to use Kelvin. You could use any temperature scale, so
 long as it is the same for both temperatures.

Given that he already has a handy conversion function to call, he should 
be able to convert t2 into the units of t1 if they're in different units 
(2 lines), and then do his comparison (5 lines).

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Functional Programming and python

2013-09-24 Thread rusi
On Tuesday, September 24, 2013 8:21:19 PM UTC+5:30, Jussi Piitulainen wrote:
 Would the type system get in the way of providing some analogous
 function in Haskell? I don't know.

Yes.
The haskell curry
curry f x y = f (x,y)
is really only curry2
curry3 would be
curry3 f x y z = f (x,y,z)
and so on upwards

Vanilla Haskell makes it real hard to put all these under one type umbrella

By comparison python's partial is quite effortless.

And this is an old conundrum in programming language design:

In C printf is easy to write and NOT put into the language but into external 
libraries
In Pascal, writeln cannot be outside the language because as a user defined 
function, its type would not fit the type system.

And so printf can be made to crash quite easily; not so writeln!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Functional Programming and python

2013-09-24 Thread Chris Angelico
On Wed, Sep 25, 2013 at 1:07 AM, rusi rustompm...@gmail.com wrote:
 And this is an old conundrum in programming language design:

 In C printf is easy to write and NOT put into the language but into external 
 libraries
 In Pascal, writeln cannot be outside the language because as a user defined 
 function, its type would not fit the type system.

 And so printf can be made to crash quite easily; not so writeln!

I assume you're talking about mismatching percent-markers and
arguments, there. That's because of a limitation in C's variadic
function support, ameliorated somewhat by gcc's warnings system, and
completely solved by other languages in which (s)printf can still be
an external function, but with reliable type checking. It's not
whether it's part of the language or not that does that.

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


removing BOM prepended by codecs?

2013-09-24 Thread J. Bagg

I've checked the original files using od and they don't have BOMs.

I'll remove them in the servlet. The overhead is probably small enough 
unless somebody is doing a massive search. We have a limit anyway to 
prevent somebody stealing the entire set of data.


I started writing the Python search because the ancient C search had 
started putting out BOMs. I'm actually mystified because our home Linux 
box does not add BOMs even though it runs 2.7 but my work one does even 
though it has the same version. The only difference is Fedora 18 v 
Fedora 17.


The BOMs are certainly there:

86 ADFB%R 10C0203z-621
%A François-Xavier Le_Bourdonnec

000 206 255 373   %   R   1   0   C   0   2   0   3   z   -

J

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


Re: removing BOM prepended by codecs?

2013-09-24 Thread Peter Otten
J. Bagg wrote:

 I've checked the original files using od and they don't have BOMs.
 
 I'll remove them in the servlet. The overhead is probably small enough
 unless somebody is doing a massive search. We have a limit anyway to
 prevent somebody stealing the entire set of data.
 
 I started writing the Python search because the ancient C search had
 started putting out BOMs. I'm actually mystified because our home Linux
 box does not add BOMs even though it runs 2.7 but my work one does even
 though it has the same version. The only difference is Fedora 18 v
 Fedora 17.
 
 The BOMs are certainly there:
 
 86 ADFB%R 10C0203z-621
 %A François-Xavier Le_Bourdonnec
 
 000 206 255 373   %   R   1   0   C   0   2   0   3   z   -
 
 J
 

Were these files edited with Notepad? According to

http://docs.python.org/2/library/codecs.html#encodings-and-unicode


To increase the reliability with which a UTF-8 encoding can be detected, 
Microsoft invented a variant of UTF-8 (that Python 2.5 calls utf-8-sig) 
for its Notepad program: Before any of the Unicode characters is written to 
the file, a UTF-8 encoded BOM (which looks like this as a byte sequence: 
0xef, 0xbb, 0xbf) is written.


To strip off such a UTF-8 encoded BOM you can open the source file with 
utf-8-sig and write the output to a (different!) file with utf-8

with codecs.open(source, r, encoding=utf-8-sig) as instream:
with codecs.open(dest, w, encoding=utf-8) as outstream:
shutil.copyfileobj(instream, outstream)

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


Re: Help with python functions?

2013-09-24 Thread giacomo boffi
kjaku...@gmail.com writes:

 def temp(T, from_unit, to_unit):
 conversion_table = {('c', 'k'):lambda x: x + 273.15,
 ('c', 'f'):lambda x: (x * (9.0/5)) + 32,
 ('k', 'c'):lambda x: x - 273.15,
 ('k', 'f'):lambda x: (x * (9.0/5)) - 459.67,
 ('f', 'c'):lambda x: (x - 32) * (5.0/9),
 ('f', 'k'):lambda x: (x + 459.67) * (5.0/9)}
 f = conversion_table[(from_unit.lower(), to_unit.lower())]
 return f(T)

 Would this be correct?

not always:

 temp(-300.0, 'c', 'k')
-26.8500023
 


-- 
le mie sacrosante questioni di principio
  VS gli sciocchi puntigli di quel cretino del mio vicino
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python IDE and function definition

2013-09-24 Thread Travis Griggs

On Sep 23, 2013, at 8:06 AM, Chris Friesen cbf...@mail.usask.ca wrote:

 
 Hi all,
 
 I'm looking for a python IDE (for Linux) that can look at code like this:
 
 class ConductorManager(manager.Manager):
def compute_recover(self, context, instance):
self.compute_api.stop(context, instance, do_cast=False)
 
 where I could highlight the stop and ask it to go to the definition. (Where 
 the definition is in a different file.)
 
 I'm running into issues where my current IDE (I'm playing with Komodo) can't 
 seem to locate the definition, I suspect because it's too ambiguous.
 
 The fact that python is dynamically typed seems to mean that there could 
 potentially be multiple answers, any class with a stop() method with the 
 right signature could presumably be plausible, right?  So rather than give 
 up, I'd like to have my IDE suggest all possible answers.

Hi Chris,

Not sure if this reproduces what you want or not. I use PyCharm (free for free 
stuff, and very affordable/worthwhile otherwise) on Linux (as well as 
OSX/Windows). I made a new project, added two files:

provider.py:

class Provider(object):
def stop(self):
pass

usage.py:

class Conglomerate(object):
def doSomething(self):
self.provision.stop()

I then highlight 'stop', hit Ctrl-B (menu option go todeclarations) and it 
brings up all the stop() definitions it could find, the Provider one on the 
top, click it and I jump there. Ctrl-Alt-B (menu option for 
gotoimplementation(s)) does nothing… UNLESS… I add this method to 
Conglomerate:

def __init__(self):
super.__init__()
self.provision = Provider()

Then go to implementations takes me right there to the other file.

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


Re: Help with python functions?

2013-09-24 Thread MRAB

On 24/09/2013 17:53, giacomo boffi wrote:

kjaku...@gmail.com writes:


def temp(T, from_unit, to_unit):
conversion_table = {('c', 'k'):lambda x: x + 273.15,
('c', 'f'):lambda x: (x * (9.0/5)) + 32,
('k', 'c'):lambda x: x - 273.15,
('k', 'f'):lambda x: (x * (9.0/5)) - 459.67,
('f', 'c'):lambda x: (x - 32) * (5.0/9),
('f', 'k'):lambda x: (x + 459.67) * (5.0/9)}
f = conversion_table[(from_unit.lower(), to_unit.lower())]
return f(T)

Would this be correct?


not always:


temp(-300.0, 'c', 'k')

-26.8500023





In other words, it depends what you mean by 'correct'.

Zero Kelvin (Absolute Zero) is the lowest possible temperature; in
reality there's no such temperature as -300°C.

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


Re: Functional Programming and python

2013-09-24 Thread rusi
On Tuesday, September 24, 2013 8:56:21 PM UTC+5:30, Chris Angelico wrote:
 On Wed, Sep 25, 2013 at 1:07 AM, rusi  wrote:
  And this is an old conundrum in programming language design:
 
  In C printf is easy to write and NOT put into the language but into 
  external libraries
 
  In Pascal, writeln cannot be outside the language because as a user defined 
  function, its type would not fit the type system.
 
  And so printf can be made to crash quite easily; not so writeln!
 
 I assume you're talking about mismatching percent-markers and
 arguments, there. That's because of a limitation in C's variadic
 function support, ameliorated somewhat by gcc's warnings system, and
 completely solved by other languages in which (s)printf can still be
 an external function, but with reliable type checking. It's not
 whether it's part of the language or not that does that.

Sure there can be and are specific workarounds.

My point was a general one:
Strong type system: Some desirable programs will get kicked out
Weak type system: Some undesirable programs will slip in
'Exactly' correct type system: Impossible by halting problem 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python, pythontex and plots

2013-09-24 Thread Piet van Oostrum
chitt...@uah.edu writes:

 True, I did not explain what I was trying to do.

 pythontex is a package that allows the inclusion of python code within a
 LaTeX document - (sort of like python.sty, but IMO, better) - I use
 it along with noweb to create documents that contain documentation,
 code and output of the code - and pythontex allows me to access variables
 within the python code embedded in the LaTeX - except for the case
 I mentioned ... Within the python code (inside the LaTeX document) I had
 a savefig(outputfile) and I was trying to reference the outputfile
 using \py{outputfile}

It could be that \includegraphics needs an expandable TeX form for its
filename, and \py probably isn't. I haven't tried pythontex yet (I
didn't know about it before your posting), so I can only guess. I am
going to try it out later. But if I am correct then the following might
work:

\newcommand{\filename}{}
\edef\filename{\py{outputfile}}

\includegraphics[scale=0.75]{\filename}

-- 
Piet van Oostrum p...@vanoostrum.org
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: removing BOM prepended by codecs?

2013-09-24 Thread wxjmfauth
Le mardi 24 septembre 2013 11:42:22 UTC+2, J. Bagg a écrit :
 I'm having trouble with the BOM that is now prepended to codecs files. 
 
 The files have to be read by java servlets which expect a clean file 
 
 without any BOM.
 
 
 
 Is there a way to stop the BOM being written?
 
 
 
 It is seriously messing up my work as the servlets do not expect it to 
 
 be there. I could delete it but that means another delay in retrieving 
 
 the data. My work is a bibliographic system and I'm writing a new search 
 
 engine in Python to replace an ancient one in C.
 
 
 
 I'm working on Linux with a locale of en_GB.UTF8
 
 
 
 -- 
 
 Dr Janet Bagg
 
 CSAC, Dept of Anthropology,
 
 University of Kent, UK

-

Some points.

- The coding of a text file does not matter. What's
count is the knowledge of the coding.

- The *mark* (once the Unicode.org terminology in FAQ) indicating
a unicode encoded raw text file is neither a byte order mark,
nor a signature, it is an encoded code point, the encoded
U+FEFF, 'ZERO WIDTH NO-BREAK SPACE', code point. (Note, a
non breaking space at the start of a text is a non sense.)

- When such a mark exists, it is always possible to work
100% safely. No possible error.

- When such a mark does not exist, in many cases only
guessing is a (the) valid solution.

These are facts.


Now to the question, should I use (put) such a mark,
esp. in utf-8? I would say the following:

It seems to me, one see more and more marked utf-8 files.
(Windows is probably a reason.)

More importantly, more and more tools and software are
handling this utf-8 mark, or are corrected to support it,
so it basicaly does not hurt too much. Eg. Python, golang 1.1
(was not the case in 1.0), LibreOffice, TeXWorks supports it
now (was once not the case), the unicode TeX engines, ...

If I had to work in archiving, it would seriously think
twice.

PS Unicode encodes characters on a per *script* (alphabet)
basis, not per *language*.

jmf

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


removing BOM prepended by codecs?

2013-09-24 Thread J. Bagg
My editor is JEdit. I use it on a Win 7 machine but have everything set 
up for *nix files as that is the machine I'm normally working on.


The files are mailed to me as updates. The library where the indexers 
work do use MS computers but this is restricted to EndNote with an 
exporter into the old Bib-Refer format which we use. I then run them 
through a Python program to check the unicode for new characters that 
also creates an ascii transliteration of the main fields and checks for 
errors.


The problem is occuring at the search stage. This stage creates a script 
with directives to search particular years and then puts the results 
into a file in /tmp. The process is left over from an old CGI version 
but is efficient and so has been kept. This has been done with a very 
old C program that a collegue wrote back in the 90s with more recent 
updates. I'm in the process of updating this to Python as it is getting 
too difficult to maintain.


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


Re: Help with python functions?

2013-09-24 Thread Denis McMahon
On Tue, 24 Sep 2013 14:51:31 +, Denis McMahon wrote:

 Question, given the original temp function as previously described by
 yourself, what does the following function f which takes the same
 params as comp do:
 
 def f( t1, u1, t2, u2 ):
 if u1 == u2:
 return t2
 else:
 return temp( t2, u2, u1 )

Hmm, maybe:

if u1 == u2:

should have been:

if u1.lower() == u2.lower():

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: removing BOM prepended by codecs?

2013-09-24 Thread Chris Angelico
On Wed, Sep 25, 2013 at 4:43 AM,  wxjmfa...@gmail.com wrote:
 - The *mark* (once the Unicode.org terminology in FAQ) indicating
 a unicode encoded raw text file is neither a byte order mark,
 nor a signature, it is an encoded code point, the encoded
 U+FEFF, 'ZERO WIDTH NO-BREAK SPACE', code point. (Note, a
 non breaking space at the start of a text is a non sense.)

 - When such a mark exists, it is always possible to work
 100% safely. No possible error.

I have a file encoded in Latin-1 which begins with LATIN SMALL LETTER
Y WITH DIAERESIS followed by LATIN SMALL LETTER THORN. I also have a
file encoded in EBCDIC (okay, I don't really, but let's pretend) that
begins with the same bytes. But of course, when such a mark exists,
there is no possible error - of that there is no manner of doubt, no
possible, probable shadow of doubt, no possible doubt whatever.

(No possible doubt whatever.)

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


Re: removing BOM prepended by codecs?

2013-09-24 Thread Piet van Oostrum
J. Bagg j.b...@kent.ac.uk writes:

 I've checked the original files using od and they don't have BOMs.

 I'll remove them in the servlet. The overhead is probably small enough
 unless somebody is doing a massive search. We have a limit anyway to
 prevent somebody stealing the entire set of data.

 I started writing the Python search because the ancient C search had
 started putting out BOMs. I'm actually mystified because our home Linux
 box does not add BOMs even though it runs 2.7 but my work one does even
 though it has the same version. The only difference is Fedora 18 v
 Fedora 17.

 The BOMs are certainly there:

 86 ADFB%R 10C0203z-621
 %A François-Xavier Le_Bourdonnec

 000 206 255 373   %   R   1   0   C   0   2   0   3   z   -

That is not a BOM or SIG. It isn't even valid utf-8.
-- 
Piet van Oostrum p...@vanoostrum.org
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue18764] The pdb print command prints repr instead of str in python3

2013-09-24 Thread Connor Osborn

Connor Osborn added the comment:

In 2.7 there is no documented command *print, the docs are explicit on this 
(it's just the built in statement). However, 3.4 treats print like a feature of 
2.7. Is this to maintain backwards compatibility? I would suggest preserving 
the original direction of the pdb, where a user has access to a p command but a 
user can always use the built in python print function.

in short:
-remove print from documented commands
-remove print alias

*This is my first patch :P Let me know if this is the correct direction, and 
what needs to be changed for acceptance, thanks.

--
keywords: +patch
Added file: http://bugs.python.org/file31855/18764.patch

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



[issue17777] Unrecognized string literal escape sequences give SyntaxErrors

2013-09-24 Thread Tim Golden

Tim Golden added the comment:

Closing as Works for me in the absence of any clear proposal for docs 
improvement.

--
resolution:  - works for me
stage: needs patch - committed/rejected
status: open - closed

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



[issue19079] chameleon benchmark fails on 3.4

2013-09-24 Thread Brett Cannon

Brett Cannon added the comment:

Decorator sounds reasonable.

--

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



[issue19079] chameleon benchmark fails on 3.4

2013-09-24 Thread Brett Cannon

Brett Cannon added the comment:

Actually, one perk of the ranges is 2n3 can be auto-calculated.

--

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



[issue16038] ftplib: unlimited readline() from connection

2013-09-24 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

I believe the problem is the set of next_retr_data attribute here:

def test_retrlines_too_long(self):
self.server.handler.next_retr_data = 'x' * self.client.maxline * 2

...because self.server.handler runs in a different thread (different than the 
main one, which is where the setattr() occurs).
We should introduce a new command in the dummy FTP server which sets 
next_retr_data from within the server thread itself. Will try to work on a 
patch later this week (I'm sorry but I can't make it earlier).

--

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



[issue16038] ftplib: unlimited readline() from connection

2013-09-24 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

On Sep 24, 2013, at 01:12 PM, Giampaolo Rodola' wrote:

Giampaolo Rodola' added the comment:

I believe the problem is the set of next_retr_data attribute here:

def test_retrlines_too_long(self):
self.server.handler.next_retr_data = 'x' * self.client.maxline * 2

...because self.server.handler runs in a different thread (different than the
main one, which is where the setattr() occurs).  We should introduce a new
command in the dummy FTP server which sets next_retr_data from within the
server thread itself. Will try to work on a patch later this week (I'm sorry
but I can't make it earlier).

+1 - that explanation makes a lot of sense, thanks!

Currently 2.6.9rc1 is planned for Monday 30-September.  It would be nice to
get this one in before then, but if not that's okay.  I think it's fairly low
risk.

--

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



[issue18764] The pdb print command prints repr instead of str in python3

2013-09-24 Thread R. David Murray

R. David Murray added the comment:

Looks good to me.

This seems like a mistake in the python3 port to me.  I'm in favor of fixing it 
as a bug.  As release manager and pdb expert, what do you think, Georg?

--

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



[issue19082] Lib/xmlrpc/client.py demo code points to the dead server

2013-09-24 Thread Vajrasky Kok

New submission from Vajrasky Kok:

Lib/xmlrpc/client.py tries to connect to http://time.xmlrpc.com/RPC2 which has 
been dead for a while. I see there is no light in the end of tunnel. Since 
this code is meant to be a demo not a general purpose tool, I say why don't we 
direct it to localhost (which can be provided by Lib/xmlrpc/server.py).

After applying this patch, you can start the server:
$ python Lib/xmlrpc/server.py
Serving XML-RPC on localhost port 8000

Then in another place, you can start the client and get result straight away:
$ python Lib/xmlrpc/client.py
2013-09-24T22:35:27
2013-09-24T22:35:27
512
3

Isn't that beautiful?

--
components: Library (Lib)
files: xmlrpc_server_client_demo.patch
keywords: patch
messages: 198359
nosy: vajrasky
priority: normal
severity: normal
status: open
title: Lib/xmlrpc/client.py demo code points to the dead server
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31856/xmlrpc_server_client_demo.patch

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



[issue19082] Lib/xmlrpc/client.py demo code points to the dead server

2013-09-24 Thread Vajrasky Kok

Changes by Vajrasky Kok sky@speaklikeaking.com:


Removed file: http://bugs.python.org/file31856/xmlrpc_server_client_demo.patch

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



[issue19082] Lib/xmlrpc/client.py demo code points to the dead server

2013-09-24 Thread Vajrasky Kok

Changes by Vajrasky Kok sky@speaklikeaking.com:


Added file: http://bugs.python.org/file31857/xmlrpc_server_client_demo.patch

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



[issue19083] IDNA prefix should be case insensitive

2013-09-24 Thread Pepijn de Vos

New submission from Pepijn de Vos:

RFC 3490 states that The ACE prefix for IDNA is xn-- or any capitalization 
thereof.

But the following does not work

 str(bXN--pythn-mua.org., idna)

--
components: Library (Lib)
files: upper-idna.patch
keywords: patch
messages: 198360
nosy: Pepijn.de.Vos
priority: normal
severity: normal
status: open
title: IDNA prefix should be case insensitive
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file31858/upper-idna.patch

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



[issue19082] Lib/xmlrpc/client.py demo code points to the dead server

2013-09-24 Thread R. David Murray

R. David Murray added the comment:

Sure :)

If you want some bonus points, can you figure out whether or not the test in 
test_xmlrpc_net is worth moving to test_xmlrpc using a similar local-server 
approach, or if it is redundant and should just be deleted?

(time.xmlrcp.com has come and gone multiple times over the years...)

--
nosy: +r.david.murray

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



[issue19081] zipimport behaves badly when the zip file changes while the process is running

2013-09-24 Thread Gregory P. Smith

Gregory P. Smith added the comment:

Here's a fix (the test is now in the patch).

--
keywords: +needs review
stage:  - patch review
Added file: http://bugs.python.org/file31860/issue19081-gps01.diff

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



[issue19084] No way to use TLS-PSK from python ssl

2013-09-24 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
nosy: +barry

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



[issue19084] No way to use TLS-PSK from python ssl

2013-09-24 Thread Karl Palsson

New submission from Karl Palsson:

OpenSSL supports TLS-PSK which some people (myself obviously) find to be 
substantially easier to use than setting up certs.

However, there's no way to use PSK via the current SSL api in python.  It would 
be very nice to be able to use PSK from python.

For OpenSSL, even the C API is particularly easy.  Attached is the 
implementation used in Mosquitto, a MQTT message broker that supports both cert 
based and PSK based TLS.

--
components: Library (Lib)
files: 5bcfpEKD.txt
messages: 198362
nosy: karlp
priority: normal
severity: normal
status: open
title: No way to use TLS-PSK from python ssl
type: behavior
versions: Python 2.7, Python 3.4
Added file: http://bugs.python.org/file31859/5bcfpEKD.txt

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



[issue19084] No way to use TLS-PSK from python ssl

2013-09-24 Thread Jesús Cea Avión

Jesús Cea Avión added the comment:

Python 2.7 is open only for bugfixes. No new features.

Do you dare to write a patch for Python 3.4? :-). If you do, remember to sign a 
Contributor Agreement.

Give it a try! :)

--
nosy: +jcea
versions:  -Python 2.7

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



[issue19084] No way to use TLS-PSK from python ssl

2013-09-24 Thread Roger Light

Changes by Roger Light ro...@atchoo.org:


--
nosy: +ralight

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



[issue19081] zipimport behaves badly when the zip file changes while the process is running

2013-09-24 Thread Daniel Stutzbach

Changes by Daniel Stutzbach stutzb...@google.com:


--
nosy: +stutzbach

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



[issue19084] No way to use TLS-PSK from python ssl

2013-09-24 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Is it different from TLS SRP, which already has a feature request in issue11943?
As Jesus said, feel free to propose a patch, even a proof of concept so that we 
start discussing the API.

--
nosy: +christian.heimes, giampaolo.rodola, janssen, pitrou
stage:  - needs patch
type: behavior - enhancement

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



[issue19085] Add tkinter basic options tests

2013-09-24 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

The proposed patch adds tests for all options of all widgets. They test that 
widgets support all documented options, accepts valid values in different 
formats, reject invalid values, and return values in expected format. This 
would be helpful for regression testing.

The patch tested with Tcl/Tk 8.5 and 8.6 on Linux. All new tests are compatible 
with wantobjects=1 and wantobjects=0.

It will be good to test it with Tcl/Tk 8.4 (or even 8.3) and on Windows.

--
components: Tests, Tkinter
files: tkinter_options_tests.patch
keywords: patch
messages: 198366
nosy: gpolo, serhiy.storchaka, terry.reedy
priority: normal
severity: normal
stage: patch review
status: open
title: Add tkinter basic options tests
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file31861/tkinter_options_tests.patch

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



[issue18844] allow weights in random.choice

2013-09-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Most existing implementation produce just index. That is why weighted_choice() 
accepts singular weights list and returns index. On the other hand, I think 
working with mapping will be wished feature too (especially because Counter is 
in stdlib). Indexable sequences and mappings are similar. In both cases 
weighted_choice() returns value which can be used as index/key of input 
argument.

If you need choice an element from some sequence, just use 
seq[weighted_choice(weights)]. Actually weighted_choice() has no common code 
with choice() and has too different use cases. They should be dissimilar as far 
as possible. Perhaps we even should avoid the choice part in function names 
(are there any ideas?) to accent this.

--

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



[issue17618] base85 encoding

2013-09-24 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +haypo

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



[issue19077] More robust TemporaryDirectory cleanup

2013-09-24 Thread STINNER Victor

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


--
nosy: +haypo

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



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2013-09-24 Thread STINNER Victor

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


--
nosy: +haypo

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



[issue19050] crash while writing to a closed file descriptor

2013-09-24 Thread STINNER Victor

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


--
nosy: +haypo

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



[issue19058] test_sys.test_ioencoding_nonascii() fails with ASCII locale encoding

2013-09-24 Thread STINNER Victor

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


--
title: test_ioencoding_nonascii (test_sys) fails on Snow Leopard - 
test_sys.test_ioencoding_nonascii() fails with ASCII locale encoding

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



[issue16038] ftplib: unlimited readline() from connection

2013-09-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch.

--
Added file: http://bugs.python.org/file31862/ftplib_maxline.patch

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



[issue19046] SystemError: ..\Objects\weakrefobject.c:903: bad argument to internal function

2013-09-24 Thread STINNER Victor

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


--
nosy: +haypo

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



[issue19058] test_sys.test_ioencoding_nonascii() fails with ASCII locale encoding

2013-09-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Shouldn't FS_NONASCII be None with ASCII locale encoding?

--

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



[issue19058] test_sys.test_ioencoding_nonascii() fails with ASCII locale encoding

2013-09-24 Thread STINNER Victor

STINNER Victor added the comment:

Shouldn't FS_NONASCII be None with ASCII locale encoding?

See the description of the variable in test.support:

# FS_NONASCII: non-ASCII character encodable by os.fsencode(),
# or None if there is no such character.

The file system encoding an the locale encoding can be different... especially 
when PYTHONIOENCODING is used.

The test should not use FS_NONASCII.

--

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



[issue16038] ftplib: unlimited readline() from connection

2013-09-24 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

On Sep 24, 2013, at 09:59 PM, Serhiy Storchaka wrote:

Added file: http://bugs.python.org/file31862/ftplib_maxline.patch

This looks great and fixes the test failure problem.  Thanks!  Serhiy, please
feel free to apply this to the 2.6 branch, or let me know if you'd rather I
apply it.

--

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



[issue18844] allow weights in random.choice

2013-09-24 Thread Madison May

Madison May added the comment:

You have me convinced, Serhiy.  I see the value in making the two functions 
distinct.

For naming purposes, perhaps weighted_index() would be more descriptive.

--

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



[issue19085] Add tkinter basic options tests

2013-09-24 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +ned.deily

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



[issue19071] Documentation on what self is for module-level functions is misleading/wrong.

2013-09-24 Thread A. Jesse Jiryu Davis

Changes by A. Jesse Jiryu Davis je...@emptysquare.net:


--
nosy: +emptysquare

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



[issue19058] test_sys.test_ioencoding_nonascii() fails with ASCII locale encoding

2013-09-24 Thread R. David Murray

R. David Murray added the comment:

Also note that on OS X I believe the fsencoding is always utf-8, but the locale 
can of course be something else.

--

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



[issue19011] Enum should have a __getattr__ that makes all the instances available from an instance

2013-09-24 Thread Ethan Furman

Ethan Furman added the comment:

As discussed on PyDev[1], Enum members are bonafide class attributes, as in 
they show on the class, not on the instances.

Documentation patch attached.

[1] https://mail.python.org/pipermail/python-dev/2013-September/128874.html

--
stage:  - patch review
type:  - behavior
Added file: http://bugs.python.org/file31863/issue19011.stoneleaf.01.patch

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



[issue19040] Problems with overriding Enum.__new__

2013-09-24 Thread Ethan Furman

Ethan Furman added the comment:

Doc patch is in #19011.  I'll close this one when that one is closed.

--

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



[issue18596] enable usage of AddressSanitizer in CPython [PATCH]

2013-09-24 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
nosy: +ncoghlan

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