ANN Nanpy 0.9

2014-04-23 Thread Andrea Stagi
Hi all,

I'm glad to announce you Nanpy 0.9 release!
https://pypi.python.org/pypi/nanpy/0.9

The main purpose of Nanpy is making programmers' life easier, giving them
something to create prototypes faster and use Arduino in a simpler way,
thanks to a simple and powerful language like Python. Also Nanpy can run on
RaspberryPi (tested with Raspbian http://www.raspbian.org/) so you can use
it for communicating with Arduino :)

Let's start with a classic example, turn on a led placed in the 13th pin..

from nanpy import (ArduinoApi, SerialManager)

connection = SerialManager()
a = ArduinoApi(connection=connection)
a.pinMode(13, a.OUTPUT)
a.digitalWrite(13, a.HIGH)

NOTE: you can also use the old serial_manager global object

There are a lot of projects able to do that. Nanpy can do more!
Nanpy is easily extensible and can theoretically use every library,
allowing you to create how many objects you want.
We started supporting OneWire, Lcd, Stepper and Servo library and they're
still incomplete.
Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and
print something!

connection = SerialManager()
lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2], connection=connection)
lcd.printString(Hello World!)

really straightforward now, isn't it? :)

Multithreading
--
What happens if you call methods in an async context? Nothing bad, all
works! every call is mutually exclusive.. For example, suppose that two
threads need to write on the same Lcd and in different positions at the
same time... well, just call printString on the Lcd object specifying the
position (row and column)

#Thread_1
...
lcd.printString(Hello First Row!, 0, 0)
...

#Thread_2

lcd.printString(Hello Second Row!, 0, 1)
...

How to build and install

You need to build the firmware for your Arduino first, just clone the
firmware repository at https://github.com/nanpy/firmware and follow the
README to configure and build it.

To install Nanpy Python library just type (as root):

python setup.py install

How to use
--
### Serial communication

Nanpy autodetects the serial port for you, anyway you can specify another
serial port manually:

from nanpy import SerialManager
connection = SerialManager(device='/dev/ttyACM1')

### Import modules

Import all the modules you need :)

from nanpy import Arduino
from nanpy import (OneWire, Lcd)
...

How to contribute
-
Nanpy needs a lot of work to be a great tool. You can contribute with
patches (bugfixing, writing improvements, creating support for a new
library not included in Nanpy yet, writing examples and so on), writing
documentation, reporting bugs, creating packages or simply spreading Nanpy
through the web if you like it :) If you have any doubt or problem, please
contact me at stagi.and...@gmail.com

Do you want to support us with a coffee? We need it to code all night long!
if you like this project and you want to support it with some cents, please
donate :)
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclickhosted_button_id=TDTPP5JHVJK8J


-- 
Andrea Stagi (@4stagi) - Develer S.r.l
Job profile: http://linkedin.com/in/andreastagi
Website: http://4spills.blogspot.it/
Github: http://github.com/astagi
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: Portable Python 2.7.6.1

2014-04-23 Thread Perica Zivkovic
Dear people,

I would like to announce new release of the Portable Python based on Python 
2.7.6

Included in this release:
-
* PyScripter v2.5.3
* PyCharm Community Edition 3.1.2 (Thanks to cebik)
* NymPy 1.8.1
* SciPy 0.13.3
* Matplotlib 1.3.1
* PyWin32 218
* Django 1.6.2
* PIL 1.1.7
* Py2Exe 0.6.9
* wxPython 3.0.0.0
* NetworkX 1.7
* Lxml 3.3.4
* PySerial 2.7
* PyODBC 3.0.7
* PyGame 1.9.1
* PyGTK 2.24.2
* PyQt 4.10.4
* IPython 1.2.1
* Pandas 0.11.0
* Dateutil 2.2
* PyParsing 2.0.1
* Six 1.6.1
* XLRD 0.9.2
* XLWT 0.7.5
* XLUtils 1.7.0
* OpenPyXL 1.8.5

Improvements since last release:

Upgraded most of the libraries to the latest available versions and fixed lots 
of configuration bugs.

Added
* PyCharm (kudos to Cebik!)
* Dateutil
* PyParsing
* Six
* Libraries for Excel (XLRD, XLWT, XLUtils and OpenPyXL)

Installation and use:
-
After downloading, run the installer, select the packages you would like to 
install, select the target folder and you are done! In the root folder of the 
distribution you will find shortcuts for selected applications. Some of the 
most popular free Python IDE's come preinstalled and preconfigured with 
Portable Python. How to use and configure them further please consult their 
documentation or project sites.

Download location: http://portablepython.com/wiki/PortablePython2.7.6.1

Warning: Default installation installs all packages - make sure to review 
packages selection during installation process as it can take quite some time 
to install 800+MB on the USB drive(s).

Please use feedback and support section on the portal to request new packages 
or to report issues.

Keep pythoning !

Perica Zivkovic
http://www.PortablePython.com
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


[ANN] Pylint 1.2 released

2014-04-23 Thread Sylvain Thénault
Hi there,

Pylint 1.2 has been uploaded to pypi by the end of the last week! More info on 
this heavy release on http://www.logilab.org/blogentry/240019.

As usual, feedback and comments welcome.

Enjoy!
-- 
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
CubicWeb, the semantic web framework:http://www.cubicweb.org
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Re: object().__dict__

2014-04-23 Thread Ben Finney
Pavel Volkov sai...@lists.xtsubasa.org writes:

 The attribute list is different now and there's no __dict__ and the
 object does not accept new attributes.
 Please explain what's going on.

It's a leaky abstraction, unfortunately.

By default, all user-defined types will provide their instances with a
‘__dict__’ attribute, whic is a mapping to store the instance's
attributes.

But some types don't have that, and ‘object’ is one of them. It
deliberately overrides the default behaviour, and has no ‘__dict__’ for
its instances.

 foo = object()

 foo.bar = spam
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'object' object has no attribute 'bar'

 foo.__dict__
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'object' object has no attribute '__dict__'

Your user-defined types, even though they inherit from ‘object’, will
get a ‘__dict__’ as normal::

 class Bag:
  A simple type to hold attributes. 

 Bag.__mro__
(class '__main__.Bag', class 'object')

 foo = Bag()
 foo.bar = spam
 foo.__dict__
{'bar': 'spam'}

See the discussion of ‘__slots__’, and note also that it's not
recommended to use this unless you know exactly why you need it
URL:https://docs.python.org/3/reference/datamodel.html#slots.

I consider it a wart of Python that its ‘object’ instances lack the
ability to gain arbitrary attributes in the way you expect.

-- 
 \  “Every man would like to be God, if it were possible; some few |
  `\  find it difficult to admit the impossibility.” —Bertrand |
_o__)Russell, _Power: A New Social Analysis_, 1938 |
Ben Finney

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


Re: object().__dict__

2014-04-23 Thread Cameron Simpson

On 23Apr2014 09:39, Pavel Volkov sai...@lists.xtsubasa.org wrote:

There are some basics about Python objects I don't understand.
Consider this snippet:


class X: pass

...

x = X()
dir(x)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', 
'__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', 
'__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', 
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', 
'__sizeof__', '__str__', '__subclasshook__', '__weakref__']

x.foo = 11


And now I want to make a simple object in a shorter way, without 
declaring X class:



y = object()
dir(y)
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', 
'__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', 
'__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', 
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', 
'__subclasshook__']

y.foo = 12

Traceback (most recent call last):
File stdin, line 1, in module
AttributeError: 'object' object has no attribute 'foo'

The attribute list is different now and there's no __dict__ and the 
object does not accept new attributes.

Please explain what's going on.


The base object class has a fixed set of attributes; you can't add more.

Almost every other class lets you add attributes, but the price for that is 
that it is slightly in memory footprint and slower to access.


Look up the __slots__ dunder var in the Python doco index:

  https://docs.python.org/3/glossary.html#term-slots

You'll see it as a (rarely used, mostly discouraged) way to force a fixed set 
of attributes onto a class. As with object, this brings a smaller memory 
footprint and faster attribute access, but the price is flexibility.


Cheers,
Cameron Simpson c...@zip.com.au

Try being nothing but bored for 4 hours straight, and then tell me that
there's no fear involved.   - d...@elxr.jpl.nasa.gov (Dave Hayes)
--
https://mail.python.org/mailman/listinfo/python-list


Re: Unicode in Python

2014-04-23 Thread Devin Jeanpierre
On Tue, Apr 22, 2014 at 10:52 PM, Steven D'Aprano st...@pearwood.info wrote:
 There's not just the keyboard mapping. There's the mental cost of knowing
 which keyboard mapping you need (is it Greek, Hebrew, or maths
 symbols?), the cost of remembering the mapping from the keys you see on
 the keyboard to the keys they are mapped to (is Ω mapped to O or W?)
 and so forth. If you know lambda-calculus, you might associate λ with
 functions, [...]

Or if you know Python and the name of the letter (lambda).

But yes, typing out the special characters is annoying. I just use
words. The only downside to using words is, how do you specify capital
versus lowercase letters? Gamma = ... violates the style guide! :(

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


Re: Unicode in Python

2014-04-23 Thread Ben Finney
Devin Jeanpierre jeanpierr...@gmail.com writes:

 But yes, typing out the special characters is annoying. I just use
 words.

I use words that describe the meaning, where feasible.

 The only downside to using words is, how do you specify capital
 versus lowercase letters?

Why do you need to, for an identifier? If uppercase gamma is
semantically different from lowercase gamma for identifying a value,
then both are too terse and the meaning should be spelled out in a
better chosen semantic name.

-- 
 \   “Some people have a problem, and they think “I know, I'll use |
  `\ Perl!”. Now they have some number of problems but they're not |
_o__) sure whether it's a string or an integer.” —Benno Rice, 2011 |
Ben Finney

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


Re: Unicode in Python

2014-04-23 Thread Rustom Mody
On Wednesday, April 23, 2014 11:22:33 AM UTC+5:30, Steven D'Aprano wrote:

 25 Unicode characters down, 1114000+ to go :-)

The question would arise if there was some suggestion to add
1114000(+) characters to the syntactic/lexical definition of python.

IOW while its true that unicode is a character-set, its better to think
of it as a repertory  -- here is the universal set from which a choice is 
available.

On Wednesday, April 23, 2014 11:20:35 AM UTC+5:30, Chris Angelico wrote:
 On Wed, Apr 23, 2014 at 3:31 PM, Rustom Mody wrote:
  Chris Angelico wrote:
  it's impossible for most people to type (and programming with a palette
  of arbitrary syntactic tokens isn't my idea of fun)...
  Where's the suggestion to use a palette of arbitrary tokens ?
  I just tried a greek keyboard; ie do
  $ setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll 
  -layout us,gr
  Thereafter typing
  abcdefghijklmnopqrstuvwxyz
  after a Shift-Alt
  gives
  αβψδεφγηιξκλμνοπ;ρστθωςχυζ
  One more Shift-Alt and back to roman

 Okay. Now what about your other symbols? Your alternative assignment
 operator, for instance. How do you type that?

In case you missed it, I said:

 Of course
 - One would need to define such a keyboard (setxkb)
 - One would have to find similar technologies for other OSes

In more detail:
In our normal use of a US-104 keyboard, every letter 'costs' something.
eg 'a' costs 1 keystroke
   'A' costs 2 (Shift+a)
Most people do not count that as a significant cost.
and when kids come on this list and talk smsese -- i wanna do so-n-so

we chide them for keystrokes at the cost of readability.

In such a (default) setup typing a ∧ or ∨ is not possible at all without
something like a char-picker and at best has an ergonomic cost that is an
order of magnitude higher than the 'naturally available' characters.

On the other hand when/if a keyboard mapping is defined in which
the characters that are commonly needed are available, it is
reasonable to expect the ∨,∧ to cost no more than 2 strokes each
(ie about as much as an 'A'; slightly more than an 'a'. Which means
that '∨' is expected to cost about the same as 'or' and ∧ to cost less than an 
'and'

Readability is another question altogether.
Random example from my machine
calendar.py line 99
If one finds this:

return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)

more readable than
return year%4=0 ∧ (year%100≠0  ∨  year%100 = 0)
then perhaps the following is the most preferred?

COMPUTE YEAR MODULO 4 EQUALS 0 AND YEAR MODULO 100 NOT
EQUAL TO ZERO OR YEAR MODULO 100 EQUAL to 0

IOW COBOL is desirable?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unicode in Python

2014-04-23 Thread Chris Angelico
On Wed, Apr 23, 2014 at 4:57 PM, Rustom Mody rustompm...@gmail.com wrote:
 In such a (default) setup typing a ∧ or ∨ is not possible at all without
 something like a char-picker and at best has an ergonomic cost that is an
 order of magnitude higher than the 'naturally available' characters.

 On the other hand when/if a keyboard mapping is defined in which
 the characters that are commonly needed are available, it is
 reasonable to expect the ∨,∧ to cost no more than 2 strokes each
 (ie about as much as an 'A'; slightly more than an 'a'. Which means
 that '∨' is expected to cost about the same as 'or' and ∧ to cost less than 
 an 'and'

So how much effort are you going to go to for, effectively, the same
end result? You can type or with the same keystrokes, and it takes
zero setup work and zero memorization (you may forget which keystroke
you set up for ∨, but I doubt you'll forget how to spell or, even if
you think it means gold/yellow). Where's the benefit? I'm seriously
not seeing it.

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


Re: Unicode in Python

2014-04-23 Thread Steven D'Aprano
On Tue, 22 Apr 2014 23:57:46 -0700, Rustom Mody wrote:

 perhaps the following is the most preferred?
 
 COMPUTE YEAR MODULO 4 EQUALS 0 AND YEAR MODULO 100 NOT EQUAL TO ZERO OR
 YEAR MODULO 100 EQUAL to 0
 
 IOW COBOL is desirable?

If the only choices are COBOL on one hand and the mutant offspring of 
Perl and APL on the other, I'd vote for COBOL.

But surely they aren't the only options, and it is possible to find a 
happy medium which is neither excessively verbose nor painfully, 
cryptically terse.

Remember that we're talking about general purpose programming here. There 
are domains which favour terseness and a vast number of symbols, e.g. 
mathematics, but most programming is not in that domain, even when it 
uses tools from that domain.


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


how to write list in a file

2014-04-23 Thread Dhananjay
Hello everyone,

I am trying hard to write a list to a file as follows:


def average_ELECT(pwd):
os.chdir(pwd)
files = filter(os.path.isfile, os.listdir('./'))
folders = filter(os.path.isdir, os.listdir('./'))
eelec = 0.0; evdw = 0.0; EELEC = []; elecutoff = [];
g = Gnuplot.Gnuplot()
for f1 in files:
#   if f1[21:23]=='12':
if f1[27:29]==sys.argv[1]: # vdw cutoff remains constant; see 2nd
column of output
fl1 = open(f1,'r').readlines()
#   print len(fl1)

for i in range(1, len(fl1)):
fl1[i]=fl1[i].split()
eelec = eelec + float(fl1[i][1])
evdw = evdw + float(fl1[i][2])
#print fl1[i][1], fl1[i][2]
avg_eelec = eelec/40
avg_evdw = evdw/40
#   print eelec, evdw
#   print f1[21:23], f1[27:29], avg_eelec, avg_evdw
print f1[21:23], f1[27:29], avg_eelec
#   EELEC.append(avg_eelec); elecutoff.append(float(f1[21:23]))
eelec=0.0; evde=0.0;
a = f1[21:23]+' '+f1[27:29]+' '+str(avg_eelec)
EELEC.append(a)
print sorted(EELEC)
with open('EElect_elec12-40_vdwxxx.dat','w') as wr:
for i in EELEC:
print i
wr.write(%s\n % i)
wr.close()


The script is printing print sorted(EELEC) as well as print f1[21:23],
f1[27:29], avg_eelec very well.
However, for some reason, I neither see any file (expected to see
EElect_elec12-40_vdwxxx.dat as per the script) generated nor any error
message.

Could anyone suggest me correction here.

Thanking you in advance.

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


Re: Unicode in Python

2014-04-23 Thread Steven D'Aprano
On Tue, 22 Apr 2014 23:57:46 -0700, Rustom Mody wrote:

 On the other hand when/if a keyboard mapping is defined in which the
 characters that are commonly needed are available, it is reasonable to
 expect the ∨,∧ to cost no more than 2 strokes each (ie about as much as
 an 'A'; slightly more than an 'a'. Which means that '∨' is expected to
 cost about the same as 'or' and ∧ to cost less than an 'and'

Oh, a further thought...

Consider your example:

return year%4=0 ∧ (year%100≠0 ∨ year%100 = 0)

vs 

return year%4=0 and (year%100!=0 or year%100 = 0) 


[aside: personally I like ≠ and if there was a platform independent way 
to type it in any editor, I'd much prefer it over != or  ]

Apart from the memorization problem, which I've already touched on, there 
is the mode problem. Keyboard layouts are modes, and you're swapping 
modes. Every time you swap modes, there is a small mental cost. Think of 
it as an interrupt which has to be caught, pausing the current thought 
and starting a new one. So rather than:

char char char char char char char ...

you have:

char char char INTERRUPT
char INTERRUPT
char char char ...


which is a heavier cost that it appears from just counting keystrokes. Of 
course, the more experienced you become, the smaller that cost will be, 
but it will never be quite as low as just a regular keystroke.

Normally, when people use multiple keyboards, its because that interrupt 
cost is amortized over a significant amount of typing:

INTERRUPT (English layout)
paragraph paragraph paragraph paragraph
INTERRUPT (Greek layout)
paragraph paragraph paragraph
INTERRUPT (English again)
paragraph ...

and possibly even lost in the noise of a far greater interrupt, namely 
task-switching from one application to another. So it's manageable. But 
switching layouts for a single character is likely to be far more 
painful, especially for casual users of that layout. 

Based on an extremely generous estimate that I use lambda four times in 
100 lines of code, I might use λ perhaps once in a thousand non-Greek 
characters. Similarly, I might use ∧ or ∨ maybe once per hundred 
characters. That means I'm unlikely to ever get familiar enough with 
those that the cost of two interrupts per use will be negligible.


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


Re: how to write list in a file

2014-04-23 Thread David Palao
2014-04-23 9:53 GMT+02:00 Dhananjay dhananjay.c.jo...@gmail.com:
 Hello everyone,

 I am trying hard to write a list to a file as follows:


 def average_ELECT(pwd):
 os.chdir(pwd)
 files = filter(os.path.isfile, os.listdir('./'))
 folders = filter(os.path.isdir, os.listdir('./'))
 eelec = 0.0; evdw = 0.0; EELEC = []; elecutoff = [];
 g = Gnuplot.Gnuplot()
 for f1 in files:
 #   if f1[21:23]=='12':
 if f1[27:29]==sys.argv[1]: # vdw cutoff remains constant; see 2nd
 column of output
 fl1 = open(f1,'r').readlines()
 #   print len(fl1)

 for i in range(1, len(fl1)):
 fl1[i]=fl1[i].split()
 eelec = eelec + float(fl1[i][1])
 evdw = evdw + float(fl1[i][2])
 #print fl1[i][1], fl1[i][2]
 avg_eelec = eelec/40
 avg_evdw = evdw/40
 #   print eelec, evdw
 #   print f1[21:23], f1[27:29], avg_eelec, avg_evdw
 print f1[21:23], f1[27:29], avg_eelec
 #   EELEC.append(avg_eelec); elecutoff.append(float(f1[21:23]))
 eelec=0.0; evde=0.0;
 a = f1[21:23]+' '+f1[27:29]+' '+str(avg_eelec)
 EELEC.append(a)
 print sorted(EELEC)
 with open('EElect_elec12-40_vdwxxx.dat','w') as wr:
 for i in EELEC:
 print i
 wr.write(%s\n % i)
 wr.close()


 The script is printing print sorted(EELEC) as well as print f1[21:23],
 f1[27:29], avg_eelec very well.
 However, for some reason, I neither see any file (expected to see
 EElect_elec12-40_vdwxxx.dat as per the script) generated nor any error
 message.

 Could anyone suggest me correction here.

 Thanking you in advance.

 -- DJ



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


A couple of minor points:
* You don't need wr.close() after the with open(...) as wr: block.
* Are you sure that you are looking in the right directory?
* Why do you need the g = Gnuplot.Gnuplot() line? It looks to me
that you have skipped some things while doing copy and paste?

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


Re: object().__dict_

2014-04-23 Thread Duncan Booth
Pavel Volkov sai...@lists.xtsubasa.org wrote:

 There are some basics about Python objects I don't understand.
 Consider this snippet:
 
 class X: pass
 ... 
 x = X()
 dir(x)
 ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__',
 '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__',
 '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__',
 '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
 '__sizeof__', '__str__', '__subclasshook__', '__weakref__']
 x.foo = 11
 
 And now I want to make a simple object in a shorter way, without
 declaring X class:
 
 y = object()
 dir(y)
 ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__',
 '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__',
 '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__',
 '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
 '__subclasshook__'] 
 y.foo = 12
 Traceback (most recent call last):
   File stdin, line 1, in module
 AttributeError: 'object' object has no attribute 'foo'
 
 The attribute list is different now and there's no __dict__ and the
 object does not accept new attributes.
 Please explain what's going on.
 
 
Not all classes have a __dict__ attribute. Mostly builtin classes (e.g. 
tuple, list, int, ...), but also if you have an class using __slots__ 
which subclasses a class with no __dict__ it won't have a __dict__.

Subclasses don't remove attributes, they only add them (although in 
Python you can bend that rule it still applies here). Therefore for any 
classes to not have a __dict__ attribute the ultimate base class 
'object' has to not have a __dict__.

The consequence, as you found out, is that you cannot add attributes to 
an instance of 'object()', you have to create at least an empty subclass 
which doesn't include a `__slots__` attribute to get a class that can 
accept arbitrary attributes.


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


Re: object().__dict__

2014-04-23 Thread Amirouche Boubekki
2014-04-23 8:11 GMT+02:00 Cameron Simpson c...@zip.com.au:

 On 23Apr2014 09:39, Pavel Volkov sai...@lists.xtsubasa.org wrote:

 There are some basics about Python objects I don't understand.
 Consider this snippet:

  class X: pass

 ...

  x = X()
 dir(x)

 ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__',
 '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__',
 '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__',
 '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__',
 '__str__', '__subclasshook__', '__weakref__']

  x.foo = 11


 And now I want to make a simple object in a shorter way, without
 declaring X class:


If you don't want to go through the usual syntax that defines classes you
can use the equivalent code using type to dynamically create a class:

MyClassObject = type('MyClassObject', (object,), dict())

Mind the fact that MyClassObject is a specific kind of object: a class, a
priori, not harmful in anyway



  y = object()
 dir(y)

 ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__',
 '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__',
 '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__',
 '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
 '__subclasshook__']

  y.foo = 12

 Traceback (most recent call last):
 File stdin, line 1, in module
 AttributeError: 'object' object has no attribute 'foo'

 The attribute list is different now and there's no __dict__ and the
 object does not accept new attributes.
 Please explain what's going on.


 The base object class has a fixed set of attributes; you can't add more.


Just like any other builtin type: int, float etc... which also means you
can't add method to them dynamically.

Mind the fact that an instance of object is still useful to implement
efficient SENTINEL objects



 Almost every other class lets you add attributes, but the price for that
 is that it is slightly in memory footprint and slower to access.


class defined in Python except if you define a __slots__



 Look up the __slots__ dunder var in the Python doco index:

   https://docs.python.org/3/glossary.html#term-slots

 You'll see it as a (rarely used, mostly discouraged) way to force a fixed
 set of attributes onto a class. As with object, this brings a smaller
 memory footprint and faster attribute access, but the price is flexibility.


True, still can be the only way to save few MB or... GB without falling
back to C or PyPy.

Have a look at PyPy to how to save memory (and speed things up) without
slots:
http://morepypy.blogspot.fr/2010/11/efficiently-implementing-python-objects.html

In Python 3 there is a class that is equivalent to:

class foo(object):
pass

simple object with a __dict__, I can't find it anymore and also there is
SimpleNamespacehttps://docs.python.org/3/library/types.html#types.SimpleNamespaceclass.

To sum up:

- If you want to create a sentinel value, use object()
- If you want to create an object to hold values and access them as
attributes, use something like SimpleNamespace


 Cheers,
 Cameron Simpson c...@zip.com.au

 Try being nothing but bored for 4 hours straight, and then tell me that
 there's no fear involved.   - d...@elxr.jpl.nasa.gov (Dave Hayes)
 --
 https://mail.python.org/mailman/listinfo/python-list

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


Re: object().__dict__

2014-04-23 Thread Phil Connell
On Wed, Apr 23, 2014 at 03:48:32PM +0200, Amirouche Boubekki wrote:
 2014-04-23 8:11 GMT+02:00 Cameron Simpson c...@zip.com.au:
  Look up the __slots__ dunder var in the Python doco index:
 
https://docs.python.org/3/glossary.html#term-slots
 
  You'll see it as a (rarely used, mostly discouraged) way to force a fixed
  set of attributes onto a class. As with object, this brings a smaller
  memory footprint and faster attribute access, but the price is flexibility.
 
 
 True, still can be the only way to save few MB or... GB without falling
 back to C or PyPy.
 
 Have a look at PyPy to how to save memory (and speed things up) without
 slots:
 http://morepypy.blogspot.fr/2010/11/efficiently-implementing-python-objects.html

Is there any analysis of how this balances increased memory usage from the JIT
vs the CPython VM (with a reasonable amount of code)?

I'd thought that one of the main disadvantages of PyPy was drastically
increased memory usage for any decent-sized program. Would be interested to
know if this was not the case :)


Cheers,
Phil

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


Re: object().__dict__

2014-04-23 Thread Amirouche Boubekki
2014-04-23 15:59 GMT+02:00 Phil Connell pconn...@gmail.com:

 On Wed, Apr 23, 2014 at 03:48:32PM +0200, Amirouche Boubekki wrote:
  2014-04-23 8:11 GMT+02:00 Cameron Simpson c...@zip.com.au:
   Look up the __slots__ dunder var in the Python doco index:
  
 https://docs.python.org/3/glossary.html#term-slots
  
   You'll see it as a (rarely used, mostly discouraged) way to force a
 fixed
   set of attributes onto a class. As with object, this brings a smaller
   memory footprint and faster attribute access, but the price is
 flexibility.
  
 
  True, still can be the only way to save few MB or... GB without falling
  back to C or PyPy.
 
  Have a look at PyPy to how to save memory (and speed things up) without
  slots:
 
 http://morepypy.blogspot.fr/2010/11/efficiently-implementing-python-objects.html

 Is there any analysis of how this balances increased memory usage from the
 JIT
 vs the CPython VM (with a reasonable amount of code)?

 I'd thought that one of the main disadvantages of PyPy was drastically
 increased memory usage for any decent-sized program. Would be interested to
 know if this was not the case :)


I have a similar thought, I don't how that memory consumption increase (a
constant? a factor? probably both...)

but if the program use an absurd amount of memory even in CPython then PyPy
will be able to catchup based on comment #1 of a PyPy core dev in
http://tech.oyster.com/save-ram-with-python-slots/ see also
http://pypy.readthedocs.org/en/latest/interpreter-optimizations.html#dictionary-optimizations

Still it requires more analysis. When does PyPy trigger the optimization?




 Cheers,
 Phil

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

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


Re: object().__dict__

2014-04-23 Thread Phil Connell
On Wed, Apr 23, 2014 at 04:21:26PM +0200, Amirouche Boubekki wrote:
 2014-04-23 15:59 GMT+02:00 Phil Connell pconn...@gmail.com:
 
  On Wed, Apr 23, 2014 at 03:48:32PM +0200, Amirouche Boubekki wrote:
   2014-04-23 8:11 GMT+02:00 Cameron Simpson c...@zip.com.au:
Look up the __slots__ dunder var in the Python doco index:
   
  https://docs.python.org/3/glossary.html#term-slots
   
You'll see it as a (rarely used, mostly discouraged) way to force a
  fixed
set of attributes onto a class. As with object, this brings a smaller
memory footprint and faster attribute access, but the price is
  flexibility.
   
  
   True, still can be the only way to save few MB or... GB without falling
   back to C or PyPy.
  
   Have a look at PyPy to how to save memory (and speed things up) without
   slots:
  
  http://morepypy.blogspot.fr/2010/11/efficiently-implementing-python-objects.html
 
  Is there any analysis of how this balances increased memory usage from the
  JIT
  vs the CPython VM (with a reasonable amount of code)?
 
  I'd thought that one of the main disadvantages of PyPy was drastically
  increased memory usage for any decent-sized program. Would be interested to
  know if this was not the case :)
 
 
 I have a similar thought, I don't how that memory consumption increase (a
 constant? a factor? probably both...)
 
 but if the program use an absurd amount of memory even in CPython then PyPy
 will be able to catchup based on comment #1 of a PyPy core dev in
 http://tech.oyster.com/save-ram-with-python-slots/ see also
 http://pypy.readthedocs.org/en/latest/interpreter-optimizations.html#dictionary-optimizations

Absolutely. For long-running code manipulating large amounts of data I can
imagine the PyPy optimisations being a win.

On the other hand, if the code/data ratio is larger, CPython may well win in
terms of memory use.


 
 Still it requires more analysis. When does PyPy trigger the optimization?

Indeed. Without measuring this is all idle speculation ;)


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


Re: Unicode in Python

2014-04-23 Thread Rustom Mody
On Wednesday, April 23, 2014 1:23:00 PM UTC+5:30, Steven D'Aprano wrote:
 On Tue, 22 Apr 2014 23:57:46 -0700, Rustom Mody wrote:

  On the other hand when/if a keyboard mapping is defined in which the
  characters that are commonly needed are available, it is reasonable to
  expect the ∨,∧ to cost no more than 2 strokes each (ie about as much as
  an 'A'; slightly more than an 'a'. Which means that '∨' is expected to
  cost about the same as 'or' and ∧ to cost less than an 'and'

 Oh, a further thought...

 Consider your example:

 return year%4=0 ∧ (year%100≠0 ∨ year%100 = 0)

 vs

 return year%4=0 and (year%100!=0 or year%100 = 0)

 [aside: personally I like ≠ and if there was a platform independent way
 to type it in any editor, I'd much prefer it over != or  ]

 Apart from the memorization problem, which I've already touched on, there
 is the mode problem. Keyboard layouts are modes, and you're swapping
 modes. Every time you swap modes, there is a small mental cost. Think of
 it as an interrupt which has to be caught, pausing the current thought
 and starting a new one. So rather than:

 char char char char char char char ...

 you have:

 char char char INTERRUPT
 char INTERRUPT
 char char char ...

 which is a heavier cost that it appears from just counting keystrokes. Of
 course, the more experienced you become, the smaller that cost will be,
 but it will never be quite as low as just a regular keystroke.

 Normally, when people use multiple keyboards, its because that interrupt
 cost is amortized over a significant amount of typing:

 INTERRUPT (English layout)
 paragraph paragraph paragraph paragraph
 INTERRUPT (Greek layout)
 paragraph paragraph paragraph
 INTERRUPT (English again)
 paragraph ...

 and possibly even lost in the noise of a far greater interrupt, namely
 task-switching from one application to another. So it's manageable. But
 switching layouts for a single character is likely to be far more
 painful, especially for casual users of that layout.

 Based on an extremely generous estimate that I use lambda four times in
 100 lines of code, I might use λ perhaps once in a thousand non-Greek
 characters. Similarly, I might use ∧ or ∨ maybe once per hundred
 characters. That means I'm unlikely to ever get familiar enough with
 those that the cost of two interrupts per use will be negligible.

Its gratifying to see an argument whose framing is cognitive-based!

More on that later.

For now: mode/modeless

Yes most of us prefer the Shift key to the Caps Lock even for stretches of 
capitals.  So analogously here is a modeless solution

Earlier I found this mode-switching version
$ setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll -layout 
us,gr
this makes Shift-Alt the mode-switcher

This one on the other hand
$ setxkbmap -layout us,gr -option grp:switch
will make right-alt behave like 'Greek-Shift'

ie typing
abcdefghijklmnopqrstuvwxyz
with RAlt depressed throughout, produces
αβψδεφγηιξκλμνοπ;ρστθωςχυζ

This makes the a Greek letter's ergonomic cost identical to a capital English
letter's:  For Greek use RAlt the way one uses Shift for English.

Notes:
1. Tried on Debian and Ubuntu -- Recent Ubuntus are rather more ill-mannered in
the way they appropriates keys. Still it works as far as I can see.

2. ';' ?? ie semicolon is produced from 'q'? Whats that semicolon doing there?? 
But then Greek is -- well -- Greek to me! (As is xkb!)
-- 
https://mail.python.org/mailman/listinfo/python-list


App segmentation fault (CentOS 6.5)

2014-04-23 Thread Reginaldo
Hi,

I have a GUI app that is written using wx. When I run it on CentOS 6.5, the 
following error messages are displayed and the app closes:

(python:10096): Pango-WARNING **: shaping failure, expect ugly output. 
shape-engine='BasicEngineFc', font='DejaVu Sans 10.9990234375', text=''

(python:10096): Pango-CRITICAL **: pango_layout_get_line_count: assertion 
`layout != NULL' failed

(python:10096): Gdk-CRITICAL **: IA__gdk_draw_layout: assertion 
`PANGO_IS_LAYOUT (layout)' failed
Segmentation fault

I checked if this was a font issue, but the font is installed on the system.

I use an idle thread in my application.

Could some let me know what the problem may be in this case? Thank you!

Python Version used: 2.6.6
wxPython Version used: 2.8.11
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: App segmentation fault (CentOS 6.5)

2014-04-23 Thread Mark H Harris

On 4/23/14 1:08 PM, Reginaldo wrote:


I have a GUI app that is written using wx. When I run it on CentOS 6.5, the 
following error messages are displayed and the app closes:


   Only fails on CentOS ?



I use an idle thread in my application.


   Is your CentOS launching idle with -n switch ?



   What is different on this setup ?

   Have you tried more than one CentOS system?






  marcus

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


Re: object().__dict__

2014-04-23 Thread CHIN Dihedral
On Wednesday, April 23, 2014 10:21:26 PM UTC+8, Amirouche Boubekki wrote:
 2014-04-23 15:59 GMT+02:00 Phil Connell pcon...@gmail.com:
 
 
 
 On Wed, Apr 23, 2014 at 03:48:32PM +0200, Amirouche Boubekki wrote:
 
  2014-04-23 8:11 GMT+02:00 Cameron Simpson c...@zip.com.au:
 
 
   Look up the __slots__ dunder var in the Python doco index:
 
  
 
     https://docs.python.org/3/glossary.html#term-slots
 
  
 
   You'll see it as a (rarely used, mostly discouraged) way to force a fixed
 
   set of attributes onto a class. As with object, this brings a smaller
 
   memory footprint and faster attribute access, but the price is 
   flexibility.
 
  
 
 
 
  True, still can be the only way to save few MB or... GB without falling
 
  back to C or PyPy.
 
 
 
  Have a look at PyPy to how to save memory (and speed things up) without
 
  slots:
 
  http://morepypy.blogspot.fr/2010/11/efficiently-implementing-python-objects.html
 
 
 
 Is there any analysis of how this balances increased memory usage from the JIT
 
 vs the CPython VM (with a reasonable amount of code)?
 
 
 
 I'd thought that one of the main disadvantages of PyPy was drastically
 
 increased memory usage for any decent-sized program. Would be interested to
 
 know if this was not the case :)
 
 
 
 I have a similar thought, I don't how that memory consumption increase (a 
 constant? a factor? probably both...)
 
 but if the program use an absurd amount of memory even in CPython then PyPy 
 will be able to catchup based on comment #1 of a PyPy core dev in 
 http://tech.oyster.com/save-ram-with-python-slots/ see also 
 http://pypy.readthedocs.org/en/latest/interpreter-optimizations.html#dictionary-optimizations
 
 
 
 
 Still it requires more analysis. When does PyPy trigger the optimization?
 
  
 
 
 
 
 
 
 Cheers,
 
 Phil
 
 
 
 --
 
 https://mail.python.org/mailman/listinfo/python-list

 The auto-code generation  of valid python codes in PyPy is helpful in CAD/CAM 
and non-idiot robot brains.
-- 
https://mail.python.org/mailman/listinfo/python-list


Moving to an OOP model from an classically imperitive one

2014-04-23 Thread tim . thelion
Hello,

I am currently writting a program called subuser(subuser.org), which is written 
as classically imperative code.  Subuser is, essentially, a package manager.  
It installs and updates programs from repositories.

I have a set of source files 
https://github.com/subuser-security/subuser/tree/master/logic/subuserCommands/subuserlib
 which have functions in them.  Each function does something to a program, it 
identifies the program by the programs name.  For example, I have an 
installProgram function defined as such:

def installProgram(programName, useCache):

Now I've run into a flaw in this model.  There are certain situations where a 
programName is not a unique identifier. It is possible for two repositories 
to each have a program with the same name.  Obviously, I could go through my 
code and replace all use of the string programName with a tuple of 
(programName, repository).  Or I could define a new class with two attributes: 
programName and repository, and pass such a simple object arround, or pass a 
dictionary.  However, I think this would be better solved by moving fully to an 
OOP model.  That is, I would have a SubuserProgram class which had methods such 
as install, describe, isInstalled...

There is one problem though.  Currently, I have these functions logically 
organized into source files, each between 40 and 170 LOC.  I fear that if I 
were to put all of these functions into one class, than I would have a single, 
very large source file.  I don't like working with large source files for 
practicall reasons.  If I am to define the class SubuserProgram in the file 
SubuserProgram.py, I do not want all 
https://github.com/subuser-security/subuser/blob/master/logic/subuserCommands/subuserlib/run.py#L162
 of run.py to be moved into that file as well.

I thought about keeping each method in a separate file, much as I do now, 
something like:

###
#FileA.py
###
def a(self):
  blah

###
#FileB.py
###
def b(self):
  blah

###
#Class.py
###
import FileA, FileB
class C:
  a=FileA.a
  b=FileB.b

This works, but I find that it is hard to read.  When I come across FileA, and 
I see self it just seems very confusing.  I suffer a bout of who-am-iism.

I asked on IRC and it was sugested that I use multiple classes, however I see 
no logical way to separate a SubuserProgram object into multiple classes.

So I thought I would seek your advice.

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


Re: Moving to an OOP model from an classically imperitive one

2014-04-23 Thread Mark Lawrence

On 23/04/2014 21:57, tim.thel...@gmail.com wrote:

Hello,

I am currently writting a program called subuser(subuser.org), which is written 
as classically imperative code.  Subuser is, essentially, a package manager.  
It installs and updates programs from repositories.

I have a set of source files 
https://github.com/subuser-security/subuser/tree/master/logic/subuserCommands/subuserlib
 which have functions in them.  Each function does something to a program, it 
identifies the program by the programs name.  For example, I have an 
installProgram function defined as such:

def installProgram(programName, useCache):

Now I've run into a flaw in this model.  There are certain situations where a programName is not a unique identifier. 
It is possible for two repositories to each have a program with the same name.  Obviously, I could go through my code and replace 
all use of the string programName with a tuple of (programName, repository).  Or I could define a new class with two 
attributes: programName and repository, and pass such a simple object arround, or pass a dictionary.  However, I think this would 
be better solved by moving fully to an OOP model.  That is, I would have a SubuserProgram class which had methods such as 
install, describe, isInstalled...

There is one problem though.  Currently, I have these functions logically organized 
into source files, each between 40 and 170 LOC.  I fear that if I were to put all of 
these functions into one class, than I would have a single, very large source file.  
I don't like working with large source files for practicall reasons.  If I am to 
define the class SubuserProgram in the file SubuserProgram.py, I do not want all 
https://github.com/subuser-security/subuser/blob/master/logic/subuserCommands/subuserlib/run.py#L162
 of run.py to be moved into that file as well.

I thought about keeping each method in a separate file, much as I do now, 
something like:

###
#FileA.py
###
def a(self):
   blah

###
#FileB.py
###
def b(self):
   blah

###
#Class.py
###
import FileA, FileB
class C:
   a=FileA.a
   b=FileB.b

This works, but I find that it is hard to read.  When I come across FileA, and I see 
self it just seems very confusing.  I suffer a bout of who-am-iism.

I asked on IRC and it was sugested that I use multiple classes, however I see 
no logical way to separate a SubuserProgram object into multiple classes.

So I thought I would seek your advice.

Tim



You're writing Python, not Java, so put your code into one file and stop 
messing about.


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


Mark Lawrence

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


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


Re: Moving to an OOP model from an classically imperitive one

2014-04-23 Thread Ian Kelly
On Apr 23, 2014 5:01 PM, tim.thel...@gmail.com wrote:
 I asked on IRC and it was sugested that I use multiple classes, however I
see no logical way to separate a SubuserProgram object into multiple
classes.

You say you already have the methods logically separated into files. How
about adding one abstract class per file, and then letting SubuserProgram
inherit from each of those individual classes?

As another alternative that you haven't mentioned yet, you could create a
decorator to be applied to each method, which will inject it into the class
at the time it is defined. The explicitness of the decorator solves your
confusion problem of why does this function use self. It creates a couple
of new problems though: 1) reading the class won't tell you what methods it
contains; and 2) making sure the class is fully constructed before it is
used becomes tricky.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Moving to an OOP model from an classically imperitive one

2014-04-23 Thread Ethan Furman

On 04/23/2014 01:57 PM, tim.thel...@gmail.com wrote:


There is one problem though.  Currently, I have these functions logically
 organized into source files, each between 40 and 170 LOC.  I fear that if
I were to put all of these functions into one class, than I would have a
 single, very large source file.  I don't like working with large source
 files for practicall reasons.


I'm curious what these practical reasons are.  One my smallest source files has 
870 lines in it, my largest nearly 9000.

If the problem is your editor, you should seriously consider switching.

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


Re: Moving to an OOP model from an classically imperitive one

2014-04-23 Thread MRAB

On 2014-04-23 21:57, tim.thel...@gmail.com wrote:

Hello,

I am currently writting a program called subuser(subuser.org), which
is written as classically imperative code.  Subuser is, essentially,
a package manager.  It installs and updates programs from
repositories.

I have a set of source files
https://github.com/subuser-security/subuser/tree/master/logic/subuserCommands/subuserlib
which have functions in them.  Each function does something to a
program, it identifies the program by the programs name.  For
example, I have an installProgram function defined as such:

def installProgram(programName, useCache):

Now I've run into a flaw in this model.  There are certain situations
where a programName is not a unique identifier. It is possible for
two repositories to each have a program with the same name.
Obviously, I could go through my code and replace all use of the
string programName with a tuple of (programName, repository).  Or I
could define a new class with two attributes: programName and
repository, and pass such a simple object arround, or pass a
dictionary.  However, I think this would be better solved by moving
fully to an OOP model.  That is, I would have a SubuserProgram class
which had methods such as install, describe, isInstalled...


[snip]
Could you make the program name unique just by combining it with the
repository name in a single string?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Moving to an OOP model from an classically imperitive one

2014-04-23 Thread Chris Angelico
On Thu, Apr 24, 2014 at 7:42 AM, Ethan Furman et...@stoneleaf.us wrote:
 On 04/23/2014 01:57 PM, tim.thel...@gmail.com wrote:


 There is one problem though.  Currently, I have these functions logically
  organized into source files, each between 40 and 170 LOC.  I fear that if
 I were to put all of these functions into one class, than I would have a
  single, very large source file.  I don't like working with large source
  files for practicall reasons.


 I'm curious what these practical reasons are.  One my smallest source files
 has 870 lines in it, my largest nearly 9000.

 If the problem is your editor, you should seriously consider switching.

It's probably not the case here, but one good reason for splitting a
file into pieces is to allow separate people or systems to update
different parts. Lots of Linux programs support either
/etc/foobar.conf or /etc/foobar.conf.d/ where the former is one file
and the latter is a directory of separate files, generally deemed to
be concatenated to the main config file. (Example:
/etc/apt/sources.list and /etc/apt/sources.list.d/ - the main config
for your Debian repositories, the directory for additional ones for
VirtualBox or PostgreSQL.) It's easier to allow someone to completely
overwrite a file than to try to merge changes.

But that's not often the case with source code.

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


Re: how to write list in a file

2014-04-23 Thread Terry Reedy

On 4/23/2014 3:53 AM, Dhananjay wrote:

Hello everyone,

I am trying hard to write a list to a file as follows:


def average_ELECT(pwd):
 os.chdir(pwd)


I would 'print pwd' to make sure where files are being opened.


 files = filter(os.path.isfile, os.listdir('./'))
 folders = filter(os.path.isdir, os.listdir('./'))
 eelec = 0.0; evdw = 0.0; EELEC = []; elecutoff = [];
 g = Gnuplot.Gnuplot()
 for f1 in files:
#   if f1[21:23]=='12':
 if f1[27:29]==sys.argv[1]: # vdw cutoff remains constant; see
2nd column of output
 fl1 = open(f1,'r').readlines()
 #   print len(fl1)

 for i in range(1, len(fl1)):
 fl1[i]=fl1[i].split()
 eelec = eelec + float(fl1[i][1])
 evdw = evdw + float(fl1[i][2])
 #print fl1[i][1], fl1[i][2]
 avg_eelec = eelec/40
 avg_evdw = evdw/40
 #   print eelec, evdw
 #   print f1[21:23], f1[27:29], avg_eelec, avg_evdw
 print f1[21:23], f1[27:29], avg_eelec
 #   EELEC.append(avg_eelec); elecutoff.append(float(f1[21:23]))
 eelec=0.0; evde=0.0;
 a = f1[21:23]+' '+f1[27:29]+' '+str(avg_eelec)
 EELEC.append(a)
 print sorted(EELEC)
 with open('EElect_elec12-40_vdwxxx.dat','w') as wr:
 for i in EELEC:
 print i
 wr.write(%s\n % i)
 wr.close()


The script is printing print sorted(EELEC) as well as print
f1[21:23], f1[27:29], avg_eelec very well.
However, for some reason, I neither see any file (expected to see
EElect_elec12-40_vdwxxx.dat as per the script) generated nor any error
message.

Could anyone suggest me correction here.

Thanking you in advance.

-- DJ







--
Terry Jan Reedy

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


Re: why my cur.executescript can not run?

2014-04-23 Thread Terry Reedy

On 4/23/2014 7:23 AM, length power wrote:

please download the attachment


Cinfo.zip. Please do not post with attachments. This is a text list, and 
binary attachments can be a vehicle for malware. Instead, reduce your 
code to the minimum necessary to exhibit the problem and include it in 
the post, or if still too large, include a link to a storage location on 
the web where it can be viewed in a browser before downloading.


--
Terry Jan Reedy

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


Re: App segmentation fault (CentOS 6.5)

2014-04-23 Thread Terry Reedy

On 4/23/2014 3:46 PM, Mark H Harris wrote:

On 4/23/14 1:08 PM, Reginaldo wrote:


I have a GUI app that is written using wx. When I run it on CentOS
6.5, the following error messages are displayed and the app closes:


Only fails on CentOS ?



I use an idle thread in my application.


Is your CentOS launching idle with -n switch ?


I am quite sure that his 'idle thread' had nothing to do with Idle. 
Rather, it should be a thread that runs when the app is otherwise idle. 
However, if he were trying to run wx and Idle/tk in the same process, I 
would expect problems.


--
Terry Jan Reedy

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


Re: Moving to an OOP model from an classically imperitive one

2014-04-23 Thread Gregory Ewing

tim.thel...@gmail.com wrote:

I think this would be better solved
by moving fully to an OOP model.  That is, I would have a SubuserProgram
class which had methods such as install, describe, isInstalled...


This wouldn't necessarily be better. Don't be taken in by the
everything is better as a class kind of dogma that seems to
prevail in some circles.

If all you do is take a bunch of module-level functions and
put them into a single class, you haven't really changed anything.
It's still the same design, you've just arranged the source
differently.

There are a couple of good reasons for turning a function into
a method. One is if it embodies implementation details that you
want to keep separated from the rest of the program. But if
*all* of your code is inside the class, there isn't any rest
of the program to keep it separate from.

Another is if you want to be able to override it in subclasses.
If there were different kinds of SubuserProgram that needed to
be installed in different ways, for example, it would make
sense to structure this as a collection of classes with an
install() method. But even then, you don't have to put all
the installation code in the classes -- the methods could just
be stubs that call out to different module-level functions if
you wanted.

A reasonable compromise might be to keep the *data* assocated
with a SubuserProgram in a class, maybe together with a few
methods that are tightly coupled to it, but have the major
pieces of functionality such as install() implemented by
separate functions that operate *on* the class, rather than
being inside it.


Currently, I have these functions logically
organized into source files, each between 40 and 170 LOC.


That's quite small as these things typically go. You can afford
to make them somewhat larger; I tend to find that files start to
get unwieldy around 1000 lines or so.

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


Re: Moving to an OOP model from an classically imperitive one

2014-04-23 Thread Gregory Ewing

Ian Kelly wrote:

How 
about adding one abstract class per file, and then letting 
SubuserProgram inherit from each of those individual classes?


I'd recommend against that kind of thing, because it makes
the code hard to follow. With module-level functions, you can
tell where any given function is coming from by looking at the
imports (as long as you haven't used 'import *', which is a
bad idea for this very reason).

But if you're looking at a method call on a class that
inherits from half a dozen base classes, it's hard to tell
which class it's implemented in.

In other words, massively multiple inheritance is the OO
equivalent of 'import *'.

The same goes for any scheme for injecting methods into a
class after defining it, only more so, because the reader
won't be expecting weird things like that.

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


retrieve source code from code object as returned by compile()

2014-04-23 Thread Justin Ezequiel
Is there a way to get the original source?
I am trying to retrieve the main script from a py2exe'd old program.
The programmer neglected to commit to SVN before leaving.

Using Easy Python Decompiler I am able to get the source for the imported 
modules.
Using Resources Viewer from PlexData and some code I am able to retrieve the 
code object. I am however stumped as to how to retrieve the source from this 
code object. 

PythonWin 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] 
on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for 
further copyright information.
 s = 'import time\nprint time.time()\n'
 c = compile(s, 'foo.py', 'exec')
 exec(c)
1398299623.77
 c
code object module at 01E5C5C0, file foo.py, line 1
 for n in dir(c):
... if n.startswith('_'): continue
... print n
... a = getattr(c, n)
... print type(a)
... print `a`
... print
... 
co_argcount
type 'int'
0

co_cellvars
type 'tuple'
()

co_code
type 'str'
'd\x00\x00d\x01\x00k\x00\x00Z\x00\x00e\x00\x00i\x00\x00\x83\x00\x00GHd\x01\x00S'

co_consts
type 'tuple'
(-1, None)

co_filename
type 'str'
'foo.py'

co_firstlineno
type 'int'
1

co_flags
type 'int'
64

co_freevars
type 'tuple'
()

co_lnotab
type 'str'
'\x0c\x01'

co_name
type 'str'
'module'

co_names
type 'tuple'
('time',)

co_nlocals
type 'int'
0

co_stacksize
type 'int'
2

co_varnames
type 'tuple'
()
 len(s)
30
 len(c.co_code)
27
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: App segmentation fault (CentOS 6.5)

2014-04-23 Thread Wesley
在 2014年4月24日星期四UTC+8上午2时08分29秒,Reginaldo写道:
 Hi,
 
 
 
 I have a GUI app that is written using wx. When I run it on CentOS 6.5, the 
 following error messages are displayed and the app closes:
 
 
 
 (python:10096): Pango-WARNING **: shaping failure, expect ugly output. 
 shape-engine='BasicEngineFc', font='DejaVu Sans 10.9990234375', text=''
 
 
 
 (python:10096): Pango-CRITICAL **: pango_layout_get_line_count: assertion 
 `layout != NULL' failed
 
 
 
 (python:10096): Gdk-CRITICAL **: IA__gdk_draw_layout: assertion 
 `PANGO_IS_LAYOUT (layout)' failed
 
 Segmentation fault
 
 
 
 I checked if this was a font issue, but the font is installed on the system.
 
 
 
 I use an idle thread in my application.
 
 
 
 Could some let me know what the problem may be in this case? Thank you!
 
 
 
 Python Version used: 2.6.6
 
 wxPython Version used: 2.8.11

Maybe you can gdb python attach the running pid and check the backtrace.
Severay days ago, I use this guy to address thread hang and memory leak issues.
Just say here if that helps.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to write list in a file

2014-04-23 Thread Dave Angel
Terry Reedy tjre...@udel.edu Wrote in message:
 On 4/23/2014 3:53 AM, Dhananjay wrote:
 Hello everyone,

 I am trying hard to write a list to a file as follows:


 def average_ELECT(pwd):
  os.chdir(pwd)
 
 I would 'print pwd' to make sure where files are being opened.
 
  files = filter(os.path.isfile, os.listdir('./'))
  

I wouldn't.  I've seen too many flaky problems to trust os.chdir
 in real code.  I think the op should build each filename with
 os.path.append or similar. All paths used for actual file
 operations should either be absolute,  or strictly relative to
 the user's cwd when the script started.  And even the latter is
 suspect when you're anywhere near Windows. 

-- 
DaveA

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


Re:Moving to an OOP model from an classically imperitive one

2014-04-23 Thread Dave Angel
tim.thel...@gmail.com Wrote in message:


I don't really understand your problem or your examples,  but
 others apparently do. So I'll just make a few comments.
 


 
 There is one problem though.  Currently, I have these functions logically 
 organized into source files, each between 40 and 170 LOC.  I fear that if I 
 were to put all of these functions into one class, than I would have a 
 single, very large source file.  I don't like working with large source files 
 for practicall reasons.

Definitely limit your source file size. 10k lines is probably a
 good limit.

  If I am to define the class SubuserProgram in the file SubuserProgram.py, 

That's a big mistake right there.  Never let the module name match
 the class name.  If you really only happen to have a single class
 in the file, then just use lower case for the filename.
 


-- 
DaveA

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


Re: retrieve source code from code object as returned by compile()

2014-04-23 Thread Gregory Ewing

Justin Ezequiel wrote:

Using Easy Python Decompiler I am able to get the source for the imported
modules. Using Resources Viewer from PlexData and some code I am able to
retrieve the code object. I am however stumped as to how to retrieve the
source from this code object.


Easy Python Decompiler should be able to do that, but you
may need to delve into its innards a bit to find an entry
point where you can feed in a code object.

Alternatively you could create a .pyc file out of the code
object and then use Easy Python Decompiler on that. The
following snippet of code should do that:

import marshal
import py_compile
import time

with open('output.pyc', 'wb') as fc:
fc.write('\0\0\0\0')
py_compile.wr_long(fc, long(time.time()))
marshal.dump(codeobject, fc)
fc.flush()
fc.seek(0, 0)
fc.write(py_compile.MAGIC)

(Taken from: 
http://stackoverflow.com/questions/8627835/generate-pyc-from-python-ast)


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


[issue19475] Add microsecond flag to datetime isoformat()

2014-04-23 Thread Chris Rebert

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


--
nosy: +cvrebert

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



[issue6305] islice doesn't accept large stop values

2014-04-23 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
assignee:  - rhettinger

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



[issue21291] subprocess Popen objects are not thread safe w.r.t. wait() and returncode being set

2014-04-23 Thread Gregory P. Smith

Changes by Gregory P. Smith g...@krypto.org:


Added file: 
http://bugs.python.org/file35007/issue21291-patch-with-test-gps01.diff

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



[issue21331] Reversing an encoding with unicode-escape returns a different result

2014-04-23 Thread Sworddragon

Sworddragon added the comment:

The documentation says that unicode_internal is deprecated since Python 3.3 but 
not unicode_escape. Also, isn't unicode_escape different from utf-8? For 
example my original intention was to convert 2 byte string characters to their 
control characters. For example the file test.txt contains the 17 byte utf-8 
raw content ---a---\n---ä---. Now I want to convert '\\n' to '\n':

 file = open('test.txt', 'r')
 content = file.read()
 file.close()
 content = content.encode('utf-8').decode('unicode-escape')
 print(content)
---a---
---ä---


I'm getting now successfully 2 lines but I have noticed not getting the ä 
anymore. After that I have made a deeper look and opened this ticket.

If unicode_escape gets really deprecated maybe I could simply replace the 
characters 0-31 and 127 to achieve practically the same behavior.

--

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



[issue21207] urandom persistent fd - not re-openned after fd close

2014-04-23 Thread Charles-François Natali

Charles-François Natali added the comment:

 Updated patch using an anonymous struct.

LGTM!

--

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



[issue21291] subprocess Popen objects are not thread safe w.r.t. wait() and returncode being set

2014-04-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 5d745d97b7da by Gregory P. Smith in branch '3.4':
subprocess's Popen.wait() is now thread safe so that multiple threads
http://hg.python.org/cpython/rev/5d745d97b7da

New changeset df45d0336dad by Gregory P. Smith in branch 'default':
subprocess's Popen.wait() is now thread safe so that multiple threads
http://hg.python.org/cpython/rev/df45d0336dad

--
nosy: +python-dev

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



[issue17552] socket.sendfile()

2014-04-23 Thread Charles-François Natali

Charles-François Natali added the comment:

1) I really don't like the use_fallback argument: as a user, I don't
care if it's using sendfile/splice/whatever WIndows uses.
I view this as a channel transfer (like Java's
http://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#transferFrom(java.nio.channels.ReadableByteChannel,
long, long)), which moves bytes around from one FD to another.
If the user want precise control, he can just go ahead and call the
syscall itself.
Apart from complicating the prototype, what do this bring?

2) Just returning the number of bytes sent is fine

3) I really don't like the blocksize argument. Just use a really large
value internally to minimize the number of syscalls, that's all that
matters. I've *never* seen code which explicitly uses a blocksize: in
99% of cases, it just uses stat to find out the file size, and call
sendfile with it. Trying to be consistent with ftplib is IMO a bad
idea, since the API is just completely broken (I mean, just
sending/retrieving a file is complex). A useful parameter instead
would be to support sending only part of the file, so adding a count
argument.

You can have a look at
http://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#transferFrom(java.nio.channels.ReadableByteChannel,
long, long) for an example many people bash Java, but they've designed
some great APIs :-)

--

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



[issue21291] subprocess Popen objects are not thread safe w.r.t. wait() and returncode being set

2014-04-23 Thread Gregory P. Smith

Gregory P. Smith added the comment:

This fix is also present in subprocess32 3.2.6 on PyPI for use on Python 2.

--
resolution:  - fixed
stage:  - commit review
status: open - closed
type:  - behavior

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



[issue21334] nntplib throws exceptions making sinntp unusable

2014-04-23 Thread randomcoder1

New submission from randomcoder1:

Sinntp is a nntp client. It uses nntplib from Python as a nntp library to fetch 
messages from NNTP servers.

I've tested this on two environments with the following package versions:

1) Ubuntu 12.04.4 , python-support 1.0.14ubuntu2, Python 2.7.3-0ubuntu2.2 , 
sinntp 1.4-1 , libpython2.7 2.7.3-0ubuntu3.4
2) Debian jessie , python-support 1.0.15, Python 2.7.5-5, sinntp 1.5-1 , 
libpython2.7 version 2.7.6-8

sinntp crashed on 2) and threw NNTP* exceptions which are described in more 
detail in the bugreport-data.tgz file that comes with this  bugreport. I was 
also able to isolate one NNTP article that caused it to crash, that's also 
included.

I've included above the libpython2.7 version because
user@machine:/tmp$ sudo apt-file -x search 'nntplib.py$'
[..]
libpython2.7-stdlib: /usr/lib/python2.7/nntplib.py
[..]

Upon trying to replace the sinntp 1.5-1 on 2) with the one in 1) , the problem 
was still present, so I believe sinntp can be excluded.

I think the bug is caused by the newer version of libpython2.7 in 2).

--
components: Library (Lib)
files: bureport-data.tgz
messages: 217060
nosy: randomcoder1
priority: normal
severity: normal
status: open
title: nntplib throws exceptions making sinntp unusable
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file35008/bureport-data.tgz

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



[issue21334] nntplib throws exceptions making sinntp unusable

2014-04-23 Thread randomcoder1

randomcoder1 added the comment:

I'm cross-referencing this here too. 
https://code.google.com/p/sinntp/issues/detail?id=9

--

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



[issue21334] nntplib throws exceptions making sinntp unusable

2014-04-23 Thread randomcoder1

randomcoder1 added the comment:

I forgot to mention that in the environment 1) described above, everything 
worked fine.

--

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



[issue21334] nntplib throws exceptions making sinntp unusable

2014-04-23 Thread Jakub Wilk

Jakub Wilk added the comment:

For the reference, the exception is:

Traceback (most recent call last):
  File /home/user/sources/sinntp/sinntp, line 357, in module
connection.quit()
  File /usr/lib/python2.7/nntplib.py, line 608, in quit
resp = self.shortcmd('QUIT')
  File /usr/lib/python2.7/nntplib.py, line 268, in shortcmd
return self.getresp()
  File /usr/lib/python2.7/nntplib.py, line 223, in getresp
resp = self.getline()
  File /usr/lib/python2.7/nntplib.py, line 212, in getline
raise NNTPDataError('line too long')
nntplib.NNTPDataError: line too long

The change in the behavior is intentional. The maximum line length has been 
limited to 2048 to prevent denial of service. This is issue #16040 aka 
CVE-2013-1752.

This is what relevant standards say:

RFC 3977 §3.1.1: “This document does not place any limit on the length of a 
line in a multi-line block. However, the standards that define the format of 
articles may do so.”
RFC 5322 §2.1.1: “Each line of characters MUST be no more than 998 characters, 
and SHOULD be no more than 78 characters, excluding the CRLF.”

The message that sinntp tripped over had lines longer than RFC 5322 permits, so 
it shouldn't have been accepted by the server in the first place.

I don't think there's much to be fixed on the Python side.

What could be improved is error handling in sinntp; but let's discuss this in 
the sinntp bug tracker. :)

--
nosy: +jwilk

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



[issue20136] Logging: StreamHandler does not use OS line separator.

2014-04-23 Thread Thorsten Weimann

Thorsten Weimann added the comment:

Please re-open. The IO system only takes care of line separators, if no 
encoding is given.

--
nosy: +Thorsten.W

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



[issue21251] Standard library trace module crashes with exception

2014-04-23 Thread Martin Kolman

Martin Kolman added the comment:

@ 1.: Reproducer attached to the comment - just build the C code and run 
trace_test.py It is maybe not as minimal as it could be but I'm afraid the 
context of what the module is doing would be lost if it was cut down too 
aggressively.

@ 2.: I'm afraid this is not applicable in this case - pyblock just flat out 
does not support Python 3 and I haven't been able to find out even any 
third-party Python 3 port of it. I even tried to force run the current code 
with Python 3, just in case, but it just tracebacks during import due to Python 
3 incompatible code, even before even importing the C extensions.

--
Added file: http://bugs.python.org/file35009/pyblock.tar.xz

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



[issue21332] subprocess bufsize=1 docs are misleading

2014-04-23 Thread Jakub Wilk

Changes by Jakub Wilk jw...@jwilk.net:


--
nosy: +jwilk

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



[issue9338] argparse optionals with nargs='?', '*' or '+' can't be followed by positionals

2014-04-23 Thread Jakub Wilk

Changes by Jakub Wilk jw...@jwilk.net:


--
nosy: +jwilk

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



[issue21109] tarfile: Traversal attack vulnerability

2014-04-23 Thread Jakub Wilk

Changes by Jakub Wilk jw...@jwilk.net:


--
nosy: +jwilk

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



[issue20995] Use Better Default Ciphers for the SSL Module

2014-04-23 Thread Mark Kubacki

Mark Kubacki added the comment:

The cipher strings rely too much on AES for my taste. Imagine that 
ChaCha20Poly1305 or any other strong cipher suite is introduced to OpenSSL in 
the future.

Enabling using general, and demoting using narrow terms, seems IMHO a better 
approach. For example:

ECDH+HIGH:DH+HIGH:!aNULL:!MD5:!RC4:-3DES:HIGH

--
nosy: +markk

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



[issue20995] Use Better Default Ciphers for the SSL Module

2014-04-23 Thread Donald Stufft

Donald Stufft added the comment:

The cipher string includes HIGH, so if ChaCha20Poly1305 or another cipher suite 
is added to OpenSSL it'll get included in the cipher string by default.

So the major difference of what you suggest would be no longer prioritizing 
ciphers. However I would argue that would be bad. The priority exists so that 
we get the best possible cipher is as many situations as we possibly can. It 
doesn't mean that we'll get the best possible cipher in *every* single 
situation, but generally we will.

To this ends it prioritizes:
* PFS with a secure cipher over everything else (Your string would do this 
as well)
* After that prefer ECDHE over DHE
* After that, prefer AES-GCM
* After that, prefer AES-CBC
* After that, any other HIGH cipher
* After that, 3DES
* After that, any use of RC4 including those with PFS

So if OpenSSL added ChaCha20Poly1305 it would fit into the priority after 
AES-GCM and AES-CBC. 

For any device that has hardware support for AES (AES-NI) AES-GCM is hands down 
a better choice of cipher. It is secure, has no issues in the spec itself, and 
it is *fast*, like 900MB/s for AES-128-GCM on a Sandy Bridge Xeon w/ AES-NI 
(ChaCha20Poly1305 got 500MB/s on the same hardware, however it is a 256bit 
cipher will AES-128-GCM is a 128 bit cipher). Using ChaCha20 on those devices 
would be a worse choice than AES-GCM.

However on lower powered devices, such  as smart phones, especially those 
without hardware support for AES, ChaCha20 really shines. A Galaxy Nexus can do 
AES-256-GCM at 20MB/s whereas it can do ChaCha20Poly1305 at 92MB/s (same phone).

So in an ideal world, assuming ChaCha20 was implemented in OpenSSL, we'd adjust 
the default cipher string based on the hardware they are running on. However 
since we don't have the ability to do that then preferring AES (which we know 
on some systems will be much faster) over an unknown future cipher (which we 
have no knowledge of if it will be faster or not) is a much more reasonable 
choice. If at some point in the future OpenSSL gains ChaCha20Poly1305 support 
then these strings should probably change to put ChaCha20Poly1305 in between 
AES-GCM and AES-CBC because on any given the system the likelyhood that you 
want AES-GCM is still higher than ChaCha20, but the likelyhood you want 
ChaCha20 over AES-CBC is greater.

It's also important to note that the server in any TLS communication is the end 
that picks exactly which cipher we select. Ideally all servers will be 
configured to have the strongest cipher first, and to prefer their own cipher 
order. In that case for the *client* side of a TLS connection the order of the 
ciphers doesn't matter and thus your string vs the implemented string has no 
difference in behavior. However if the server doesn't enforce their own 
preference for ciphers, then the difference will be that an undefined cipher 
will be selected (could be AESGCM, AESCBC, ChaCha20, or Camellia). On the 
server side of this, if you're using Python to terminate your TLS on the server 
side, the likelyhood that a server is running on a low powered device where the 
benefits of ChaCha20Poly1305 are the highest are pretty low and preferring 
AES-GCM is an even safer idea.

--

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



[issue21333] Document recommended exception for objects that shouldn't be pickled

2014-04-23 Thread Berker Peksag

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


--
nosy: +alexandre.vassalotti, pitrou

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



[issue20995] Use Better Default Ciphers for the SSL Module

2014-04-23 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 For any device that has hardware support for AES (AES-NI) AES-GCM is
 hands down a better choice of cipher. It is secure, has no issues in
 the spec itself, and it is *fast*, like 900MB/s for AES-128-GCM on a
 Sandy Bridge Xeon w/ AES-NI (ChaCha20Poly1305 got 500MB/s on the same
 hardware, however it is a 256bit cipher will AES-128-GCM is a 128 bit
 cipher). Using ChaCha20 on those devices would be a worse choice than
 AES-GCM.

I think performance isn't really relevant, except perhaps on very busy
servers. A smartphone acting as a *client* certainly shouldn't need to
download 20 MB/s of encrypted data.

--

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



[issue20995] Use Better Default Ciphers for the SSL Module

2014-04-23 Thread Donald Stufft

Donald Stufft added the comment:

 I think performance isn't really relevant, except perhaps on very busy
 servers. A smartphone acting as a *client* certainly shouldn't need to
 download 20 MB/s of encrypted data.

Well, if you factor out performance then ChaCha20Poly1305 and AES-GCM are more
or less equivalent in preference with AES-CBC still less than either of them
because of problematic construction choices in the TLS spec. If you factor
out performance completely there is maybe a slight preference for
ChaCha20Poly1305 over AES-GCM simply because AES-GCM is hard to implement in
a timing safe way in software. However that discussion is mostly academic as
right now ChaCha20Poly1305 is not available in OpenSSL.

In general I agree that the performance of all of these are good enough that
the average user of this API won't be able to tell the difference, however
there is no cost to selecting the generally more performant of the two so I
think it still makes sense to consider it.

Hopefully what I was trying to achieve was provide some more context for markk 
so he'd hopefully be able to better understand why the string cipher calls out 
AES specifically before falling back to HIGH.

--

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



[issue20995] Use Better Default Ciphers for the SSL Module

2014-04-23 Thread Mark Kubacki

Mark Kubacki added the comment:

Thanks for the detailed insight, Donald! And I certainly love the progress 
these changes here bring. :-)

Perhaps limiting the scope to ChaCha20Poly1305 (»CCP«) has been a wrong 
approach of mine to explain my concerns:

We should not refer to any particular cipher in those lists, and by that avoid 
to revisit the defaults at any point in the future.

0. Properties of any cipher to come are known to the makers of OpenSSL first.
1. Python shouldn't duplicate the work of ordering ciphers, which is already 
done by OpenSSL.
2. … especially because it is unknown which ciphers a user's OpenSSL does 
actually implement (Is EC present? CCP? HC-256 or HC-128? WIERZA? Rabbit? 
NTRU…) or will implement in the future.
3. Whether a cipher is regarded as more secure than another depends on its 
implementation, too. The implementors are better judges of that, and hence 
ordering should done by them and could vary between versions [e.g., of OpenSSL].
4. Given our experiences with Python 2.7 I'd like to argue that there is 
reluctance to upgrading existing installations and its cipher suite strings. ;-)

But we know from experience with already established ciphers if and when to 
demote them.

That said I don't insist on any changes.

--

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



[issue21334] nntplib throws exceptions making sinntp unusable

2014-04-23 Thread randomcoder1

randomcoder1 added the comment:

@Jakub Sure, I've submitted a patch in the sinntp googlecode issue tracker. 
When you have some time, please have a look at it.

--

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



[issue20995] Use Better Default Ciphers for the SSL Module

2014-04-23 Thread Alex Gaynor

Alex Gaynor added the comment:

It would be great if we could rely on OpenSSL's ordering. It would be seriously 
fantastic. OpenSSL is best positioned to be able to do the right things, it's 
updated at the right times. It should be where we do this.

Unfortunately the OpenSSL maintainers have utterly abdicated any responsibility 
for helping secure users, and has gone with poor defaults, obligating us to 
fill the hole.

--

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



[issue21334] nntplib throws exceptions making sinntp unusable

2014-04-23 Thread randomcoder1

Changes by randomcoder1 randomcod...@gmail.com:


--
resolution:  - third party
status: open - closed

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



[issue21335] Update importlib.__init__ to reset _frozen_imnportlib's loader to SourceFileLoader

2014-04-23 Thread Brett Cannon

New submission from Brett Cannon:

When importlib.__init__ tries to mask the fact that _frozen_importlib is frozen 
it should also reset __loader__ to be an instance of SourceFileLoader. This 
will allow tracebacks to include source lines thanks to 
SourceFileLoader.get_source().

--
assignee: brett.cannon
components: Library (Lib)
messages: 217073
nosy: brett.cannon
priority: low
severity: normal
stage: needs patch
status: open
title: Update importlib.__init__ to reset _frozen_imnportlib's loader to 
SourceFileLoader
type: behavior
versions: Python 3.5

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



[issue21335] Update importlib.__init__ to reset _frozen_importlib's loader to SourceFileLoader

2014-04-23 Thread Zachary Ware

Changes by Zachary Ware zachary.w...@gmail.com:


--
title: Update importlib.__init__ to reset _frozen_imnportlib's loader to 
SourceFileLoader - Update importlib.__init__ to reset _frozen_importlib's 
loader to SourceFileLoader

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



[issue20136] Logging: StreamHandler does not use OS line separator.

2014-04-23 Thread Vinay Sajip

Vinay Sajip added the comment:

 Please re-open.

This is configurable in Python 3.2 and later using the terminator attribute, 
but this can't be added to 2.7 as it would constitute a new feature.

--

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



[issue17160] test_urllib2net fails

2014-04-23 Thread ddve...@ucar.edu

ddve...@ucar.edu added the comment:

Well, ok, thanks :-)

But I'm still wondering if it's not possible to use mocks for this test. 
or at least example.com (as in issue #20939) which is supposed to be 
more stable than python.org

--

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



[issue17386] Bring Doc/make.bat as close to Doc/Makefile as possible

2014-04-23 Thread Zachary Ware

Zachary Ware added the comment:

Having looked at this again, the current patch is just far bigger than it needs 
to be and tries to do too much, not to mention being rather out of date now.

So, here's a much less ambitious, much simpler patch with many fewer ways it 
can go wrong (but also not quite as close a match to using Makefile).  Instead 
of only allowing specific targets, the script now only specifies 
non-Sphinx-builder targets (like clean, check, help, htmlview, and serve) and 
assumes that any first argument it doesn't recognize is supposed to be a Sphinx 
builder.  htmlhelp is still special-cased in the build target.  Not listing 
all the Sphinx builder targets explicitly means that builders like dirhtml, 
pickle, or json, or any builders added in future Sphinx versions will just 
work without our having to do anything for them.

--
assignee: docs@python - zach.ware
stage: commit review - patch review
versions: +Python 3.5
Added file: http://bugs.python.org/file35010/issue17386.diff

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



[issue21336] ntpath.splitdrive fails on None argument

2014-04-23 Thread Ben Ma

New submission from Ben Ma:

 import ntpath
 ntpath.splitdrive(None)
Traceback (most recent call last):
  File stdin, line 1, in module
  File E:\python3\lib\ntpath.py, line 159, in splitdrive
if p and len(p)  1:
TypeError: object of type 'NoneType' has no len()

Solution: (that I've found)

Lib/ntpath.py
#in function splitdrive
...
empty = _get_empty(p)
+++ if p and len(p)  1:
--- if len(p)  1:
sep = _get_sep(p)
...
return p[:2], p[2:]
+++ else:
+++ p = ''
return empty, p
...

--
components: Library (Lib)
messages: 217077
nosy: runapp
priority: normal
severity: normal
status: open
title: ntpath.splitdrive fails on None argument
type: crash
versions: Python 3.4

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



[issue21336] ntpath.splitdrive fails on None argument

2014-04-23 Thread Eric V. Smith

Eric V. Smith added the comment:

Why are you passing None, and what would you expect the result to be?

The function is documented as taking a string.

--
nosy: +eric.smith
type: crash - behavior

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



[issue18967] Find a less conflict prone approach to Misc/NEWS

2014-04-23 Thread Ezio Melotti

Ezio Melotti added the comment:

One of the Mercurial devs convinced me to pursue what I had initially proposed 
in msg197645 and write a merge script (attached).

The script is still a proof of concept, it makes a few assumptions and doesn't 
handle all the cases, but I did a few tests and it seems to work for at least 
some cases.  If people like it it can be improved.

In short it parses Misc/NEWS, see what news entries have been added in the 
changeset(s) that it's being merged, and adds them at the top of the 
corresponding section.

To enable it download the file, set it as executable (chmod +x newsmerge.py), 
and add the following to .hg/hgrc:

[merge-tools]
newsmerge.executable = /path/to/newsmerge.py
newsmerge.priority = 100
newsmerge.premerge = True
newsmerge.args = $base $local $other -o $output

[merge-patterns]
Misc/NEWS = newsmerge

This will kick in only if the regular merge results in a conflict (so if you 
don't see any of the debug output from newsmerge it means that mercurial 
managed to merge Misc/NEWS on its own without conflicts).

--
Added file: http://bugs.python.org/file35011/newsmerge.py

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



[issue17552] socket.sendfile()

2014-04-23 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

 1) I really don't like the use_fallback argument
 Apart from complicating the prototype, what do this bring?

My initial thought was that the user might want to know *why* a file cannot be 
sent by using the fastest method and hence wants to see the original exception. 
Anyway, I have not strong opinions about this so I guess we can also drop it.


 A useful parameter instead would be to support sending only part of the file, 
 so adding a count argument.

Have you read my patch? This is already provided by the offset parameter.


 I really don't like the blocksize argument.
 I've *never* seen code which explicitly uses a blocksize

Both sendfile() and TransmitFile provide a blocksize parameter for very good 
reasons therefore it seems natural that an API built on top of them exposes the 
same parameter as well.
Some examples in the stdlib which comes to mind using a blocksize are 
asynchat.async_chat.ac_out_buffer_size and ftplib.FTP.storbinary and I'm sure 
if you grep for blocksize you'll find others.
Providing a blocksize is also necessary to tell how many bytes to read from 
file in case send() is used, 'cause it's *crucial* that you don't read the 
whole file into memory.
I will also give a real world example: if your app wants to limit the transfer 
speed you will want to explicitly transmit smaller chunks of data and then 
sleep, and the only way to do that is by manipulating the blocksize. So yes: 
a blocksize parameter *is* necessary, so please stop beating that horse. 
As for using a bigger value: I made some benchmarks by using different sizes 
and I didn't notice any noticeable difference.

--

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



[issue17552] socket.sendfile()

2014-04-23 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Note: my example about limiting the transfer speed does not really apply 'cause 
as this stands right now it cannot be used with non-blocking sockets. Other 
arguments do though and I hope it's clear that we need blocksize.

--

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



[issue17552] socket.sendfile()

2014-04-23 Thread akira

akira added the comment:

 I really don't like the use_fallback argument ..

I initially also thought so. But I've suggested the parameter to replace 
`(was_os_sendfile_used, os_sendfile_error)` returned value as a *trade off* 
between a slight complexity in the interface vs. allowing to detect performance 
bugs easily e.g., when someone passed a file-like object incompatible with 
os.sendfile by accident (it is not enough to have a valid fileno. What 
mmap-like means?).

 .. as a user, I don't care if it's using sendfile/splice/whatever WIndows 
 uses.
 .. what do this bring?

The reason sendfile exists is performance. Otherwise socket.makefile and 
shutil.copyfileobj could be used instead.

use_fallback parameter provides a way to assert that an ineffective fallback is 
not used by accident. It may be ignored by most users.

An alternative is a new separate public method that doesn't use the fallback.

--

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



[issue20849] add exist_ok to shutil.copytree

2014-04-23 Thread Justin Myers

Changes by Justin Myers jus...@justinmyers.net:


--
nosy: +justin.myers

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



[issue21332] subprocess bufsize=1 docs are misleading

2014-04-23 Thread akira

Changes by akira 4kir4...@gmail.com:


--
nosy: +akira

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



[issue9764] Tools/buildbot/external.bat should download and built tix

2014-04-23 Thread Zachary Ware

Zachary Ware added the comment:

This is fixed in 3.5, PCbuild/tix.vcxproj builds Tix in Debug and Release modes.

--
nosy: +zach.ware
resolution:  - fixed
stage: needs patch - resolved
status: open - closed
versions: +Python 3.5 -Python 3.2

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



[issue9765] tcl-8 vs tcl8

2014-04-23 Thread Zachary Ware

Zachary Ware added the comment:

PCbuild/tix.vcxproj explicitly sets TCL_DIR and TK_DIR in the command line used 
to build Tix, using the paths used by the rest of the solution and the 
Tools/buildbot scripts; would the attached patch now be acceptable (for 3.5 
only)?

--
nosy: +zach.ware
stage: needs patch - patch review
versions: +Python 3.5 -Python 3.2

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



[issue9765] tcl-8 vs tcl8

2014-04-23 Thread Martin v . Löwis

Martin v. Löwis added the comment:

For 3.5, it's fine.

--
stage: patch review - commit review

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



[issue21278] Running the test suite with -v makes the test_ctypes and the test_zipimport erroneously reported as failed

2014-04-23 Thread ddve...@ucar.edu

ddve...@ucar.edu added the comment:

Ok, let me dig into it and see if I can figure it out

On 04/20/2014 05:10 PM, Ezio Melotti wrote:

 Ezio Melotti added the comment:

 Do you want to propose a patch?

 --
 components: +Tests
 nosy: +ezio.melotti
 type:  - behavior

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


--

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



[issue9765] tcl-8 vs tcl8

2014-04-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4ff37fbcd4e8 by Zachary Ware in branch 'default':
Issue #9765: Adjust where Tools/msi/msi.py looks for Tcl/Tk license terms.
http://hg.python.org/cpython/rev/4ff37fbcd4e8

--
nosy: +python-dev

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



[issue9765] tcl-8 vs tcl8

2014-04-23 Thread Zachary Ware

Zachary Ware added the comment:

Done, thanks!

--
assignee:  - zach.ware
resolution:  - fixed
stage: commit review - resolved
status: open - closed

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



[issue21337] Add tests for Tix

2014-04-23 Thread Zachary Ware

New submission from Zachary Ware:

We should have some tests for Tix, which currently has none.  The Windows 
buildbots will be able to run the tests, but Tix is not guaranteed to be 
available elsewhere.

--
components: Tests, Tkinter
keywords: easy
messages: 217089
nosy: zach.ware
priority: low
severity: normal
stage: needs patch
status: open
title: Add tests for Tix
type: enhancement
versions: Python 3.5

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



[issue17552] socket.sendfile()

2014-04-23 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Considering the current indecision about certain design aspects I started a 
discussion on python-ideas: 
https://mail.python.org/pipermail/python-ideas/2014-April/027752.html

--

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



[issue17552] socket.sendfile()

2014-04-23 Thread Yury Selivanov

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


--
nosy: +yselivanov

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



[issue19385] dbm.dumb should be consistent when the database is closed

2014-04-23 Thread Jim Jewett

Jim Jewett added the comment:

_check_closed sounds like you expect it to be closed, and might even assert 
that it is closed, except that you want the check run even in release mode 
and/or it might fail.  Since being closed is actually the unexpectedly broken 
state, I would prefer that you rename it to something else, like _verify_open.

--
nosy: +Jim.Jewett

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



[issue17305] IDNA2008 encoding missing

2014-04-23 Thread Derek Wilson

Derek Wilson added the comment:

It is worth noting that the do exist some domains that have been registered in 
the past that work with IDNA2003 but not IDNA2008.

There definitely needs to be IDNA2008 support, for my use case I need to 
attempt IDNA2008 and then fall back to IDNA2003.

When support for IDNA2008 is added, please retain support for IDNA2003.

I would say that ideally there would be a codec that could handle both - 
attempt to use IDNA2008 and on error fallback to idna2003. I realize this isn't 
official but it would certainly be useful.

--
nosy: +underrun

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



[issue19385] dbm.dumb should be consistent when the database is closed

2014-04-23 Thread Claudiu.Popa

Claudiu.Popa added the comment:

gzip uses the same name, _check_closed, but your suggestion sounds good. I'll 
update the patch.

--

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



[issue21331] Reversing an encoding with unicode-escape returns a different result

2014-04-23 Thread R. David Murray

R. David Murray added the comment:

Using unicode_escape to decode non-ascii is simply wrong.  It can't work.

--

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



[issue21331] Reversing an encoding with unicode-escape returns a different result

2014-04-23 Thread R. David Murray

R. David Murray added the comment:

To understand why, understand that a byte string has no encoding inherent.  So 
when you call b'utf8string'.decode('unicode_escape'), python has no way to know 
how to interpret the non-ascii characters in that bytestring.  If you want the 
unicode_escape representation of something, you want to do 
'string'.encode('unicode_escape').  If you then want that as a python string, 
you can do:

'mystring'.encode('unicode_escape').decode('ascii')

In theory there ought to be a way to use the codecs module to go directly from 
unicode string to unicode-escaped string, but I don't know how to do it, since 
the proposal for the 'transform' method was rejected :)

Just to bend your brain a bit further, note that this does work:

 codecs.decode(codecs.encode('ä', 'unicode-escape').decode('ascii'), 
 'unicode-escape')
'ä'

--

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



[issue21331] Reversing an encoding with unicode-escape returns a different result

2014-04-23 Thread R. David Murray

R. David Murray added the comment:

Also, I'm not sure what this should do, but what it does do doesn't look right:

 codecs.decode('ä', 'unicode-escape')
'ä'

--

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



[issue19385] dbm.dumb should be consistent when the database is closed

2014-04-23 Thread Jim Jewett

Jim Jewett added the comment:

I think the requested timing regression was for the non-broken case.  When the 
database has NOT been closed, and keys() still works, will it be way slower 
than before?

Note that I am not asking you to do that test (though the eventual committer 
might); the implementation of whichdb leaves me believing that almost anyone 
who is likely to care will have already followed the docunmentation's 
recommendation to install another *dbm ahead of dumb.

--

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



[issue2159] dbmmodule inquiry function is performance prohibitive

2014-04-23 Thread Jesús Cea Avión

Jesús Cea Avión added the comment:

First, Python 2.4 has been out of support for a really long time. Deleting.

Eric, let me clarify the situation, because this report is old and I forgot the 
details.

I think current situation is this, when doing something like if db : 
DO_SOMETHING:

a) If the database is closed, raise an exception.

b) If database is empty, returns False.

c) If database has any entry, returns True. Takes time proportional to database 
length, because it is going to go thru it.

The patch you are proposing:

a) If the database is closed, raise an exception.

b) If database is empty, returns 0.

c) If database has any entry, returns 1. Fast and simply checking if the 
database has at least a single record.

Why 0/1 instead of True/False?. This is going to be a 3.5 patch, True/False are 
really there, they are not aliases.

PS: When done, I will probably port this patch to current pybsddb work, 
although I am not sure that Berkeley DB has firstkey for all database types 
it support. Would you allow this porting, Eric? 
https://pypi.python.org/pypi/bsddb3/6.0.1

--
versions:  -Python 2.4

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



[issue17552] socket.sendfile()

2014-04-23 Thread Guido van Rossum

Guido van Rossum added the comment:

Can you also think about how this would be wrapped in asyncio?

--
nosy: +gvanrossum

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



[issue16104] Compileall script: add option to use multiple cores

2014-04-23 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
title: Use multiprocessing in compileall script - Compileall script: add 
option to use multiple cores

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



[issue21338] Silent mode for compileall

2014-04-23 Thread Thomas Kluyver

New submission from Thomas Kluyver:

The compileall module's command line interface has a -q (quiet) flag which 
suppresses most of the output, but it still prints error messages. I'd like an 
entirely silent mode with no output.

My use case is byte-compiling Python files as part of a graphical installer. I 
do this by running:

py -${PY_QUALIFIER} -m compileall -q $INSTDIR\pkgs

I'd like to be able to use pyw so a terminal doesn't pop up, but if I do that, 
it exits early. I think this is due to the issue with stdout/stderr buffers 
filling up on pythonw.

--
components: Library (Lib)
messages: 217100
nosy: takluyver
priority: normal
severity: normal
status: open
title: Silent mode for compileall

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



[issue21324] dbhash leaks random memory fragments to a database

2014-04-23 Thread Jesús Cea Avión

Jesús Cea Avión added the comment:

I could be wrong, but I think this is an Oracle Berkeley DB bug. I contacted 
Oracle yesterday about this. Stand by.

--

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



[issue21324] dbhash/bsddb leaks random memory fragments to a database

2014-04-23 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
title: dbhash leaks random memory fragments to a database - dbhash/bsddb leaks 
random memory fragments to a database

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



[issue21338] Silent mode for compileall

2014-04-23 Thread Ezio Melotti

Ezio Melotti added the comment:

This seems a reasonable request.  Do you want to propose a patch?

--
keywords: +easy
nosy: +ezio.melotti
stage:  - needs patch
type:  - enhancement
versions: +Python 3.5

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



  1   2   >