MicroPython 1.3.7 released

2014-12-08 Thread Paul Sokolovsky
Hello,

MicroPython is a Python3 language implementation which scales down to
run on microcontrollers with tens of Ks of RAM and few hundreds of Ks
of code size. Besides microcontrollers, it's also useful for small
embedded Linux systems, where storage space is limited, for embedding
as a scripting engine into standalone applications, where quick startup
time is needed, etc.

http://micropython.org/
https://github.com/micropython/micropython

It went several months since the original announcement of MicroPython 1.0
(https://mail.python.org/pipermail/python-list/2014-June/672994.html),
there were number of releases in the meantime, but we were too busy
implementing new features, so this announcement provides just high-level
overview of changes:

* Basic Unicode support added (thanks to Chris Angelico for driving the
  effort)
* More functionality of standard types and functions are implemented
  (for example, MicroPython can run subset of http.client module
  functionality from CPython3 stdlib).
* Highly optimized for code size implementations of important Python
  modules are added. There offer subset of functionality and prefixed
  with u. For example, ure, uheapq, uzlib, uhashlib, ubinascii are
  provided.
* Lots of microcontroller hardware bindings added and generalized. 


Besides core interpreter, there's also good progress on modules and
applications:

* MicroPython standard library project,
  https://github.com/micropython/micropython-lib , an effort to
  port/develop as much as possible Python stdlib modules to
  MicroPython, has good progress, with few dozens of modules available
  on PyPI already (pip-micropython wrapper is provided to install
  them).
* An asyncio subset implementation, dubbed uasyncio, is available
  and should be stable enough.
* Proof of concept web microframework, picoweb, based on uasyncio is
  being developed: https://github.com/pfalcon/picoweb
* Lots of other projects available on github.


Reference implementation of MicroPython runs on a microcontroller board
with 1Mb Flash and 128Kb RAM, which should offer good platform for
people interested in microcontroller usage (more info:
http://micropython.org/). MicroPython can also be easily built and
supported on Linux, MacOSX, and Windows systems (more info:
https://github.com/micropython/micropython)


-- 
Best regards,
 Paul  mailto:pmis...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: Bokeh 0.7 released

2014-12-08 Thread Damian Avila
On behalf of the Bokeh team, I am very happy to announce the release of
Bokeh version 0.7!

Bokeh is a Python library for visualizing large and realtime datasets on
the web.
Its goal is to provide to developers (and domain experts) with capabilities
to easily create novel and powerful visualizations that extract insight
from local or remote (possibly large) data sets, and to easily publish
those visualization to the web for others to explore and interact with.

This release includes many major new features:

* IPython widgets and animations without a Bokeh server
* Touch UI working for tools on mobile devices
* Vastly improved linked data table
* More new (and improving) bokeh.charts (high level charting interface)
* Color mappers on the python side
* Improved toolbar
* Many new tools: lasso, poly, and point selection, crosshair inspector

Check our blog post: http://continuum.io/blog/bokeh-0.7, to watch some of
these tools in action! And you can also see the CHANGELOG for full details.

We would like to mention that the Github Organization for Bokeh is growing!
This organization was already home to bokeh-scala and bokeh.jl, and now the
Bokeh project itself has a new home there as well, located at
https://github.com/bokeh/bokeh. Anyone interested in developing new
language bindings for Bokeh is encouraged to contact us about hosting your
project under this organization.

Also, the release of Bokeh 0.8 should happen in early 2015. Some notable
features we intend to work on are:

* Simplifying production and multi-user Bokeh server deployments
* Colorbar axis and axis location inspectors
* Better support for maps and projections

As usual, don't forget to check out the full documentation, interactive
gallery, and tutorial at

http://bokeh.pydata.org

as well as the Bokeh IPython notebook nbviewer index (including all the
tutorials) at:


http://nbviewer.ipython.org/github/bokeh/bokeh-notebooks/blob/master/index.ipynb

To install the latest release, if you are using Anaconda, you can install
it with conda:

conda install bokeh

Alternatively, you can install it with pip:

pip install bokeh

BokehJS is also available by CDN for use in standalone Javascript
applications:

http://cdn.pydata.org/bokeh-0.7.0.min.js
http://cdn.pydata.org/bokeh-0.7.0.min.css

Finally, BokehJS is also installable with the Node Package Manager.

Issues, enhancement requests, and pull requests can be made on the Bokeh
Github page: https://github.com/bokeh/bokeh

Questions can be directed to the Bokeh mailing list: bo...@continuum.io

Thank you for your attention!

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

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


SQLObject 1.7.0

2014-12-08 Thread Oleg Broytman
Hello!

I'm pleased to announce version 1.7.0, the first stable release of branch
1.7 of SQLObject.


What's new in SQLObject
===

* Python 2.5 is no longer supported. The minimal supported version is
  Python 2.6.

* DateTimeCol and TimeCol can read values with microseconds (created by
  SQLObject 2.0) but do not write microseconds back.

* Upgrade ez_setup to 2.2.

* Adapt duplicate error message strings for SQLite 3.8.

* Allow unicode in .orderBy(u'-column').

* Fix a minor bug in MSSQLConnection: do not override callable server_version
  with a non-callable.

Contributors for this release are Geoffrey Wossum, Neil Muller and
Andrew Trusty.

For a more complete list, please see the news:
http://sqlobject.org/News.html


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
https://pypi.python.org/pypi/SQLObject/1.7.0

News and changes:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Re: module import questions and question about pytest and module imports

2014-12-08 Thread sam pendleton
Thanks for getting back with me!

On Sun, Dec 7, 2014 at 11:26 AM, Dave Angel da...@davea.name wrote:
 On 12/05/2014 11:50 PM, sam pendleton wrote:

 garage/
  |- __init__.py
  |- cars/
  |- __init__.py
  |- hummer.py
 tests/
  |- test_cars.py

 at the top of test_cars.py, there is this:
  from garage.cars import hummer

 pytest is on this import statement, so i guess it's incorrect.


 No idea what that statement is trying to say.

Sorry Dave, I was saying that pytest is hung up there stating it can't
import that module.


 If you're going to import something, it either has to be on the sys.path, or
 in the current directory.  Is garage/ on your sys.path?

 You can examine sys.path  by
import sys
print(sys.path)

Having to put the garage package on the sys.path seems a little off,
why wouldn't relative imports work?

Do most people somehow put their packages in sys.path when bundling
their python packages up to be shared with setuptools or other python
package managers? If so, how?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Iterables struggling using map() built-in

2014-12-08 Thread Steven D'Aprano
On Mon, 08 Dec 2014 11:35:36 +1100, Chris Angelico wrote:

 On Mon, Dec 8, 2014 at 11:27 AM, Roy Smith r...@panix.com wrote:
 Although, to be honest, I'm wondering if this is more straight-forward
 (also not tested):

 def myzip37(*args):
 if not args:
 return
 iters = list(map(iter, args))
 
 Yes, I prefer this too. It's explicit and clear that passing no
 arguments will yield no values.

The first version is explicit and clear too. I'm sorry to say this, but 
it is true: if you (generic you) don't recognise that

while iters:
...


skips the while block if iters is an empty list, then *you* have a 
problem, not the code. You're simply not fluent with the language. (Or 
you have a strange blind-spot, in which case you have my sympathy but 
that's your problem to deal with, not mine.) This is not an obscure 
corner of some rarely-used library that has a strange and weird API, it 
is a fundamental part of Python.

I *guarantee* that there are people who will bitch and moan about your 
example too, and insist that the only right way to write it is to be 
explicit that an empty tuple is falsey:

if not args == ():
return

and there will be some who are convinced that operator precedence is too 
implicit:

if not (args == ()):   # args != () is okay too
return


Dumbing down code is an anti-pattern, because there's always somebody 
just a little less fluent in the language who will complain that it isn't 
dumbed down enough.

Sometimes we have this meme that if you can't take in code at a glance 
and instantly understand it, it's bad code. But that meme is untrue, and 
we all know that it is untrue: real world code is often hard to 
understand because it can't be any simpler. Try understanding the code 
for a web server, or code that calculates the square root of a number, or 
code for importing a module.

Occasionally, very occasionally, we have a combination of programming 
language and algorithm which combines in such a way that you can actually 
implement a useful algorithm in a simple, elegant, minimalist way. As 
programmers, we all know how fecking rare this is: we start with an 
elegant five line function, and by the time we cover all the corners and 
fix the bugs it's twenty lines and you can't tell what it does any more 
without studying it for ten minutes. zip() is an exception, you can write 
zip() in Python beautifully. It breaks my heart that there are people who 
think that it is improved by adding unnecessary guard clauses to it.



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


Re: Python Iterables struggling using map() built-in

2014-12-08 Thread Chris Angelico
On Mon, Dec 8, 2014 at 8:40 PM, Steven D'Aprano st...@pearwood.info wrote:
 The first version is explicit and clear too. I'm sorry to say this, but
 it is true: if you (generic you) don't recognise that

 while iters:
 ...


 skips the while block if iters is an empty list, then *you* have a
 problem, not the code.

Of course it skips the body if iters starts out empty. The argument is
whether or not it makes sense to use this to mean if iters: while
True: because iters will never be changed. Is it abusing syntax or a
valid way to spell that condition?

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


Re: Reasons for source code line length limits (was: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?)

2014-12-08 Thread Gene Heskett
On Sunday 07 December 2014 23:44:40 Ben Finney did opine
And Gene did reply:
 jtan ad...@grails.asia writes:
  One reason why you would want max length 79 is because of working
  with terminals.
 
 That reason is decreasingly relevant as terminals become virtual, in a
 display window that can be much larger if we choose.
 
 Much more relevant is the ability to have two or even three code
 windows side-by-side, for comparison during a merge operation. For
 this purpose, a 75–80 column limit is a great help.
 
 But regardless of display technology, the biggest reason to stick to a
 limit like 80 or less is: reader technology. The ability for humans to
 comprehend long lines of text is poor, and there *is* a cognitive point
 beyond which it's not helpful to have longer lines.
 
 That line-length limit is different for different people, and many
 readers (and especially code writers) will fool themselves that they
 can read longer lines while unknowingly harming their comprehension.
 But for sure, it remains relatively constant across generations of
 humans, no matter how the display capacity increases.

This last point about line length vs comprehension, I am glad you 
mentioned, Ben. I still work in assembler on smaller, narrower bus 
machines, and I find that the one operation on data per line of source is 
a great help in tracking what the code is doing,  The biggest problem with 
that is that most assemblers format the output listing so the comments 
column starts at column 40 or so.  This 80 column limit, purely arbitrary, 
often results in the printout listing being clipped off, or is line 
wrapped by the printer driver, severely reducing the value of the comment 
when you want to revisit that code later for some reason.  For that 
reason, I generally do my assembler listing printouts with the -olandscape 
switch in effect.

Even in the gcode I write (I have some cnc mill and lathe machines) is 
usually wide enough that the landscape mode for the paper copy is used.

Now if one could buy 3 ring binders for landscape printouts. But ask for 
those at Staples and you, like the sign says, get the dumb looks for free. 
:(

Some languages need character wasting wrappers around the variable names 
used, and in gcode that is a 3 or 4 character wrapper dependent on 
whether its to be local to the subroutine, or is globally visible from 
anyplace in the program. Gcode itself hasn't a line length limit that 
matters, 32k IIRC, but I still like to limit data manipulations to 5 
additions and maybe a couple of mul's per line. However for me, that has 
comprehension problems for the exact reason that it winds up doing far 
more data manipulation per line, so I will often use a local variable, 
with one manipulation per line, a heck of a lot easier to understand even 
2 weeks later as my short term memory isn't as good as the years go by, 
and there are now 80 of them.

So it is a valid concern Ben, thanks for mentioning it.  I have an intense 
dislike for folks who think they should build an empire state building in 
one line of code.

Cheers, Gene Heskett
-- 
There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order.
-Ed Howdershelt (Author)
Genes Web page http://geneslinuxbox.net:6309/gene
US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS
-- 
https://mail.python.org/mailman/listinfo/python-list


MicroPython 1.3.7 released

2014-12-08 Thread Paul Sokolovsky
Hello,

MicroPython is a Python3 language implementation which scales down to
run on microcontrollers with tens of Ks of RAM and few hundreds of Ks
of code size. Besides microcontrollers, it's also useful for small
embedded Linux systems, where storage space is limited, for embedding
as a scripting engine into standalone applications, where quick startup
time is needed, etc.

http://micropython.org/
https://github.com/micropython/micropython

It went several months since the original announcement of MicroPython 1.0
(https://mail.python.org/pipermail/python-list/2014-June/672994.html),
there were number of releases in the meantime, but we were too busy
implementing new features, so this announcement provides just high-level
overview of changes:

* Basic Unicode support added (thanks to Chris Angelico for driving the
  effort)
* More functionality of standard types and functions are implemented
  (for example, MicroPython can run subset of http.client module
  functionality from CPython3 stdlib).
* Highly optimized for code size implementations of important Python
  modules are added. There offer subset of functionality and prefixed
  with u. For example, ure, uheapq, uzlib, uhashlib, ubinascii are
  provided.
* Lots of microcontroller hardware bindings added and generalized. 


Besides core interpreter, there's also good progress on modules and
applications:

* MicroPython standard library project,
  https://github.com/micropython/micropython-lib , an effort to
  port/develop as much as possible Python stdlib modules to
  MicroPython, has good progress, with few dozens of modules available
  on PyPI already (pip-micropython wrapper is provided to install
  them).
* An asyncio subset implementation, dubbed uasyncio, is available
  and should be stable enough.
* Proof of concept web microframework, picoweb, based on uasyncio is
  being developed: https://github.com/pfalcon/picoweb
* Lots of other projects available on github.


Reference implementation of MicroPython runs on a microcontroller board
with 1Mb Flash and 128Kb RAM, which should offer good platform for
people interested in microcontroller usage (more info:
http://micropython.org/). MicroPython can also be easily built and
supported on Linux, MacOSX, and Windows systems (more info:
https://github.com/micropython/micropython)


-- 
Best regards,
 Paul  mailto:pmis...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-08 Thread Jean-Michel Pichavant
- Original Message -
 From: Aahan Krish kr...@aahan.me
 To: python-list@python.org
 Sent: Monday, 8 December, 2014 3:15:43 AM
 Subject: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?
 
 My understanding from talking to different people is that many do use
 tabs (instead of spaces) for indentation in their code.
 
 My question is to them (because I want to use tabs too) is: how do
 you
 maintain a line-length of 79 characters?
 
 E.g. scenario: The tab setting in your editor could be 2 or 4, and in
 other developer's browser it could be 8. The code will be longer than
 79 chars in the latter's editor.
 
 I want to know if it's at all possible or if you use some simple and
 realistic (practical) hacks.
 
 *PS: Please avoid, That's why you should use spaces, type of
 comments. I would like to avoid flame wars.*
 
 TY,
 Aahan

You simply need to define the standard width for you tab display. 4 is very 
common.

Those in your team who want to use a different display (3 flowers for instance) 
can, but they'll have to deal with the 79 limit by themselves which can be 
tricky.
Note that the 79 limit is a legacy value from the time where code was developed 
in 80 characters terminals with names not exceeding 8 characters (by 
convention).

Given the number of monitors you have and their width, you may extend this 
limit. For instance, I can easily make a 3 files merge with 160 chars per line 
without problem.
Considering the current state of most developer hardware, a limit around 100 
char per line is most of the time a better choice.

Remember that breaking a line of 81 characters often leads to readability issue 
for no (modern) reason.


JM






-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: module import questions and question about pytest and module imports

2014-12-08 Thread Dave Angel

On 12/07/2014 11:50 AM, sam pendleton wrote:

Thanks for getting back with me!

On Sun, Dec 7, 2014 at 11:26 AM, Dave Angel da...@davea.name wrote:

On 12/05/2014 11:50 PM, sam pendleton wrote:


garage/
  |- __init__.py
  |- cars/
  |- __init__.py
  |- hummer.py
tests/
  |- test_cars.py

at the top of test_cars.py, there is this:
  from garage.cars import hummer

pytest is on this import statement, so i guess it's incorrect.



No idea what that statement is trying to say.


Sorry Dave, I was saying that pytest is hung up there stating it can't
import that module.


Why don't you just try running the module, and post the stacktrace when 
it gets an exception?  I've never used pytest, and don't know why it 
would hang on any particular line.






If you're going to import something, it either has to be on the sys.path, or
in the current directory.  Is garage/ on your sys.path?

You can examine sys.path  by
import sys
print(sys.path)


Having to put the garage package on the sys.path seems a little off,
why wouldn't relative imports work?

Do most people somehow put their packages in sys.path when bundling
their python packages up to be shared with setuptools or other python
package managers? If so, how?



When you get to the point of bulding a distribution, you'll be putting 
your packages in the dist_packages directory, which is on sys.path. 
However, generally your distribution utility will handle those details.


In the meantime, you can set some environment variable to add locally to 
your sys.path.


As for relative import versus other choices, that varies between Python 
2.x and 3.x, and you haven't specified exactly what Python version 
you're running or what OS you're on.


In Python 2.x, relative import was considered to be ambiguous, and 
people figured it had to change.  You might want to read


https://docs.python.org/2.5/whatsnew/pep-328.html


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


Re: Nested dictionaries from a list ?

2014-12-08 Thread Dave Angel

On 12/07/2014 06:52 PM, Denis McMahon wrote:

On Sun, 07 Dec 2014 12:01:26 -0500, Dave Angel wrote:


On 12/07/2014 11:18 AM, Wacky wrote:



I've a list of users 



I haven't run this through the Python, so please forgive any typos.



users = [ 
mess = { 


users is redundant, as it's mess.keys()

maintaining a separate list of users and having the users as the keys in
mess suggests redundancy, and the potential for errors if the two data
items get out of synch. Better imo to just have the data in one place.



Unless there's an order that wants to be retained.  But I would change 
the list into a list of user objects, rather than of strings.  And I'd 
know that eventually it would be a sparse list (as users come and go, 
and you don't want to reuse the indices).  So it would be another 
dictionary mapping userid and User instance.


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


Re: module import questions and question about pytest and module imports

2014-12-08 Thread Jean-Michel Pichavant
- Original Message -
 From: sam pendleton samp4...@gmail.com
 Having to put the garage package on the sys.path seems a little off,
 why wouldn't relative imports work?
 
 Do most people somehow put their packages in sys.path when bundling
 their python packages up to be shared with setuptools or other python
 package managers? If so, how?

If it feels more natural to you, you can also update the env variable 
PYTHONPATH and add the path to your dev package.
That way you don't need to add python code.

But if you plan to distribute your package with setuptools, the solution would 
probably be to install your package before testing it (and probably use 
virtualenv).

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


why can't download file from linux server into local window disk c:?

2014-12-08 Thread pengsir



My vps ip is x.y.z.w ,i want to download /etc/passwd from linux server  
into my local window disk c: .


import paramiko
host = x.y.z.w
port = 22
transport = paramiko.Transport((host, port))
password = mykey
username = root
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
filepath = '/etc/passwd'
localpath = 'c:'
sftp.get(filepath, localpath)

Traceback (most recent call last):
  File stdin, line 1, in module
  File D:\Python34\lib\site-packages\paramiko\sftp_client.py, line 
719, in get


with open(localpath, 'wb') as fl:
PermissionError: [Errno 13] Permission denied: 'c:'
--
https://mail.python.org/mailman/listinfo/python-list


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Luuk

On 9-12-2014 09:14, pengsir wrote:



My vps ip is x.y.z.w ,i want to download /etc/passwd from linux server
into my local window disk c: .

import paramiko
host = x.y.z.w
port = 22
transport = paramiko.Transport((host, port))
password = mykey
username = root
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
filepath = '/etc/passwd'
localpath = 'c:'
sftp.get(filepath, localpath)

Traceback (most recent call last):
   File stdin, line 1, in module
   File D:\Python34\lib\site-packages\paramiko\sftp_client.py, line
719, in get

 with open(localpath, 'wb') as fl:
PermissionError: [Errno 13] Permission denied: 'c:'


You, 'root', does not have enoug permission to do it


C:\temp\util\Putty\pscp root@opensuse:/etc/passwd .
Using keyboard-interactive authentication.
Password:
Access denied



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


Re: localization virt-manager

2014-12-08 Thread belyaevigorek
пятница, 28 ноября 2014 г., 16:42:40 UTC+3 пользователь Akira Li написал:
 Беляев Игорь belyaevigo...@yandex.ru writes:
 
  I can't install localization for Virt-manager (virt-manager launched on 
  python2.7 (Windows XP)).
 
 virt-manager is a GUI for KVM, Xen, LXC virtual machines. It is a Linux
 application.
 
I understand that virt-manager is a Linux application. But I ran virt-manager 
on Windows. 

  How do I correctly install location? 
 
 Do you mean *locale*?
 
Under *locale* I understand localization. Not translated strings from *.ui 
files. The problem lies in the localization.
  How can I change the value of the environment variable LANG?
 
 On Windows, you could use *setx* command to set an environment variable.
 
 LANG envvar defines a default value for LC_* envvars on POSIX systems [1]
 that define application's locale (after setlocale() call) e.g., in bash:
 
   $ LANG=en_US.UTF-8 some-program
 
 I don't know whether LANG has any meaning on Windows.
 
 [1] http://pubs.opengroup.org/onlinepubs/007908799/xbd/envvar.html
 
 
 --
 Akira


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


[newbie] how to make program suggest to install missing modules

2014-12-08 Thread hugocoolens
I'd like to add the following to a python-program:

when a module (take rtlsdr as an example) is not installed on the system I'd 
like to ask the program something like:

module rtlsdr is missing, shall I install it? y or n
if n --sorry but then I can't run this program and quit program
if y --execute this command: 
os.system(sudo pip install pyrtlsdr)

continue program

can anyone here show me how to perform this properly?

thanks in advance
hugo

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


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread ishish

with open(localpath, 'wb') as fl:
PermissionError: [Errno 13] Permission denied: 'c:'


I remember gloomily (haven't used windows since ages) that newer 
Windows versions don't like users to write directly to C:. Have you 
tried to save the file to your Documents folder?


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


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Luuk

On 8-12-2014 18:37, ishish wrote:

with open(localpath, 'wb') as fl:
PermissionError: [Errno 13] Permission denied: 'c:'


I remember gloomily (haven't used windows since ages) that newer Windows
versions don't like users to write directly to C:. Have you tried to
save the file to your Documents folder?

Regards,
Alba


no, it's the ssh-server denying a log on from 'root'
--
https://mail.python.org/mailman/listinfo/python-list


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Chris Angelico
On Tue, Dec 9, 2014 at 5:11 AM, Luuk luu...@gmail.com wrote:
 On 8-12-2014 18:37, ishish wrote:

 with open(localpath, 'wb') as fl:
 PermissionError: [Errno 13] Permission denied: 'c:'


 I remember gloomily (haven't used windows since ages) that newer Windows
 versions don't like users to write directly to C:. Have you tried to
 save the file to your Documents folder?

 Regards,
 Alba


 no, it's the ssh-server denying a log on from 'root'

It looks to me more like an issue with path naming. Try 'c:/' instead
of 'c:', or use '/' to mean the root directory of the current drive.
Alternatively, do a web search for the problem and the symptoms, as
you're unlikely to be the first person to have run into this.

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


Re: [newbie] how to make program suggest to install missing modules

2014-12-08 Thread sohcahtoa82
On Monday, December 8, 2014 9:44:50 AM UTC-8, hugocoolens wrote:
 I'd like to add the following to a python-program:
 
 when a module (take rtlsdr as an example) is not installed on the system I'd 
 like to ask the program something like:
 
 module rtlsdr is missing, shall I install it? y or n
 if n --sorry but then I can't run this program and quit program
 if y --execute this command: 
 os.system(sudo pip install pyrtlsdr)
 
 continue program
 
 can anyone here show me how to perform this properly?
 
 thanks in advance
 hugo

Hint:

try:
import someModule
except ImportError:
print Module is missing
# handle it!

Just make sure to attempt to import it again after making the call to pip to 
install it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Is cmd.Cmd.cmdloop() integration with asyncio server possible?

2014-12-08 Thread Benjamin Risher
I'm working on an asyncio server project.  I'd also like to have a cmd.Cmd 
style command loop interface for spawning instances of the server.  As far as 
I've seen, running an asyncio server requires

...
loop.run_forever()
...

And cmd.Cmd.cmdloop() is a blocking loop, so I'm not able to call them 
sequentially.  Is there a way to get the cmdloop to run asynchronously?  Or a 
way to call asyncio.streams.start_server from the cmdloop and actually have it 
run continuously?  I've tried a few things but nothing has been successful.  I 
should mention that by itself, the server functions.

For brevity, I'll try to keep the code to what is relevant.  

class MyServer:
...
def start():
server = asyncio.async(
asyncio.streams.start_server(
self.accept_client,
host=self.ip,
port=self.port,
loop=self.loop
)
)
return server
...

class MyMenu(cmd.Cmd):
def __init__(self, loop):
cmd.Cmd.__init__(self)

...
do_serve(self, **kwargs):
server = MyServer(self.loop, **kwargs)
instance = server.start()

if __name__ == '__main__':
loop = asyncio.get_event_loop()
menu = MyMenu(loop)
menu.cmdloop()

Calling loop.run_forever() at any point breaks the menu functionality.  Any 
help would be greatly appreciated.  

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


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread MRAB

On 2014-12-09 08:14, pengsir wrote:



My vps ip is x.y.z.w ,i want to download /etc/passwd from linux server
into my local window disk c: .

import paramiko
host = x.y.z.w
port = 22
transport = paramiko.Transport((host, port))
password = mykey
username = root
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
filepath = '/etc/passwd'
localpath = 'c:'
sftp.get(filepath, localpath)

Traceback (most recent call last):
File stdin, line 1, in module
File D:\Python34\lib\site-packages\paramiko\sftp_client.py, line
719, in get

  with open(localpath, 'wb') as fl:
PermissionError: [Errno 13] Permission denied: 'c:'


It's trying to open the file 'c:', but that's not a file, it's a folder.

Try, say, 'c:/passwd' instead.
--
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] how to make program suggest to install missing modules

2014-12-08 Thread Jean-Michel Pichavant
- Original Message -
 From: sohcahto...@gmail.com
 try:
 import someModule
 except ImportError:
 print Module is missing
 # handle it!
 
 Just make sure to attempt to import it again after making the call to
 pip to install it.

Note that ImportError may be raised for other reasons than a missing module.

Check https://docs.python.org/2/library/imp.html and the imp.find_module, it 
could be a safer way to check for a missing module.

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread alister
On Mon, 08 Dec 2014 19:11:40 +0100, Luuk wrote:

 On 8-12-2014 18:37, ishish wrote:
 with open(localpath, 'wb') as fl:
 PermissionError: [Errno 13] Permission denied: 'c:'

 I remember gloomily (haven't used windows since ages) that newer
 Windows versions don't like users to write directly to C:. Have you
 tried to save the file to your Documents folder?

 Regards,
 Alba
 
 no, it's the ssh-server denying a log on from 'root'

windows systems dont usualy have an SSH server  root is not a normal 
windows user name

on most systems that DO have a ssh server root logins are usually 
prohibited, either enable root logins (dangerous) or log in with a user 
that has permissions to do what you require. if you don't have access to 
the server then you need assistance from someone who is authorised.






-- 
Do you know Montana?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: jitpy - Library to embed PyPy into CPython

2014-12-08 Thread Joshua Landau
On 7 December 2014 at 14:31, Albert-Jan Roskam
fo...@yahoo.com.dmarc.invalid wrote:
 On Sun, Dec 7, 2014 11:06 AM CET Stefan Behnel wrote:

I think this is trying to position PyPy more in the same corner as other
JIT compilers for CPython, as opposed to keeping it a completely separate
thing which suffers from being not CPython. It's a huge dependency, but
so are others.

 You mean like psyco? Well, if implementation differences between cpython and 
 pypy are a problem, it might be useful. I've only come across a few 
 unimportant ones. Bu then, I never reimplement __del__.
 http://pypy.readthedocs.org/en/latest/cpython_differences.html

Some libraries don't work on PyPy; SciPy for example. If you want to
use SciPy but use PyPy where appropriate, this is a good bet.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Thomas Rachel

Am 09.12.2014 09:14 schrieb pengsir:


My vps ip is x.y.z.w ,i want to download /etc/passwd from linux server
into my local window disk c: .



localpath = 'c:'


[...]


 with open(localpath, 'wb') as fl:
PermissionError: [Errno 13] Permission denied: 'c:'


That's completely clear: you are not allowed to create a file named 
'c:'. You should replace it with a full path name, such as


localpath = 'c:\\passwd'

or such.


Thomas

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


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Thomas Rachel

Am 08.12.2014 19:11 schrieb Luuk:


no, it's the ssh-server denying a log on from 'root'


You are repating yourself.

How could possibly

with open(localpath, 'wb') as fl:
PermissionError: [Errno 13] Permission denied: 'c:'

be a problem with the SSH server?
--
https://mail.python.org/mailman/listinfo/python-list


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Tim Chase
On 2014-12-08 19:11, Luuk wrote:
 On 8-12-2014 18:37, ishish wrote:
  with open(localpath, 'wb') as fl:
  PermissionError: [Errno 13] Permission denied: 'c:'
 
  I remember gloomily (haven't used windows since ages) that newer
  Windows versions don't like users to write directly to C:. Have
  you tried to save the file to your Documents folder?
 
  Regards,
  Alba
 
 no, it's the ssh-server denying a log on from 'root'

I'm going to go out on a limb and say that's pretty clearly not the
issue.  The exception states that the problem is one of permissions
on the C:

  PermissionError: [Errno 13] Permission denied: 'c:'

which ishish clearly identified as a Windows doesn't let you do that
any more issue.  Additionally, I don't know off the top of my if the
Paramiko libraries expect a file-name, or if they expect a directory
into which the file gets put based on the server-side name.

The best solution is to do as ishish proposed: write the file to some
other appropriate (i.e., writable) location.  A simple fix might be

  import os
  # ...
  localpath = os.path.expanduser('~')

or

  localpath = os.path.join(
os.path.expanduser('~'),
'passwd.txt',
)

A stop-gap solution might be to just run the program in a writable
directory:

  c:\ cd %TEMP%
  c:\...\TEMP python myprog.py

A far worse solution would be to run the script as Administrator on
the Win32 box, which will grant permission to write in the root of C:

-tkc



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


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Tim Chase
On 2014-12-08 18:46, alister wrote:
 on most systems that DO have a ssh server root logins are usually 
 prohibited, either enable root logins (dangerous) or log in with a
 user that has permissions to do what you require. if you don't have
 access to the server then you need assistance from someone who is
 authorised.

Just for the record, you can enable root logins but disallow password
logins, so root has to be done with a public/private key-pair.

That said, I do as you describe and still SSH to my ssh-user account,
then su to root as needed from there.  But at least there's a
middle ground that isn't as vulnerable as putting a root account out
there to be banged on by any script-o-matic bot that finds it.

I also like to change my external SSH port to something
non-traditional (and have configured port-knocking in the past) to
prevent the obvious pokes I would otherwise see in my sshd/auth/access
logs.

-tkc


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


Re: [newbie] how to make program suggest to install missing modules

2014-12-08 Thread sohcahtoa82
On Monday, December 8, 2014 10:46:47 AM UTC-8, Jean-Michel Pichavant wrote:
 - Original Message -
  From: sohcahto...@gmail.com
  try:
  import someModule
  except ImportError:
  print Module is missing
  # handle it!
  
  Just make sure to attempt to import it again after making the call to
  pip to install it.
 
 Note that ImportError may be raised for other reasons than a missing module.
 
 Check https://docs.python.org/2/library/imp.html and the imp.find_module, it 
 could be a safer way to check for a missing module.
 
 JM
 
 
 -- IMPORTANT NOTICE: 
 
 The contents of this email and any attachments are confidential and may also 
 be privileged. If you are not the intended recipient, please notify the 
 sender immediately and do not disclose the contents to any other person, use 
 it for any purpose, or store or copy the information in any medium. Thank you.

Good point.

Of course, imp.find_module ALSO throws ImportError if the module can't be 
found, but at least in that case, you'd know the exact cause.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Chris Angelico
On Tue, Dec 9, 2014 at 6:50 AM, Tim Chase python.l...@tim.thechases.com wrote:
 Just for the record, you can enable root logins but disallow password
 logins, so root has to be done with a public/private key-pair.

 That said, I do as you describe and still SSH to my ssh-user account,
 then su to root as needed from there.  But at least there's a
 middle ground that isn't as vulnerable as putting a root account out
 there to be banged on by any script-o-matic bot that finds it.

I've done both of these. Most of my boxes don't have passwords on the
root account AND don't allow SSH to root, relying on a sudo-enabled
account usually; and it's perfectly possible to also deny password
access to *any* account via SSH. Quite good for security... though it
can create an awkward bootstrap problem if you lose all private keys
that had access.

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


Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-08 Thread sohcahtoa82
 On Mon, Dec 8, 2014 at 10:15 AM, Aahan Krish kr...@aahan.me wrote:
 My understanding from talking to different people is that many do use
 
 tabs (instead of spaces) for indentation in their code.
 
 
 
 My question is to them (because I want to use tabs too) is: how do you
 
 maintain a line-length of 79 characters?
 
 
 
 E.g. scenario: The tab setting in your editor could be 2 or 4, and in
 
 other developer's browser it could be 8. The code will be longer than
 
 79 chars in the latter's editor.
 
 
 
 I want to know if it's at all possible or if you use some simple and
 
 realistic (practical) hacks.
 
 
 
 *PS: Please avoid, That's why you should use spaces, type of
 
 comments. I would like to avoid flame wars.*
 
 
 
 TY,
 
 Aahan

On Sunday, December 7, 2014 6:26:01 PM UTC-8, jtan wrote:
 One reason why you would want max length 79 is because of working with 
 terminals.  Maybe ssh to you server and check how many spaces are consumed by 
 a tab?  In my boxes, it is usually 1 tab = 8 spaces.  So perhaps just use 
 that setting in your editor?


My terminals are 120 columns wide.

Are there still people that are limiting their terminals to 80 columns?  If so, 
why?  I mean, I can understand if you're running on an ancient square monitor, 
but I see no reason to limit your terminal to 80 columns if you're running any 
sort of window environment on monitor with a horizontal resolution greater than 
1280.

Because that's how we've always done it! is a pretty shitty reason to 
continue doing something.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: jitpy - Library to embed PyPy into CPython

2014-12-08 Thread Christopher
On Saturday, December 6, 2014 3:30:56 PM UTC-5, Albert-Jan Roskam wrote:
 
 On Fri, Dec 5, 2014 8:54 PM CET Mark Lawrence wrote:
 
 For those who haven't heard thought this might be of interest 
 https://github.com/fijal/jitpy
 
 Interesting, but it is not clear to me when you would use jitpy instead of 
 pypy. Too bad pypy alone was not included in the benchmarks (cython would 
 have also been nice).

There are plenty of situations. For example, I am building an app that requires 
access to modules that don't currently work under pypy. With this tool I could 
still take advantage of pypy JIT, but use CPython for other stuff.
-- 
https://mail.python.org/mailman/listinfo/python-list


SQLObject 1.7.0

2014-12-08 Thread Oleg Broytman
Hello!

I'm pleased to announce version 1.7.0, the first stable release of branch
1.7 of SQLObject.


What's new in SQLObject
===

* Python 2.5 is no longer supported. The minimal supported version is
  Python 2.6.

* DateTimeCol and TimeCol can read values with microseconds (created by
  SQLObject 2.0) but do not write microseconds back.

* Upgrade ez_setup to 2.2.

* Adapt duplicate error message strings for SQLite 3.8.

* Allow unicode in .orderBy(u'-column').

* Fix a minor bug in MSSQLConnection: do not override callable server_version
  with a non-callable.

Contributors for this release are Geoffrey Wossum, Neil Muller and
Andrew Trusty.

For a more complete list, please see the news:
http://sqlobject.org/News.html


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
https://pypi.python.org/pypi/SQLObject/1.7.0

News and changes:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-08 Thread Ben Finney
sohcahto...@gmail.com writes:

 My terminals are 120 columns wide.

Mine are wider. So what?

 Are there still people that are limiting their terminals to 80
 columns?

I don't know. Terminal width is not the sole reason to keep code lines
within 80 columns.

-- 
 \   “The fundamental principle of science, the definition almost, |
  `\ is this: the sole test of the validity of any idea is |
_o__) experiment.” —Richard P. Feynman |
Ben Finney

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


When do default parameters get their values set?

2014-12-08 Thread bSneddon
I ran into an issue setting variables from a GUI module that imports a back end 
module.  My approach was wrong obviously but what is the best way to set values 
in a back end module.

#module name beTest.py

cfg = { 'def' : 'blue'}

def printDef(argT = cfg['def']):
print argT
 

#module name feTest
import beTest

beTest.cfg['def'] = no red
beTest.printDef()



This prints blue.  I suppose because I am changing a local copy of cfg 
dictionary.  What is the write approach here?


Thanks

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


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread Nobody
On Tue, 09 Dec 2014 00:14:15 -0800, pengsir wrote:

 localpath = 'c:'
 sftp.get(filepath, localpath)

  with open(localpath, 'wb') as fl:
 PermissionError: [Errno 13] Permission denied: 'c:'

It's trying to open c:, which is a drive, as if it was a file.

You have to specify the destination filename, not just the directory.

Also, you probably shouldn't be trying to write to the root directory of
the C drive. You should probably be using a directory beneath either
%USERPROFILE% or %ALLUSERSPROFILE%.

Writing to the root of the system drive tends to require Administrator
privileges. Even if the current user is an administrator, the process must
have elevated privilege (e.g. via Run as Administrator or an explicit
privilege-elevation request from within the code).

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


Re: When do default parameters get their values set?

2014-12-08 Thread Chris Angelico
On Tue, Dec 9, 2014 at 9:10 AM, bSneddon w.g.sned...@gmail.com wrote:
 I ran into an issue setting variables from a GUI module that imports a back 
 end module.  My approach was wrong obviously but what is the best way to set 
 values in a back end module.

 #module name beTest.py

 cfg = { 'def' : 'blue'}

 def printDef(argT = cfg['def']):
 print argT

They're set when you define the function, and become attributes of the function.

If you want to lazily fetch the defaults, here's one common idiom:

def printDef(argT=None):
Print the argT value, defaults to cfg['def']
if argT is None: argT = cfg['def']
print(argT)

This depends on None not being a meaningful argument value, of course.
If you need to have any object at all able to be passed in, you'd need
to create a dedicated sentinel object, or use *args and unpack
yourself; but for a lot of cases, None works fine.

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


Re: When do default parameters get their values set?

2014-12-08 Thread Chris Kaynor
On Mon, Dec 8, 2014 at 2:10 PM, bSneddon w.g.sned...@gmail.com wrote:

 I ran into an issue setting variables from a GUI module that imports a
 back end module.  My approach was wrong obviously but what is the best way
 to set values in a back end module.

 #module name beTest.py

 cfg = { 'def' : 'blue'}

 def printDef(argT = cfg['def']):

print argT


Here is your problem. The default argument value is evaulated at the time
the function is defined, not when it is called, so argT will boung to
'blue' by default, unless overridden in the call.
In this simple case, you could just change the function to:

def printDef():
print cfg['def']

In more complicated cases, where you actually need to pass in the argument
with a default, the best way is to use a sentinel value (I'm using None in
the case):

def printDef(argT = None):
argT = argT or cfg['def'] # If argT could be False or another falsy
value, use argT = argT if argT is not None else cfg['def']. This is also
useful if None needs to be a valid value.
print argT




 #module name feTest
 import beTest

 beTest.cfg['def'] = no red
 beTest.printDef()



 This prints blue.  I suppose because I am changing a local copy of cfg
 dictionary.  What is the write approach here?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: When do default parameters get their values set?

2014-12-08 Thread Dave Angel

On 12/08/2014 05:10 PM, bSneddon wrote:

I ran into an issue setting variables from a GUI module that imports a back end 
module.  My approach was wrong obviously but what is the best way to set values 
in a back end module.



To answer the subject line, the default parameter(s) are evaluated when 
the function is compiled, and then stored with the function.  So in this 
case the default for argT is an immutable string blue  Being 
immutable, nothing will change that for the run of the program.



#module name beTest.py

cfg = { 'def' : 'blue'}

def printDef(argT = cfg['def']):
print argT


#module name feTest
import beTest

beTest.cfg['def'] = no red
beTest.printDef()



This prints blue.  I suppose because I am changing a local copy of cfg 
dictionary.  What is the write approach here?



You're not making a local copy of any dictionary.  The symptoms you have 
would be identical even if you run beTest.py directly (with those two 
lines added, of course).


The RIGHT approach depends on what your goal is here.  Obviously this is 
simplified from some more complex use, but you haven't stated what your 
desires are, so I don't necessarily know how to achieve them.


There is only one dictionary, and it does change when you you say:
   beTest.cfg['def'] = no red

But if you need to do a lookup in that dictionary upon calling 
primtDef(), then you're going to make the evaluation at that time, not 
at default-time.


How about the following, fairly common idiom for default values:

def printDef(argT = None]):
if argT = None:
argT = cfg['def']
print argT





--
DaveA

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


Re: When do default parameters get their values set?

2014-12-08 Thread Tim Chase
On 2014-12-08 14:10, bSneddon wrote:
 I ran into an issue setting variables from a GUI module that
 imports a back end module.  My approach was wrong obviously but
 what is the best way to set values in a back end module.
 
 #module name beTest.py
 
 cfg = { 'def' : 'blue'}
 
 def printDef(argT = cfg['def']):

At this point (after the def has completed defining the function),
the expression is evaluated and assigned to the default argument.

 beTest.cfg['def'] = no red
 beTest.printDef()
 
 This prints blue.  I suppose because I am changing a local copy
 of cfg dictionary.  What is the write approach here?

Well, you can bind to a default dictionary rather than an entry in
that dictionary:


  cfg = {'def': 'blue'}
  def printDef(config=cfg):
...
access(config['def'])

which will make the look-up happen at run-time rather than
definition/bind-time.

  beTest.cfg['def'] = 'Red!'
  beTest.printDef()
  # should print Red!

-tkc



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


Re: Maintaining Maximum Line Length When Using Tabs Instead of Spaces?

2014-12-08 Thread Dave Angel

On 12/08/2014 03:20 PM, sohcahto...@gmail.com wrote:




On Sunday, December 7, 2014 6:26:01 PM UTC-8, jtan wrote:

One reason why you would want max length 79 is because of working with 
terminals.  Maybe ssh to you server and check how many spaces are consumed by a 
tab?  In my boxes, it is usually 1 tab = 8 spaces.  So perhaps just use that 
setting in your editor?



My terminals are 120 columns wide.

Are there still people that are limiting their terminals to 80 columns?  If so, 
why?


I frequently have more than just one terminal open on my xserver.  I 
might have several terminals, or I might also have a browser or another 
application.  And I rearrange the windows so the parts I'm interested in 
are showing whatever I'd like to simultaneously see.



 I mean, I can understand if you're running on an ancient square monitor,
 but I see no reason to limit your terminal to 80 columns if you're running any 
sort of window environment on monitor with a horizontal resolution greater than 
1280.


What's square got to do with anything?  I have displays ranging from 
about 3 inches across to about 29.  The size matters, not usually the 
pixel count (my cell phone has 1920 pixels across).




Because that's how we've always done it! is a pretty  reason to continue 
doing something.


No need to throw feces around.  There are several reasons besides history.

1) physical screen size, divided by the number of simultaneous windows 
one wants horizontally visible.


2) vision acuity.  When the print gets small enough, my elderly eyes 
can't read it reliably.


3) Human preference and ability.  Notice that large books and newspapers 
use multiple columns, or pictures  ads to break up the page.  A line 
beyond some length makes it hard to take it all in at once.


4) Other media.  Sometimes we actually make listings on paper.

If code is only going to be used by one person, then it may make sense 
for that person to make it as wide as the size he personally can handle, 
with his abilities and equipment and usage habits.


But when there are multiple people, it sometimes makes sense to 
constrain code to the most stringent of their abilities.


And one's abilities change over time, just as his equipment does.

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


Re: When do default parameters get their values set?

2014-12-08 Thread bSneddon
Thanks to all.  I now understand what is happening.   Originally wrote a script 
 be executed from command line.   No want to use Gui to change defaults.   Will 
refactor to fix where necessary.

On Monday, December 8, 2014 5:10:58 PM UTC-5, bSneddon wrote:
 I ran into an issue setting variables from a GUI module that imports a back 
 end module.  My approach was wrong obviously but what is the best way to set 
 values in a back end module.
 
 #module name beTest.py
 
 cfg = { 'def' : 'blue'}
 
 def printDef(argT = cfg['def']):
   print argT
  
 
 #module name feTest
 import beTest
 
 beTest.cfg['def'] = no red
 beTest.printDef()
 
 
 
 This prints blue.  I suppose because I am changing a local copy of cfg 
 dictionary.  What is the write approach here?
 
 
 Thanks
 
 Bill
-- 
https://mail.python.org/mailman/listinfo/python-list


Question on lambdas

2014-12-08 Thread memilanuk


So... I was browsing some questions on reddit, and one of them involved 
tkinter and lambdas.  Managed to help the person out, but in the process 
ended up with more questions of my own :/


My basic confusion revolves around this: in one instance I see things 
like the following:


R1 = tk.Radiobutton(root, text='A', value=100, variable=var,
command=lambda: update_label2('A', 100))

and in another example I see things like this:

class MyText(Text):
def __init__(self, master, **kw):
apply(Text.__init__, (self, master), kw)
self.bind(Return, lambda e: break)


What I'm having trouble finding a concrete answer to is the difference 
between:


lambda: some_func

lambda e: some_func

lambda e=e: some_func

Any help would be greatly appreciated.

TIA,

Monte

--
Shiny!  Let's be bad guys.

Reach me @ memilanuk (at) gmail dot com

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


Re: Question on lambdas

2014-12-08 Thread Chris Angelico
On Tue, Dec 9, 2014 at 10:43 AM, memilanuk memila...@gmail.com wrote:
 What I'm having trouble finding a concrete answer to is the difference
 between:

 lambda: some_func

 lambda e: some_func

These two are quite simple. (In each case, it's an expression, not a
function, for what it's worth.) They're (roughly) equivalent to these
functions:

def anonymous():
return some_func
def anonymous(e):
return some_func

In other words, the second one takes an argument, the first doesn't.

 lambda e=e: some_func

I'm not sure what this one ought to be; do you have an example? If the
e= part comes before the lambda, though, then it's simply a named
argument getting a lambda function bound to it. In your example above,
this:

Radiobutton(... command=lambda: update_label2('A', 100))

is equivalent to this:

def anonymous():
return update_label2('A', 100)
RadioButton(... command=anonymous)

It's that simple.

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


Re: Question on lambdas

2014-12-08 Thread Ben Finney
memilanuk memila...@gmail.com writes:

 What I'm having trouble finding a concrete answer to is the difference
 between:

(Note that where you write “some_func” the syntax requires an
expression, not a function. I've changed your examples to be clear).

 lambda: some_expr

This creates a new function which expects zero parameters. The function,
when called, will return the value of ‘some_expr’.

 lambda x: some_expr

This creates a new function which expects one positional parameter named
‘x’. The function, when called, will return the value of ‘some_expr’.

 lambda x=some_value: some_expr

This creates a new function which expects one parameter named ‘x’, which
parameter has a default value of ‘some_value’. The function, when
called, will return the value of ‘some_expr’.

 Any help would be greatly appreciated.

Hope that helps.

It's best to remember that ‘lambda’ is syntactic sugar for creating a
function; the things it creates are not special in any way, they are
normal functions, not “lambdas”.

What is different is that the function starts with no name bound to it,
and the syntax allows only a single expression as the body of the
function.

-- 
 \   “Theology is the effort to explain the unknowable in terms of |
  `\ the not worth knowing.” —Henry L. Mencken |
_o__)  |
Ben Finney

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


Re: Question on lambdas

2014-12-08 Thread Gary Herron

On 12/08/2014 03:43 PM, memilanuk wrote:


So... I was browsing some questions on reddit, and one of them 
involved tkinter and lambdas.  Managed to help the person out, but in 
the process ended up with more questions of my own :/


My basic confusion revolves around this: in one instance I see things 
like the following:


R1 = tk.Radiobutton(root, text='A', value=100, variable=var,
command=lambda: update_label2('A', 100))

and in another example I see things like this:

class MyText(Text):
def __init__(self, master, **kw):
apply(Text.__init__, (self, master), kw)
self.bind(Return, lambda e: break)


What I'm having trouble finding a concrete answer to is the difference 
between:


lambda: some_func

A function to be called with no parameters



lambda e: some_func

A function to be called with one parameter



lambda e=e: some_func
A function to be called with one or zero parameters.  In the case of a 
call with no parameters, a default value has been supplied.  The e=e may 
be slightly confusing, because 'e' is used in two contexts, one for the 
name of the parameter inside the function, and the other the name of the 
supplied default value (from the outer scope).


Any help would be greatly appreciated.

TIA,

Monte



Hope that helps,

Gary Herron


--
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

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


Re: Question on lambdas

2014-12-08 Thread Chris Angelico
On Tue, Dec 9, 2014 at 10:58 AM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 lambda x=some_value: some_expr

 This creates a new function which expects one parameter named ‘x’, which
 parameter has a default value of ‘some_value’. The function, when
 called, will return the value of ‘some_expr’.

*facepalm* For some reason I forgot about default parameters _inside_
the lambda function, and thought only of named parameters _outside_
it. Ben's right, that's what your lambda e=e: syntax is doing.

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


Re: Python Iterables struggling using map() built-in

2014-12-08 Thread Roy Smith
In article 5485721c$0$2817$c3e8da3$76491...@news.astraweb.com,
 Steven D'Aprano st...@pearwood.info wrote:

 On Mon, 08 Dec 2014 11:35:36 +1100, Chris Angelico wrote:
 
  On Mon, Dec 8, 2014 at 11:27 AM, Roy Smith r...@panix.com wrote:
  Although, to be honest, I'm wondering if this is more straight-forward
  (also not tested):
 
  def myzip37(*args):
  if not args:
  return
  iters = list(map(iter, args))
  
  Yes, I prefer this too. It's explicit and clear that passing no
  arguments will yield no values.
 
 The first version is explicit and clear too. I'm sorry to say this, but 
 it is true: if you (generic you) don't recognise that
 
 while iters:
 ...
 
 
 skips the while block if iters is an empty list, then *you* have a 
 problem, not the code.

The problem is not that the while body is skipped if iters is falsey.  
Thats quite clear.

The problem is that the looping termination isn't actually controlled by 
the control variable being exhausted.  It's controlled by an exception 
getting thrown.  I'm OK with breaking out of a loop by throwing an 
exception, but if that's what you're going to do, then make it clear 
that's the case by doing while 1 or while True.  Those screams out, 
Hey, look at me, I'm an infinite loop, which is your clue that there's 
something else going on.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why can't download file from linux server into local window disk c:?

2014-12-08 Thread pengsir

It's trying to open the file 'c:', but that's not a file, it's a folder.

Try, say, 'c:/passwd' instead.


It works for me, i tried ,it is ok .

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


Re: Python re.search simple question

2014-12-08 Thread Denis McMahon
On Mon, 08 Dec 2014 12:22:37 +0530, Ganesh Pal wrote:

 pattern
 'Token-based migrations cannot be mixed with level-based: [prev 0 , now
 1]'

Because [] defines a character class in a regex, if you want literal 
[ and ] you need to escape them with backslash.

[prev 0 , now 1] - match any single character from the set prev0,now1 

\[prev 0 , now 1\] - match the actual text [prev 0 , now 1]

Try these:

re.search('[prev 0 , now 1]','p') # matches (p in prev0,now1 )

re.search('[prev 0 , now 1]','x') # doesn't match (x not in prev0,now1 )

re.search('\[prev 0 , now 1\]','p') # doesn't match

re.search('\[prev 0 , now 1\]','[prev 0 , now 1]') # matches

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


Re: When do default parameters get their values set?

2014-12-08 Thread Terry Reedy

 def f(a=default +arg value): return a

 f.__defaults__
('default arg value',)

Before any calls, the expression has be evaluated.  When f() is called 
with no arg, the local name 'a' is associated with
'default arg value'. Then code execution begins. Use dir(f), for 
instance, to invesigate internals.


--
Terry Jan Reedy

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


Re: Question on lambdas

2014-12-08 Thread MRAB

On 2014-12-08 23:58, Ben Finney wrote:

memilanuk memila...@gmail.com writes:


What I'm having trouble finding a concrete answer to is the difference
between:


(Note that where you write “some_func” the syntax requires an
expression, not a function. I've changed your examples to be clear).


lambda: some_expr


This creates a new function which expects zero parameters. The function,
when called, will return the value of ‘some_expr’.


lambda x: some_expr


This creates a new function which expects one positional parameter named
‘x’. The function, when called, will return the value of ‘some_expr’.


lambda x=some_value: some_expr


This creates a new function which expects one parameter named ‘x’, which
parameter has a default value of ‘some_value’. The function, when
called, will return the value of ‘some_expr’.


This is useful when you want to 'capture' the current value of
'some_value' to be passed to some_expr; if you didn't, then some_expr
would be using the value of 'some_value' at the time it was called,
which might be different if some variable it used had been changed.


Any help would be greatly appreciated.


Hope that helps.

It's best to remember that ‘lambda’ is syntactic sugar for creating a
function; the things it creates are not special in any way, they are
normal functions, not “lambdas”.

What is different is that the function starts with no name bound to it,
and the syntax allows only a single expression as the body of the
function.



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


Re: Question on lambdas

2014-12-08 Thread Christoph Becker
Ben Finney wrote:

 It's best to remember that ‘lambda’ is syntactic sugar for creating a
 function; the things it creates are not special in any way, they are
 normal functions, not “lambdas”.

Could you please elaborate why ‘lambda’ does not create “lambdas”.  I'm
a Python beginner (not new to programming, though), and rather confused
about your statement.

-- 
Christoph M. Becker

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


Re: Question on lambdas

2014-12-08 Thread Chris Angelico
On Tue, Dec 9, 2014 at 12:44 PM, Christoph Becker cmbecke...@gmx.de wrote:
 Ben Finney wrote:

 It's best to remember that ‘lambda’ is syntactic sugar for creating a
 function; the things it creates are not special in any way, they are
 normal functions, not “lambdas”.

 Could you please elaborate why ‘lambda’ does not create “lambdas”.  I'm
 a Python beginner (not new to programming, though), and rather confused
 about your statement.

For the same reason that def doesn't create defs, and for
doesn't create fors (uhh... the Force?). Both lambda and def
create functions. Functions are things that can be called, and they're
created by the def statement, the lambda expression, and very VERY
occasionally, by directly calling the function constructor. You could
distinguish between lambda functions and def functions if you
like, but the distinction is almost never significant. In fact,
usually you don't even need to distinguish between functions and other
callables (types, objects with __call__ methods, bound method objects,
etc, etc, etc).

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


Re: Question on lambdas

2014-12-08 Thread Terry Reedy

On 12/8/2014 8:53 PM, Chris Angelico wrote:

On Tue, Dec 9, 2014 at 12:44 PM, Christoph Becker cmbecke...@gmx.de wrote:

Ben Finney wrote:


It's best to remember that ‘lambda’ is syntactic sugar for creating a
function; the things it creates are not special in any way, they are
normal functions, not “lambdas”.


Could you please elaborate why ‘lambda’ does not create “lambdas”.  I'm
a Python beginner (not new to programming, though), and rather confused
about your statement.


For the same reason that def doesn't create defs, and for
doesn't create fors (uhh... the Force?). Both lambda and def
create functions. Functions are things that can be called, and they're
created by the def statement, the lambda expression, and very VERY
occasionally, by directly calling the function constructor. You could
distinguish between lambda functions and def functions if you
like, but the distinction is almost never significant. In fact,
usually you don't even need to distinguish between functions and other
callables (types, objects with __call__ methods, bound method objects,
etc, etc, etc).


To exemplify Chris's answer: Consider

 def f1(a, b='hi'): return a+b

 f2 = lambda a, b='hi': a+b


I believe the only difference between any of the attributes of f1 and f2 is

 f1.__name__
'f1'
 f2.__name__
'lambda'
 f1.__code__.co_name
'f1'
 f2.__code__.co_name
'lambda'

All other values of corresponding attributes of f1 and f2, and 
f1.__code__ and f2.__code__, should be the same.  For instance


 f1.__code__.co_varnames
('a', 'b')
 f2.__code__.co_varnames
('a', 'b')

--
Terry Jan Reedy


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


Re: module import questions and question about pytest and module imports

2014-12-08 Thread Ian Kelly
On Sun, Dec 7, 2014 at 9:50 AM, sam pendleton samp4...@gmail.com wrote:
 Having to put the garage package on the sys.path seems a little off,
 why wouldn't relative imports work?

Relative imports are relative to a package's hierarchy of namespaces, not
relative to the file system. As such, you can't perform a relative import
of a module that isn't in the same top-level package (and besides this, the
import statement that you posted was an absolute import anyway).

All top-level packages have to be on sys.path, or the import system won't
be able to find them.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Iterables struggling using map() built-in

2014-12-08 Thread Steven D'Aprano
Roy Smith wrote:

 Chris Angelico wrote:
  I'm actually glad PEP 479 will break this kind of code. Gives a good
  excuse for rewriting it to be more readable.
 
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 What kind of code is that? Short, simple, Pythonic and elegant? :-)
 
 Here's the code again, with indentation fixed:
 
 
 def myzip(*args):
 iters = map(iter, args)
 while iters:
 res = [next(i) for i in iters]
 yield tuple(res)
 
 Ugh.  When I see while foo, my brain says, OK, you're about to see a
 loop which is controlled by the value of foo being changed inside the
 loop.

Yes. Me too. 99% of the time when you see while foo, that's what you'll
get, so it's the safe assumption. But it's only an assumption, not a
requirement. When you read a bit more of the code and see that iters isn't
being modified, your reaction ought to be closer oh wow, that's neat
than oh noes it's different from what I expected.

while foo is logically equivalent to if foo: while foo:. The if is
completely redundant.


 That's not at all what's happening here, so my brain runs into a 
 wall.

I hope you are exaggerating for effect, because if you genuinely mean that
reading that code causes major mental trauma (perhaps the equivalent of a
mental BSOD) then you've probably picked the wrong industry to be working
in. Imagine how you would cope reading genuinely obfuscated code. You would
probably have a nervous breakdown :-)

It's okay to read code which forces you to reevaluate your initial
assumption about the code. People, especially (allegedly) smart people like
programmers, are intelligent and flexible. If you can't do that, you're
going to hate Python:

- Python has no repeat N times loop, we have to use for i in range(...)
instead, so seeing a for-loop doesn't necessarily mean that the loop
variable will be used. Sometimes it isn't.


- I cannot count the number of times I've read, or written, a method that
doesn't use self, but doesn't bother to declare it as a staticmethod.


- The official way to get a single arbitrary value from a set without
removing it is:

for value in the_set:
return value

GvR recently gave an example of how to process a single element in a
possibly-empty iterator:

for x in it:
print(x)
break
else:
print('nothing')


so there are two examples of using a for-loop to *not* loop over something.


- Ducktyping. Just because some code is using a goose, doesn't mean that a
goose is required. Perhaps a duck is required but a goose is close enough.


 Next problem, what the heck is res?  We're not back in the punch-card
 days.  We don't have to abbreviate variable names to save columns.

*shrug* I didn't pick the name. But res is a standard abbreviation
for result or resource, and from context it clearly should be result.


[...]
 I think this function makes a good test to separate the masters from the
 apprentices.
 
 The goal of good code is NOT to separate the masters from the
 apprentices.  The goal of good code is to be correct 

So far I agree.


 and easy to 
 understand by the next guy who comes along to maintain it.

No. That is *one secondary goal*. Efficiency is another secondary goal.
Sometimes education is even more important, and in this specific case the
function is being used to teach people.

Another secondary goal ought to be beauty and elegance over ugliness. It's
not often a beautiful function actually is good enough for production use.
It's usually surrounded by an inelegant if not downright ugly pile of code
testing arguments, checking for error conditions, handling corner cases,
etc. That ugliness can obfuscate the underlying algorithm and make the
function harder to understand. If it isn't *necessary*, take it out.

Perfection is achieved, not when there is nothing more to add, 
but when there is nothing left to take away.

While ease of maintenance is an important goal, think about what we are
discussing. zip() is a primitive function. Once you have decided on the
public API, it will probably never need any maintenance. It's not like the
requirements will change -- yeah, we used to want to zip the items
together, but now we need to add a 9% superannuation surcharge to them
first.

The beauty of this code is that it is so simple that it cannot fail to be
bug-free. (Am I wrong? Have I missed a corner-case?) There's no unnecessary
code in the function that can hide bugs and obfuscate what it does.

And it is so simple that it's hard to see anything written in pure Python
being more efficient. So as far as maintenance goes, that's irrelevant.
That function is simply finished, done, complete. Anything you do to
improve it can only make it slower, buggier, or uglier.

(And that's a rare and beautiful thing in code.)


 If you can read this function and instantly tell how it works, that it is
 bug-free and duplicates the behaviour of the built-in zip(), you're
 probably Raymond Hettinger. If 

Re: Question on lambdas

2014-12-08 Thread memilanuk

On 12/08/2014 03:58 PM, Ben Finney wrote:

memilanuk memila...@gmail.com writes:


What I'm having trouble finding a concrete answer to is the difference
between:





lambda: some_expr


This creates a new function which expects zero parameters. The function,
when called, will return the value of ‘some_expr’.


lambda x: some_expr


This creates a new function which expects one positional parameter named
‘x’. The function, when called, will return the value of ‘some_expr’.



so in the first example in my original post:

...
lambda: update_label2('A', 100)

would this work the same?  It looks as though it'd be passing the same 
two parameters to the same function...


lambda: 'A', 100: update_label2()


Also, in my second example:

class MyText(Text):
def __init__(self, master, **kw):
apply(Text.__init__, (self, master), kw)
self.bind(Return, lambda e: break)

(from the page @ 
http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm, if anyone 
cares)


I'm kind of missing what 'e' is and where its defined and what it's 
supposed to be passing to break...?  The whole bind method for classes 
and instances is a wee bit above my pay grade right about now; but I 
happened to stumble upon this example when I went looking for more info 
on lambda :/








lambda x=some_value: some_expr


This creates a new function which expects one parameter named ‘x’, which
parameter has a default value of ‘some_value’. The function, when
called, will return the value of ‘some_expr’.



I was reading in 'Programming Python 4th ed' by Lutz and he talks about 
something to do with default values vs. enclosing scopes...  that 
something like:


lambda x=x: some_expr

when evaluated inside a function loop to create buttons, etc., causes 
'x' to be evaluated as the default value at the function creation time, 
vs. when the function is actually called.  Do I have that more or less 
correct?


TIA,

Monte



--
Shiny!  Let's be bad guys.

Reach me @ memilanuk (at) gmail dot com

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


Re: Python Iterables struggling using map() built-in

2014-12-08 Thread Terry Reedy

On 12/8/2014 9:50 PM, Steven D'Aprano wrote:

Roy Smith wrote:


Chris Angelico wrote:



def myzip(*args):
 iters = map(iter, args)
 while iters:
 res = [next(i) for i in iters]
 yield tuple(res)


Ugh.  When I see while foo, my brain says, OK, you're about to see a
loop which is controlled by the value of foo being changed inside the
loop.


Yes. Me too. 99% of the time when you see while foo, that's what you'll
get, so it's the safe assumption. But it's only an assumption, not a
requirement. When you read a bit more of the code and see that iters isn't
being modified, your reaction ought to be closer oh wow, that's neat


To me it is a code smell.  iters is empty if and only if args is empty. 
 If args is empty, iters should not be created.


if args:
  iters = ...
  while True
... (return on exception)

makes the logic clear.

--
Terry Jan Reedy

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


Re: Question on lambdas

2014-12-08 Thread Ben Finney
Christoph Becker cmbecke...@gmx.de writes:

 Ben Finney wrote:

  It's best to remember that ‘lambda’ is syntactic sugar for creating
  a function; the things it creates are not special in any way, they
  are normal functions, not “lambdas”.

 Could you please elaborate why ‘lambda’ does not create “lambdas”. I'm
 a Python beginner (not new to programming, though), and rather
 confused about your statement.

We already have a term for what the ‘lambda’ keyword creates: a
function.

That is, ‘lambda’ creates a function object, without anything to
distinguish it from a function created any other way.

-- 
 \ “Here is a test to see if your mission on earth is finished. If |
  `\  you are alive, it isn't.” —Francis Bacon |
_o__)  |
Ben Finney

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


Re: Question on lambdas

2014-12-08 Thread Ben Finney
memilanuk memila...@gmail.com writes:

 ...
 lambda: update_label2('A', 100)

 would this work the same?

(I don't know what you mean here by “the same”; the same as what?)

The above creates a new function, which expects no parameters (because
there are no parameters before its ‘:’).

The function, when called, will return the value of the expression
‘update_label2('A', 100)’.

 It looks as though it'd be passing the same two parameters to the same
 function...

Yes, it looks that way, and that's what it does. The parameters are
fixed in the expression and will be the same each time the new function
is called.

 lambda: 'A', 100: update_label2()

This is a syntax error.

Have you tried experimenting with these? Carefully read the reference
material on the ‘lambda’ syntax, and create some functions and
experiment with them.

-- 
 \ “Not to be absolutely certain is, I think, one of the essential |
  `\ things in rationality.” —Bertrand Russell |
_o__)  |
Ben Finney

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


some problem with scrapy and py2exe

2014-12-08 Thread cdd801
i want to bulit an scrapy project into an exe file with py2exe,but there is a 
error happened after i run the exe-file (for example 'a7cxk.exe')in the cmd ,it 
happened 

Traceback (most recent call last):
  File a7cxk.py, line 2, in module
  File scrapy\__init__.pyc, line 10, in module
  File pkgutil.pyc, line 591, in get_data
IOError: [Errno 2] No such file or directory: 'scrapy\\VERSION'

Anyone can give me some tips ?  thks


my setup.py:
from distutils.core import setup
import glob
setup(
console=[a7cxk.py], 
data_files=[
(config_file, glob.glob(r'D:\python\w7c_first\config_file\conf.ini'))])


then i run it in cmd:
python setup.py py2exe


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


Re: Question on lambdas

2014-12-08 Thread Steven D'Aprano
On Tue, 09 Dec 2014 02:44:12 +0100, Christoph Becker wrote:

 Ben Finney wrote:
 
 It's best to remember that ‘lambda’ is syntactic sugar for creating a
 function; the things it creates are not special in any way, they are
 normal functions, not “lambdas”.
 
 Could you please elaborate why ‘lambda’ does not create “lambdas”.  I'm
 a Python beginner (not new to programming, though), and rather confused
 about your statement.


Compare these:

py def f1():
... return 23
... 
py f2 = lambda: 23
py type(f1) is type(f2)
True


Functions created with lambda are exactly the same type of object as 
functions created with def.

Functions created with lambda accept exactly the same arguments as 
functions created with def. They differences are:

- functions created with lambda all have the same internal name;
- functions created with def have the name you give them;

- functions created with lambda are expressions and can be embedded
  directly in function calls, lists, etc;
- functions created with def are statements and must stand alone.




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


Re: Python Iterables struggling using map() built-in

2014-12-08 Thread Steven D'Aprano
On Tue, 09 Dec 2014 00:03:33 -0500, Terry Reedy wrote:

 On 12/8/2014 9:50 PM, Steven D'Aprano wrote:
 Roy Smith wrote:

 Chris Angelico wrote:
 
 def myzip(*args):
  iters = map(iter, args)
  while iters:
  res = [next(i) for i in iters]
  yield tuple(res)

 Ugh.  When I see while foo, my brain says, OK, you're about to see
 a loop which is controlled by the value of foo being changed inside
 the loop.

 Yes. Me too. 99% of the time when you see while foo, that's what
 you'll get, so it's the safe assumption. But it's only an assumption,
 not a requirement. When you read a bit more of the code and see that
 iters isn't being modified, your reaction ought to be closer oh wow,
 that's neat
 
 To me it is a code smell.  iters is empty if and only if args is empty.
   If args is empty, iters should not be created.
 
 if args:
iters = ...
while True
  ... (return on exception)
 
 makes the logic clear.

When you understand why this body of code is inelegant and ugly, you 
should understand why the above is inelegant and ugly:

def double(x):
if x != 0:
x *= 2
return x




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


Re: Question on lambdas

2014-12-08 Thread Rustom Mody
On Tuesday, December 9, 2014 5:28:49 AM UTC+5:30, Ben Finney wrote:
 memilanuk writes:
 
  What I'm having trouble finding a concrete answer to is the difference
  between:
 
 (Note that where you write “some_func” the syntax requires an
 expression, not a function. I've changed your examples to be clear).
 
  lambda: some_expr
 
 This creates a new function which expects zero parameters. The function,
 when called, will return the value of ‘some_expr’.
 
  lambda x: some_expr
 
 This creates a new function which expects one positional parameter named
 ‘x’. The function, when called, will return the value of ‘some_expr’.
 
  lambda x=some_value: some_expr
 
 This creates a new function which expects one parameter named ‘x’, which
 parameter has a default value of ‘some_value’. The function, when
 called, will return the value of ‘some_expr’.
 
  Any help would be greatly appreciated.
 
 Hope that helps.
 
 It's best to remember that ‘lambda’ is syntactic sugar for creating a
 function; the things it creates are not special in any way, they are
 normal functions, not “lambdas”.

This is a good thing to remember (and better than most of the λ-calculus memes
floating around the net).

 What is different is that the function starts with no name bound to it,
 and the syntax allows only a single expression as the body of the
 function.

Cant quarrel with this as a fact but its the wrong emphasis IMHO:
Its not that lambdas are functions without names -- so called `anonymous' 
functions.
Its rather that defs are functions with names, ie a def bundles up two 
independent activities:
naming and function-making.

Do we call constants 'anonymous variables'?
One could of course but its misleading because constants come before variables

Most people know this in the form: Arithmetic comes before algebra
A CS buzz version: Functional programming is simpler than imperative 
programming.
However I find this unhelpful and misleading for the same reason that 'λ is 
an anonymous function' is: If functional programming were 'programming with 
functions' then
C would be a functional language wink

Here is our attempt at explaining this in more detail in 'modern' format
https://www.youtube.com/watch?v=FZoq-GlOdSs

The above is all with 'conceptual-fundamentals' hat firmly on.

From the pragmatic pov, the need to mix naming with function-making is
so overwhelmingly what is needed, that rarely/never using lambdas is ok.

JFTR Miranda one of the seminal functional languages, had no lambdas, only
(the equivalent of) defs.
Put differently, Ive no issue with Guido wanting to remove lambda from python
[In any case in the unicode age I'd prefer it spelt as λ]

Ive an issue with people claiming to have a degree in CS not knowing (basics of)
λ-calculus
-- 
https://mail.python.org/mailman/listinfo/python-list


encrypt the http request url on the local machine

2014-12-08 Thread iMath
my software on the local machine needs to send http request to a specific web 
server , is there any way to protect the http request url from being found by 
Packet analyzer software like Wireshark and fiddler. The sever is not mine, so 
I can do nothing in the server .

It would be better to show some code, I am an absolutely newbie in encryption .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: encrypt the http request url on the local machine

2014-12-08 Thread iMath
在 2014年12月9日星期二UTC+8下午2时58分36秒,iMath写道:
 my software on the local machine needs to send http request to a specific web 
 server , is there any way to protect the http request url from being found by 
 Packet analyzer software like Wireshark and fiddler. The sever is not mine, 
 so I can do nothing in the server .
 
 It would be better to show some code, I am an absolutely newbie in encryption 
 .

P.S the server doesn't support https protocol
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question on lambdas

2014-12-08 Thread memilanuk

On 12/08/2014 09:30 PM, Ben Finney wrote:

memilanuk memila...@gmail.com writes:


...
lambda: update_label2('A', 100)

would this work the same?


(I don't know what you mean here by “the same”; the same as what?)

The above creates a new function, which expects no parameters (because
there are no parameters before its ‘:’).

The function, when called, will return the value of the expression
‘update_label2('A', 100)’.


It looks as though it'd be passing the same two parameters to the same
function...


Yes, it looks that way, and that's what it does. The parameters are
fixed in the expression and will be the same each time the new function
is called.


lambda: 'A', 100: update_label2()


This is a syntax error.

Have you tried experimenting with these? Carefully read the reference
material on the ‘lambda’ syntax, and create some functions and
experiment with them.



Fair enough.  What I was trying to do when I got into all this was 
something like this:


import tkinter as tk

root = tk.Tk()
root.wm_title('Radio Buttons')

label1 = tk.Label(root)
label1.config(text='Please select an option below.')
label1.pack()


def update_label2(option, value):
selection = current selection is: \n\n + str(option) + :  + 
str(value)

label2.config(text=selection)

var = tk.IntVar()
var.set(100)

R1 = tk.Radiobutton(root, text='A', value=100, variable=var,
command=lambda: update_label2('A', 100))
R1.pack(anchor='center')
R2 = tk.Radiobutton(root, text='B', value=80, variable=var,
command=lambda option='B', value=80: update_label2())
R2.pack(anchor='center')
R3 = tk.Radiobutton(root, text='C', value=60, variable=var,
command=lambda: update_label2('C', 60))
R3.pack(anchor='center')


label2 = tk.Label(root)
label2.config(text='Current selection is: \n \nA: 100')
label2.pack()

root.mainloop()


So to me, the purpose of 'lambda' in this case is to call a function 
when a particular widget - in this case a radio button - is clicked. 
Thats why I wondered if 'lambda: update_label2('A', 100)' - where I'm 
using lambda to call another function, with the parameters inside the 
parentheses, was equivalent to 'lambda 'A', 100: update_label2()' where 
I would be using lambda to 'feed' the parameters to the function.  I see 
what you mean about the syntax error = it should be 'lambda option='A', 
value=100:update_label2()' but even then it doesn't really work as the 
update_label2 function complains about not being given any values at all.


  File /home/monte/Dropbox/Code/python/sandbox/reddit.py, line 31, in 
lambda

command=lambda option='B', value=80: update_label2())
TypeError: update_label2() missing 2 required positional arguments: 
'option' and 'value'



--
Shiny!  Let's be bad guys.

Reach me @ memilanuk (at) gmail dot com

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


Re: encrypt the http request url on the local machine

2014-12-08 Thread dieter
iMath redstone-c...@163.com writes:

 my software on the local machine needs to send http request to a specific web 
 server , is there any way to protect the http request url from being found by 
 Packet analyzer software like Wireshark and fiddler. The sever is not mine, 
 so I can do nothing in the server .

Not sure about fiddler but wireshark is a logger at tcp level.
When you use https (rather than http), a tcp logger may still see
the host (it definitely sees the IP address) but will not see
the rest of the url (as this is transmitted in encrypted form).

The protection provided by https is sufficient for normal use.
I recently heared a scientific talk suggesting that https protection
can be preached with a lot of computing power. Thus, there is likely
no protection against secret service surveillance (and maybe law
enforcement agencies).

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


Re: encrypt the http request url on the local machine

2014-12-08 Thread Chris Angelico
On Tue, Dec 9, 2014 at 6:08 PM, iMath redstone-c...@163.com wrote:
 在 2014年12月9日星期二UTC+8下午2时58分36秒,iMath写道:
 my software on the local machine needs to send http request to a specific 
 web server , is there any way to protect the http request url from being 
 found by Packet analyzer software like Wireshark and fiddler. The sever is 
 not mine, so I can do nothing in the server .

 It would be better to show some code, I am an absolutely newbie in 
 encryption .

 P.S the server doesn't support https protocol

If the server doesn't support encrypted HTTP requests, you either need
some other form of encryption that the server _does_ support, or a
proxy that can decrypt the request and pass it on (in which case
packet sniffing at the proxy could reveal what's happening). Why are
you so worried about packet sniffing? Is it something you expect to
happen?

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


Re: Do you like the current design of python.org?

2014-12-08 Thread Rustom Mody
On Friday, December 5, 2014 4:13:27 PM UTC+5:30, Steven D'Aprano wrote:
 But most of all, I despise the menus that pop up covering what I am trying
 to read the page just because I happened to move the mouse over a button. I
 loathe the practice of stuffing content into menus instead of using links
 to individual web pages. And I hold nothing but scorn for the fact that the
 main page has a slideshow.

I thought I'd argue against this (and the general tenor of these complaints)
Tried to click on the  in what looked like a console session

and for the last 5 minutes I am staring at
Loading console ...

with the L in a different color...

Pretty... but not exactly what I expect in an interactive console.

Lest it seem like I am agreeing with these complaints, I'd like to say:
Either python goes this way or the way of Fortran and Cobol.

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


[issue23007] Unnecessary big intermediate result in Lib/bisect.py

2014-12-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

What troubles?

--
nosy: +serhiy.storchaka

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread Alexey Poryadin

New submission from Alexey Poryadin:

When is called `select`, but registered no one `fileobject` rise exception:
...
polled = self._selector.select(timeout)
  File /usr/lib/python3.4/selectors.py, line 424, in select
fd_event_list = self._epoll.poll(timeout, max_ev)
ValueError: maxevents must be greater than 0, got 0

Of course, it makes no sense to call `select` if there is nothing to watch. But 
select.epol.poll is not raises exception in the same case if `max_ev`=-1. And 
this simplifies the application code and is useful if need just sleep for a 
timeout.

So, I suggest a small fix:
-fd_event_list = self._epoll.poll(timeout, max_ev)
+fd_event_list = self._epoll.poll(timeout, max_ev or -1)

--
messages: 232300
nosy: Alexey.Poryadin
priority: normal
severity: normal
status: open
title: selectors.EpollSelector.select raises exception when nothing to select.
type: behavior
versions: Python 3.4

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread STINNER Victor

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


--
nosy: +haypo, neologix

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread STINNER Victor

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


--
versions: +Python 3.5

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread STINNER Victor

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


--
components: +asyncio
nosy: +gvanrossum, yselivanov

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



[issue21998] asyncio: a new self-pipe should be created in the child process after fork

2014-12-08 Thread Martin Richard

Martin Richard added the comment:

Currently, this is what I do in the child after the fork:

 selector = loop._selector
 parent_class = selector.__class__.__bases__[0]
 selector.unregister = lambda fd: parent_class.unregister(selector, fd)

It replaces unregister() by _BaseSelectorImpl.unregister(), so our data 
structures are still cleaned (the dict _fd_to_key, for instance).

If a fix for this issue is desired in tulip, the first solution proposed by 
Guido (closing the selector and let the unregister call fail, see the -trivial- 
patch attached) is probably good enough.

--
keywords: +patch
Added file: 
http://bugs.python.org/file37385/close_self_pipe_after_selector.patch

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



[issue23010] unclosed file warning when defining unused logging FileHandler in dictConfig

2014-12-08 Thread Walter Doekes

New submission from Walter Doekes:

If you define a FileHandler in your logging dictConfig but fail to use it in 
the same configuration, the file handle is leaked and a ResourceWarning is 
thrown.

Versions:

$ python3 -V
Python 3.4.0
$ apt-cache show python3.4 | grep ^Version
Version: 3.4.0-2ubuntu1

Expected:

$ PYTHONWARNINGS=default,ignore::DeprecationWarning \
python3 problem.py 
imported once

Observed:

$ PYTHONWARNINGS=default,ignore::DeprecationWarning \
python3 problem.py 
.../lib/python3.4/importlib/_bootstrap.py:656:
ResourceWarning: unclosed file
  _io.FileIO name='/tmp/debug.log' mode='ab'
  code = marshal.loads(data)
imported once

To reproduce, save below as problem.py:

if __name__ == '__main__':
LOGGING = {
'version': 1,
'handlers': {
'logfile': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/tmp/debug.log',
},
},
}

from logging.config import dictConfig
dictConfig(LOGGING)

# using importlib on a new file triggers the warnings
import importlib, shutil, os
shutil.copy(__file__, __file__ + '.new')
os.unlink(__file__)
os.rename(__file__ + '.new', __file__)
importlib.import_module('problem')
else:
print('imported once')


Fixed by:

--- /usr/lib/python3.4/logging/config.py.orig   2014-12-08 
14:06:24.911460799 +0100
+++ /usr/lib/python3.4/logging/config.py2014-12-08 14:16:17.519460799 
+0100
@@ -637,6 +637,16 @@ class DictConfigurator(BaseConfigurator)
 except Exception as e:
 raise ValueError('Unable to configure root '
  'logger: %s' % e)
+
+# Close unused loggers
+used_handlers = set()
+for logger in logging.root.manager.loggerDict.values():
+if hasattr(logger, 'handlers') and logger.handlers:
+used_handlers.add(*logger.handlers)
+for name, handler in handlers.items():
+if handler not in used_handlers:
+if hasattr(handler, 'close'):
+handler.close()
 finally:
 logging._releaseLock()
 

The fix above might not be the best fix, but it proves where the problem is. 
Perhaps the handlers shouldn't be instantiated until the first user of such a 
handler is instantiated.

This issue was found by using Django 1.7 with Python 3.4 when enabling the 
PYTHONWARNINGS.

Cheers,
Walter Doekes
OSSO B.V.

--
components: Library (Lib)
messages: 232302
nosy: wdoekes
priority: normal
severity: normal
status: open
title: unclosed file warning when defining unused logging FileHandler in 
dictConfig
versions: Python 3.4

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



[issue23011] Duplicate Paragraph in documentation for json module

2014-12-08 Thread berndca

New submission from berndca:

There is a duplication of the first section of 18.2.2 (JSON) Encoders and 
Decoders of the python 2.7.9RC1 doc as well of the corresponding paragraph in 
19.2.2 of the Python 3 docs.

--
assignee: docs@python
components: Documentation
messages: 232303
nosy: berndca, docs@python
priority: normal
severity: normal
status: open
title: Duplicate Paragraph in documentation for json module
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5

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



[issue23011] Duplicate Paragraph in documentation for json module

2014-12-08 Thread Simeon Visser

Simeon Visser added the comment:

What paragraph are you referring to? Various documented parameters are similar 
but I don't see duplicate paragraphs.

--
nosy: +simeon.visser

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



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

2014-12-08 Thread Trent Nelson

Changes by Trent Nelson tr...@snakebite.org:


--
nosy: +trent

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



[issue23012] RuntimeError: settrace/setprofile function gets lost

2014-12-08 Thread Armin Rigo

New submission from Armin Rigo:

It's not possible to write a settrace() or setprofile() function that remains 
active if we're about to run out of stack. If we are, we get a RuntimeError 
when the function is called. The RuntimeError is normally propagated, but in 
case it is eaten (e.g. see example) then the program continues to run normally 
--- but the trace/profile function is disabled from now on.

--
files: test9.py
messages: 232305
nosy: arigo
priority: normal
severity: normal
status: open
title: RuntimeError: settrace/setprofile function gets lost
type: behavior
Added file: http://bugs.python.org/file37386/test9.py

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



[issue23012] RuntimeError: settrace/setprofile function gets lost

2014-12-08 Thread STINNER Victor

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


--
nosy: +haypo

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



[issue23010] unclosed file warning when defining unused logging FileHandler in dictConfig

2014-12-08 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
nosy: +vinay.sajip

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



[issue20603] sys.path disappears at shutdown

2014-12-08 Thread Brett Cannon

Brett Cannon added the comment:

That's enough reason for me to close this as out of date. =)

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

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread Yury Selivanov

Yury Selivanov added the comment:

Patch attached. Tests pass on Linux.

--
keywords: +patch
Added file: http://bugs.python.org/file37387/epoll_01.patch

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



[issue21998] asyncio: a new self-pipe should be created in the child process after fork

2014-12-08 Thread STINNER Victor

STINNER Victor added the comment:

I suggest to split this issue: create a new issue focus on 
selectors.EpollSelector, it doesn't behave well with forking. If I understood 
correctly, you can workaround this specific issue by forcing the selector to 
selectors.SelectSelector for example, right?

--

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread STINNER Victor

STINNER Victor added the comment:

+s.select(timeout=0)

I suggest to ensure that the result is an empty list.

--

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread Yury Selivanov

Changes by Yury Selivanov yseliva...@gmail.com:


Added file: http://bugs.python.org/file37388/epoll_02.patch

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread Yury Selivanov

Yury Selivanov added the comment:

I agree. Please see another one.

--

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread STINNER Victor

STINNER Victor added the comment:

It's a little bit surprising to call epoll_wait() without any FD subscribed, 
but select([], [], [], delay) is a known way to sleep 'delay' seconds, so why 
not using epoll in a similar way? :-)

epoll_02.patch looks good to me. Can you please also apply the patch to the 
Tulip project?

(By the way, test_selectors.py to Tulip is completly different, we may just 
reuse the file from CPython and drop the code from Tulip.)

--

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



[issue23013] Tweak wording for importlib.util.LazyLoader in regards to Loader.create_module()

2014-12-08 Thread Brett Cannon

New submission from Brett Cannon:

The docs for importlib.util.LazyLoader emphatically say that a loader cannot 
define importlib.abc.Loader.create_module() if it is to be subclassed. What in 
fact should say is that the subclass' create_module() will not be called; 
whether it is defined or not is of no consequence.

--
assignee: brett.cannon
components: Documentation
keywords: easy
messages: 232312
nosy: brett.cannon
priority: normal
severity: normal
stage: needs patch
status: open
title: Tweak wording for importlib.util.LazyLoader in regards to 
Loader.create_module()
versions: Python 3.5

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



[issue23008] pydoc enum.{,Int}Enum fails

2014-12-08 Thread Berker Peksag

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


--
nosy: +ethan.furman

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



[issue23014] Don't have importlib.abc.Loader.create_module() be optional

2014-12-08 Thread Brett Cannon

New submission from Brett Cannon:

I continue to be bothered by how we designed 
importlib.abc.Loader.create_module(). I don't like that it's optional and I 
don't like that it can return None.

I would much rather make it so that importlib.abc.Loader.create_module() was a 
static method that does what importlib.util.module_from_spec() does. I would 
also like importlib to throw a fit if exec_module() was defined on a loader but 
not create_module() with a DeprecationWarning to start and then an 
AttributeError later (as I said, this requires exec_module() defined and does 
not play into the whole load_module() discussion). This should also hopefully 
promote people subclassing importlib.abc.Loader more as well.

What do other people think?

--
components: Interpreter Core
messages: 232313
nosy: brett.cannon, eric.snow, ncoghlan
priority: normal
severity: normal
stage: test needed
status: open
title: Don't have importlib.abc.Loader.create_module() be optional
type: behavior
versions: Python 3.5, Python 3.6

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread Guido van Rossum

Guido van Rossum added the comment:

Please add a comment explaining the complaint from epoll.poll() we're
trying to avoid here.

I presume Tulip never gets into this state because of the self-pipe.

On Mon, Dec 8, 2014 at 8:01 AM, STINNER Victor rep...@bugs.python.org
wrote:


 STINNER Victor added the comment:

 It's a little bit surprising to call epoll_wait() without any FD
 subscribed, but select([], [], [], delay) is a known way to sleep 'delay'
 seconds, so why not using epoll in a similar way? :-)

 epoll_02.patch looks good to me. Can you please also apply the patch to
 the Tulip project?

 (By the way, test_selectors.py to Tulip is completly different, we may
 just reuse the file from CPython and drop the code from Tulip.)

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue23009
 ___


--

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



[issue22935] Disabling SSLv3 support

2014-12-08 Thread Kurt Roeckx

Kurt Roeckx added the comment:

I did update the documentation to mention that, but it seems none of my 
documentation changes got applied.

--

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b2ee06684b6a by Yury Selivanov in branch '3.4':
selectors: Make sure EpollSelecrtor.select() works when no FD is registered.
https://hg.python.org/cpython/rev/b2ee06684b6a

New changeset 202995833ef4 by Yury Selivanov in branch 'default':
selectors: Make sure EpollSelecrtor.select() works when no FD is registered.
https://hg.python.org/cpython/rev/202995833ef4

--
nosy: +python-dev

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread Yury Selivanov

Yury Selivanov added the comment:

 Please add a comment explaining the complaint from epoll.poll() we're
trying to avoid here.

Good point! Committed.

--

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



[issue23009] selectors.EpollSelector.select raises exception when nothing to select.

2014-12-08 Thread Yury Selivanov

Changes by Yury Selivanov yseliva...@gmail.com:


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

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



  1   2   >