Wing IDE 5.0.8 released

2014-07-23 Thread Wingware

Hi,

Wingware has released version 5.0.8 of Wing IDE, our cross-platform 
integrated

development environment for the Python programming language.

Wing IDE includes a professional quality code editor with vi, emacs, 
visual studio,
and other key bindings, auto-completion, call tips, goto-definition, 
find uses, refactoring,
context-aware auto-editing, a powerful graphical debugger, version 
control, unit testing,

search, and many other features.  For details see http://wingware.com/

Changes in this minor release include:

Debug stack is accessible from the toolbar's Show Position icon
Added Step Over Statement and Step Over Block to step through code 
more rapidly
Added experimental selection-add-next-occurence command for 
creating multiple selections

Added step-over-line command to step over current physical line
Fix debugging with Stackless 2.7.8
Fix debugging 32-bit Python on OS X
About 34 other bug fixes; see the change log for details

For details see http://wingware.com/pub/wingide/5.0.8/CHANGELOG.txt

A summary of new features in Wing 5:

Native GUI on OS X and better overall OS-native look and feel
Draggable tools and editors
Configurable toolbar and editor  project context menus
Lockable editor splits and mode to open different files in each split
Sharable color palettes and syntax highlighting configurations
Auto-editing is on by default (except some operations that have a 
learning curve)
Optional Python Turbo completion (context-appropriate completion on 
all non-symbol keys)
Improved Source Assistant with PEP 287 docstring rendering and 
return types

Move debug program counter
Named file sets
New Project dialog
Sharable launch configurations and named entry points
Asynchronous I/O in Debug Probe and Python Shell
More control over unit testing environment
Initial preferences dialog for new users
Support for Python 3.4 and Stackless Python 2.7 and 3.3
Support for Django 1.6
Support for matplotlib on Anaconda and with MacOSX backend
Support for Maya 2015, MotionBuilder 2015, Nuke 8, and Source Filmmaker
Improved integrated and PDF documentation
Expanded and rewritten tutorial
Multiple selections
Debug stepping by physical line, statement, and block

For more information on what's new in Wing 5, see 
http://wingware.com/wingide/whatsnew


Free trial: http://wingware.com/wingide/trial
Downloads: http://wingware.com/downloads
Feature list: http://wingware.com/wingide/features
Sales: http://wingware.com/store/purchase
Upgrades: https://wingware.com/store/upgrade

Questions?  Don't hesitate to email us at supp...@wingware.com.

Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com

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

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


Re: Question about Pass-by-object-reference?

2014-07-23 Thread Chris Angelico
On Wed, Jul 23, 2014 at 3:35 PM, Steven D'Aprano st...@pearwood.info wrote:
 If you say nothing is being passed, then my response would be Oh, you
 aren't calling the function at all? Or just calling it with no arguments?

The latter. Suppose you have a class method that takes optional args,
and you override it in a subclass. The subclass's method may choose to
swallow any args it was given, and pass nothing to the super()
method. I have code doing exactly this, and sometimes it's important
to comment it as such (although I'll usually word it as pass on no
args or something, rather than just pass nothing). But yes. If
there are any arguments, they are being passed.

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


Re: Is it possible to install Python on a network?

2014-07-23 Thread Chris Angelico
On Wed, Jul 23, 2014 at 2:18 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 roys2005 roys2...@gmail.com writes:

 Does this mean Python cannot be or should not be installed at a
 central location?

 Can you explain better what you mean by this?

 As stated, it doesn't make much sense to me: Any machine which supports
 running Python can be central or distributed, but it can only be invoked
 on the same machine. What does it mean *to you* to say “install Python
 on a network”?

On one computer, install Python into /foo/bar/spam/python. On another
computer, mount firstcomputer:/foo/bar/spam as /foo/bar/spam. Run
Python the same way on both systems.

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


Re: Question about Pass-by-object-reference?

2014-07-23 Thread Ben Finney
Steven D'Aprano st...@pearwood.info writes:

 On Wed, 23 Jul 2014 11:59:45 +1000, Ben Finney wrote:
  fl rxjw...@gmail.com writes:
  On Tuesday, July 22, 2014 8:27:15 PM UTC-4, Terry Reedy wrote:
   Nothing is being 'passed'.
 
  Thanks, but I don't understand your point yet. Could you give me
  another example in which something is passed?
  
  The point being made is that no values are is “passed” in a function
  call. If you have learned that term from elsewhere, it doesn't apply
  sensibly to Python.

 Hmmm. I don't know that I like that. I think that these two sentences 
 mean the same thing:

 Call the function with x as argument.
 Pass x to the function.

 They both describe what is being done, only from slightly different 
 points of view.

You're free to think that, but I'm agreeing with Terry that the
conflation is unwarranted and confusing in the attempt to explain what
is happening.

Rather, “Call the function ‘foo’ with ‘x’ as an argument” has no
implication that the argument ‘x’ travels anywhere, or is exclusively
located either inside the function or out of it, or any other inferences
that are invited by the statement “Pass ‘x’ to the function”.

So you may *intend* them to mean the same thing. But the terminology
comes with baggage, both from other programming languages and from
non-programming meanings of the English word “pass”. They don't
communicate the same thing.

 In mathematics, to call a function is a completely abstract action.

Right, and the terms aren't located anywhere we need to identify, they
don't travel anywhere, and “pass” isn't used to refer to them. These are
good reasons for avoiding the statement “pass a value ‘x’ to the
function ‘foo’”.

 But in programming languages, calling a function has concrete actions:
 certain things have to happen even before the function itself
 executes. What sort of things? Well, for starters, somehow the
 arguments need to be passed to the function

No. The function needs to *know what the arguments are*. Using the verb
“pass” to refer to an action which has nothing to do with motion through
any space is clearly confusing the matter here.

 If you say nothing is being passed, then my response would be Oh,
 you aren't calling the function at all? Or just calling it with no
 arguments?

To which my response is “You're mistakenly conflating the above two
statements”.


Steven D'Aprano st...@pearwood.info writes:

 On Tue, 22 Jul 2014 20:27:15 -0400, Terry Reedy wrote:

  When you call a function, Python binds function parameter names to
  argument objects in the function's local namespace, the same as in
  name assignments. […] Nothing is being 'passed'.

 If nothing is being passed, how does the function know to bind 1 and
 'x' to names a and b, rather than (say) this?

 a, b = 23, 'Surprise!

Because the objects 1 and 'x' are made known to and made available to
the function. They're not passed because they don't go anywhere.

I acknowledge that “pass the value 1 to the function ‘foo’” is
entrenched and I'm not advocating to remove it, but it's foolish to
ignore that this term invites unwarranted inferences.

Heck, you have argued strongly that the whole “how are values passed in
Python?” question is rather misguided and can only be answered by
casting out assumptions about “pass”. I'm saying the mis-guidance comes
from using the verb “pass a value” for an action that doesn't involve
values going anywhere.

-- 
 \  “It is the integrity of each individual human that is in final |
  `\examination. On personal integrity hangs humanity's fate.” |
_o__)   —Richard Buckminster Fuller, _Critical Path_, 1981 |
Ben Finney

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


Re: What Next After Python Basics

2014-07-23 Thread Orochi
Ok 
Thank You Guys for the suggestions.
I am starting with simple Data Structures and Algorithm studied in 
College,trying to code them in python.
Besides I am also trying to use Python in competitive programming.(codechef.com)
Its fun.

Thank you all !
-- 
https://mail.python.org/mailman/listinfo/python-list


My sys.excepthook dies painfully

2014-07-23 Thread Steven D'Aprano
I have some code which sets up a logger instance, then installs it as 
sys.excepthook to capture any uncaught exceptions:



import logging
import logging.handlers
import sys

FACILITY = logging.handlers.SysLogHandler.LOG_LOCAL6
mylogger = logging.getLogger('spam')
handler = logging.handlers.SysLogHandler(
address='/dev/log', facility=FACILITY)
formatter = logging.Formatter(%(levelname)s:%(message)s [%(module)s])
handler.setFormatter(formatter)
mylogger.addHandler(handler)
mylogger.setLevel(logging.DEBUG)
mylogger.info('started logging')

def my_error_handler(type, value, tb):
msg = Uncaught %s: %s % (type, value)
mylogger.exception(msg)
sys.__excepthook__(type, value, tb)  # print the traceback to stderr

# Install exception handler.
mylogger.info('installing error handler')
sys.excepthook = my_error_handler

foo  # Die with uncaught NameError.



If I run this code, the INFO logging messages are logged, but the 
exception is not. Instead it is printed to the console:


Error in sys.excepthook:
Traceback (most recent call last):
  File /home/steve/mylogging.py, line 28, in my_error_handler
mylogger.exception(msg)
AttributeError: 'NoneType' object has no attribute 'exception'

Original exception was:
Traceback (most recent call last):
  [...]
  File /home/steve/mylogging.py, line 35, in module
foo
NameError: name 'foo' is not defined



(I've trimmed out some of the traceback, because the details aren't 
relevant.)

Any ideas what I'm doing wrong? How does mylogger get set to None?



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


Re: Distributing python applications as a zip file

2014-07-23 Thread Tim Golden
On 23/07/2014 06:30, Gary Herron wrote:
 On 07/22/2014 09:23 PM, Steven D'Aprano wrote:
 A little known feature of Python: you can wrap your Python application in
 a zip file and distribute it as a single file.


  Really!  20 years of Pythoning, and I'd never seen this!  When was this
 introduced?

This post by Brett Cannon is useful:


http://sayspy.blogspot.co.uk/2010/03/various-ways-of-distributing-python.html

I was trying to track down a presentation in the same vein which I saw
him give at EuroPython a few years ago, but I can't seem to find it. It
basically says the same thing but it's a slightly clearer read.

TJG


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


Re: My sys.excepthook dies painfully

2014-07-23 Thread Chris Angelico
On Wed, Jul 23, 2014 at 5:14 PM, Steven D'Aprano st...@pearwood.info wrote:
 Error in sys.excepthook:
 Traceback (most recent call last):
   File /home/steve/mylogging.py, line 28, in my_error_handler
 mylogger.exception(msg)
 AttributeError: 'NoneType' object has no attribute 'exception'

 Original exception was:
 Traceback (most recent call last):
   [...]
   File /home/steve/mylogging.py, line 35, in module
 foo
 NameError: name 'foo' is not defined

I was not able to repro this with the 3.5-messy that I have on this
system, nor a clean 3.4.1 from Debian Jessie. It's slightly different:

rosuav@dewey:~$ python3 mylogging.py
Error in sys.excepthook:
Traceback (most recent call last):
  File /usr/lib/python3.4/logging/__init__.py, line 846, in handle
self.emit(record)
  File /usr/lib/python3.4/logging/handlers.py, line 881, in emit
msg = self.format(record)
  File /usr/lib/python3.4/logging/__init__.py, line 821, in format
return fmt.format(record)
  File /usr/lib/python3.4/logging/__init__.py, line 566, in format
record.exc_text = self.formatException(record.exc_info)
  File /usr/lib/python3.4/logging/__init__.py, line 516, in formatException
traceback.print_exception(ei[0], ei[1], tb, None, sio)
  File /usr/lib/python3.4/traceback.py, line 169, in print_exception
for line in _format_exception_iter(etype, value, tb, limit, chain):
  File /usr/lib/python3.4/traceback.py, line 146, in _format_exception_iter
for value, tb in values:
  File /usr/lib/python3.4/traceback.py, line 125, in _iter_chain
context = exc.__context__
AttributeError: 'NoneType' object has no attribute '__context__'

Original exception was:
Traceback (most recent call last):
  File mylogging.py, line 24, in module
foo  # Die with uncaught NameError.
NameError: name 'foo' is not defined

(Obviously that's the clean 3.4, but it's the same exception in 3.5.)

From what I can see, the problem is that sys.exc_info() is returning
None, None, None at this point, and the Logger.exception() method
specifically looks for the currently-being-handled exception. You can
get equivalent functionality with this:

def my_error_handler(type, value, tb):
msg = Uncaught %s: %s % (type, value)
mylogger.error(msg, exc_info=(type, value, tb))
sys.__excepthook__(type, value, tb)  # print the traceback to stderr

At least, I think that's correct. It does seem to dump a lot of stuff
into a single line in the log, though.

Can't repro your exact traceback, though, so I don't know what's going on there.

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


Re: My sys.excepthook dies painfully

2014-07-23 Thread Steven D'Aprano
On Wed, 23 Jul 2014 07:14:27 +, Steven D'Aprano wrote:

 I have some code which sets up a logger instance, then installs it as
 sys.excepthook to capture any uncaught exceptions:

Oh! I should have said, I'm running Python 2.6.



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


Re: Distributing python applications as a zip file

2014-07-23 Thread Chris Angelico
On Wed, Jul 23, 2014 at 2:23 PM, Steven D'Aprano st...@pearwood.info wrote:
 On Linux, you can even hack the zip file to include a shebang line!


 steve@runes:~$ cat appl
 #!/usr/bin/env python
 # This is a Python application stored in a ZIP archive.
 steve@runes:~$ cat appl.zip  appl
 steve@runes:~$ chmod u+x appl
 steve@runes:~$ ./appl
 NOBODY expects the Spanish Inquisition!!!

This, by the way, depends on a feature of the zip file format: you
start reading from the back, with the key indexes, and then come to
the front. It's designed to allow various self-extracting archive
formats to be easily unzipped (imagine, if you will, a SFX built for
Windows when you're on Unix - rather than try to run the program (with
all the difficulties and risks that would entail), you just unzip it),
and it works nicely here too. I suppose, then, it would be possible to
make a minimal Unix SFX prefix: #!/usr/bin/env unzip\n on the
beginning of a zip should do the job :)

(Yes, I'm aware that that violates most of the point of an SFX, in
that the target system doesn't need to have pkunzip installed, but
it's still neat how short it can be.)

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


Re: My sys.excepthook dies painfully

2014-07-23 Thread Chris Angelico
On Wed, Jul 23, 2014 at 5:46 PM, Steven D'Aprano st...@pearwood.info wrote:
 On Wed, 23 Jul 2014 07:14:27 +, Steven D'Aprano wrote:

 I have some code which sets up a logger instance, then installs it as
 sys.excepthook to capture any uncaught exceptions:

 Oh! I should have said, I'm running Python 2.6.

Ah! I tried it in 2.7 and it seemed to work. One moment...

huix@huix:~$ python mylogging.py
Traceback (most recent call last):
  File mylogging.py, line 24, in module
foo  # Die with uncaught NameError.
NameError: name 'foo' is not defined
huix@huix:~$ python -V
Python 2.6.6
huix@huix:~$ tail /var/log/syslog
...
Jul 23 18:01:49 huix INFO: started logging [mylogging]
Jul 23 18:01:49 huix INFO: installing error handler [mylogging]
Jul 23 18:01:49 huix ERROR: Uncaught type 'exceptions.NameError':
name 'foo' is not defined [mylogging]#012None

Still not sure what's going on. Odd.

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


Re: Distributing python applications as a zip file

2014-07-23 Thread Thomas Heller

Am 23.07.2014 06:23, schrieb Steven D'Aprano:

A little known feature of Python: you can wrap your Python application in
a zip file and distribute it as a single file. The trick to make it
runnable is to put your main function inside a file called __main__.py
inside the zip file.


Look here:

http://legacy.python.org/dev/peps/pep-0441/
https://pypi.python.org/pypi/pyzzer
https://pypi.python.org/pypi/pyzaa/0.1.0

Or write your own little utility to create such a thing, it's not 
complicated.


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


Re: Distributing python applications as a zip file

2014-07-23 Thread Leo Jay
On Wed, Jul 23, 2014 at 12:23 PM, Steven D'Aprano st...@pearwood.info wrote:
 A little known feature of Python: you can wrap your Python application in
 a zip file and distribute it as a single file. The trick to make it
 runnable is to put your main function inside a file called __main__.py
 inside the zip file. Here's a basic example:

 steve@runes:~$ cat __main__.py
 print(NOBODY expects the Spanish Inquisition!!!)

 steve@runes:~$ zip appl __main__.py
   adding: __main__.py (stored 0%)
 steve@runes:~$ rm __main__.py
 steve@runes:~$ python appl.zip
 NOBODY expects the Spanish Inquisition!!!


 On Linux, you can even hack the zip file to include a shebang line!


 steve@runes:~$ cat appl
 #!/usr/bin/env python
 # This is a Python application stored in a ZIP archive.
 steve@runes:~$ cat appl.zip  appl
 steve@runes:~$ chmod u+x appl
 steve@runes:~$ ./appl
 NOBODY expects the Spanish Inquisition!!!


 It's not quite self-contained, as you still need to have Python
 installed, but otherwise it's a good way to distribute a Python
 application as a single file that users can just copy and run.


But if you use windows and you happen to use multiprocessing,
please be aware of this bug I encountered several years ago.
https://mail.python.org/pipermail/python-dev/2011-December/115071.html

-- 
Best Regards,
Leo Jay
-- 
https://mail.python.org/mailman/listinfo/python-list


What is a nit(sp?) function.

2014-07-23 Thread Antoon Pardon
I have been looking at some python talks on you tube:

https://www.youtube.com/watch?v=o9pEzgHorH0

and

https://www.youtube.com/watch?v=sPiWg5jSoZI

And these two both mentioned nits or nit functions or something
like that. I tried to google it but came up empty.

Anyone an idea what they are talking about.

-- 
Antoon Pardon

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


RE: Automating windows media player on win7

2014-07-23 Thread Deogratius Musiige
Hi mate,



The fix you provided works perfect. However, if I put it in a class and import, 
make instance and execute in another file, the audio is not played.

What am I missing? This is what I do:



FileA.py
class WMPlayer():
'''
@
'''
#static var
#first instance is a primary , following are secondary.
#you can have one primary and as many secondary as you like
def __init__(self):
'''
init all attributes
'''
#self.mp = Dispatch(WMPlayer.OCX)
#pass

def play_song(self):
mp = Dispatch(WMPlayer.OCX)
tune = mp.newMedia(r./SleepAway.mp3)
mp.currentPlaylist.appendItem(tune)
mp.controls.play()
sleep(1)
mp.controls.playItem(tune)
raw_input(Press Enter to stop playing)
#sleep(5)

mp.controls.stop()



FileB.py

from wmp.WMPlayer import *



class sTest(unittest.TestCase):


def test_wmplayer(self):
self.wmp = WMPlayer()

self.wmp.play_song()







Best regards / Med venlig hilsen



Deogratius Musiige

Sennheiser Communications A/S

Direct +45 5618 0320





-Original Message-
From: Python-list [mailto:python-list-bounces+demu=senncom@python.org] On 
Behalf Of Deogratius Musiige
Sent: 6. juni 2014 15:39
To: MRAB; python-list@python.org
Subject: RE: Automating windows media player on win7



Thanks a lot mate.



You just made my day.

I have looked around the net but cannot find the controls available.



I would like to be able to:

- get current playing track

- get wmplayer state (playing/paused/stopped)

- get the selected sound device



Thanks a lot



Br

Deo

-Original Message-

From: Python-list [mailto:python-list-bounces+demu=senncom@python.org] On 
Behalf Of MRAB

Sent: 4. juni 2014 21:23

To: python-list@python.orgmailto:python-list@python.org

Subject: Re: Automating windows media player on win7



On 2014-06-03 09:10, Deogratius Musiige wrote:

 Hi guys,



 I have been fighting with automating wmplayer but with no success.



 It looks to me that using the .OCX would be the best option. I found

 the code below on the net but I cannot get it to work.



 I can see from device manager that a driver is started by I get no

 audio out.



 What am I doing wrong guys?



 # this program will play MP3, WMA, MID, WAV files via the

 WindowsMediaPlayer from win32com.client import Dispatch



 mp = Dispatch(WMPlayer.OCX)

 tune = mp.newMedia(./plays.wav)

 mp.currentPlaylist.appendItem(tune)

 mp.controls.play()

 raw_input(Press Enter to stop playing)

 mp.controls.stop()



I've found that adding PlayItem and sleep seems to work:



#! python2.7

# -*- coding: utf-8 -*-

from win32com.client import Dispatch

from time import sleep



mp = Dispatch(WMPlayer.OCX)

tune = mp.NewMedia(r./plays.wav)

mp.CurrentPlaylist.AppendItem(tune)

mp.Controls.Play()

sleep(1)

mp.Controls.PlayItem(tune)

raw_input(Press Enter to stop playing)

mp.Controls.Stop()



--

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



--

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


Re: What is a nit(sp?) function.

2014-07-23 Thread Chris Angelico
On Wed, Jul 23, 2014 at 7:43 PM, Antoon Pardon
antoon.par...@rece.vub.ac.be wrote:
 I have been looking at some python talks on you tube:

 https://www.youtube.com/watch?v=o9pEzgHorH0

 and

 https://www.youtube.com/watch?v=sPiWg5jSoZI

 And these two both mentioned nits or nit functions or something
 like that. I tried to google it but came up empty.

They're fairly long, each; can you point me to the exact point where
the term is said?

It might be an accent difference on a word like neat as in simple,
tidy, elegant.

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


Re: What is a nit(sp?) function.

2014-07-23 Thread Peter Otten
Antoon Pardon wrote:

 I have been looking at some python talks on you tube:
 
 https://www.youtube.com/watch?v=o9pEzgHorH0
 
 and
 
 https://www.youtube.com/watch?v=sPiWg5jSoZI
 
 And these two both mentioned nits or nit functions or something
 like that. I tried to google it but came up empty.
 
 Anyone an idea what they are talking about.
 

__init__ ?

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


Question about asyncio doc example

2014-07-23 Thread Saimadhav Heblikar
Hi,

The example in question is
https://docs.python.org/3/library/asyncio-task.html#example-hello-world-coroutine.
I'd like to learn the purpose of the statement
yield from asyncio.sleep(2) in that example.

In particular, I'd like to know if asyncio.sleep() is used as a
substitute for slow/time consuming operation, i.e. in real code,
whether there will be a real time consuming statement in place of
asyncio.sleep().

-- 
Regards
Saimadhav Heblikar
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Automating windows media player on win7

2014-07-23 Thread MRAB

On 2014-07-23 10:20, Deogratius Musiige wrote:


Hi mate,

The fix you provided works perfect. However, if I put it in a class 
and import, make instance and execute in another file, the audio is 
not played.


What am I missing? This is what I do:

I'm assuming that you're not actually calling the files FileA.py and 
FileB.py.


*FileA.py*


You need these imports:

from win32com.client import Dispatch
from time import sleep


classWMPlayer():

'''

@

'''

#static var

#first instance is a primary , following are secondary.

#you can have one primary and as many secondary as you like

def__init__(self):

'''

init all attributes

'''

#self.mp = Dispatch(WMPlayer.OCX)

#pass

defplay_song(self):

mp = Dispatch(WMPlayer.OCX)

tune = mp.newMedia(r./SleepAway.mp3)

mp.currentPlaylist.appendItem(tune)

mp.controls.play()

sleep(1)

mp.controls.playItem(tune)

raw_input(Press Enter to stop playing)

#sleep(5)

mp.controls.stop()

**

*FileB.py*


You need this import:

import unittest


**

fromwmp.WMPlayer import*

classsTest(unittest.TestCase):

deftest_wmplayer(self):

self.wmp = WMPlayer()

self.wmp.play_song()


You also need to run the test:

if __name__ == '__main__':
unittest.main()

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


Re: Question about asyncio doc example

2014-07-23 Thread Yaşar Arabacı
asyncio.sleep() returns you a Future. When you yield from a future,
your coroutine blocks, until the Future completes. In the meantime,
event loop continutes to execute other things that are waiting to be
executed. The Future returned from asyncio.sleep gets completed after
specified seconds.

2014-07-23 13:43 GMT+03:00 Saimadhav Heblikar saimadhavhebli...@gmail.com:
 Hi,

 The example in question is
 https://docs.python.org/3/library/asyncio-task.html#example-hello-world-coroutine.
 I'd like to learn the purpose of the statement
 yield from asyncio.sleep(2) in that example.

 In particular, I'd like to know if asyncio.sleep() is used as a
 substitute for slow/time consuming operation, i.e. in real code,
 whether there will be a real time consuming statement in place of
 asyncio.sleep().

 --
 Regards
 Saimadhav Heblikar
 --
 https://mail.python.org/mailman/listinfo/python-list



-- 
http://ysar.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is a nit(sp?) function.

2014-07-23 Thread MRAB

On 2014-07-23 10:43, Antoon Pardon wrote:

I have been looking at some python talks on you tube:

https://www.youtube.com/watch?v=o9pEzgHorH0

and

https://www.youtube.com/watch?v=sPiWg5jSoZI

And these two both mentioned nits or nit functions or something like
that. I tried to google it but came up empty.

Anyone an idea what they are talking about.


In the first video, when talking about the Greeting class, he said
that it had 2 methods, one of which was init.
--
https://mail.python.org/mailman/listinfo/python-list


RE: Automating windows media player on win7

2014-07-23 Thread Deogratius Musiige
Hi,
I have the mentioned imports. And for the matter of fact I can play the audio. 

The problem is when I make a class with the wmplayer automating code and make 
an instance of this class in my testing code.
When I run this instance, I do not get any audio out?

Best regards / Med venlig hilsen

Deogratius Musiige
Sennheiser Communications A/S
Direct  +45 5618 0320


-Original Message-
From: Python-list [mailto:python-list-bounces+demu=senncom@python.org] On 
Behalf Of MRAB
Sent: 23. juli 2014 12:57
To: python-list@python.org
Subject: Re: Automating windows media player on win7

On 2014-07-23 10:20, Deogratius Musiige wrote:

 Hi mate,

 The fix you provided works perfect. However, if I put it in a class 
 and import, make instance and execute in another file, the audio is 
 not played.

 What am I missing? This is what I do:

I'm assuming that you're not actually calling the files FileA.py and FileB.py.

 *FileA.py*

You need these imports:

from win32com.client import Dispatch
from time import sleep

 classWMPlayer():

 '''

 @

 '''

 #static var

 #first instance is a primary , following are secondary.

 #you can have one primary and as many secondary as you like

 def__init__(self):

 '''

 init all attributes

 '''

 #self.mp = Dispatch(WMPlayer.OCX)

 #pass

 defplay_song(self):

 mp = Dispatch(WMPlayer.OCX)

 tune = mp.newMedia(r./SleepAway.mp3)

 mp.currentPlaylist.appendItem(tune)

 mp.controls.play()

 sleep(1)

 mp.controls.playItem(tune)

 raw_input(Press Enter to stop playing)

 #sleep(5)

 mp.controls.stop()

 **

 *FileB.py*

You need this import:

import unittest

 **

 fromwmp.WMPlayer import*

 classsTest(unittest.TestCase):

 deftest_wmplayer(self):

 self.wmp = WMPlayer()

 self.wmp.play_song()

You also need to run the test:

if __name__ == '__main__':
 unittest.main()

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


Re: Distributing python applications as a zip file

2014-07-23 Thread Burak Arslan

On 07/23/14 07:23, Steven D'Aprano wrote:
 A little known feature of Python: you can wrap your Python application in 
 a zip file and distribute it as a single file. The trick to make it 
 runnable is to put your main function inside a file called __main__.py 
 inside the zip file. Here's a basic example:

 steve@runes:~$ cat __main__.py 
 print(NOBODY expects the Spanish Inquisition!!!)

 steve@runes:~$ zip appl __main__.py 
   adding: __main__.py (stored 0%)
 steve@runes:~$ rm __main__.py 
 steve@runes:~$ python appl.zip 
 NOBODY expects the Spanish Inquisition!!!



does it support package_data? or more specifically, does
pkg_resources.resource_* detect that the script is running from a zip
file and adjust accordingly?
-- 
https://mail.python.org/mailman/listinfo/python-list


how to download special range content with requests in python?

2014-07-23 Thread 水静流深
url='http://debian.cites.illinois.edu/pub/debian-cd/7.6.0/amd64/iso-cd/debian-7.6.0-amd64-CD-1.iso'
 import requests
 r = requests.get(url).read(0,1000)  ‍

why i can not download special range(from 0 to 1)  content with requests  
in python‍?-- 
https://mail.python.org/mailman/listinfo/python-list


Error in example in multiprocessing

2014-07-23 Thread Akshay Verma
Example under
17.2.1.6. Using a pool of workers
https://docs.python.org/3.4/library/multiprocessing.html#using-a-pool-of-workers
Has a error. As far as I understand, The input to res sleep function should
be List and not integer.

res = pool.apply_async(sleep, 10)


Let me know if I am wrong.

Best Regards,
Akshay Verma.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to download special range content with requests in python?

2014-07-23 Thread Joel Goldstick
On Wed, Jul 23, 2014 at 5:44 AM, 水静流深 1248283...@qq.com wrote:

 url='
 http://debian.cites.illinois.edu/pub/debian-cd/7.6.0/amd64/iso-cd/debian-7.6.0-amd64-CD-1.iso
 '
 import requests
 r = requests.get(url).read(0,1000)  ‍

 why i can not download special range(from 0 to 1)  content with
 requests  in python‍?


I've never heard of anyone reading an iso file with requests.  I'm guessing
it will work, but it is probably quite large.

What actually happens when you run your code?


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




-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to download special range content with requests in python?

2014-07-23 Thread Joel Goldstick
On Wed, Jul 23, 2014 at 9:03 AM, Joel Goldstick
joel.goldst...@gmail.com wrote:




 On Wed, Jul 23, 2014 at 5:44 AM, 水静流深 1248283...@qq.com wrote:

 url='http://debian.cites.illinois.edu/pub/debian-cd/7.6.0/amd64/iso-cd/debian-7.6.0-amd64-CD-1.iso'
 import requests
 r = requests.get(url).read(0,1000)  ‍

 why i can not download special range(from 0 to 1)  content with requests 
  in python‍?


 I've never heard of anyone reading an iso file with requests.  I'm guessing 
 it will work, but it is probably quite large.

 What actually happens when you run your code?


Also:
file.read([size])

a file object can take a size, but not two arguments aparently




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




 --
 Joel Goldstick
 http://joelgoldstick.com




-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Automating windows media player on win7

2014-07-23 Thread MRAB


On 2014-07-23 12:55, Deogratius Musiige wrote:

Hi,
I have the mentioned imports. And for the matter of fact I can play the audio.

The problem is when I make a class with the wmplayer automating code and make 
an instance of this class in my testing code.
When I run this instance, I do not get any audio out?

[snip]

When I made the changes I mentioned, the code worked for me.

Could you post _all_ of the code you're trying, including the imports 
and the line that calls the test?


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


Re: Network/multi-user program

2014-07-23 Thread memilanuk

On 07/21/2014 11:26 AM, Chris Angelico wrote:

On Tue, Jul 22, 2014 at 4:16 AM, Monte Milanuk memila...@invalid.com wrote:

On 2014-07-21, Chris Angelico ros...@gmail.com wrote:

On Tue, Jul 22, 2014 at 2:07 AM, Monte Milanuk memila...@invalid.com wrote:

So I guess I'm asking for advice or simplified examples of how to
go about connecting a client desktop app to a parent/master desktop app,
so I can get some idea of how big of a task I'm looking at here, and
whether that would be more or less difficult than trying to do the
equivalent job using a web framework.


Easier way: Don't have a master desktop app, but instead have a
master database. Since you're posting this to python-list, I'll assume
you currently intend writing this in Python; you can make a really
simple transition from single-user-single-desktop to a networked
system, although of course you'll want to think in terms of multiple
users from the start.


So... if everybody is using the same application to access the same
database, how would you prevent say, a data entry user from accidentally
breaking something above their pay-grade?  Set up some sort of
role-based privilege system to limit them to write access for some
portions and read-only for others?


That would be one way, yes. The first question you'd need to ask is:
How do you know who's data-entry and who's admins? As soon as you
solve that (probably with some sort of login), you tie the access
level to that.


Given the small user base and the nature of the events, volunteer staff, 
everybody knowing everybody, etc. its pretty much a matter of the match 
admin saying You, you and you - data entry ;)



If you need absolute security, you would have the user enter a login
and password which would actually be the database credentials. Then
you grant exact rights in the database manager, permitting ONLY what
that user is allowed to do. It's then utterly impossible, even for
someone who knows Python and SQL, to do damage.


Intriguing... and probably the most technically correct way as far as 
role-based access.  But also very unlikely that most of the end-users 
would be able to set up the DB correctly.  Just sayin'...



But more likely, what
you really want is a cut-down UI that simplifies things: if the user
is data-entry level, you take away all the admin-type options. It
might be possible to fiddle around in internals and gain elevated
access, but that's not an issue in many environments.


That sounds very much like what I'm thinking of... maybe a token nod @ 
security with a passwd for 'admin' and 'data-entry' roles to keep idle 
passers-by from snooping or diddling with things they shouldn't.  Even 
if it just greyed-out / disabled buttons, tabs, etc. based on role that 
would probably meet needs.



In any case, these are issues you'd need to figure out regardless of
the development model. Ultimately, you could treat the entire
computer, network, database, etc as a black box, and just look at two
entities: the human, and the UI s/he is using. All permissions issues
can be explained at that level.


Not really clear on what you're talking about on this part...

Monte




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


Re: Is it possible to install Python on a network?

2014-07-23 Thread roys2005

Dan,

  Thanks for the information. So, one option is to build Python
  from source code to be able to install /where/ever/...

  I still wonder why there is no distribution package for *ix that
  contains binaries/libraries that can be installed /where/ever/...

  Or, may be there is - I just don't know - but I want to know.

- Koushik



On Tuesday, July 22, 2014 11:51:06 PM UTC-4, Dan Stromberg wrote:
 
 Back when I was a sysadmin, I would install CPython to a few different
 
 NFS filesystems for hundreds of machines to use (more than one
 
 filesystem because we had about 5 *ix variants - you probably only
 
 need 1). It's just a matter of ./configure --prefix=/where/ever 
 
 make  make install once you have the build dependencies.
 
 
 
 It worked fine, but if you symlink you get into trouble because Python
 
 can't find it's default module path where it expects; symlinking can
 
 require a wrapper that sets an environment variable - I believe it was
 
 $PYTHONPATH.
 
 
 
 Perhaps it would be appropriate to ask: Why are you wondering if it works?

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


Re: Is it possible to install Python on a network?

2014-07-23 Thread roys2005
Ben,

  I am trying to find out how I can install Python on a central machine
  so that all users can use it, rather than using /usr/local/bin/python.
 ( I am talking about unix/linux platform )

  Since, I do not know the answer, I was asking if Python
  can/can't/should/shouldn't be installed on a central machine.

  Hope that clarifies.
  Thanks,

- Koushik

 


On Wednesday, July 23, 2014 12:18:18 AM UTC-4, Ben Finney wrote:
 
 
 
  Does this mean Python cannot be or should not be installed at a
 
  central location?
 
 
 
 Can you explain better what you mean by this?
 
 
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Network/multi-user program

2014-07-23 Thread Chris Angelico
On Thu, Jul 24, 2014 at 12:14 AM, memilanuk memila...@gmail.com wrote:
 But more likely, what
 you really want is a cut-down UI that simplifies things: if the user
 is data-entry level, you take away all the admin-type options. It
 might be possible to fiddle around in internals and gain elevated
 access, but that's not an issue in many environments.

 That sounds very much like what I'm thinking of... maybe a token nod @
 security with a passwd for 'admin' and 'data-entry' roles to keep idle
 passers-by from snooping or diddling with things they shouldn't.  Even if it
 just greyed-out / disabled buttons, tabs, etc. based on role that would
 probably meet needs.

Yep, for most purposes that would be fine. In fact, you could cut it
down further, if the data-entry mode is pretty safe: have the program
start up in data-entry mode, and it has one menu item Switch to admin
mode, which prompts for a password.

 In any case, these are issues you'd need to figure out regardless of
 the development model. Ultimately, you could treat the entire
 computer, network, database, etc as a black box, and just look at two
 entities: the human, and the UI s/he is using. All permissions issues
 can be explained at that level.


 Not really clear on what you're talking about on this part...

If you were to create a web application, you'd have to worry about the
same question of is this person an admin or just data-entry. If you
were to do this as a single program that other programs script, you'd
have to worry about the same question. It's not complexity inherent in
the model of database is king, and there are several applications;
it's complexity inherent in the original problem we will have
separate admins and data-entry people.

Incidentally, there is another way you could lay it out: have two
separate programs, one of which is the d-e and the other is admins.
That could work out very nicely, if you have a specially cut-down and
simplified UI for d-e. It'd be like how some accounting packages have
a special Point-Of-Sale mode, which doesn't have permission to process
anything other than straight-forward sales, and which will use the
entire screen just for that. It's a useful feature even when you
completely trust the people involved; the simpler UI can allow
increased throughput. There's a lot of flexibility here, and
ultimately, you get exactly as much complexity as you write into your
system :)

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


Re: Is it possible to install Python on a network?

2014-07-23 Thread Chris Angelico
On Thu, Jul 24, 2014 at 12:15 AM, roys2005 roys2...@gmail.com wrote:
   Thanks for the information. So, one option is to build Python
   from source code to be able to install /where/ever/...

   I still wonder why there is no distribution package for *ix that
   contains binaries/libraries that can be installed /where/ever/...

There probably isn't, because there's no need to. Distro packages on
Linux are generally designed to play nicely with the rest of the
packages in the repository, rather than handle every possible
configuration change you might want to do; if you want full
flexibility, it's usually pretty easy to just grab the source and
build (this is distinctly different from Windows, where it's assumed
that most people don't know how to build from source, and Mac OS,
where you have to actively jump through hoops just to get a C
compiler).

On a Debian-derived system, you should be able to use sudo apt-get
build-dep python (or python3) to get the libraries etc you need, and
then either apt-get source python or hg clone
http://hg.python.org/cpython; to get the source (the former will get
you the source for the system Python, the latter will get you the
absolute latest source code for all branches - you might have to pick
which branch to use, rather than using 'default'). On Red Hat systems,
I'm sure there's an equally easy way to gather the build dependencies,
and it'll probably be in 'man yum'.

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


Execution Time and Memory taken by the program

2014-07-23 Thread Orochi
I want a timer to calculate the execution time of the program
actually I am trying to solve problems on codechef.com and want to find out the 
time and memory taken by the program to execute.

I know we can import time.time() in unix  and time.clock() in windows
also there is a library timeit().
but it doesn't give the accurate details.
What I want is :
1 . Execution time taken by the program or the CPU time
2 . Users Time
3 . Time taken by Function
4 . Memory required by the program

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


Re: Is it possible to install Python on a network?

2014-07-23 Thread Chris Angelico
On Thu, Jul 24, 2014 at 12:24 AM, roys2005 roys2...@gmail.com wrote:
   I am trying to find out how I can install Python on a central machine
   so that all users can use it, rather than using /usr/local/bin/python.
  ( I am talking about unix/linux platform )

   Since, I do not know the answer, I was asking if Python
   can/can't/should/shouldn't be installed on a central machine.

Firstly, I would *strongly* recommend keeping /usr/bin/python (or
/usr/local/bin/python, whatever `which python` says) exactly where it
is. Call that one the system Python, and treat it like bash, grep,
and all those other important tools. You'll only mess up your system
if you mess with that.

But with that sorted: I don't see any particular problem with mounting
some remote drive and running Python from it. You'll probably need to
make sure the path to it is the same as it was on the system that
installed it, and you'll definitely want to do this only on systems
with the same architecture, but otherwise you should be fine. Make
yourself a /usr/central/bin/python or something, install Python into
it, and then make /usr/central on all the others as a mount point for
/usr/central on the one where you installed it.

And then you can come back and tell us all how it went, because most
of us will have never tried it :)

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


Re: how to download special range content with requests in python?

2014-07-23 Thread Chris Angelico
On Wed, Jul 23, 2014 at 7:44 PM, 水静流深 1248283...@qq.com wrote:
 url='http://debian.cites.illinois.edu/pub/debian-cd/7.6.0/amd64/iso-cd/debian-7.6.0-amd64-CD-1.iso'
 import requests
 r = requests.get(url).read(0,1000)  ‍

 why i can not download special range(from 0 to 1)  content with requests
 in python‍?

Looking into my crystal ball, I think you're trying to have this send
the Range header. If that's the case, then there's no way you can do
that with the read() method; you have to incorporate that into the
original request, and then just read everything the server sends you.

If that's not what you're talking about, please explain further,
preferably demonstrating what you want to happen at the HTTP level.

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


Re: Execution Time and Memory taken by the program

2014-07-23 Thread Irmen de Jong
On 23-7-2014 17:50, Orochi wrote:
 I want a timer to calculate the execution time of the program
 actually I am trying to solve problems on codechef.com and want to find out 
 the time and memory taken by the program to execute.
 
 I know we can import time.time() in unix  and time.clock() in windows
 also there is a library timeit().
 but it doesn't give the accurate details.
 What I want is :
 1 . Execution time taken by the program or the CPU time
 2 . Users Time
 3 . Time taken by Function
 4 . Memory required by the program
 
 Thank you
 


Most of what you want to measure is not Python specific but handled by your 
operating
system shell. For instance, to measure #1, #2, #4 and a bunch of other metrics, 
you can
do on Linux:

$ /usr/bin/time -v  your-program

and you will get a whole lot of info about the execution of your-program.

If you want to measure Python specific stuff such as the time taken by each 
function,
you can use the Python profiler to do that:
https://docs.python.org/3.4/library/profile.html



Irmen

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


Re: My sys.excepthook dies painfully

2014-07-23 Thread Jason Swails

On Jul 23, 2014, at 1:02 AM, Chris Angelico ros...@gmail.com wrote:

 On Wed, Jul 23, 2014 at 5:46 PM, Steven D'Aprano st...@pearwood.info wrote:
 On Wed, 23 Jul 2014 07:14:27 +, Steven D'Aprano wrote:
 
 I have some code which sets up a logger instance, then installs it as
 sys.excepthook to capture any uncaught exceptions:
 
 Oh! I should have said, I'm running Python 2.6.
 
 Ah! I tried it in 2.7 and it seemed to work. One moment...
 
 huix@huix:~$ python mylogging.py
 Traceback (most recent call last):
  File mylogging.py, line 24, in module
foo  # Die with uncaught NameError.
 NameError: name 'foo' is not defined
 huix@huix:~$ python -V
 Python 2.6.6
 huix@huix:~$ tail /var/log/syslog
 ...
 Jul 23 18:01:49 huix INFO: started logging [mylogging]
 Jul 23 18:01:49 huix INFO: installing error handler [mylogging]
 Jul 23 18:01:49 huix ERROR: Uncaught type 'exceptions.NameError':
 name 'foo' is not defined [mylogging]#012None
 
 Still not sure what's going on. Odd.

Works for me, too:

swails@batman ~ $ python2.6 mylogging.py 
Traceback (most recent call last):
  File mylogging.py, line 24, in module
foo  # Die with uncaught NameError.
NameError: name 'foo' is not defined
swails@batman ~ $ sudo tail /var/log/messages 
...
Jul 23 16:02:30 batman INFO:started logging [mylogging]
Jul 23 16:02:30 batman INFO:installing error handler [mylogging]
Jul 23 16:02:30 batman ERROR:Uncaught type 'exceptions.NameError': name 'foo' 
is not defined [mylogging]

I tried it with python2.2 through python2.7 (python 2.2 and earlier did not 
have the logging module).

I'm not sure how the mylogger variable is getting set to None in your 
my_error_handler callback, but I don't see how that can possibly be happening 
with the provided code...

All the best,
Jason
-- 
https://mail.python.org/mailman/listinfo/python-list


Using pyVmomi

2014-07-23 Thread Joseph L. Casale
I am doing some scripting with pyVmomi under 2.6.8 so the code may
run directly on a vmware esxi server.

As the code is long running, it surpasses the authentication timeout. For
anyone familiar with this code and/or this style of programming, does anyone
have a recommendation for an elegant authentication retry scheme for objects
passed to code that will intermittently access the properties invoking calls.

I'd prefer to not litter try/except blocks around the usage of the objects if
possible.

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


Where is the function of Repr.repr1() in this example?

2014-07-23 Thread fl
Hi,
I run the example code below from website: 

https://docs.python.org/2/library/repr.html#repr.Repr.repr1

If I run these lines from an editor, it echoes:

 open file '...at 0x01EF4020
 dsfdsf # entered letters


If I only run the last line (hoping the same effect with running from the 
editor)
it simply echoes:

 print aRepr.repr(sys.stdin)
open file '...at 0x01EF4020
 


I have these questions about this example code:

1. What purpose of the author wants from the example code? 
2. I do not see Repr.repr1() in the code snippet. Why did the author mention
that first?
3. Why is it different from running the last line directly in the Interactive 
Window, and within an editor file?


Thanks,



..
The use of dynamic dispatching by Repr.repr1() allows subclasses of Repr to add 
support for additional built-in object types or to modify the handling of types
already supported. This example shows how special support for file objects could
be added:

import repr as reprlib
import sys

class MyRepr(reprlib.Repr):
def repr_file(self, obj, level):
if obj.name in ['stdin', 'stdout', 'stderr']:
return obj.name
else:
return repr(obj)

aRepr = MyRepr()
print aRepr.repr(sys.stdin)  # prints 'stdin'
-- 
https://mail.python.org/mailman/listinfo/python-list


I want to do something with data

2014-07-23 Thread Nicholas Cannon
Hey i am interested in using data in my programs. I know every program uses 
data but i want to do like large data processing and pick results out of a data 
like querying database. I dont really know what this is called though. Is it 
data analytics? im not sure but I would like to do this stuff. What would i 
need to learn because i know the basic file opening and stuff and also know how 
to open csv files aswell as grab data from the web. I dont know much else about 
handling data other than regular expressions which is handy when grabbing data 
from the web. I f any one could like guide me on what to learn that would be so 
good.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about Pass-by-object-reference?

2014-07-23 Thread Terry Reedy

On 7/23/2014 1:36 AM, Steven D'Aprano wrote:

On Tue, 22 Jul 2014 20:27:15 -0400, Terry Reedy wrote:


When you call a function, Python binds function parameter names to
argument objects in the function's local namespace, the same as in name
assignments. Given

def f(a, b): pass

a call f(1, 'x') starts by executing

a, b = 1, 'x'

in the local namespace.  Nothing is being 'passed'.



If nothing is being passed, how does the function know to bind 1 and 'x'
to names a and b, rather than (say) this?

a, b = 23, 'Surprise!


To quote your other message, Magic happens, and a result is returned.

--
Terry Jan Reedy

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


Re: Question about Pass-by-object-reference?

2014-07-23 Thread Terry Reedy

On 7/23/2014 1:35 AM, Steven D'Aprano wrote:

On Wed, 23 Jul 2014 11:59:45 +1000, Ben Finney wrote:


fl rxjw...@gmail.com writes:


On Tuesday, July 22, 2014 8:27:15 PM UTC-4, Terry Reedy wrote:

When you call a function, Python binds function parameter names to
argument objects in the function's local namespace, the same as in
name assignments. […]
Nothing is being 'passed'.


Non-human implementations copy object ids, but I was not writing at that 
level.



Thanks, but I don't understand your point yet. Could you give me
another example in which something is passed?


The point being made is that no values are is “passed” in a function
call. If you have learned that term from elsewhere, it doesn't apply
sensibly to Python.


Hmmm. I don't know that I like that. I think that these two sentences
mean the same thing:

 Call the function with x as argument.

 Pass x to the function.


I disagree. In Python, when one calls the function with an argument, 
computer implementatipns 'pass' an object reference, which in CPython is 
an object address. Conflating the two sentences above leads people to 
claim that python 'calls by (object) reference'.  In a sense, it does, 
But thinking in those terms often leads to false inferences about how 
Python behaves.  So I think it better not to think is such terms.



They both describe what is being done, only from slightly different
points of view.


'Passing' is an implementation of calling. I have little idea what *I* 
do when interpreting a function call while interpreting python code.



In mathematics, to call a function is a completely
abstract action. Magic happens, and a result is returned.


From a set theory point of view, nothing happens. The result simply is 
the second member of the pair with the argument as the first member.


 But in programming languages, calling a function has concrete actions:

The *essential* concrete action is the binding of something to parameter 
names. 'Passing' is a means to that end. What matters is what gets 
bound. In Python, python objects themselves get bound. And the binding 
is essentially the same as in assignment statements. Other language bind 
values or references or pointers or ..., with different consequences.


--
Terry Jan Reedy



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


Re: Error in example in multiprocessing

2014-07-23 Thread Terry Reedy

On 7/23/2014 6:27 AM, Akshay Verma wrote:

Example under


  17.2.1.6. Using a pool of workers
  
https://docs.python.org/3.4/library/multiprocessing.html#using-a-pool-of-workers

Has a error. As far as I understand, The input to res sleep function
should be List and not integer.

res  =  pool.apply_async(sleep,  10)


You are correct. Running the example results in
Traceback (most recent call last):
  File C:\Programs\Python34\lib\multiprocessing\pool.py, line 119, in 
worker

result = (True, func(*args, **kwds))
TypeError: sleep() argument after * must be a sequence, not int

Changing 10 to [10] and the Exception is the expected TimeoutError
I am fixing this now.

--
Terry Jan Reedy

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


Re: Is it possible to install Python on a network?

2014-07-23 Thread Ned Deily
In article 875ce0f0-c6a8-4b50-b97f-d11ee543e...@googlegroups.com,
 roys2005 roys2...@gmail.com wrote:
   I still wonder why there is no distribution package for *ix that
   contains binaries/libraries that can be installed /where/ever/...

One issue is that the Python build process on **ix captures the 
configured install path names into the built files in various places, 
like in _sysconfigdata.py.  So, in general, it is currently not 
supported to install a vanilla Python build into a location other than 
the path specified on the original configure commmand (default = 
/usr/local), e.g.

./configure --prefix=/path/to
make
make install

As long as you are producing a package that will be installed into the 
same path on each system and each system has a compatible architecture, 
you should be OK.

-- 
 Ned Deily,
 n...@acm.org

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


Re: I want to do something with data

2014-07-23 Thread Mark Lawrence

On 23/07/2014 23:20, Nicholas Cannon wrote:

Hey i am interested in using data in my programs. I know every program uses 
data but i want to do like large data processing and pick results out of a data 
like querying database. I dont really know what this is called though. Is it 
data analytics? im not sure but I would like to do this stuff. What would i 
need to learn because i know the basic file opening and stuff and also know how 
to open csv files aswell as grab data from the web. I dont know much else about 
handling data other than regular expressions which is handy when grabbing data 
from the web. I f any one could like guide me on what to learn that would be so 
good.



Try this for starters http://pandas.pydata.org/

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


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: Question about asyncio doc example

2014-07-23 Thread Terry Reedy

On 7/23/2014 6:43 AM, Saimadhav Heblikar wrote:

Hi,

The example in question is
https://docs.python.org/3/library/asyncio-task.html#example-hello-world-coroutine.
I'd like to learn the purpose of the statement
yield from asyncio.sleep(2) in that example.

In particular, I'd like to know if asyncio.sleep() is used as a
substitute for slow/time consuming operation, i.e. in real code,
whether there will be a real time consuming statement in place of
asyncio.sleep().


The context is
while True:
print('Hello')
yield from asyncio.sleep(3)

sleep is both itself, to shown to schedule something at intervals in a 
non-blocking fashion, as well as a placefiller.  The blocking equivalent 
would use 'time' instead of 'yield from asyncio'. The following shows 
the non-blocking feature a bit better.


import asyncio

@asyncio.coroutine
def hello():
while True:
print('Hello')
yield from asyncio.sleep(3)

@asyncio.coroutine
def goodbye():
while True:
print('Goodbye')
yield from asyncio.sleep(5.01)

@asyncio.coroutine
def world():
while True:
print('World')
yield from asyncio.sleep(2.02)

loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait([hello(), goodbye(), world()]))

Getting the same time behavior in a while...sleep loop requires 
reproducing some of the calculation and queue manipulation included in 
the event loop.


--
Terry Jan Reedy

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


How to install data analysis pandas toolkit?

2014-07-23 Thread fl
Hi,

I download data analysis pandas toolkit (Windows 32 version) to my PC:


pandas-0.14.0.win32-py2.7.exe


After I run it, I still cannot import the module:


 import pandas as pd
No module named numpy
Traceback (most recent call last):
  File interactive input, line 1, in module
  File C:\Python27\lib\site-packages\pandas\__init__.py, line 6, in module
from . import hashtable, tslib, lib
  File numpy.pxd, line 157, in init pandas.tslib (pandas\tslib.c:60843)
ImportError: No module named numpy
 



I have check the pdf manual on installation, but do not find anything on Windows
version binary installation procedures. Could you tell me how I can get through
it?


Thanks,


http://pandas.pydata.org/pandas-docs/stable/install.html#all-platforms
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to install data analysis pandas toolkit?

2014-07-23 Thread fl
On Wednesday, July 23, 2014 8:30:00 PM UTC-4, fl wrote:

I have figured it out. It is installed under Cygwin. Although there are some 
errors in the process, it works now. Thanks,
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Distributing python applications as a zip file

2014-07-23 Thread Steven D'Aprano
On Wed, 23 Jul 2014 15:23:10 +0300, Burak Arslan wrote:

 On 07/23/14 07:23, Steven D'Aprano wrote:
 A little known feature of Python: you can wrap your Python application
 in a zip file and distribute it as a single file.
[...]
 does it support package_data? or more specifically, does
 pkg_resources.resource_* detect that the script is running from a zip
 file and adjust accordingly?

No idea, sorry. Why don't you try it and see? Please let us know what you 
find.

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


Re: I want to do something with data

2014-07-23 Thread memilanuk

On 07/23/2014 03:20 PM, Nicholas Cannon wrote:

Hey i am interested in using data in my programs. I know every
program uses data but i want to do like large data processing and
pick results out of a data like querying database. I dont really know
what this is called though. Is it data analytics? im not sure but I
would like to do this stuff. What would i need to learn because i
know the basic file opening and stuff and also know how to open csv
files aswell as grab data from the web. I dont know much else about
handling data other than regular expressions which is handy when
grabbing data from the web. I f any one could like guide me on what
to learn that would be so good.



Python for Data Analysis
http://shop.oreilly.com/product/0636920023784.do

Think Stats
http://shop.oreilly.com/product/0636920020745.do

Learning IPython for Interactive Computing and Data Visualization
http://shop.oreilly.com/product/9781782169932.do

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


Re: OT: usenet reader software

2014-07-23 Thread Sturla Molden
Monte Milanuk memila...@gmail.com wrote:

 Aaaannnd here we have a good example of why it would be really nice to
 be able to filter/score based on the message *body*, not just the
 headers. 8(

Actually, here we have the reason why Usenet died.

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


Re: My sys.excepthook dies painfully

2014-07-23 Thread Steven D'Aprano
On Wed, 23 Jul 2014 13:02:51 -0700, Jason Swails wrote:

 I'm not sure how the mylogger variable is getting set to None in your
 my_error_handler callback, but I don't see how that can possibly be
 happening with the provided code...

Dammit, it's a Heisenbug... now it's gone away for me too.

http://c2.com/cgi/wiki?HeisenBug


However, I think I have a glimmer of an idea for how the global variable 
might be set to None. When the Python interpreter shuts down, it sets 
global variables to None in some arbitrary order. If the excepthook 
function isn't called until after the shutdown process begins, then 
depending on the phase of the moon, it's possible that ``mylogger`` may 
have been set to None by the time it is called.

It's quite common for __del__ methods and daemon threads to be called 
during interpreter shutdown, but I've never come across an excepthook 
doing this.

I wonder whether I ought to use atexit to register the function, rather 
than mess with sys.excepthook directly?



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


Re: My sys.excepthook dies painfully

2014-07-23 Thread Chris Angelico
On Thu, Jul 24, 2014 at 11:30 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 However, I think I have a glimmer of an idea for how the global variable
 might be set to None. When the Python interpreter shuts down, it sets
 global variables to None in some arbitrary order. If the excepthook
 function isn't called until after the shutdown process begins, then
 depending on the phase of the moon, it's possible that ``mylogger`` may
 have been set to None by the time it is called.

In other words, the problem changed when you added the NameError
trigger at the bottom of the script?

Would it be possible to snapshot all critical globals with a closure,
to force them to be held? Something like:

def handler_gen(mylogger, sys):
def my_error_handler(type, value, tb):
msg = Uncaught %s: %s % (type, value)
mylogger.exception(msg)
sys.__excepthook__(type, value, tb)  # print the traceback to stderr

# Install exception handler.
mylogger.info('installing error handler')
sys.excepthook = handler_gen(mylogger, sys)

It seems crazy, but it might work. It's a guaranteed one-way
connection, saying this function NEEDS these objects.

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


Re: Is it possible to install Python on a network?

2014-07-23 Thread Ben Finney
roys2005 roys2...@gmail.com writes:

   I am trying to find out how I can install Python on a central machine
   so that all users can use it

That's what confuses me. How do you envisage this working? On a given
machine, you can *run* programs only on that machine.

If you want to run a program on a different machine, you must somehow
invoke it using a network service already configured to do that. What
service are you expecting to use? SSH? HTTP? There is nothing about a
programming language interpreter which pents a way to run programs
across a network, unless you can specify *how* that is to happen.

What do you imaging a user doing, exactly, on machine ‘foo’ to make a
program execute on machine ‘bar’? At what step – exactly how – does the
communication between the machines occur to invoke the program? How is
the user's input, and the program's output, communicated in a way that
machine ‘foo’ knows to interact with machine ‘bar’?

-- 
 \  “The opposite of a correct statement is a false statement. But |
  `\ the opposite of a profound truth may well be another profound |
_o__)  truth.” —Niels Bohr |
Ben Finney

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


Re: Is it possible to install Python on a network?

2014-07-23 Thread Chris Angelico
On Thu, Jul 24, 2014 at 12:35 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 roys2005 roys2...@gmail.com writes:

   I am trying to find out how I can install Python on a central machine
   so that all users can use it

 That's what confuses me. How do you envisage this working? On a given
 machine, you can *run* programs only on that machine.

 If you want to run a program on a different machine, you must somehow
 invoke it using a network service already configured to do that. What
 service are you expecting to use? SSH? HTTP? There is nothing about a
 programming language interpreter which pents a way to run programs
 across a network, unless you can specify *how* that is to happen.

 What do you imaging a user doing, exactly, on machine ‘foo’ to make a
 program execute on machine ‘bar’? At what step – exactly how – does the
 communication between the machines occur to invoke the program? How is
 the user's input, and the program's output, communicated in a way that
 machine ‘foo’ knows to interact with machine ‘bar’?

Network mounts work fine for this kind of thing. I don't usually do it
with binaries, due to architecture and library incompatibilities, but
I have a directory that I mount on half a dozen systems, and part of
what it carries is a Python script. So in that sense, I do run that
program from one central machine, on all those other machines. I use
sshfs for the mounting, but other systems work too.

Of course, it is a dependency. In my case it's safe, because the
purpose of that Python script is bound up with the rest of what's
available (and which must be centralized; it's about a terabyte of
stuff, and I don't want to be constantly syncing it). It all depends
on how dangerous that is to you.

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


Re: Is it possible to install Python on a network?

2014-07-23 Thread Ben Finney
Chris Angelico ros...@gmail.com writes:

 On Thu, Jul 24, 2014 at 12:35 PM, Ben Finney ben+pyt...@benfinney.id.au 
 wrote:
  What do you imaging a user doing, exactly, on machine ‘foo’ to make
  a program execute on machine ‘bar’? At what step – exactly how –
  does the communication between the machines occur to invoke the
  program? How is the user's input, and the program's output,
  communicated in a way that machine ‘foo’ knows to interact with
  machine ‘bar’?

 Network mounts work fine for this kind of thing.

I'd rather not propose a solution until we know better what the problem
is; what “roys2005” expects the behaviour to be. So the questions above
need, IMO, answers from “roys2005”.

-- 
 \  “Whatever you do will be insignificant, but it is very |
  `\important that you do it.” —Mohandas K. Gandhi |
_o__)  |
Ben Finney

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


Re: Is it possible to install Python on a network?

2014-07-23 Thread Chris Angelico
On Thu, Jul 24, 2014 at 12:48 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 Chris Angelico ros...@gmail.com writes:

 On Thu, Jul 24, 2014 at 12:35 PM, Ben Finney ben+pyt...@benfinney.id.au 
 wrote:
  What do you imaging a user doing, exactly, on machine ‘foo’ to make
  a program execute on machine ‘bar’? At what step – exactly how –
  does the communication between the machines occur to invoke the
  program? How is the user's input, and the program's output,
  communicated in a way that machine ‘foo’ knows to interact with
  machine ‘bar’?

 Network mounts work fine for this kind of thing.

 I'd rather not propose a solution until we know better what the problem
 is; what “roys2005” expects the behaviour to be. So the questions above
 need, IMO, answers from “roys2005”.

Fair enough. Since he was talking earlier about upgrades, though, I
figured he was talking about having a single source of code, only one
place to update, and then initiate programs on the individual
computers. But yeah, need the OP's responses.

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


Re: Question about Pass-by-object-reference?

2014-07-23 Thread Steven D'Aprano
On Wed, 23 Jul 2014 18:51:47 -0400, Terry Reedy wrote:

 On 7/23/2014 1:35 AM, Steven D'Aprano wrote:
 On Wed, 23 Jul 2014 11:59:45 +1000, Ben Finney wrote:

 fl rxjw...@gmail.com writes:

 On Tuesday, July 22, 2014 8:27:15 PM UTC-4, Terry Reedy wrote:

 The point being made is that no values are is “passed” in a function
 call. If you have learned that term from elsewhere, it doesn't apply
 sensibly to Python.

 Hmmm. I don't know that I like that. I think that these two sentences
 mean the same thing:

  Call the function with x as argument.

  Pass x to the function.
 
 I disagree. In Python, when one calls the function with an argument,
 computer implementatipns 'pass' an object reference, 

Terry, while I appreciate that you are trying to prevent confusion, I 
think you're actually causing even more confusion than what you are 
arguing against. Starting with yourself.

I stated that call function with argument x and pass x to function 
mean the same thing. You said that you disagree, and then the very next 
sentence you link the two concepts together: when you call a function 
with an argument, the computer passes something to the function in some 
manner. By your own description, one implies the other. If not, then I'd 
like to see an example of a programming language where you can have one 
without the other.

I respectfully disagree with you and Ben Finney on this matter. I think 
that the plain English meanings of the two sentences will be understood 
as the same thing by any English speaker old enough to have learned about 
functions (in mathematics or computing), and that there is no harm in 
this any more than it is harmful to treat these as the same:

I went for a stroll by the river.

I took a leisurely walk along the river.


 which in CPython is an object address.

If we're talking CPython implementation, then surely it passes a pointer, 
which is an abstract data type and not necessarily just an address. 
(Pointers in most languages that have them also have a type, not just a 
value.) But that's just a niggle.


 Conflating the two sentences above leads people to
 claim that python 'calls by (object) reference'.  In a sense, it does,
 But thinking in those terms often leads to false inferences about how
 Python behaves.  So I think it better not to think is such terms.

I don't agree that this is the cause of the problem. As I've stated many 
times now, I believe that the problem is that people believe that there 
are only two argument passing conventions, pass by value and pass by 
reference. Do you think it helps matters one iota if we refer to them as 
call by value and call by reference instead of pass ...?

I've never found anyone claiming that Python is call by name, even though 
the semantics of call by name are very similar to those of call by 
reference. I'd even argue that call by name is a *better* fit (still 
wrong, but not quite as wrong) as call by reference: the difference being 
that in call by reference semantics, the argument cannot be a literal, so 
we could not write this:

some_function([])

but (as I understand it) with call by name semantics, you can. But 
because call by name is less well known than call by reference, people 
don't suggest it.

By the way, you refer to call by object reference as being a wrong 
inference. I think your terminology is messed up, and if you want to 
argue I suggest you take it up with the Effbot:

The most accurate description is CLU’s “call by object” or “call
by sharing“. Or, if you prefer, “call by object reference“.

http://effbot.org/zone/call-by-object.htm

Call by object reference would be a good name for what Python does (since 
it actually is what CPython does), if not for the unfortunate fact that 
if you drop the word object it leaves call by reference, which of 
course is a different calling convention with well-defined, and very 
different, semantics. So I prefer call by object or call by sharing.

But regardless of which name is used, we agree that that's what Python 
does (as well as Ruby and Java and others). This article:

http://javadude.com/articles/passbyvalue.htm


is a remarkable (and popular!) example of the confusion. Despite spending 
some time at the end of the article inventing his own terminology pass 
by memento and pass by proxy for remote method calls [and I'll get to 
them in a minute], the author spends the whole discussion implicitly 
assuming that call by value and call by reference are the only two ways 
that you can pass arguments to a function. This leads him to the 
remarkable conclusion that if you create a Dog instance and bind it a 
name myDog (in Java: Dog myDog; in Python, myDog = Dog()) the actual 
value of myDog is not the instance but some memory address, say 42.

You have to be very clever to be that stupid.

As Fredrik Lundh (the Effbot) wrote:

well, I guess you can, in theory, value an artificial number 
assigned to an object as much as the object 

Re: 回复: how to download special range content with requests in python?

2014-07-23 Thread Chris Angelico
On Thu, Jul 24, 2014 at 1:21 PM, 水静流深 1248283...@qq.com wrote:
 i want to write a multiple threads download program to practice my  MT
 knowledge,
 1)cut the big iso file into 20 parts
 2)start 20 process with threading and queue module to download
 3)combine the 20 parts into one iso file.

 if i have cut it into 20 parts ,how can i download the first part of it ?

 it is target to practice the threading and queue module .  ‍

Well, first off, this won't really benefit much from threading. The
biggest bottleneck is going to be the speed of your connection to that
server. Fetching in parts is likely to actually take longer.

It's certainly possible to do what you want, though. What you want is
to figure out how big the file is, and then ask the server to download
different pieces of it. But you'll need to properly understand what
you're doing on the HTTP level.

I would advise finding some other way to practice threading.

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


Re: Is it possible to install Python on a network?

2014-07-23 Thread Dan Stromberg
On Wed, Jul 23, 2014 at 7:15 AM, roys2005 roys2...@gmail.com wrote:

 Dan,

   Thanks for the information. So, one option is to build Python
   from source code to be able to install /where/ever/...

   I still wonder why there is no distribution package for *ix that
   contains binaries/libraries that can be installed /where/ever/...

In theory, you could change all the various autoconf'd tools to get
their prefix from an environment variable, but right now, they
pretty much all want to get their prefix at compile time.  Some only
use it to know where to install, but CPython is one of many that looks
for ancillary files under prefix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to install data analysis pandas toolkit?

2014-07-23 Thread Miki Tebeka
Greetings,

  import pandas as pd
 
 No module named numpy
I find the most painless way of installing the Python scientific stack is using 
Anaconda
http://continuum.io/downloads

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


回复: how to download special range content with requests in python?

2014-07-23 Thread 水静流深
i want to write a multiple threads download program to practice my  MT 
knowledge, 
1)cut the big iso file into 20 parts
2)start 20 process with threading and queue module to download
3)combine the 20 parts into one iso file.

if i have cut it into 20 parts ,how can i download the first part of it ?

it is target to practice the threading and queue module .  ‍


-- 原始邮件 --
发件人: Chris Angelico;ros...@gmail.com;
发送时间: 2014年7月23日(星期三) 晚上11:58
收件人: 
抄送: python-listpython-list@python.org; 
主题: Re: how to download special range content with requests in python?



On Wed, Jul 23, 2014 at 7:44 PM, 水静流深 1248283...@qq.com wrote:
 url='http://debian.cites.illinois.edu/pub/debian-cd/7.6.0/amd64/iso-cd/debian-7.6.0-amd64-CD-1.iso'
 import requests
 r = requests.get(url).read(0,1000)  ‍

 why i can not download special range(from 0 to 1)  content with requests
 in python‍?

Looking into my crystal ball, I think you're trying to have this send
the Range header. If that's the case, then there's no way you can do
that with the read() method; you have to incorporate that into the
original request, and then just read everything the server sends you.

If that's not what you're talking about, please explain further,
preferably demonstrating what you want to happen at the HTTP level.

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


Re: Question about Pass-by-object-reference?

2014-07-23 Thread Steven D'Aprano
On Thu, 24 Jul 2014 03:22:16 +, Steven D'Aprano wrote:

[...]
 I stated that call function with argument x and pass x to function
 mean the same thing.

Oh, a thought comes to mind. There is a sense in which calling a 
function with argument x is slightly different from passing x to a 
function: when you call a function, the compiler has to do at least two 
things: 

1) record enough information somewhere (usually on a call stack) so 
   it can return back to the caller once the function returns;

2) record in some manner the arguments to the function where the 
   function can get to them (pass the arguments).

So if you want to be pedantic and argue that calling does more than 
passing arguments, I'll have to concede the point that you are 
technically correct. But in the context of discussing the treatment of 
arguments passed to the function when you call a function, I think that's 
a distinction that matters not.


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


Re: Question about asyncio doc example

2014-07-23 Thread Saimadhav Heblikar
On 24 July 2014 05:54, Terry Reedy tjre...@udel.edu wrote:
 On 7/23/2014 6:43 AM, Saimadhav Heblikar wrote:

 Hi,

 The example in question is

 https://docs.python.org/3/library/asyncio-task.html#example-hello-world-coroutine.
 I'd like to learn the purpose of the statement
 yield from asyncio.sleep(2) in that example.

 In particular, I'd like to know if asyncio.sleep() is used as a
 substitute for slow/time consuming operation, i.e. in real code,
 whether there will be a real time consuming statement in place of
 asyncio.sleep().


 The context is
 while True:
 print('Hello')
 yield from asyncio.sleep(3)

 sleep is both itself, to shown to schedule something at intervals in a
 non-blocking fashion, as well as a placefiller.  The blocking equivalent
 would use 'time' instead of 'yield from asyncio'. The following shows the
 non-blocking feature a bit better.

 import asyncio

 @asyncio.coroutine
 def hello():
 while True:
 print('Hello')
 yield from asyncio.sleep(3)

 @asyncio.coroutine
 def goodbye():
 while True:
 print('Goodbye')
 yield from asyncio.sleep(5.01)

 @asyncio.coroutine
 def world():
 while True:
 print('World')
 yield from asyncio.sleep(2.02)

 loop = asyncio.get_event_loop()
 loop.run_until_complete(asyncio.wait([hello(), goodbye(), world()]))

 Getting the same time behavior in a while...sleep loop requires reproducing
 some of the calculation and queue manipulation included in the event loop.

 --
 Terry Jan Reedy

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

That clears it up for me. For situations where I dont really know how
long a function is going to take(say waiting for user input or a
network operation), I am better off using callbacks than yield from
asyncio.sleep(). Is my understanding correct?



-- 
Regards
Saimadhav Heblikar
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: My sys.excepthook dies painfully

2014-07-23 Thread dieter
Steven D'Aprano st...@pearwood.info writes:
 I have some code which sets up a logger instance, then installs it as 
 sys.excepthook to capture any uncaught exceptions:



 import logging
 import logging.handlers
 import sys

 FACILITY = logging.handlers.SysLogHandler.LOG_LOCAL6
 mylogger = logging.getLogger('spam')
 handler = logging.handlers.SysLogHandler(
 address='/dev/log', facility=FACILITY)
 formatter = logging.Formatter(%(levelname)s:%(message)s [%(module)s])
 handler.setFormatter(formatter)
 mylogger.addHandler(handler)
 mylogger.setLevel(logging.DEBUG)
 mylogger.info('started logging')

 def my_error_handler(type, value, tb):
 msg = Uncaught %s: %s % (type, value)
 mylogger.exception(msg)
 sys.__excepthook__(type, value, tb)  # print the traceback to stderr

 # Install exception handler.
 mylogger.info('installing error handler')
 sys.excepthook = my_error_handler

 foo  # Die with uncaught NameError.



 If I run this code, the INFO logging messages are logged, but the 
 exception is not. Instead it is printed to the console:


 Error in sys.excepthook:
 Traceback (most recent call last):
   File /home/steve/mylogging.py, line 28, in my_error_handler
 mylogger.exception(msg)
 AttributeError: 'NoneType' object has no attribute 'exception'

This tells you that mylogger is None.

This can happen during finalization. When the interpreter is shut down,
it unbinds all variables in a complex process (somewhere, there
is a description how it proceeds). Unbinding a variable effectively
means bindiung it to None.

This would suggest that the finalization starts before the excepthook
has been executed. I would consider this a bug.

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


Re: My sys.excepthook dies painfully

2014-07-23 Thread Steven D'Aprano
On Thu, 24 Jul 2014 01:30:41 +, Steven D'Aprano wrote:

 I wonder whether I ought to use atexit to register the function, rather
 than mess with sys.excepthook directly?

Ignore this. I was smoking crack. atexit has nothing to do with 
sys.excepthook and won't solve my problem.


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


Re: Question about asyncio doc example

2014-07-23 Thread Marko Rauhamaa
Saimadhav Heblikar saimadhavhebli...@gmail.com:

 For situations where I dont really know how long a function is going
 to take(say waiting for user input or a network operation), I am
 better off using callbacks than yield from asyncio.sleep(). Is my
 understanding correct?

If you choose the coroutine style of programming, you wouldn't normally
use callbacks. Instead, you would yield from any blocking event. There
are coroutine equivalents for locking, network I/O, multiplexing etc.

The callback style encodes the state in a variable. The coroutine style
(which closely resembles multithreading), encodes the state in the code
itself. Both styles can easily become really messy (because reality is
surprisingly messy).


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


[issue21955] ceval.c: implement fast path for integers with a single digit

2014-07-23 Thread Zach Byrne

Zach Byrne added the comment:

I ran the whole benchmark suite. There are a few that are slower: 
call_method_slots, float, pickle_dict, and unpack_sequence.

Report on Linux zach-vbox 3.2.0-24-generic-pae #39-Ubuntu SMP Mon May 21 
18:54:21 UTC 2012 i686 i686
Total CPU cores: 1

### 2to3 ###
24.789549 - 24.809551: 1.00x slower

### call_method_slots ###
Min: 1.743554 - 1.780807: 1.02x slower
Avg: 1.751735 - 1.792814: 1.02x slower
Significant (t=-26.32)
Stddev: 0.00576 - 0.01823: 3.1660x larger

### call_method_unknown ###
Min: 1.828094 - 1.739625: 1.05x faster
Avg: 1.852225 - 1.806721: 1.03x faster
Significant (t=2.28)
Stddev: 0.01874 - 0.24320: 12.9783x larger

### call_simple ###
Min: 1.353581 - 1.263386: 1.07x faster
Avg: 1.397946 - 1.302046: 1.07x faster
Significant (t=24.28)
Stddev: 0.03667 - 0.03154: 1.1629x smaller

### chaos ###
Min: 1.199377 - 1.115550: 1.08x faster
Avg: 1.230859 - 1.146573: 1.07x faster
Significant (t=16.24)
Stddev: 0.02663 - 0.02525: 1.0544x smaller

### django_v2 ###
Min: 2.682884 - 2.633110: 1.02x faster
Avg: 2.747521 - 2.690486: 1.02x faster
Significant (t=9.90)
Stddev: 0.02744 - 0.03010: 1.0970x larger

### fastpickle ###
Min: 1.751475 - 1.597340: 1.10x faster
Avg: 1.771805 - 1.613533: 1.10x faster
Significant (t=64.81)
Stddev: 0.01177 - 0.01263: 1.0727x larger

### float ###
Min: 1.254858 - 1.293067: 1.03x slower
Avg: 1.336045 - 1.365787: 1.02x slower
Significant (t=-3.30)
Stddev: 0.04851 - 0.04135: 1.1730x smaller

### json_dump_v2 ###
Min: 17.871819 - 16.968647: 1.05x faster
Avg: 18.428747 - 17.483397: 1.05x faster
Significant (t=4.10)
Stddev: 1.60617 - 0.27655: 5.8078x smaller

### mako ###
Min: 0.241614 - 0.231678: 1.04x faster
Avg: 0.253730 - 0.240585: 1.05x faster
Significant (t=8.93)
Stddev: 0.01912 - 0.01327: 1.4417x smaller

### mako_v2 ###
Min: 0.225664 - 0.213179: 1.06x faster
Avg: 0.234850 - 0.225984: 1.04x faster
Significant (t=10.12)
Stddev: 0.01379 - 0.01391: 1.0090x larger

### meteor_contest ###
Min: 0.777612 - 0.758924: 1.02x faster
Avg: 0.799580 - 0.780897: 1.02x faster
Significant (t=3.97)
Stddev: 0.02482 - 0.02212: 1.1221x smaller

### nbody ###
Min: 0.969724 - 0.883935: 1.10x faster
Avg: 0.996416 - 0.918375: 1.08x faster
Significant (t=12.65)
Stddev: 0.02426 - 0.03627: 1.4951x larger

### nqueens ###
Min: 1.142745 - 1.128195: 1.01x faster
Avg: 1.296659 - 1.162443: 1.12x faster
Significant (t=2.75)
Stddev: 0.34462 - 0.02680: 12.8578x smaller

### pickle_dict ###
Min: 1.433264 - 1.467394: 1.02x slower
Avg: 1.468122 - 1.506908: 1.03x slower
Significant (t=-7.20)
Stddev: 0.02695 - 0.02691: 1.0013x smaller

### raytrace ###
Min: 5.454853 - 5.538799: 1.02x slower
Avg: 5.530943 - 5.676983: 1.03x slower
Significant (t=-8.64)
Stddev: 0.05152 - 0.10791: 2.0947x larger

### regex_effbot ###
Min: 0.205875 - 0.194776: 1.06x faster
Avg: 0.28 - 0.198759: 1.06x faster
Significant (t=5.10)
Stddev: 0.01305 - 0.01112: 1.1736x smaller

### regex_v8 ###
Min: 0.141628 - 0.133819: 1.06x faster
Avg: 0.147024 - 0.140053: 1.05x faster
Significant (t=2.72)
Stddev: 0.01163 - 0.01388: 1.1933x larger

### richards ###
Min: 0.734472 - 0.727501: 1.01x faster
Avg: 0.760795 - 0.743484: 1.02x faster
Significant (t=3.50)
Stddev: 0.02778 - 0.02127: 1.3061x smaller

### silent_logging ###
Min: 0.344678 - 0.336087: 1.03x faster
Avg: 0.357982 - 0.347361: 1.03x faster
Significant (t=2.76)
Stddev: 0.01992 - 0.01852: 1.0755x smaller

### simple_logging ###
Min: 1.104831 - 1.072921: 1.03x faster
Avg: 1.146844 - 1.117068: 1.03x faster
Significant (t=4.02)
Stddev: 0.03552 - 0.03848: 1.0833x larger

### spectral_norm ###
Min: 1.710336 - 1.688910: 1.01x faster
Avg: 1.872578 - 1.738698: 1.08x faster
Significant (t=2.35)
Stddev: 0.40095 - 0.03331: 12.0356x smaller

### tornado_http ###
Min: 0.849374 - 0.852209: 1.00x slower
Avg: 0.955472 - 0.916075: 1.04x faster
Significant (t=4.82)
Stddev: 0.07059 - 0.04119: 1.7139x smaller

### unpack_sequence ###
Min: 0.30 - 0.20: 1.52x faster
Avg: 0.000164 - 0.000174: 1.06x slower
Significant (t=-13.11)
Stddev: 0.00011 - 0.00013: 1.2256x larger

### unpickle_list ###
Min: 1.333952 - 1.212805: 1.10x faster
Avg: 1.373228 - 1.266677: 1.08x faster
Significant (t=16.32)
Stddev: 0.02894 - 0.03597: 1.2428x larger

--

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



[issue22036] Obsolete reference to stringobject in comment

2014-07-23 Thread Martin Matusiak

Changes by Martin Matusiak numero...@gmail.com:


--
nosy: +benjamin.peterson

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



[issue20468] resource module documentation is incorrect

2014-07-23 Thread Ronald Oussoren

Ronald Oussoren added the comment:

The attached patch (for the default branch) adds information about the unit of 
maxrss to the documentation, and removes the sentences about calculating the 
total memory size from the getpagesize documentation.

--
assignee: ronaldoussoren - 
components: +Documentation -Macintosh
keywords: +needs review, patch
stage:  - patch review
Added file: http://bugs.python.org/file36044/issue-20468.txt

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



[issue22037] Poor grammar in asyncio TCP echo client example

2014-07-23 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Fixed in d19c58e13ac9
Thanks

--
nosy: +asvetlov
resolution:  - fixed
stage:  - resolved
status: open - closed
versions: +Python 3.4, Python 3.5

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



[issue18355] Merge super() guide into documentation

2014-07-23 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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



[issue22037] Poor grammar in asyncio TCP echo client example

2014-07-23 Thread STINNER Victor

STINNER Victor added the comment:

Thanks for the patch Aaron. I wrote the documentation and I'm not a native 
english speaker. Please don't hesitate to report other grammar issues like 
that. You may group all of them in a single issue.

--
nosy: +haypo

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



[issue21933] Allow the user to change font sizes with the text pane of turtledemo

2014-07-23 Thread Lita Cho

Lita Cho added the comment:

Oops! I was suppose to add 'Control' not 'Ctrl'. I can fix that quickly but I 
will wait till the other patch goes through.

--

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



[issue21597] Allow turtledemo code pane to get wider.

2014-07-23 Thread Lita Cho

Lita Cho added the comment:

Just to clarify, should I submit a new patch with outlined style changes?

--

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



[issue21987] TarFile.getmember on directory requires trailing slash iff over 100 chars

2014-07-23 Thread Lars Gustäbel

Lars Gustäbel added the comment:

Apparently, the problem is located in TarInfo._proc_gnulong(). I attached a 
patch.

When tarfile reads an archive, it strips trailing slashes from all filenames, 
except GNUTYPE_LONGNAME headers, which is a bug. tarfile creates GNU_FORMAT tar 
files by default, hence it uses an additional GNUTYPE_LONGNAME header for 
filenames 100 chars. That's why tarfile_issue.py fails if used with 
PAX_FORMAT, because PAX_FORMAT doesn't have this bug.

--
keywords: +patch
Added file: http://bugs.python.org/file36045/issue21987.diff

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



[issue17709] http://docs.python.org/2.7/objects.inv doesn't support :func:`repr` or :exc:`Exception`

2014-07-23 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Cannot reproduce.

--
nosy: +asvetlov
resolution:  - out of date
stage:  - resolved
status: open - closed

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



[issue21777] Separate out documentation of binary sequence methods

2014-07-23 Thread Nick Coghlan

Nick Coghlan added the comment:

3rd in progress draft - converted most of the inherently assumes ASCII docs 
now. I think this set of changes really makes it clear how non-trivial it 
actually is to infer the binary domain behaviour from the str docs, which have 
all sorts of Unicode complications. You can't easily infer the behaviour from 
the Python 2 docs either, since these operations were locale dependent for 
Python 2 str objects.

--
Added file: 
http://bugs.python.org/file36046/separate_binary_sequence_docs_v3.diff

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



[issue21777] Separate out documentation of binary sequence methods

2014-07-23 Thread Nick Coghlan

Nick Coghlan added the comment:

Note I haven't added back the immutability guarantees yet - I'll do that before 
declaring this ready for final review.

--

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



[issue21777] Separate out documentation of binary sequence methods

2014-07-23 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +chris.jerdonek, ezio.melotti, zach.ware
stage:  - patch review

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



[issue22045] Python make issue

2014-07-23 Thread Shannon Kerr

New submission from Shannon Kerr:

If you execute the following commands on a system that doesn’t already have 
Python 2.7.X installed on it, it will result in bloated libs that statically 
link libpythyon2.7.a instead of the locally built libpython2.7.so:

./configure
make
sudo make install
./configure —enable-shared
make
sudo make install


Due to the library search path order in the Python build tools being:
-L /usr/local/lib -L .
the first lib found is in /usr/local/lib and it is the static library, so this 
is used to link.  This results in, for example, cPickle.so being 4.9M instead 
of 188K.

Shouldn't the just-built local library be used before anything on the system?

--
components: Build
messages: 223736
nosy: skerr
priority: normal
severity: normal
status: open
title: Python make issue
versions: Python 2.7

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



[issue22045] Python make issue

2014-07-23 Thread Shannon Kerr

Changes by Shannon Kerr sk...@tycoint.com:


--
type:  - compile error

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



[issue22045] Python make issue

2014-07-23 Thread Shannon Kerr

Changes by Shannon Kerr sk...@tycoint.com:


--
type: compile error - behavior

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



[issue22046] ZipFile.read() should mention that it might throw NotImplementedError

2014-07-23 Thread Jason Heeris

New submission from Jason Heeris:

As per issue 5701, the zipfile.ZipFile.read() method will throw a 
NotImplementedError if the compression scheme is not supported. However, there 
is no mention of this possibility in the documentation for the read() method. I 
would suggest, say, Calling read() on a ZipFile that uses an unsupported 
compression scheme (eg. implode) will raise a NotImplementedError.

It looks like you can use the testzip() method to check that this won't happen 
(ie. after you open the file but before you extract an entry). If that is 
really the expected way to check for this kind of condition, it would be nice 
to mention that too (under either method).

--
assignee: docs@python
components: Documentation
messages: 223737
nosy: detly, docs@python
priority: normal
severity: normal
status: open
title: ZipFile.read() should mention that it might throw NotImplementedError
type: enhancement
versions: Python 2.7, Python 3.3

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



[issue22041] http POST request with python 3.3 through web proxy

2014-07-23 Thread Alejandro Mj

Changes by Alejandro Mj witchar...@gmail.com:


--
nosy:  -AlexMJ

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



[issue21591] exec(a, b, c) not the same as exec a in b, c in nested functions

2014-07-23 Thread Dirkjan Ochtman

Changes by Dirkjan Ochtman dirk...@ochtman.nl:


--
nosy: +djc

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



[issue17293] uuid.getnode() MAC address on AIX

2014-07-23 Thread Mark Lawrence

Mark Lawrence added the comment:

David is listed against AIX on the experts list 
https://docs.python.org/devguide/experts.html.  That alone suggests to me that 
AIX is an officially supported platform.

--

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



[issue14484] missing return in win32_kill?

2014-07-23 Thread STINNER Victor

STINNER Victor added the comment:

I understand that os.kill(pid, sig) should call TerminateProcess() or 
GenerateConsoleCtrlEvent() depending on the value of sig.

The problem is that these two functions are very different. A process can set a 
control handler for CTRL_C_EVENT and CTRL_BREAK_EVENT, so can decide how to 
handle GenerateConsoleCtrlEvent() event.

TerminateProcess() kills the process with the specified exit code.

To me it looks wrong to call TerminateProcess() with a signal number or event 
for the exit code!? We need to expose TerminateProcess() as a new Python 
function, os.TerminateProcess(pid, exitcode) for example.

os.kill(pid, sig) should raise a ValueError if sig is not CTRL_C_EVENT nor 
CTRL_BREAK_EVENT.

--
nosy: +haypo

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



[issue22041] http POST request with python 3.3 through web proxy

2014-07-23 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


--
nosy: +demian.brecht

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



[issue22038] Implement atomic operations on non-x86 platforms

2014-07-23 Thread STINNER Victor

STINNER Victor added the comment:

+ #define __ATOMIC_RELAXED 0

You should use the _Py_ prefix for these constants, to avoid conflicts in 
applications.

(You may also replace tabs with spaces, the PEP 7 says Use 4-space indents and 
no tabs at all. but I also prefer to avoid tabs in other places.)

I tested your patch on Fedora 20 (Linux kernel 3.14.8, GCC 4.8.2, glibc 2.18) 
on x86_64 (Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz) and the whole Python test 
suite pass.

GCC 4.9 (released a few month ago) provides the stdatomic.h header:
https://gcc.gnu.org/gcc-4.9/changes.html

pyatomic.h contains this comment:

/* XXX: When compilers start offering a stdatomic.h with lock-free
   atomic_int and atomic_address types, include that here and rewrite
   the atomic operations in terms of it. */

But using stdatomic.h header can be done in a separated issue.

--
nosy: +haypo

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



[issue21580] PhotoImage(data=...) apparently has to be UTF-8 or Base-64 encoded

2014-07-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +terry.reedy

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



[issue21888] plistlib.FMT_BINARY behavior doesn't send required dict parameter

2014-07-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
assignee:  - serhiy.storchaka

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



[issue21423] concurrent.futures.ThreadPoolExecutor should accept an initializer argument

2014-07-23 Thread Dan O'Reilly

Dan O'Reilly added the comment:

It seems like everyone agrees that this functionality is useful, so I'm 
reviving this in hopes of getting a patch pushed through. I've updated Andreas' 
patch so that it applies cleanly against the latest tree, and tweaked the 
handling of exceptions in initializer. Now, ProcessPoolExecutor will raise a 
BrokenPoolException should an initializer method fail, and ThreadPoolExecutor 
will raise a RunTimeError stating that the pool can't be used because an 
initializer failed.

I was hoping to use multiprocessing.Pool's handling of initializer exceptions 
as a guide for the right behavior here, but it actually does terrible job: an 
exception raised in the initializer is completely unhandled, and results in an 
endless loop of new processes being started up and immediately failing. But 
that's a separate bug report. :)

For now there are still unit tests for testing exceptions being raised in the 
initializer, but they're noisy; the traceback for each initializer exception 
gets printed to stdout. I'm not sure if that's undesirable behavior or not.

If the new behavior looks ok, the docs will need an update to.

--
nosy: +dan.oreilly
Added file: http://bugs.python.org/file36047/pool_init.patch

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



[issue21044] tarfile does not handle file .name being an int

2014-07-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 825137d0d4ca by Serhiy Storchaka in branch '3.4':
Correct issue #21044 patch author.
http://hg.python.org/cpython/rev/825137d0d4ca

New changeset 4fe27263f9d4 by Serhiy Storchaka in branch 'default':
Correct issue #21044 patch author.
http://hg.python.org/cpython/rev/4fe27263f9d4

--

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



[issue21888] plistlib.FMT_BINARY behavior doesn't send required dict parameter

2014-07-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 09746dc1a3b4 by Serhiy Storchaka in branch '3.4':
Issue #21888: plistlib's load() and loads() now work if the fmt parameter is
http://hg.python.org/cpython/rev/09746dc1a3b4

New changeset 275d02865d11 by Serhiy Storchaka in branch 'default':
Issue #21888: plistlib's load() and loads() now work if the fmt parameter is
http://hg.python.org/cpython/rev/275d02865d11

--
nosy: +python-dev

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



[issue22047] argparse improperly prints mutually exclusive options when they are in a group

2014-07-23 Thread Sam Kerr

New submission from Sam Kerr:

The following code:

   import argparse
   parser = argparse.ArgumentParser()
   group1 = parser.add_mutually_exclusive_group()
   group2 = group1.add_mutually_exclusive_group()
   group2.add_argument('-hello',action='store_true', help=A flag)
   args = parser.parse_args()

produces this output:

   skerr@gravel:~$ python bug.py -h
   usage: bug.py [-h] [[-hello]

   optional arguments:
-h, --help  show this help message and exit
-hello  A flag
   skerr@gravel:~$ 

Note the double [[ around hello, but there is no double ]] to close it. This is 
the error.

--
components: Library (Lib)
messages: 223744
nosy: Sam.Kerr
priority: normal
severity: normal
status: open
title: argparse improperly prints mutually exclusive options when they are in a 
group
type: behavior
versions: Python 2.7

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



[issue21888] plistlib.FMT_BINARY behavior doesn't send required dict parameter

2014-07-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


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

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



[issue18168] plistlib output self-sorted dictionary

2014-07-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
resolution:  - out of date
stage:  - resolved
status: open - closed

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



[issue1598] unexpected response in imaplib

2014-07-23 Thread Lita Cho

Changes by Lita Cho lita@gmail.com:


--
nosy:  -Lita.Cho

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



  1   2   >