GeoBases: data services and visualization

2013-01-30 Thread alexprengere
This new project provides tools to play with geographical data. It also works 
with non-geographical data, except for map visualizations :).

There are embedded data sources in the project, but you can easily play with 
your own data in addition to the available ones. Files containing data about 
airports, train stations, countries, ... are loaded, then you can:

 - performs various types of queries ( find this key, or find keys with this 
property)
 - fuzzy searches based on string distance ( find things roughly named like 
this)
 - geographical searches ( find things next to this place)
 - get results on a map, or export it as csv data, or as a Python object

This is entirely written in Python. The core part is a Python package, but 
there is a command line tool as well!

This project is licensed under a Creative Commons Attribution-ShareAlike 3.0 
Unported License.
The current version is 4.18.

For tutorials and documentation, check out 
http://opentraveldata.github.com/geobases/.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Please provide a better explanation of tuples and dictionaries

2013-01-30 Thread rusi
On Jan 30, 7:55 am, Daniel W. Rouse Jr.
dwrous...@nethere.comNOSPAM wrote:
 Or, can an anyone provide an example of
 more than a three-line example of a tuple or dictionary?

Have you seen this byt the creator of python -- GvR?
http://www.python.org/doc/essays/graphs.html

 I have recently started learning Python (2.7.3) but need a better
 explanation of how to use tuples and dictionaries.

This is an important question: To start off you need to digest whats
the diff between value oriented and object oriented. Since this is
more to do with paradigm than with a specific language you may read
for example:
http://www.haskell.org/haskellwiki/The_Monad.Reader/Issue3/Functional_Programming_vs_Object_Oriented_Programming

In the python data structure world:
value | object
tuple | list
XX| dictionary
frozen-set | set



 I am currently using Learning Python by Mark Lutz and David Ascher,
 published by O'Reilly (ISBN 1-56592-464-9)--but I find the explanations
 insufficient and the number of examples to be sparse. I do understand some
 ANSI C programming in addition to Python (and the book often wanders off
 into a comparison of C and Python in its numerous footnotes), but I need a
 better real-world example of how tuples and dictionaries are being used in
 actual Python code.

 Any recommendations of a better book that doesn't try to write such compact
 and clever code for a learning book?

 The purpose of my learning Python in this case is not for enterprise level
 or web-based application level testing at this point. I initially intend to
 use it for Software QA Test Automation purposes.

 Thanks in advance for any replies.

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


Re: Ways to apply while learning....

2013-01-30 Thread Ritchie Flick
It's perfectly normal that you need to look things up, even the most
seasoned programmer has to look up something at some point.

Finding small projects is often difficult, because many projects grow to
such an extent, that they're simply to difficult to grasp for a beginner
and even for an experienced programmer if the code documentation sucks.

I would suggets reading some python code on http://ww.github.com
Learning through reading other peoples code also helps in learning a
language.


On Wed, Jan 30, 2013 at 12:09 AM, David Hutto dwightdhu...@gmail.comwrote:

 On Tue, Jan 29, 2013 at 5:57 PM,  agamal...@gmail.com wrote:
  Hello,
  I am learning programming as a spare time hobby and learning python
 through codecademy.
 
  Today I have downloaded and installed aptana, and found out that
 although I have been progressing for some time now but I do not remember
 how to code and I have to look everything up.

 When using different languages to mean client needs,this will be a
 necessity.

 
  I want to know what is the best way to learn python and some small
 projects that I can make using console

 you might need to utilize subrocess, but many ahve their preference.
 (I know there is a long way to develop something for the desktop)
 Do you mean command line app, or with a GUI?
 
  Thank you.
  ps: I am coming from vb6 paradigm.
  --
  http://mail.python.org/mailman/listinfo/python-list



 --
 Best Regards,
 David Hutto
 CEO: http://www.hitwebdevelopment.com
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Ritchie Flick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fonts Tinker

2013-01-30 Thread Angel
THis one workd fine:

.option_add('*Font', Heveltica 14) 

Thanks!

Á.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading data from 2 different files and writing to a single file

2013-01-30 Thread inshu chauhan
On Mon, Jan 28, 2013 at 6:05 PM, Dennis Lee Bieber wlfr...@ix.netcom.comwrote:

 On Mon, 28 Jan 2013 14:31:31 +0100, inshu chauhan
 insidesh...@gmail.com declaimed the following in
 gmane.comp.python.general:

  In the code below I am trying to read 2 files f1 and f2 , extract some
 data
  from them and then trying to write them into a single file that is 'nf'.
 
  import cv
  f1 = open(rZ:\modules\Feature_Vectors_300.arff)
  f2 = open(rZ:\modules\Feature_Vectors_300_Pclass.arff)
  nf = open(rZ:\modules\trial.arff, w)
 
 
  for l in f1:
  sp = l.split(,)

 If you are going to be splitting on commas, you might want to read
 up on the csv (comma separate values) module


The  csv module has many fuctions but not of much use to me and it makes my
programme slower


 
  if len(sp)!= 12:
  continue
  else:

 Given the apparent block structure, you could drop the
 continue/else, and more cleanly just use


Yeah, Thats Right


 if len(sp) == 12:
  ix = sp[0].strip()
  iy = sp[1].strip()
  print ix, iy
 
 for s in f2:

 It's been mentioned that the indentation is wrong here


I dont know why the indentation is wrong ?


  st = s.split(,)
 
 csv module again

  if len(st)!= 11:
  continue
  else:

 I'm tempted to repeat the comment on reversing the conditional BUT

  clas = st[10].strip()
 
   print ix, iy, clas
   print  nf, ix, iy, clas
 
 The indentation of the print statements is not aligned with the
 previous assignment -- the effect is the same however as everything
 under the else is executed anyway.

 But as has also been mentioned, ignoring indentation, the apparent
 algorithm you have here is going to process every line of f2 for the
 first line of f1 -- and then for later lines in f1 it will find f2 is at
 the end of file, and do nothing. If it is supposed to process every line
 of f2 for each line of f1, you'll need to rewind f2.


For that I added 'Break' statement as suggested by Chris in above mails.


 If you mean to match one line of f1 with one line of f2, you do not
 want nested loops. But now you have to define the behavior if one of the
 two files is correct length and the other is not? Do you skip both or
 read the next line from the wrong length file? And how will you handle
 files with different numbers of records.


Yes , actually my Prog was like this :
for l in f1:
sp = l.split(,)

if len(sp)!= 12:
continue
else:
ix = sp[0].strip()
iy = sp[1].strip()


for s in f2:
st = s.split(,)

if len(st)!= 11:
continue
else:
clas = st[10].strip()

print ix, iy, clas
print  nf, ix, iy, clas
break


f1.close()
f2.close()
nf.close()

I actually dont want nested loops but cant find another way to achieve what
I want, But for these files I am sure that they have equal lengths, thats
why I am taking the risk of using nested loops.. Can you suggest any
different way to go around this problem , which could be flexible and
non-errorneous ?





 --
 Wulfraed Dennis Lee Bieber AF6VN
 wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/

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

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


Re: Reading data from 2 different files and writing to a single file

2013-01-30 Thread Chris Angelico
On Wed, Jan 30, 2013 at 9:43 PM, inshu chauhan insidesh...@gmail.com wrote:
 I actually dont want nested loops but cant find another way to achieve what
 I want, But for these files I am sure that they have equal lengths, thats
 why I am taking the risk of using nested loops.. Can you suggest any
 different way to go around this problem , which could be flexible and
 non-errorneous ?

Easy. Just trim off the header row(s), if you know how many to expect,
and then use zip() as Dave mentioned earlier.

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


Sorting a hierarchical table (SQL)

2013-01-30 Thread Frank Millman

Hi all

This is not really a python question, but I am hoping that some of you 
can offer some suggestions.


I have a SQL table with hierarchical data. There are two models that can 
be used to represent this - Adjacency Lists and Nested Sets. Here is a 
link to an article that discusses and compares the two approaches -


http://explainextended.com/2009/09/24/adjacency-list-vs-nested-sets-postgresql/

A feature of the Nested Sets model is that a SELECT returns the rows by 
following the links in the structure - root first, followed by its first 
child, followed by *its* first child, until the bottom is reached, then 
any siblings, then up one level to the next child, and so on, until the 
entire tree is exhausted.


I am looking for a way to emulate this behaviour using Adjacency Lists. 
It is not that easy.


The article above shows a way of doing this using an Array. 
Unfortunately that is a PostgreSQL feature not available in all 
databases, so I want to avoid that. Here is the best I have come up with.


For each row, I know the parent id, I know the level (depth in the 
tree), and I know the sequence number - every row has a sequence number 
that is unique within any group of siblings within the tree, always 
starting from zero.


I create a string to be used as a sort key, consisting of the parent's 
sort key, a comma, and the row's sequence number. So the root has a key 
of '0', the first child has '0,0', its first child has '0,0,0', etc.


If there could never be more than 10 siblings, that would work, but if 
it goes over 10, the next key would contain the substring '10', which 
sorts earlier than '2', which would be incorrect.


Therefore, on the assumption that there will never be more that 1 
siblings, I zero-fill each element to a length of 4, so the first key is 
'', the next one is ',', then ',,', etc.


All this is done in SQL, as part of a complicated SELECT statement.

It works, and it would be unusual to have a tree with a depth of more 
than 4 or 5, so I can live with it.


However, it is not pretty. I wondered if anyone can suggest a more 
elegant solution.


Thanks

Frank Millman

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


pyrudp

2013-01-30 Thread Jorge Alberto Diaz Orozco
can someone give me a link to download pyrudp.
I tried here http://code.google.com/p/pyrudp/ but didn´t worked.

if someone can give me another idea it will be great to. 
I´m traying to make a reliable udp connection

help will be really appreciated



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


Re: Reading data from 2 different files and writing to a single file

2013-01-30 Thread Dave Angel

On 01/30/2013 05:43 AM, inshu chauhan wrote:

On Mon, Jan 28, 2013 at 6:05 PM, Dennis Lee Bieber wlfr...@ix.netcom.comwrote:


On Mon, 28 Jan 2013 14:31:31 +0100, inshu chauhan
insidesh...@gmail.com declaimed the following in
gmane.comp.python.general:


In the code below I am trying to read 2 files f1 and f2 , extract some

data

from them and then trying to write them into a single file that is 'nf'.

import cv
f1 = open(rZ:\modules\Feature_Vectors_300.arff)
f2 = open(rZ:\modules\Feature_Vectors_300_Pclass.arff)
nf = open(rZ:\modules\trial.arff, w)


for l in f1:
 sp = l.split(,)


 If you are going to be splitting on commas, you might want to read
up on the csv (comma separate values) module



The  csv module has many fuctions but not of much use to me and it makes my
programme slower





 if len(sp)!= 12:
 continue
 else:


 Given the apparent block structure, you could drop the
continue/else, and more cleanly just use



Yeah, Thats Right



 if len(sp) == 12:

 ix = sp[0].strip()
 iy = sp[1].strip()
 print ix, iy

for s in f2:


 It's been mentioned that the indentation is wrong here



I dont know why the indentation is wrong ?


Your for statement is not lined up with the print that precedes it.  If 
your code were really that way, you'd be getting an indentation error. 
So we assume it's because your email editor is mangling the code.  Post 
in text email, not in html.







 st = s.split(,)


 csv module again


 if len(st)!= 11:
 continue
 else:


 I'm tempted to repeat the comment on reversing the conditional BUT


 clas = st[10].strip()

  print ix, iy, clas
  print  nf, ix, iy, clas


 The indentation of the print statements is not aligned with the
previous assignment -- the effect is the same however as everything
under the else is executed anyway.

 But as has also been mentioned, ignoring indentation, the apparent
algorithm you have here is going to process every line of f2 for the
first line of f1 -- and then for later lines in f1 it will find f2 is at
the end of file, and do nothing. If it is supposed to process every line
of f2 for each line of f1, you'll need to rewind f2.



For that I added 'Break' statement as suggested by Chris in above mails.



 If you mean to match one line of f1 with one line of f2, you do not
want nested loops. But now you have to define the behavior if one of the
two files is correct length and the other is not? Do you skip both or
read the next line from the wrong length file? And how will you handle
files with different numbers of records.



Yes , actually my Prog was like this :
for l in f1:
 sp = l.split(,)

 if len(sp)!= 12:
 continue
 else:
 ix = sp[0].strip()
 iy = sp[1].strip()


for s in f2:


This is not nested, it's back at the left margin.  Or it could be 
posting wrong because you're still posting in html, instead of plain 
text email.




 st = s.split(,)

 if len(st)!= 11:
 continue
 else:
 clas = st[10].strip()

 print ix, iy, clas
 print  nf, ix, iy, clas
 break


f1.close()
f2.close()
nf.close()

I actually dont want nested loops but cant find another way to achieve what
I want, But for these files I am sure that they have equal lengths, thats
why I am taking the risk of using nested loops.


You have that backwards.  Because you say you can assume they're the 
same length, you don't need the flexibility (and unreadability) of the 
nested approach.  The zip approach works great, and nested is unnecessary.


. Can you suggest any

different way to go around this problem , which could be flexible and
non-errorneous ?





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


Re: GeoBases: data services and visualization

2013-01-30 Thread guil . genet
Le mardi 29 janvier 2013 22:25:39 UTC+1, Alex Prengere a écrit :
 This new project provides tools to play with geographical data. It also works 
 with non-geographical data, except for map visualizations :). There are 
 embedded data sources in the project, but you can easily play with your own 
 data in addition to the available ones. Files containing data about airports, 
 train stations, countries, ... are loaded, then you can: - performs various 
 types of queries ( find this key, or find keys with this property) - fuzzy 
 searches based on string distance ( find things roughly named like this) - 
 geographical searches ( find things next to this place) - get results on a 
 map, or export it as csv data, or as a Python object This is entirely written 
 in Python. The core part is a Python package, but there is a command line 
 tool as well! For tutorials and documentation, check out 
 http://opentraveldata.github.com/geobases/

Preum's
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GeoBases: data services and visualization

2013-01-30 Thread guil . genet
Le mercredi 30 janvier 2013 14:28:46 UTC+1, guil@gmail.com a écrit :
 Le mardi 29 janvier 2013 22:25:39 UTC+1, Alex Prengere a écrit :  This new 
 project provides tools to play with geographical data. It also works with 
 non-geographical data, except for map visualizations :). There are embedded 
 data sources in the project, but you can easily play with your own data in 
 addition to the available ones. Files containing data about airports, train 
 stations, countries, ... are loaded, then you can: - performs various types 
 of queries ( find this key, or find keys with this property) - fuzzy searches 
 based on string distance ( find things roughly named like this) - 
 geographical searches ( find things next to this place) - get results on a 
 map, or export it as csv data, or as a Python object This is entirely written 
 in Python. The core part is a Python package, but there is a command line 
 tool as well! For tutorials and documentation, check out 
 http://opentraveldata.github.com/geobases/ Preum's

First
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyrudp

2013-01-30 Thread Rodrick Brown
On Jan 30, 2013, at 8:12 AM, Jorge Alberto Diaz Orozco
jaoro...@estudiantes.uci.cu wrote:

 can someone give me a link to download pyrudp.
 I tried here http://code.google.com/p/pyrudp/ but didn´t worked.

 if someone can give me another idea it will be great to.
 I´m traying to make a reliable udp connection

What about the native socket call to SOCK_DGRAM?

Here is a simple example to read messages of a udp socket.

import socket
UDP_IP = 127.0.0.1
UDP_PORT = 5005

sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))

while True:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
print received message:, data


 help will be really appreciated



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


Re: Reading data from 2 different files and writing to a single file

2013-01-30 Thread inshu chauhan
On Wed, Jan 30, 2013 at 2:23 PM, Dave Angel d...@davea.name wrote:

 On 01/30/2013 05:43 AM, inshu chauhan wrote:

 On Mon, Jan 28, 2013 at 6:05 PM, Dennis Lee Bieber wlfr...@ix.netcom.com
 wrote:

  On Mon, 28 Jan 2013 14:31:31 +0100, inshu chauhan
 insidesh...@gmail.com declaimed the following in
 gmane.comp.python.general:

  In the code below I am trying to read 2 files f1 and f2 , extract some

 data

 from them and then trying to write them into a single file that is 'nf'.

 import cv
 f1 = open(rZ:\modules\Feature_**Vectors_300.arff)
 f2 = open(rZ:\modules\Feature_**Vectors_300_Pclass.arff)
 nf = open(rZ:\modules\trial.arff, w)


 for l in f1:
  sp = l.split(,)


  If you are going to be splitting on commas, you might want to
 read
 up on the csv (comma separate values) module


 The  csv module has many fuctions but not of much use to me and it makes
 my
 programme slower



  if len(sp)!= 12:
  continue
  else:


  Given the apparent block structure, you could drop the
 continue/else, and more cleanly just use


 Yeah, Thats Right


  if len(sp) == 12:

  ix = sp[0].strip()
  iy = sp[1].strip()
  print ix, iy

 for s in f2:


  It's been mentioned that the indentation is wrong here


 I dont know why the indentation is wrong ?


 Your for statement is not lined up with the print that precedes it.  If
 your code were really that way, you'd be getting an indentation error. So
 we assume it's because your email editor is mangling the code.  Post in
 text email, not in html.




   st = s.split(,)

   csv module again

   if len(st)!= 11:
  continue
  else:


  I'm tempted to repeat the comment on reversing the conditional
 BUT

   clas = st[10].strip()

   print ix, iy, clas
   print  nf, ix, iy, clas

   The indentation of the print statements is not aligned with
 the
 previous assignment -- the effect is the same however as everything
 under the else is executed anyway.

  But as has also been mentioned, ignoring indentation, the
 apparent
 algorithm you have here is going to process every line of f2 for the
 first line of f1 -- and then for later lines in f1 it will find f2 is at
 the end of file, and do nothing. If it is supposed to process every line
 of f2 for each line of f1, you'll need to rewind f2.


 For that I added 'Break' statement as suggested by Chris in above mails.


  If you mean to match one line of f1 with one line of f2, you do
 not
 want nested loops. But now you have to define the behavior if one of the
 two files is correct length and the other is not? Do you skip both or
 read the next line from the wrong length file? And how will you handle
 files with different numbers of records.


 Yes , actually my Prog was like this :
 for l in f1:
  sp = l.split(,)

  if len(sp)!= 12:
  continue
  else:
  ix = sp[0].strip()
  iy = sp[1].strip()


 for s in f2:


 This is not nested, it's back at the left margin.  Or it could be posting
 wrong because you're still posting in html, instead of plain text email.




 Yes My Initial code was not nested at the same time of no use too,  I am
 trying to use zip() now :) :) nyways..


   st = s.split(,)

  if len(st)!= 11:
  continue
  else:
  clas = st[10].strip()

  print ix, iy, clas
  print  nf, ix, iy, clas
  break


 f1.close()
 f2.close()
 nf.close()

 I actually dont want nested loops but cant find another way to achieve
 what
 I want, But for these files I am sure that they have equal lengths, thats
 why I am taking the risk of using nested loops.


 You have that backwards.  Because you say you can assume they're the same
 length, you don't need the flexibility (and unreadability) of the nested
 approach.  The zip approach works great, and nested is unnecessary.


 . Can you suggest any

 different way to go around this problem , which could be flexible and
 non-errorneous ?




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


Re: security quirk

2013-01-30 Thread Martin Musatov
On Jan 29, 8:55 pm, RichD r_delaney2...@yahoo.com wrote:
 I read Wall Street Journal, and occasionally checkNotepadPlus
UserLang name=MUSATOV ext=.myl udlVersion=2.0
Settings
Global caseIgnored=no allowFoldOfComments=no
forceLineCommentsAtBOL=no foldCompact=yes /
Prefix Keywords1=no Keywords2=no Keywords3=no
Keywords4=no Keywords5=no Keywords6=no Keywords7=no
Keywords8=no /
/Settings
KeywordLists
Keywords name=Comments id=000commentBegin 01comment
02commentEnd 03 04/Keywords
Keywords name=Numbers, additional id=1/Keywords
Keywords name=Numbers, prefixes id=2/Keywords
Keywords name=Numbers, extras with prefixes id=3/
Keywords
Keywords name=Numbers, suffixes id=4/Keywords
Keywords name=Operators1 id=5();/Keywords
Keywords name=Operators2 id=6/Keywords
Keywords name=Folders in code1, open id=7Open/
Keywords
Keywords name=Folders in code1, middle id=8middle/
Keywords
Keywords name=Folders in code1, close id=9Close/
Keywords
Keywords name=Folders in code2, open id=10Open/
Keywords
Keywords name=Folders in code2, middle id=11middle/
Keywords
Keywords name=Folders in code2, close id=12Close/
Keywords
Keywords name=Folders in comment, open id=13Open/
Keywords
Keywords name=Folders in comment, middle
id=14middle/Keywords
Keywords name=Folders in comment, close id=15Close/
Keywords
Keywords name=Keywords1 id=16%%/Keywords
Keywords name=Keywords2 id=17/Keywords
Keywords name=Keywords3 id=18/Keywords
Keywords name=Keywords4 id=19/Keywords
Keywords name=Keywords5 id=20/Keywords
Keywords name=Keywords6 id=21/Keywords
Keywords name=Keywords7 id=22/Keywords
Keywords name=Keywords8 id=23/Keywords
Keywords name=Delimiters id=24/Keywords
/KeywordLists
Styles
WordsStyle name=DEFAULT styleID=0 fgColor=FF
bgColor=00 fontName=Monotype Corsiva fontStyle=7
fontSize=14 nesting=0 /
WordsStyle name=COMMENTS styleID=1 fgColor=00
bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=LINE COMMENTS styleID=2
fgColor=00 bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=NUMBERS styleID=3 fgColor=00
bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=KEYWORDS1 styleID=4 fgColor=00
bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=KEYWORDS2 styleID=5 fgColor=00
bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=KEYWORDS3 styleID=6 fgColor=00
bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=KEYWORDS4 styleID=7 fgColor=00
bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=KEYWORDS5 styleID=8 fgColor=00
bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=KEYWORDS6 styleID=9 fgColor=00
bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=KEYWORDS7 styleID=10 fgColor=00
bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=KEYWORDS8 styleID=11 fgColor=00
bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=OPERATORS styleID=12 fgColor=00
bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=FOLDER IN CODE1 styleID=13
fgColor=FF bgColor=00 fontName= fontStyle=7
fontSize=10 nesting=0 /
WordsStyle name=FOLDER IN CODE2 styleID=14
fgColor=00 bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=FOLDER IN COMMENT styleID=15
fgColor=FF bgColor=00 fontName=Times New Roman
fontStyle=7 fontSize=8 nesting=0 /
WordsStyle name=DELIMITERS1 styleID=16
fgColor=00 bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=DELIMITERS2 styleID=17
fgColor=00 bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=DELIMITERS3 styleID=18
fgColor=00 bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=DELIMITERS4 styleID=19
fgColor=00 bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=DELIMITERS5 styleID=20
fgColor=00 bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=DELIMITERS6 styleID=21
fgColor=00 bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=DELIMITERS7 styleID=22
fgColor=00 bgColor=FF fontStyle=0 nesting=0 /
WordsStyle name=DELIMITERS8 styleID=23
fgColor=00 bgColor=FF fontStyle=0 nesting=0 /
/Styles
/UserLang
/NotepadPlus

 articles on their Web site.  It's mostly free, with some items
 available to subscribers only.  It seems random, which ones
 they block, about 20%.

 Anywho, sometimes I use their search utility, the usual author
 or title search, and it blocks, then I look it up on Google, and
 link from there, and it loads!  ok, Web 

Re: security quirk

2013-01-30 Thread Gandalf Parker
RichD r_delaney2...@yahoo.com contributed wisdom to  news:b968c6c6-5aa9-
4584-bd7a-5b097f17c...@pu9g2000pbc.googlegroups.com:

 Web gurus, what's going on?
 

That is the fault of the site itself.
If they are going to block access to users then they should also block 
access to the automated spiders that hit the site to collect data.
-- 
http://mail.python.org/mailman/listinfo/python-list


looping versus comprehension

2013-01-30 Thread Robin Becker
An email in reportlab-us...@reportlab.com claimed that the following loop in a 
charting module was taking a long time



I use ReportLab 2.6 but I also found the problem in ReportLab daily from 
01/29/2013 in /src/reportlab/graphics/charts/lineplots.py:
276  # Iterate over data columns.
277  if self.joinedLines:
278  points = []
279  for xy in row:
280  points += [xy[0], xy[1]]

If I use a list comprehension instead, the plot is generated within seconds or 
minutes:
278  points = [[xy[0], xy[1]] for xy in row]


however, when I tried an experiment in python 2.7 using the script below I find 
that the looping algorithms perform better. A naive loop using list += list 
would appear to be an O(n**2) operation, but python seems to be doing better 
than that. Also why does the append version fail so dismally. Is my test coded 
wrongly or is pre-allocation of the list making this better than expected?


C:\code\teststpoints 86000 86
 START n=86000 
existing algorithm took 0.08 seconds
existing algorithm using list took 0.12 seconds
existing algorithm using list assuming length 2 took 0.12 seconds
map(list,row) took 0.16 seconds
[list(xy) for xy in row] took 0.28 seconds
[[xy[0],xy[1]] for xy in row] took 0.22 seconds
append algorithm took 0.19 seconds
 END   n=86000 


 START n=86 
existing algorithm took 0.86 seconds
existing algorithm using list took 1.33 seconds
existing algorithm using list assuming length 2 took 1.25 seconds
map(list,row) took 3.44 seconds
[list(xy) for xy in row] took 3.03 seconds
[[xy[0],xy[1]] for xy in row] took 2.70 seconds
append algorithm took 2.48 seconds
 END   n=86 

#
import sys, time
def main(n):
print 20*'#','START n=%s'%n,20*'#'
row = [(i,i+1) for i in xrange(2*n)]
print 'existing algorithm',
t0 = time.time()
points = []
for xy in row:
points += [xy[0],xy[1]]
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print 'existing algorithm using list',
t0 = time.time()
points = []
for xy in row:
points += list(xy[:2])
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print 'existing algorithm using list assuming length 2',
t0 = time.time()
points = []
for xy in row:
points += list(xy)
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print 'map(list,row)',
t0 = time.time()
points = map(list,row)
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print '[list(xy) for xy in row]',
t0 = time.time()
points = [list(xy) for xy in row]
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print '[[xy[0],xy[1]] for xy in row]',
t0 = time.time()
points = [[xy[0],xy[1]] for xy in row]
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print 'append algorithm',
t0 = time.time()
points = [].append
for xy in row:
points([xy[0],xy[1]])
points = points.__self__
t1 = time.time()
print 'took %.2f seconds' % (t1-t0)

print 20*'#','END   n=%s'%n,20*'#','\n\n'

if __name__=='__main__':
if len(sys.argv)==1:
N = [86000]
else:
N = map(int,sys.argv[1:])
for n in N:
main(n)
#
--
Robin Becker

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


Re: looping versus comprehension

2013-01-30 Thread Chris Angelico
On Thu, Jan 31, 2013 at 1:58 AM, Robin Becker ro...@reportlab.com wrote:
 however, when I tried an experiment in python 2.7 using the script below I
 find that the looping algorithms perform better. A naive loop using list +=
 list would appear to be an O(n**2) operation, but python seems to be doing
 better than that. Also why does the append version fail so dismally. Is my
 test coded wrongly or is pre-allocation of the list making this better than
 expected?

First off, are you aware that your first three blocks of code and your
last four produce different results? The first ones flatten the list,
the others simply convert tuples to lists. With n = 3:

 points = []
 for xy in row:
points += [xy[0],xy[1]]
 points
[0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]
 map(list,row)
[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]

Once that's sorted out, then timings can be played with. But it's
worth noting that list appending is not going to be O(N*N), because
it's going to allow room for expansion.

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


Re: pyrudp

2013-01-30 Thread Jorge Alberto Diaz Orozco
I´ve tried it but it´s not reliable. Datagrams can arive disorganised or just 
not arive.
Some programmers said I most use TCP, but I need to use UDP.
that´s why I need pyrudp, but I can not find it.

On Jan 30, 2013, at 8:12 AM, Jorge Alberto Diaz Orozco

What about the native socket call to SOCK_DGRAM?

Here is a simple example to read messages of a udp socket.

import socket
UDP_IP = 127.0.0.1
UDP_PORT = 5005

sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))

while True:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
print received message:, data
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyrudp

2013-01-30 Thread Michael Torrie
On 01/30/2013 10:02 AM, Jorge Alberto Diaz Orozco wrote:
 I´ve tried it but it´s not reliable. Datagrams can arive disorganised or just 
 not arive.
 Some programmers said I most use TCP, but I need to use UDP.
 that´s why I need pyrudp, but I can not find it.

Excuse me for chuckling, but your complaint that UDP packets can arive
disorganised or just not arive describes exactly what UDP does by
design! If you need to use UDP then you will have to live with this.  I
always consider UDP to stand for UNRELIABLE datagram packets.  They
can and do come in any order, or not at all.  That's exactly the
expected behavior of UDP.

If you want to build a reliable connection on top of UDP you'll have to
invent some sort of tcp-like protocol that uses UDP packets.  An example
of a real all that does this is openvpn.  The Bell Labs Plan 9 RUDP
protocol is probably what you were shooting for by trying to use the
non-existent pyrudp code.  But I fear you'll have to implement it
yourself.  pyrudp is an empty project on Google Code.  The owner
intended to develop some code but never did.

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


how to use subprocess to execute an exe with args and an output

2013-01-30 Thread noydb
I am looking for some guidance on using subprocess to execute an EXE with 
arguments and an output.  The below code works in that it returns a 0 exit 
code, but no output file is created.  I have tried a few different versions of 
this code (used Popen instead, some stderr/stdout), but no luck.  Can anyone 
offer an explanation or suggestion?  (GPSBabel is freeware)
Python 2.7 on windows7 64-bit

import subprocess
subprocess.call([rC:\Program Files (x86)\GPSBabel\gpsbabel.exe,
-i, gdb, -f, rC:\Temp\GDBdata\testgps28.gdb,
-o, gpx, rC:\Temp\gpx\test28output.gpx])

If I use this below, I get a returncode of 1, exit code of 0.
import subprocess
x = subprocess.Popen([rC:\Program Files (x86)\GPSBabel\gpsbabel.exe,
-i, gdb, -f, rC:\Temp\GDBdata\testgps28.gdb,
-o, gpx, rC:\Temp\gpx\test28output.gpx,
shell=True, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE])

x.wait()
print x.returncode

Thanks in advance for any help
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to use subprocess to execute an exe with args and an output

2013-01-30 Thread noydb
To add on, I need to eventually write a script that takes input, feeds it into 
this exe, and takes the output file to perform more 'tools'/manipulations on 
it.  Is call or Popen called for, why?  Or maybe some other module???
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to use subprocess to execute an exe with args and an output

2013-01-30 Thread Chris Rebert
On Wed, Jan 30, 2013 at 9:15 AM, noydb jenn.du...@gmail.com wrote:
 I am looking for some guidance on using subprocess to execute an EXE with 
 arguments and an output.  The below code works in that it returns a 0 exit 
 code, but no output file is created.  I have tried a few different versions 
 of this code (used Popen instead, some stderr/stdout), but no luck.  Can 
 anyone offer an explanation or suggestion?  (GPSBabel is freeware)
 Python 2.7 on windows7 64-bit

 import subprocess
 subprocess.call([rC:\Program Files (x86)\GPSBabel\gpsbabel.exe,
 -i, gdb, -f, rC:\Temp\GDBdata\testgps28.gdb,
 -o, gpx, rC:\Temp\gpx\test28output.gpx])

If my cursory reading of GPSBabel's documentation is right, you're
missing a -F before the output filepath. Try:

subprocess.call([
rC:\Program Files (x86)\GPSBabel\gpsbabel.exe,
-i, gdb,
-f, rC:\Temp\GDBdata\testgps28.gdb,
-o, gpx,
-F, rC:\Temp\gpx\test28output.gpx,
])

Regards,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: looping versus comprehension

2013-01-30 Thread Robin Becker

On 30/01/2013 15:49, Chris Angelico wrote:

On Thu, Jan 31, 2013 at 1:58 AM, Robin Becker ro...@reportlab.com wrote:

however, when I tried an experiment in python 2.7 using the script below I
find that the looping algorithms perform better. A naive loop using list +=
list would appear to be an O(n**2) operation, but python seems to be doing
better than that. Also why does the append version fail so dismally. Is my
test coded wrongly or is pre-allocation of the list making this better than
expected?


First off, are you aware that your first three blocks of code and your
last four produce different results? The first ones flatten the list,
the others simply convert tuples to lists. With n = 3:


points = []
for xy in row:

 points += [xy[0],xy[1]]

points

[0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]

map(list,row)

[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]

Once that's sorted out, then timings can be played with. But it's
worth noting that list appending is not going to be O(N*N), because
it's going to allow room for expansion.

ChrisA



No I missed that :( the list is a flattened one.

That'll teach me not to copy the code from the users without checking. Now you 
point it out it's clear that his code is doing something different. Presumably 
it's not drawing the same thing at all :) no wonder it got much faster.

--
Robin Becker
--
http://mail.python.org/mailman/listinfo/python-list


Re: pyrudp

2013-01-30 Thread Rob Day
Have you seen http://pyraknet.slowchop.com/? It appears to do a similar thing.

On 30 January 2013 17:02, Jorge Alberto Diaz Orozco
jaoro...@estudiantes.uci.cu wrote:
 I´ve tried it but it´s not reliable. Datagrams can arive disorganised or just 
 not arive.
 Some programmers said I most use TCP, but I need to use UDP.
 that´s why I need pyrudp, but I can not find it.

 On Jan 30, 2013, at 8:12 AM, Jorge Alberto Diaz Orozco

 What about the native socket call to SOCK_DGRAM?

 Here is a simple example to read messages of a udp socket.

 import socket
 UDP_IP = 127.0.0.1
 UDP_PORT = 5005

 sock = socket.socket(socket.AF_INET, # Internet
 socket.SOCK_DGRAM) # UDP
 sock.bind((UDP_IP, UDP_PORT))

 while True:
 data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
 print received message:, data
 --
 http://mail.python.org/mailman/listinfo/python-list



-- 
Robert K. Day
robert@merton.oxon.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to use subprocess to execute an exe with args and an output

2013-01-30 Thread MRAB

On 2013-01-30 17:15, noydb wrote:

I am looking for some guidance on using subprocess to execute an EXE with 
arguments and an output.  The below code works in that it returns a 0 exit 
code, but no output file is created.  I have tried a few different versions of 
this code (used Popen instead, some stderr/stdout), but no luck.  Can anyone 
offer an explanation or suggestion?  (GPSBabel is freeware)
Python 2.7 on windows7 64-bit

import subprocess
subprocess.call([rC:\Program Files (x86)\GPSBabel\gpsbabel.exe,
 -i, gdb, -f, rC:\Temp\GDBdata\testgps28.gdb,
 -o, gpx, rC:\Temp\gpx\test28output.gpx])

If I use this below, I get a returncode of 1, exit code of 0.
import subprocess
x = subprocess.Popen([rC:\Program Files (x86)\GPSBabel\gpsbabel.exe,
 -i, gdb, -f, rC:\Temp\GDBdata\testgps28.gdb,
 -o, gpx, rC:\Temp\gpx\test28output.gpx,
 shell=True, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE])

x.wait()
print x.returncode

Thanks in advance for any help


The second example is incorrect. The parts starting from shell are
supposed to be further arguments for Popen itself, not something passed
to gpsbabel.exe:

x = subprocess.Popen([rC:\Program Files (x86)\GPSBabel\gpsbabel.exe,
 -i, gdb, -f, rC:\Temp\GDBdata\testgps28.gdb,
 -o, gpx, rC:\Temp\gpx\test28output.gpx],
 shell=True, stdout=subprocess.PIPE,
 stderr=subprocess.PIPE)

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


Re: how to use subprocess to execute an exe with args and an output

2013-01-30 Thread noydb
oh DUH!  that was it, just missing the -F.  Thank-you!!

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


Re: security quirk

2013-01-30 Thread RichD
On Jan 30, Gandalf  Parker gand...@the.dead.isp.of.community.net
wrote:
  Web gurus, what's going on?

 That is the fault of the site itself.
 If they are going to block access to users then they should also block
 access to the automated spiders that hit the site to collect data.

well yeah, but what's going on, under the hood?
How does it get confused?  How could this
happen?  I'm looking for some insight, regarding a
hypothetical programmimg glitch -


--
Rich
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: security quirk

2013-01-30 Thread Joel Goldstick
On Wed, Jan 30, 2013 at 2:39 PM, RichD r_delaney2...@yahoo.com wrote:

 On Jan 30, Gandalf  Parker gand...@the.dead.isp.of.community.net
 wrote:
   Web gurus, what's going on?
 
  That is the fault of the site itself.
  If they are going to block access to users then they should also block
  access to the automated spiders that hit the site to collect data.

 well yeah, but what's going on, under the hood?
 How does it get confused?  How could this
 happen?  I'm looking for some insight, regarding a
 hypothetical programmimg glitch -


 --
 Rich
 --

 As was pointed out, this really is off topic for this group.  You might
try googling.  The NYTimes makes articles available by adding a parameter
to the tail of the url I believe


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


Re: pyrudp

2013-01-30 Thread Jorge Alberto Diaz Orozco
I want to use a reliable UDP connection like you say, a TCP like connection but 
over UDP. thaks for your recomendation, if I get good results I promise to 
share them.

- Original Message -
From: Michael Torrie torr...@gmail.com
To: python-list@python.org
Sent: Wednesday, January 30, 2013 9:16:15 AM
Subject: Re: pyrudp

Excuse me for chuckling, but your complaint that UDP packets can arive
disorganised or just not arive describes exactly what UDP does by
design! If you need to use UDP then you will have to live with this.  I
always consider UDP to stand for UNRELIABLE datagram packets.  They
can and do come in any order, or not at all.  That's exactly the
expected behavior of UDP.

If you want to build a reliable connection on top of UDP you'll have to
invent some sort of tcp-like protocol that uses UDP packets.  An example
of a real all that does this is openvpn.  The Bell Labs Plan 9 RUDP
protocol is probably what you were shooting for by trying to use the
non-existent pyrudp code.  But I fear you'll have to implement it
yourself.  pyrudp is an empty project on Google Code.  The owner
intended to develop some code but never did.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to use subprocess to execute an exe with args and an output

2013-01-30 Thread Terry Reedy

On 1/30/2013 1:11 PM, MRAB wrote:

On 2013-01-30 17:15, noydb wrote:

I am looking for some guidance on using subprocess to execute an EXE
with arguments and an output.  The below code works in that it returns
a 0 exit code, but no output file is created.  I have tried a few
different versions of this code (used Popen instead, some
stderr/stdout), but no luck.  Can anyone offer an explanation or
suggestion?  (GPSBabel is freeware)
Python 2.7 on windows7 64-bit

import subprocess
subprocess.call([rC:\Program Files (x86)\GPSBabel\gpsbabel.exe,
 -i, gdb, -f, rC:\Temp\GDBdata\testgps28.gdb,
 -o, gpx, rC:\Temp\gpx\test28output.gpx])

If I use this below, I get a returncode of 1, exit code of 0.
import subprocess
x = subprocess.Popen([rC:\Program Files (x86)\GPSBabel\gpsbabel.exe,
 -i, gdb, -f, rC:\Temp\GDBdata\testgps28.gdb,
 -o, gpx, rC:\Temp\gpx\test28output.gpx,
 shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE])

x.wait()
print x.returncode

Thanks in advance for any help


The second example is incorrect. The parts starting from shell are
supposed to be further arguments for Popen itself, not something passed
to gpsbabel.exe:

x = subprocess.Popen([rC:\Program Files (x86)\GPSBabel\gpsbabel.exe,
  -i, gdb, -f, rC:\Temp\GDBdata\testgps28.gdb,
  -o, gpx, rC:\Temp\gpx\test28output.gpx],
  shell=True, stdout=subprocess.PIPE,
  stderr=subprocess.PIPE)



and it is apparently best to not use shell=True unless actually needed 
for shell processing, which I do not think is the case here.


--
Terry Jan Reedy

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


Re: security quirk

2013-01-30 Thread Big Bad Bob

On 01/29/13 20:55, RichD so wittily quipped:

I read Wall Street Journal, and occasionally check
articles on their Web site.  It's mostly free, with some items
available to subscribers only.  It seems random, which ones
they block, about 20%.

Anywho, sometimes I use their search utility, the usual author
or title search, and it blocks, then I look it up on Google, and
link from there, and it loads!  ok, Web gurus, what's going on?


in my last post, I quoted an article from 'The Register' where they talk 
about how Facebook (literally) broke that feature.


[this works in a LOT of places, but sometimes you have to enable cookies 
or javascript to actually see the content]


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


derived class name in python 2.6/2.7

2013-01-30 Thread Sells, Fred
This is simple, but I just cannot find it after quite a bit of searching

I have this basic design

class  A:
def __init__(self):
print 'I am an instance of ', self.__class__.name

class B(A):
pass


X = B
I would like this to print I am an instance of B  but I keep getting A.  Can 
someone help me out here.

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


A new script which creates Python 3.3 venvs with Distribute and pip installed in them

2013-01-30 Thread Vinay Sajip
Python 3.3 includes a script, pyvenv, which is used to create virtual 
environments. However, Distribute and pip are not installed in such 
environments - because, though they are popular, they are third-party packages 
- not part of Python.

The Python 3.3 venv machinery allows customisation of virtual environments 
fairly readily. To demonstrate how to do this, and to provide at the same time 
a script which might be useful to people, I've created a script, pyvenvex.py, at

https://gist.github.com/4673395

which extends the pyvenv script to not only create virtual environments, but to 
also install Distribute and pip into them. The script needs Python 3.3, and one 
way to use it is:

1. Download the script to a directory in your path, and (on Posix platforms) 
make it executable.
2. Add a shebang line at the top of your script, pointing to your Python 3.3 
interpreter (Posix, and also Windows if you have the PEP 397 launcher which is 
part of Python 3.3 on Windows).
3. Run the pyvenvex script to create your virtual environments, in place of 
pyvenv, when you want Distribute and pip to be installed for you (this is how 
virtualenv sets up environments it creates). You can run the script with -h to 
see the command line options available, which are a superset of the pyvenv 
script.

Regards,

Vinay Sajip
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: derived class name in python 2.6/2.7

2013-01-30 Thread Oscar Benjamin
On 30 January 2013 20:05, Sells, Fred fred.se...@adventistcare.org wrote:
 This is simple, but I just cannot find it after quite a bit of searching

 I have this basic design

 class  A:
 def __init__(self):
 print 'I am an instance of ', self.__class__.name

Did you mean to use __name__ instead of name?


 class B(A):
 pass

 X = B

I assume that this is
X = B()

 I would like this to print I am an instance of B  but I keep getting A.  
 Can someone help me out here.

If you make those two changes then it should do what you want.


Oscar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: derived class name in python 2.6/2.7

2013-01-30 Thread Dave Angel

On 01/30/2013 03:05 PM, Sells, Fred wrote:

This is simple, but I just cannot find it after quite a bit of searching

I have this basic design

class  A:
def __init__(self):
print 'I am an instance of ', self.__class__.name

class B(A):
pass


X = B
I would like this to print I am an instance of B  but I keep getting A.  Can 
someone help me out here.



Why would creating an alias for class B execute the initializer for 
either class?


perhaps you meant:

x = B()

BTW, since you're on 2.x python, you should derive A from object. 
Otherwise it's an old-style class.


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


Re: A new script which creates Python 3.3 venvs with Distribute and pip installed in them

2013-01-30 Thread Ian Kelly
On Wed, Jan 30, 2013 at 1:09 PM, Vinay Sajip vinay_sa...@yahoo.co.uk wrote:
 Python 3.3 includes a script, pyvenv, which is used to create virtual 
 environments. However, Distribute and pip are not installed in such 
 environments - because, though they are popular, they are third-party 
 packages - not part of Python.

 The Python 3.3 venv machinery allows customisation of virtual environments 
 fairly readily. To demonstrate how to do this, and to provide at the same 
 time a script which might be useful to people, I've created a script, 
 pyvenvex.py, at

 https://gist.github.com/4673395

 which extends the pyvenv script to not only create virtual environments, but 
 to also install Distribute and pip into them. The script needs Python 3.3, 
 and one way to use it is:

 1. Download the script to a directory in your path, and (on Posix platforms) 
 make it executable.
 2. Add a shebang line at the top of your script, pointing to your Python 3.3 
 interpreter (Posix, and also Windows if you have the PEP 397 launcher which 
 is part of Python 3.3 on Windows).
 3. Run the pyvenvex script to create your virtual environments, in place of 
 pyvenv, when you want Distribute and pip to be installed for you (this is how 
 virtualenv sets up environments it creates). You can run the script with -h 
 to see the command line options available, which are a superset of the pyvenv 
 script.

I have a shell script for this:

#!/bin/sh
python3 -m venv $1
cd $1
. bin/activate
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
bin/easy_install pip
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyrudp

2013-01-30 Thread garabik-news-2005-05
Jorge Alberto Diaz Orozco jaoro...@estudiantes.uci.cu wrote:
 I want to use a reliable UDP connection like you say, a TCP like
 connection but over UDP. thaks for your recomendation, if I get good
 results I promise to share them.


utalk (long since disappeared from the surface of the internet) did have
such an implementation, and I once wrote a half-cooked python
implementation of its semi-reliable protocol over UDP.

Nowadays, I'd recommend using openvpn, or perhaps investigate the
possibility of PPP over UDP, or maybe look into SCTP.

-- 
 ---
| Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ |
| __..--^^^--..__garabik @ kassiopeia.juls.savba.sk |
 ---
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
-- 
http://mail.python.org/mailman/listinfo/python-list


help

2013-01-30 Thread aramildaern
Hi everyone! I don't mean to intrude, but ive heard great things about this 
group and ive stumped myself with my python code.

heres my code:
#! /usr/bin/python

import sys

global labelList 
labelList= dict()

global counter
counter = 0

def execute(line):
if line.find(::print) != -1:
stripPrint = line.find(::print)
startPrint = line.find('', stripPrint)
stopPrint = line.find('', startPrint + 1)
printSection = line[startPrint + 1 : stopPrint]
print(printSection)

if line.find(::label) != -1:
stripLabel = line.find(::label)
startLabel = line.find(' ', stripLabel)
stopLabel = line.find('--', startLabel + 1)
label = line[startLabel + 1 : stopLabel]
line.strip(\r\n)
labelList[label] = counter

if len(sys.argv)  2:
print(error: no input files)
print(compilation terminated)

else:
fileName = sys.argv[1]
jadeFile = open(fileName, 'r')

for line in jadeFile:
counter = counter + 1
execute(line)

jadeFile.close()

i = 0

while i  len(labelList):
print(labelList.keys()[i], :, labelList.values()[i])
i = i + 1


and its giving me a bunch of errors thanks for the help in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help

2013-01-30 Thread Ian Kelly
On Wed, Jan 30, 2013 at 2:16 PM,  aramilda...@gmail.com wrote:
 Hi everyone! I don't mean to intrude, but ive heard great things about this 
 group and ive stumped myself with my python code.

 heres my code:

It would be helpful if you would also include the error that you get
when trying to run the code.

 global labelList
 labelList= dict()

 global counter
 counter = 0

That said, these lines stick out as being obviously wrong.  The global
statement is used within the context of a function to declare that a
name used within that function has global scope rather than local
scope.  There is no meaning to using the statement at the module level
like this -- Python already knows the name is global, because it's not
being used within a function -- and I'd be surprised if this didn't
result in a SyntaxError.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help

2013-01-30 Thread Joel Goldstick
On Wed, Jan 30, 2013 at 4:16 PM, aramilda...@gmail.com wrote:

 Hi everyone! I don't mean to intrude, but ive heard great things about
 this group and ive stumped myself with my python code.


No intrusion.  That is what the list is for.

Two points:

You should use a descriptive subject line -- Help isn't really
descriptive.
You should run your code, cut and paste the traceback you get showing the
errors.  This is extremely useful for people to help you with, and as you
program, you will learn how useful it can be to find problems on your own.

So, do that, and come back with that info


 heres my code:
 #! /usr/bin/python

 import sys

 global labelList
 labelList= dict()

 global counter
 counter = 0

 def execute(line):
 if line.find(::print) != -1:
 stripPrint = line.find(::print)
 startPrint = line.find('', stripPrint)
 stopPrint = line.find('', startPrint + 1)
 printSection = line[startPrint + 1 : stopPrint]
 print(printSection)

 if line.find(::label) != -1:
 stripLabel = line.find(::label)
 startLabel = line.find(' ', stripLabel)
 stopLabel = line.find('--', startLabel + 1)
 label = line[startLabel + 1 : stopLabel]
 line.strip(\r\n)
 labelList[label] = counter

 if len(sys.argv)  2:
 print(error: no input files)
 print(compilation terminated)

 else:
 fileName = sys.argv[1]
 jadeFile = open(fileName, 'r')

 for line in jadeFile:
 counter = counter + 1
 execute(line)

 jadeFile.close()

 i = 0

 while i  len(labelList):
 print(labelList.keys()[i], :, labelList.values()[i])
 i = i + 1


 and its giving me a bunch of errors thanks for the help in advance!
 --
 http://mail.python.org/mailman/listinfo/python-list




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


Re: pyrudp

2013-01-30 Thread Dave Angel

On 01/30/2013 02:55 PM, Jorge Alberto Diaz Orozco wrote:

I want to use a reliable UDP connection like you say, a TCP like connection but 
over UDP. thaks for your recomendation, if I get good results I promise to 
share them.



It's nice to want but what is your actual condition/problem?  Are you 
trying to re-invent the wheel, implement a senior project, or are you 
trying to work around some administrative or technical restriction 
against tcp?  What's the use case?


Do you have control over both ends?  Are you writing both ends of the 
imitation tcp you're writing?


One of the car magazines published a road test of the Mercedes GT 
(garbage truck).  It had plenty of power, but its top speed was 6 mph, 
and it leaned horribly around the pylon obstacle course.  Not what I'd 
take to the race track.


Point is that a definitive specification of requirements will be much 
more useful than a simple wanna.


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


Re: A new script which creates Python 3.3 venvs with Distribute and pip installed in them

2013-01-30 Thread Vinay Sajip
Ian Kelly ian.g.kelly at gmail.com writes:

 
 I have a shell script for this:
 

Sure - there's a similar one at

https://gist.github.com/4591655

The main purpose of the script was to illustrate how to subclass 
venv.EnvBuilder,
and I've added it as an example to the 3.3 and in-development documentation:

http://docs.python.org/3/library/venv.html#an-example-of-extending-envbuilder

Doing it in Python means that it runs cross-platform, offers a few benefits
such as command line help, or the option to install Distribute but not pip.

Regards,

Vinay Sajip

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


Re: help

2013-01-30 Thread Chris Angelico
On Thu, Jan 31, 2013 at 8:16 AM,  aramilda...@gmail.com wrote:
 Hi everyone! I don't mean to intrude, but ive heard great things about this 
 group and ive stumped myself with my python code.

Hi! As others have said, this is no intrusion, but it'd help a lot if
you posted your errors and used a more useful subject line.
Additionally, when you post, can you give some example lines from the
file? This part of your code is impossible for us to simulate:

 fileName = sys.argv[1]
 jadeFile = open(fileName, 'r')

 for line in jadeFile:
 counter = counter + 1
 execute(line)

 jadeFile.close()

But this much I can suggest:

 i = 0

 while i  len(labelList):
 print(labelList.keys()[i], :, labelList.values()[i])
 i = i + 1

Instead of iterating with a counter, you can iterate with a Python 'for' loop.

for label,count in labelList.items():
print(label,:,count)

It's that simple!

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


Re: pyrudp

2013-01-30 Thread Chris Angelico
On Thu, Jan 31, 2013 at 6:55 AM, Jorge Alberto Diaz Orozco
jaoro...@estudiantes.uci.cu wrote:
 I want to use a reliable UDP connection like you say, a TCP like connection 
 but over UDP. thaks for your recomendation, if I get good results I promise 
 to share them.

To get something reliable over UDP, you're going to need to
acknowledge everything you're sent, and if you don't hear back an
acknowledgement, re-send. Basically reimplement TCP, or parts of it.
Why do you need to use UDP?

I've used UDP for a number of purposes, but usually in a fire and
forget system. For instance, my latest use of it was a peer-to-peer
self-healing network; each node would broadcast a periodic UDP packet
saying Hi, I'm here, and here's my current status, and each node
would keep track of the timestamp when it last received such a packet
from each known IP address. If the time-since-last-received exceeds
three broadcast intervals, the node is considered to be dead. But for
this to work, I have to not care about individual packet loss; there
is no data in the packet that won't be repeated in the next one. This
is a reliable *system* built on UDP.

Can you explain your goals and restrictions? Might help us figure out
how to advise.

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


Re: security quirk

2013-01-30 Thread Auric__
Martin Musatov wrote:

 On Jan 29, 8:55 pm, RichD r_delaney2...@yahoo.com wrote:
 I read Wall Street Journal, and occasionally checkNotepadPlus
 UserLang name=MUSATOV ext=.myl udlVersion=2.0
[snip]
 /UserLang
 /NotepadPlus

Ignoring the big ol' unneccessary crosspost... What the fuck?

-- 
Oooh, I just learned a new euphemism.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyrudp

2013-01-30 Thread Jorge Alberto Diaz Orozco
I have restrictions in my system that does not allow me to use TCP, so I want 
to make a pipe over UDP imitating TCP behavior.
I have control over both endpoints, and I´m writing both of them.
I just don´t want to re-invent the wheel and I´m looking for a reliable UDP 
sockets implementation for Python so I can start from there.

_

It's nice to want but what is your actual condition/problem?  Are you 
trying to re-invent the wheel, implement a senior project, or are you 
trying to work around some administrative or technical restriction 
against tcp?  What's the use case?

Do you have control over both ends?  Are you writing both ends of the 
imitation tcp you're writing?

One of the car magazines published a road test of the Mercedes GT 
(garbage truck).  It had plenty of power, but its top speed was 6 mph, 
and it leaned horribly around the pylon obstacle course.  Not what I'd 
take to the race track.

Point is that a definitive specification of requirements will be much 
more useful than a simple wanna.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyrudp

2013-01-30 Thread Chris Angelico
On Thu, Jan 31, 2013 at 11:04 AM, Jorge Alberto Diaz Orozco
jaoro...@estudiantes.uci.cu wrote:
 I have restrictions in my system that does not allow me to use TCP, so I want 
 to make a pipe over UDP imitating TCP behavior.
 I have control over both endpoints, and I´m writing both of them.
 I just don´t want to re-invent the wheel and I´m looking for a reliable UDP 
 sockets implementation for Python so I can start from there.

Then... I think the place to start is here:

http://www.ietf.org/rfc/rfc793.txt

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


confusion with decorators

2013-01-30 Thread Jason Swails
Hello,

I was having some trouble understanding decorators and inheritance and all
that.  This is what I was trying to do:

# untested
class A(object):
   def _protector_decorator(fcn):
  def newfcn(self, *args, **kwargs):
 return fcn(self, *args, **kwargs)
  return newfcn

   @_protector_decorator
   def my_method(self, *args, **kwargs):
   do something here 

class B(A):
   def _protector_decorator(fcn):
  def newfcn(self, *args, **kwargs):
 raise MyException('I do not want B to be able to access the
protected functions')
  return newfcn

The goal of all that was to be able to change the behavior of my_method
inside class B simply by redefining the decorator. Basically, what I want
is B.my_method() to be decorated by B._protector_decorator, but in the code
I'm running it's decorated by A._protector_decorator.

I presume this is because once the decorator is applied to my_method in
class A, A.my_method is immediately bound to the new, 'decorated' function,
which is subsequently inherited (and not decorated, obviously), by B.

Am I correct here?  My workaround was to simply copy the method from class
A to class B, after which B._protector_decorator decorated the methods in
B.  While this doesn't make the use of decorators completely pointless (the
decorators actually do something in each class, it's just different), it
does add a bunch of code duplication which I was at one point hopeful to
avoid.

I'm still stumbling around with decorators a little, but this exercise has
made them a lot clearer to me.

Thanks!
Jason
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: confusion with decorators

2013-01-30 Thread Dave Angel

On 01/30/2013 07:34 PM, Jason Swails wrote:

Hello,

I was having some trouble understanding decorators and inheritance and all
that.  This is what I was trying to do:

# untested
class A(object):
def _protector_decorator(fcn):
   def newfcn(self, *args, **kwargs):
  return fcn(self, *args, **kwargs)
   return newfcn

@_protector_decorator
def my_method(self, *args, **kwargs):
do something here 

class B(A):
def _protector_decorator(fcn):
   def newfcn(self, *args, **kwargs):
  raise MyException('I do not want B to be able to access the
protected functions')
   return newfcn

The goal of all that was to be able to change the behavior of my_method
inside class B simply by redefining the decorator. Basically, what I want
is B.my_method() to be decorated by B._protector_decorator, but in the code
I'm running it's decorated by A._protector_decorator.

I presume this is because once the decorator is applied to my_method in
class A, A.my_method is immediately bound to the new, 'decorated' function,
which is subsequently inherited (and not decorated, obviously), by B.

Am I correct here?  My workaround was to simply copy the method from class
A to class B, after which B._protector_decorator decorated the methods in
B.  While this doesn't make the use of decorators completely pointless (the
decorators actually do something in each class, it's just different), it
does add a bunch of code duplication which I was at one point hopeful to
avoid.

I'm still stumbling around with decorators a little, but this exercise has
made them a lot clearer to me.




I'm certainly not the expert on decorators;  I've only used them for 
simple things.  But I think I can clear up one misconception.


The decorator function will execute while *compiling* the class A, and 
the one in class B is unreferenced.


The decorator @_protector_decorator is shorthand for something like
   mymethod = _protector_decorator(mymethod)

So by the time the compiler ends with class A, the mymethod has its 
final value.


(Note, I've not used a decorator that was defined inside a class, so I'm 
probably missing the appropriate A. or self. or cls. overrides.)
But the order of definition is still correct.  A decorator executes 
once, just after a function is completed.




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


Re: security quirk

2013-01-30 Thread alex23
On Jan 31, 5:39 am, RichD r_delaney2...@yahoo.com wrote:
 well yeah, but what's going on, under the hood?
 How does it get confused?  How could this
 happen?  I'm looking for some insight, regarding a
 hypothetical programmimg glitch -

As has been stated, this has nothing to do with Python, so please stop
posting your questions here.

However, here's an answer to get you to stop repeating yourself: it's
not uncommon to find that content you're restricted from accessing via
a site's own search is available to you through Google. This has to do
with Google's policy of _requiring_ that pages that it is allowed to
index _must_ be available for view. Any site that allows Google to
index its pages that then blocks you from viewing them will swiftly
find themselves web site-a non gratis in Google search. As most
websites are attention whores, they'll do anything to ensure they
remain within Google's indices.

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


Re: security quirk

2013-01-30 Thread Arne Vajhøj

On 1/29/2013 11:55 PM, RichD wrote:

I read Wall Street Journal, and occasionally check
articles on their Web site.  It's mostly free, with some items
available to subscribers only.  It seems random, which ones
they block, about 20%.

Anywho, sometimes I use their search utility, the usual author
or title search, and it blocks, then I look it up on Google, and
link from there, and it loads!  ok, Web gurus, what's going on?


WSJ want their articles to be findable from Google.

So they open up for Google indexing them.

If they require any type of registration to see an article,
then Google will remove the link.

So therefore WSJ (and many other web sites!) gives more access
if you come from Google than if not.

Arne


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


Re: help

2013-01-30 Thread Steven D'Aprano
aramilda...@gmail.com wrote:

 its giving me a bunch of errors thanks for the help in advance!

Yay! Guessing games! I love guessing games! Let me see if I can guess the
errors you have...

/usr/bin/python: bad interpreter: No such file or directory

You haven't actually got Python installed, or at least not where you think
it is.

Am I close? If not, I recommend that you actually show us the errors you are
getting.



-- 
Steven

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


Re: help

2013-01-30 Thread Dave Angel

On 01/30/2013 04:16 PM, aramilda...@gmail.com wrote:

Hi everyone! I don't mean to intrude, but ive heard great things about this 
group and ive stumped myself with my python code.

heres my code:
#! /usr/bin/python

import sys

global labelList
labelList= dict()

global counter
counter = 0

def execute(line):
 if line.find(::print) != -1:
 stripPrint = line.find(::print)
 startPrint = line.find('', stripPrint)
 stopPrint = line.find('', startPrint + 1)
 printSection = line[startPrint + 1 : stopPrint]
 print(printSection)

 if line.find(::label) != -1:
 stripLabel = line.find(::label)
 startLabel = line.find(' ', stripLabel)
 stopLabel = line.find('--', startLabel + 1)
 label = line[startLabel + 1 : stopLabel]
 line.strip(\r\n)
 labelList[label] = counter

if len(sys.argv)  2:
 print(error: no input files)
 print(compilation terminated)

else:
 fileName = sys.argv[1]
 jadeFile = open(fileName, 'r')

 for line in jadeFile:
 counter = counter + 1
 execute(line)

 jadeFile.close()

 i = 0

 while i  len(labelList):
 print(labelList.keys()[i], :, labelList.values()[i])
 i = i + 1


and its giving me a bunch of errors thanks for the help in advance!



davea@think2:~/temppython$ python aram.py
error: no input files
compilation terminated


These messages are triggered by sys.argv being less than 2.  Cure is to 
pass some string as the first argument on the command line.


Fixed that:

davea@think2:~/temppython$ ./aram.py  myfile.txt
Traceback (most recent call last):
  File ./aram.py, line 33, in module
jadeFile = open(fileName, 'r')
IOError: [Errno 2] No such file or directory: 'myfile.txt'

(notice that I pasted the full traceback into this message.)
Problem is that the program is treating that parameter as a filename, 
and I don't have a file by that filename.


davea@think2:~/temppython$ ./aram.py  aram.py
) != -1:
)
('stripLabel = line.find(::label)', ':', 20)
('!= -1:', ':', 19)

Worked perfectly.  Of course, nobody has said what it's supposed to do. 
 So anything that doesn't display an error must be okay.


How about describing what version of Python this is intended for, how 
you ran it, and what errors you're getting.  Don't paraphrase, don't 
summarize (lots of errors ???!), just copy/paste.


And if it's appropriate, show a sample data file for it to open, not 
attached, but pasted into your email message.


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


Re: pyrudp

2013-01-30 Thread Chris Angelico
On Thu, Jan 31, 2013 at 3:26 PM,  w...@mac.com wrote:
 Now, the good news is that because UDP-based protocols all run in user memory 
 space (as opposed to TCP that runs privileged in kernel space) it is 
 relatively straightforward for non-privledged users to write and test UDP 
 transport schemes and this has become a fairly standard CS exercise at the 
 graduate level.  If I were in your shoes, I'd start Googling for the papers 
 published on protocols like HURRICANE, ATAU, or even just the general subject 
 of UDP transport protocols.


I'd still include reading up on TCP. The RFC has a good bit about why
things are the way they are; when you're designing a protocol that
does similar things, it's worth getting an understanding of what your
predecessors did. Either you'll get some ideas (yeah, that's how I'll
do it!) or you'll decide you can do better, but it's still worth a
read.

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


Re: looping versus comprehension

2013-01-30 Thread Steven D'Aprano
On Thu, 31 Jan 2013 02:49:31 +1100, Chris Angelico wrote:

 it's worth
 noting that list appending is not going to be O(N*N), because it's going
 to allow room for expansion.

This is true for list.append, which is amortized constant time. But it is 
not true for list addition, alist + blist, which is O(N**2) and hence 
gets really, really slow:

steve@runes:~$ python -m timeit L = [] for i in xrange(1000): L = L + [1]
100 loops, best of 3: 3.08 msec per loop
steve@runes:~$ python -m timeit L = [] for i in xrange(5000): L = L + [1]
10 loops, best of 3: 71 msec per loop
steve@runes:~$ python -m timeit L = [] for i in xrange(25000): L = L + [1]
10 loops, best of 3: 2.06 sec per loop


Notice that as the number of list additions goes up by a factor of 5, 
the time taken goes up by a factor of 25.

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


Re: pyrudp

2013-01-30 Thread wrw
On Jan 30, 2013, at 7:14 PM, Chris Angelico ros...@gmail.com wrote:

 On Thu, Jan 31, 2013 at 11:04 AM, Jorge Alberto Diaz Orozco
 jaoro...@estudiantes.uci.cu wrote:
 I have restrictions in my system that does not allow me to use TCP, so I 
 want to make a pipe over UDP imitating TCP behavior.
 I have control over both endpoints, and I´m writing both of them.
 I just don´t want to re-invent the wheel and I´m looking for a reliable UDP 
 sockets implementation for Python so I can start from there.
 
 Then... I think the place to start is here:
 
 http://www.ietf.org/rfc/rfc793.txt
 
 ChrisA
 -- 
 http://mail.python.org/mailman/listinfo/python-list

I think you really ought to think about this long and hard.  Although TCP 
started as a fairly simple-minded protocol designed to guarantee reliable 
delivery of packets in the order in which they were transmitted, it has evolved 
considerably over the years.  It now incorporates concepts of fairness and a 
very sophisticated rate control system that is constantly probing available 
network bandwidth to be sure it isn't over driving or hogging the network 
connection.  It would be easy to say: I really don't need all that - all I'm 
doing is X. - but in reality you do, and getting reliable delivery over UDP 
really does require it all.

Now, the good news is that because UDP-based protocols all run in user memory 
space (as opposed to TCP that runs privileged in kernel space) it is relatively 
straightforward for non-privledged users to write and test UDP transport 
schemes and this has become a fairly standard CS exercise at the graduate 
level.  If I were in your shoes, I'd start Googling for the papers published on 
protocols like HURRICANE, ATAU, or even just the general subject of UDP 
transport protocols.  Two places you might start are:

  http://www.ogf.org/documents/GFD.55.pdf 

and

  http://www.ornl.gov/~webworks/cppr/y2001/rpt/121150.pdf

Most, if not all of these UDP schemes are in the public domain, have been 
written in high-level languages, and could be translated into python.

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


Re: confusion with decorators

2013-01-30 Thread Steven D'Aprano
On Wed, 30 Jan 2013 19:34:03 -0500, Jason Swails wrote:

 Hello,
 
 I was having some trouble understanding decorators and inheritance and 
 all that.  This is what I was trying to do:
 
 # untested
 class A(object):
def _protector_decorator(fcn):
   def newfcn(self, *args, **kwargs):
  return fcn(self, *args, **kwargs)
   return newfcn

Well, that surely isn't going to work, because it always decorates the 
same function, the global fcn. 

You probably want to add an extra parameter to the newfcn definition:

def newfcn(self, fcn, *args, **kwargs):


Also, I trust you realise that this is a pointless decorator that doesn't 
do anything useful? It just adds an extra layer of indirection, without 
adding any functionality.


   @_protector_decorator
   def my_method(self, *args, **kwargs):
   do something here 

 class B(A):
   def _protector_decorator(fcn):
   def newfcn(self, *args, **kwargs):
  raise MyException('I do not want B to be able to access the
 protected functions')
   return newfcn


That's not going to work, because B's _protector_decorator never gets 
called. True, it overrides A's _protector_decorator, but too late. A has 
already used it to decorate the methods, and B does not override those 
methods, so A's version are inherited.

But even if it could work, it relies on class B protecting class A from 
B. All B needs do to overcome the protection is ... *not* define the 
magic decorator.


 The goal of all that was to be able to change the behavior of my_method
 inside class B simply by redefining the decorator. Basically, what I
 want is B.my_method() to be decorated by B._protector_decorator, but in
 the code I'm running it's decorated by A._protector_decorator.

Yes. Remember that you don't have a B.my_method, so B merely inherits 
A.my_method.


 I presume this is because once the decorator is applied to my_method in
 class A, A.my_method is immediately bound to the new, 'decorated'
 function, which is subsequently inherited (and not decorated,
 obviously), by B.

Correct.

 Am I correct here?  My workaround was to simply copy the method from
 class A to class B, after which B._protector_decorator decorated the
 methods in B.

That's not a work-around, that's an anti-pattern.

Why is B inheriting from A if you don't want it to be able to use A's 
methods? That's completely crazy, if you don't mind me saying so. If you 
don't want B to access A's methods, simply don't inherit from A.

I really don't understand what you are trying to accomplish here. 
Possibly Java.

http://dirtsimple.org/2004/12/python-is-not-java.html
http://dirtsimple.org/2004/12/java-is-not-python-either.html


But you can accomplish something close to what you are after like this:


import functools

def decorate(func):
@functools.wraps(func)
def inner(self, *args, **kwargs):
protector = getattr(self, '_protect', None)
if protector is not None:
protector()
return func(self, *args, **kwargs)
return inner


class A(object):
@decorate
def mymethod(self):
Do something useful.


class B(A):
def _protect(self):
raise RuntimeError(I'm sorry Dave, I'm afraid I cannot do that.)



Try studying that to see how it works, and then try studying it to 
realise how pointless it is, since it too relies on class B protecting 
class A from B.


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


[issue17080] A better error message for float()

2013-01-30 Thread Jonathan Livni

New submission from Jonathan Livni:

These lines of Python (2.7):

y = float(x)

gives the error:

TypeError: float() argument must be a string or a number.

In various cases such as:

x = [0]
x = None
x = SomeClass()

In addition to the information given in the error message, it could help, for 
debugging purposes, to state the type of the object given.

--
components: Interpreter Core
messages: 180967
nosy: Jonathan.Livni
priority: normal
severity: normal
status: open
title: A better error message for float()
type: enhancement
versions: Python 2.7

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



[issue17080] A better error message for float()

2013-01-30 Thread Ezio Melotti

Ezio Melotti added the comment:

Sounds reasonable to me.

--
nosy: +ezio.melotti
stage:  - needs patch
versions: +Python 3.4 -Python 2.7

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



[issue17080] A better error message for float()

2013-01-30 Thread Kushal Das

Changes by Kushal Das kushal...@gmail.com:


--
nosy: +kushaldas

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



[issue17080] A better error message for float()

2013-01-30 Thread Ezio Melotti

Ezio Melotti added the comment:

Here's an initial patch, still needs tests.
The same should be done for complex() too.
Maybe it could be applied to older branches too.

--
assignee:  - ezio.melotti
keywords: +patch
Added file: http://bugs.python.org/file28907/issue17080.diff

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



[issue16989] allow distutils debug mode to be enabled more easily

2013-01-30 Thread Chris Jerdonek

Chris Jerdonek added the comment:

I meant to comment on the patch earlier.

The fix here isn't as simple as I had originally suggested.  The patch has to 
be constructed more carefully to be more fully backwards compatible.  For 
example, it shouldn't break code that imports DEBUG from modules, or that sets 
DEBUG on other modules.  The test case you found is an example of the former.

--

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



[issue16989] allow distutils debug mode to be enabled more easily

2013-01-30 Thread Chris Jerdonek

Changes by Chris Jerdonek chris.jerdo...@gmail.com:


--
keywords:  -easy

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



[issue17081] documentation

2013-01-30 Thread wohugb

Changes by wohugb woh...@qq.com:


--
assignee: docs@python
components: Documentation
nosy: docs@python, wohugb
priority: normal
severity: normal
status: open
title: documentation
versions: Python 3.3

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



[issue17080] A better error message for float()

2013-01-30 Thread Antoine Pitrou

Antoine Pitrou added the comment:

You should put single quotes around the type name, i.e.:

float() argument must be a string or a number, not '%.200s'

--
nosy: +pitrou
stage: needs patch - patch review

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



[issue17080] A better error message for float()

2013-01-30 Thread Ezio Melotti

Ezio Melotti added the comment:

I was thinking about that but in other places they are not used.  Adding them 
is OK though.

--

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



[issue17081] documentation

2013-01-30 Thread Chris Jerdonek

Changes by Chris Jerdonek chris.jerdo...@gmail.com:


--
resolution:  - invalid
stage:  - committed/rejected
status: open - closed

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



[issue17056] Support Visual Studio 2012

2013-01-30 Thread Trent Nelson

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


--
nosy: +trent

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



[issue17077] Fix test_tools hangs

2013-01-30 Thread Jeremy Kloth

Jeremy Kloth added the comment:

It hangs on both my Windows buildbot and development machine.

The patch is tested and works correctly on Windows.

--

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



[issue16903] subprocess.Popen.communicate with universal_newlines=True doesn't accept strings on 3.2

2013-01-30 Thread Jeremy Kloth

Jeremy Kloth added the comment:

I would suggest that this be bumped to release blocker as currently passing 
bytes to communicate with universal_newlines=True on Windows causes the process 
to hang (see issue17077).

The backported test case passes on Windows without any changes to subprocess.py 
so this is a POSIX-only bug.

--
nosy: +jkloth

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



[issue17077] Fix test_tools hangs

2013-01-30 Thread STINNER Victor

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


--
nosy: +haypo

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



[issue16903] subprocess.Popen.communicate with universal_newlines=True doesn't accept strings on 3.2

2013-01-30 Thread STINNER Victor

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


--
nosy: +haypo

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



[issue17077] Fix test_tools hangs

2013-01-30 Thread Serhiy Storchaka

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


--
assignee:  - serhiy.storchaka
dependencies: +subprocess.Popen.communicate with universal_newlines=True 
doesn't accept strings on 3.2
stage:  - patch review
type:  - behavior

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



[issue16903] subprocess.Popen.communicate with universal_newlines=True doesn't accept strings on 3.2

2013-01-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Indeed, Popen.communicate() is incompatible not only between 3.2 and 3.3, but 
between Windows and POSIX too.

Documentation says the input argument should be a bytes string and 3.2 on POSIX 
works only with bytes strings. 3.2 on Windows and 3.3 on both platforms require 
an unicode string, as 3.3 documentation says. 3.2 on Windows hangs with a bytes 
string.

Patch updated with the documentation change (copied from 3.3).

--
priority: normal - critical
Added file: 
http://bugs.python.org/file28908/subprocess_communicate_string-3.2_2.patch

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



[issue17015] mock could be smarter and inspect the spec's signature

2013-01-30 Thread Michael Foord

Michael Foord added the comment:

Wow, impressive work Antoine - thanks. I am a little concerned that this relies 
on Python 3 only features of inspect, and *in fact* relies on bug fixes in 
Python 3.4 to work. That means it would be hard / impossible for the backport 
mock to have the new feature. That may be solveable (there is a backport of 
function signatures which mock could use for example).

--

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



[issue16997] subtests

2013-01-30 Thread Michael Foord

Michael Foord added the comment:

I am concerned that this feature changes the TestResult API in a backwards 
incompatible way. There are (quite a few) custom TestResult  objects that just 
implement the API and don't inherit from TestResult. I'd like to try this new 
code with (for example) the test result provided by the junitxml project and 
see what happens.

I have a broader concern too. I have seen lots of requests for test 
parameterization and none *specifically* for sub tests. They are very similar 
mechanisms (with key differences), so I don't think we want *both* in unittest. 
If test parameterization is more powerful / flexible then I would rather see 
that *instead*. 

On the other hand if subtests are *better* then lets have them instead - but 
I'd like to see that discussion happen before we just jump into subtests.

--

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



[issue16997] subtests

2013-01-30 Thread Michael Foord

Michael Foord added the comment:

Note, some brief discussion on the testing in python mailing list:

http://lists.idyll.org/pipermail/testing-in-python/2013-January/005356.html

--

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



[issue17082] Fix test discovery for test_dbm*.py

2013-01-30 Thread Zachary Ware

New submission from Zachary Ware:

This patch fixes discovery for test_dbm.py and removes test_main() from 
test_dbm, test_dbm_dumb, test_dbm_gnu, and test_dbm_ndbm.

It also removes unnecessary __init__ methods from DumbDBMTestCase and 
WhichDBTestCase, which only called unittest.TestCase.__init__ with all supplied 
arguments.

--
components: Tests
files: test_dbm-s_discovery.diff
keywords: patch
messages: 180979
nosy: brett.cannon, ezio.melotti, zach.ware
priority: normal
severity: normal
status: open
title: Fix test discovery for test_dbm*.py
type: behavior
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file28909/test_dbm-s_discovery.diff

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



[issue17015] mock could be smarter and inspect the spec's signature

2013-01-30 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 I am a little concerned that this relies on Python 3 only features of
 inspect, and *in fact* relies on bug fixes in Python 3.4 to work.

The bug fix has landed in 3.3 as well ;-)
(see 49fd1c8aeca5)
I guess a backport of inspect.signature() would allow it to work on previous 
Pythons, too.

--

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



[issue17015] mock could be smarter and inspect the spec's signature

2013-01-30 Thread Michael Foord

Michael Foord added the comment:

Ah, well if the bugfix exists everywhere that function signatures exist then it 
shouldn't be a problem. (I think there is already a backport of 
inspect.signature() by Nick Coghlan.)

--

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



[issue16997] subtests

2013-01-30 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 I am concerned that this feature changes the TestResult API in a
 backwards incompatible way. There are (quite a few) custom TestResult
 objects that just implement the API and don't inherit from TestResult.
 I'd like to try this new code with (for example) the test result
 provided by the junitxml project and see what happens.

Feel free to do it, of course :-)
In any case, we can add a hook to the TestCase subclass so that
specialized reporters can get at the parent TestCase.

(and I'm not sure how it's backwards incompatible: as long as you don't
use subtests, nothing should break - so existing software shouldn't be
affected)

 I have a broader concern too. I have seen lots of requests for test
 parameterization and none *specifically* for sub tests. They are very
 similar mechanisms (with key differences), so I don't think we want
 *both* in unittest. If test parameterization is more powerful /
 flexible then I would rather see that *instead*. 

The underlying idea of subtests is if you want to parameterize a test,
here is a useful building block. Generic parameterization APIs are
cumbersome and actually *harder* to write (and read!) than the
corresponding `for` loop. With subtests, you just write your `for` loop
and use a subtest to isolate each iteration's failures.

--

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



[issue1783] nonexistent data items declared as exports in sysmodule.h

2013-01-30 Thread Serhiy Storchaka

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


--
keywords: +patch
Added file: http://bugs.python.org/file28910/sysmodule_h_cleanup-2.7.patch

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



[issue1783] nonexistent data items declared as exports in sysmodule.h

2013-01-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here are patches.

--
assignee:  - serhiy.storchaka
keywords: +easy
nosy: +serhiy.storchaka
stage: needs patch - patch review
versions: +Python 3.2, Python 3.3, Python 3.4 -Python 3.1
Added file: http://bugs.python.org/file28911/sysmodule_h_cleanup-3.x.patch

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



[issue17083] can't specify newline string for readline for binary files

2013-01-30 Thread Bryant

New submission from Bryant:

When opening binary files in Python 3, the newline parameter cannot be set. 
While this kind of makes sense, readline() can still be used on binary files. 
This is great for my usage, but it is doing universal newline mode, I believe, 
so that any \r, \n, or \r\n triggers an EOL.

The data I'm working with is mixed ASCII/binary, with line termination 
specified by \r\n. I can't read a line (even though that concept occurs in my 
file) because some of the binary data includes \r or \n even though they aren't 
newlines in this context.

The issue here is that if the newline string can't be specified, readline() is 
useless on binary data, which often uses custom EOL strings. So would it be 
reasonable to add the newline parameter support to binary files? If not, then 
shouldn't readline() throw an exception when used on binary files?

I don't know if it's helpful here, but I've written a binary_readline() 
function supporting arbitrary EOL strings:

def binary_readline(file, newline=b'\r\n'):
line = bytearray()
newlineIndex = 0
while True:
x = file.read(1)
if x:
line += x
else:
if len(line) == 0:
return None
else:
return line
# If this character starts to match the newline string, start that 
comparison til it matches or doesn't.
while line[-1] == newline[newlineIndex]:
x = file.read(1)
if x:
line += x
else:
return line
newlineIndex += 1
if newlineIndex == len(newline):
return line
   
# We failed checking for the newline string, so reset the checking index
newlineIndex = 0

--
components: Library (Lib)
messages: 180984
nosy: susurrus
priority: normal
severity: normal
status: open
title: can't specify newline string for readline for binary files
type: behavior
versions: Python 3.3

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



[issue16997] subtests

2013-01-30 Thread Chris Jerdonek

Chris Jerdonek added the comment:

 I am concerned that this feature changes the TestResult API in a backwards 
 incompatible way.

My suggestion to add the original TestCase object to TestResult.errors, etc. 
instead and add the extra failure data to the longDescription would address 
this concern, which is why I suggested it.  The former is what currently 
happens with multiple failures per TestCase (e.g. in runTest() and tearDown()).

 The underlying idea of subtests is if you want to parameterize a test,
here is a useful building block.

The current API doesn't seem like a good building block because it bundles 
orthogonal features (i.e. to add loop failure data to a block of asserts you 
have to use the continuance feature).  Why not expose *those* as the building 
blocks?  The API can be something like--

with self.addMessage(msg):
# Add msg to the longDescription of any assertion failure within.

with self.continueTest(msg=''):
# Keep running the TestCase on any assertion failure within.

(The current subTest() is basically equivalent to continueTest() with a 
specialized message.  It could be added, too, if desired.)  Accepting a string 
message is more basic and flexible than allowing only a **kwargs dict, which 
seems a bit cute and specialized to me.

--

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



[issue16997] subtests

2013-01-30 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 The current API doesn't seem like a good building block because it
 bundles orthogonal features (i.e. to add loop failure data to a block
 of asserts you have to use the continuance feature).  Why not expose
 *those* as the building blocks?  The API can be something like--
 
 with self.addMessage(msg):
 # Add msg to the longDescription of any assertion failure
 within.
 
 with self.continueTest(msg=''):
 # Keep running the TestCase on any assertion failure within.
 
 (The current subTest() is basically equivalent to continueTest() with
 a specialized message.  It could be added, too, if desired.)
 Accepting a string message is more basic and flexible than allowing
 only a **kwargs dict, which seems a bit cute and specialized to me.

I've already replied to all this.

--

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



[issue17084] nntplib.NNTP.xover does not always return results as documented

2013-01-30 Thread David Holm

New submission from David Holm:

The response from NNTP.xover doesn't always match the format described in the 
documentation. It is supposed to return a (result, list) where the list 
contains entries of the format (article number, subject, poster, date, id, 
references, size, lines). However, I have found it to sometimes split the 
subject into two entries or only one of multiple references being in a list 
(see example below).

I am attempting to interpret the data using an enum-like structure to match the 
indices to the values but it fails very often because the date field contains 
part of the subject or the size field contains a cross reference entry.

Example using Python 2.7:

 import nntplib
 c = nntplib.NNTP(..)
 c.group('alt.binaries.linux')
('211 317334 3 317336 alt.binaries.linux', '317334', '3', '317336', 
'alt.binaries.linux')
 resp, lst = c.xover('114179', '114179')
 print resp
224 data follows
 print lst
[('114179', 'Re: Newsposter - The Linux Binary Posting Script Version 7.2', 
'Patriot americ...@shangri.la.org', 'Mon, 04 Jan 2010 17:36:44 -0600', 
'cu-dnfpxgcsr5t_wnz2dnuvz_rbi4...@giganews.com', 
['5aydnt9obm20bkrwnz2dnuvz_v2dn...@giganews.com'], 
'XGa0n.15891$0u1.11...@newsfe16.iad', '1443')]

In the example above 'XGa0n.15891$0u1.11...@newsfe16.iad' can be found at 
index 6 where the size is supposed to be.

--
components: Library (Lib)
messages: 180987
nosy: dholm
priority: normal
severity: normal
status: open
title: nntplib.NNTP.xover does not always return results as documented
type: behavior
versions: Python 2.7

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



[issue17083] can't specify newline string for readline for binary files

2013-01-30 Thread R. David Murray

R. David Murray added the comment:

If you are reading in binary mode, then all readline does is get you the next 
\n terminated chunk of data, which is a convenience in some circumstances.  You 
have to do all the newline handling yourself.  Otherwise it isn't a binary read.

I think the right way to do what you want is to write a custom subclass of 
one of the IO classes.  Should such a subclass be added to Python?  That's an 
interesting question.  A first step toward an answer might be to post it as a 
recipe on the ActiveState site and see how many people find it useful.

--
nosy: +r.david.murray
type: behavior - enhancement

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



[issue16997] subtests

2013-01-30 Thread Chris Jerdonek

Chris Jerdonek added the comment:

 I've already replied to all this.

You didn't respond to the idea of exposing both features separately after 
saying you didn't understand what I meant and saying that they were pointless 
and didn't make sense.  So I explained and also proposed a specific API to make 
the suggestion clearer and more concrete.  These don't seem pointless to me at 
all.

--

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



[issue17044] Implement PEP 422: Simple class initialisation hook

2013-01-30 Thread Daniel Urban

Daniel Urban added the comment:

I'm attaching a new patch with some documentation and one additional test.

--
Added file: http://bugs.python.org/file28912/pep422_3.patch

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



[issue16997] subtests

2013-01-30 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 You didn't respond to the idea of exposing both features separately
 after saying you didn't understand what I meant and saying that they
 were pointless and didn't make sense.  So I explained and also
 proposed a specific API to make the suggestion clearer and more
 concrete.

Well, suffice to say that I wasn't convinced at all. There are multiple
use cases for subtests in the Python test suite, but I can't think of
any for your proposed API separation. That's why I find it
uninteresting.

I'm making this proposal to solve a concrete issue, not in the interest
of minimalism. Building block was to be understood in that sense. Unit
testing is one of those areas where purity is a secondary concern.

--

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



[issue15633] httplib.response is not closed after all data has been read

2013-01-30 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Here is a patch for 2.7.
Ideally, we would raise IncompleteRead in this situation, but this would break 
existing programs.

--
keywords: +patch
stage:  - patch review
versions: +Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file28913/http_truncated_body.patch

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



[issue17085] test_socket crashes the whole test suite

2013-01-30 Thread ddve...@ucar.edu

New submission from ddve...@ucar.edu:

While running make test on my build of python 2.7.3 the suite aborts with

[..omiss..]
test_socket
make: *** [test] Alarm clock

Trying to run individually the offending test reveals a little more


$ ./python Lib/test/regrtest.py -v test_socket
== CPython 2.7.3 (default, Jan 29 2013, 11:23:48) [GCC 4.7.2]
==   Linux-2.6.32-220.13.1.el6.x86_64-x86_64-with-redhat-6.2-Santiago 
little-endian
==   /glade/scratch/ddvento/build/Python-2.7.3-westmere/build/test_python_12171
Testing with flags: sys.flags(debug=0, py3k_warning=0, division_warning=0, 
division_new=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, 
no_user_site=0, no_site=0, ignore_environment=0, tabcheck=0, verbose=0, 
unicode=0, bytes_warning=0, hash_randomization=0)
test_socket
TIPC module is not loaded, please 'sudo modprobe tipc'
testCrucialConstants (test.test_socket.GeneralModuleTests) ... ok
testDefaultTimeout (test.test_socket.GeneralModuleTests) ... ok
testGetServBy (test.test_socket.GeneralModuleTests) ... ok
testGetSockOpt (test.test_socket.GeneralModuleTests) ... ok
testGetaddrinfo (test.test_socket.GeneralModuleTests) ... ok
testHostnameRes (test.test_socket.GeneralModuleTests) ... ok
testIPv4_inet_aton_fourbytes (test.test_socket.GeneralModuleTests) ... ok
testIPv4toString (test.test_socket.GeneralModuleTests) ... ok
testIPv6toString (test.test_socket.GeneralModuleTests) ... ok
testInterpreterCrash (test.test_socket.GeneralModuleTests) ... ok
testListenBacklog0 (test.test_socket.GeneralModuleTests) ... ok
testNewAttributes (test.test_socket.GeneralModuleTests) ... ok
testNtoH (test.test_socket.GeneralModuleTests) ... ok
testNtoHErrors (test.test_socket.GeneralModuleTests) ... ok
testRefCountGetNameInfo (test.test_socket.GeneralModuleTests) ... ok
testSendAfterClose (test.test_socket.GeneralModuleTests) ... ok
testSendtoErrors (test.test_socket.GeneralModuleTests) ... ok
testSetSockOpt (test.test_socket.GeneralModuleTests) ... ok
testSockName (test.test_socket.GeneralModuleTests) ... ok
testSocketError (test.test_socket.GeneralModuleTests) ... ok
testStringToIPv4 (test.test_socket.GeneralModuleTests) ... ok
testStringToIPv6 (test.test_socket.GeneralModuleTests) ... ok
test_flowinfo (test.test_socket.GeneralModuleTests) ... ok
test_getsockaddrarg (test.test_socket.GeneralModuleTests) ... ok
test_sendall_interrupted (test.test_socket.GeneralModuleTests) ... FAIL
test_sendall_interrupted_with_timeout (test.test_socket.GeneralModuleTests) ... 
FAIL
test_sock_ioctl (test.test_socket.GeneralModuleTests) ... skipped 'Windows 
specific'
test_weakref (test.test_socket.GeneralModuleTests) ... ok
testDup (test.test_socket.BasicTCPTest) ... ok
testFromFd (test.test_socket.BasicTCPTest) ... ok
testOverFlowRecv (test.test_socket.BasicTCPTest) ... ok
testOverFlowRecvFrom (test.test_socket.BasicTCPTest) ... ok
testRecv (test.test_socket.BasicTCPTest) ... ok
testRecvFrom (test.test_socket.BasicTCPTest) ... ok
testSendAll (test.test_socket.BasicTCPTest) ... ok
testShutdown (test.test_socket.BasicTCPTest) ... ok
testClose (test.test_socket.TCPCloserTest) ... Alarm clock

$ echo $?
142

Of course my installation has an issue (which I'm trying to identify), but the 
test suite should not crash on a failure of individual test. I believe this is 
related to Issue1326841 in that the test author forgot to install the signal 
handler, or maybe was expecting the behavior Paul Rubin suggested in said bug.

--
components: Tests
messages: 180993
nosy: ddve...@ucar.edu
priority: normal
severity: normal
status: open
title: test_socket crashes the whole test suite
versions: Python 2.7

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



[issue17083] can't specify newline string for readline for binary files

2013-01-30 Thread Bryant

Bryant added the comment:

I'm not terribly worried about the right way for me to deal with my code, but 
that Python, in this instance, is inconsistent. While it doesn't want you to 
apply the concept of a line to a binary file in that it prevents you from 
specifying an EOL string, it does allow you to read that file as lines.

So my question is why shouldn't I be able to specify a newline of b\r\n and 
then use readline() on my binary file? I don't see why that concept shouldn't 
be applied here when it's definitely applicable in a lot of cases (any binary 
log format).

To resolve this I really think there're two options to maintain the consistency 
of Python's approach:
 1) Have readline() error out for binary-mode files.
 2) Allow specifying a byte-string as the newline string for binary files that 
readline() would then use.

--

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



[issue17028] launcher does not read shebang line when arguments are given

2013-01-30 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

An entry in Misc/NEWS would be nice.

--
nosy: +amaury.forgeotdarc

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



[issue17028] launcher does not read shebang line when arguments are given

2013-01-30 Thread STINNER Victor

STINNER Victor added the comment:

A test would also be nice :-)

--
nosy: +haypo

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



[issue17028] launcher does not read shebang line when arguments are given

2013-01-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 58e72cb89848 by Vinay Sajip in branch 'default':
Updated NEWS with fix for #17028.
http://hg.python.org/cpython/rev/58e72cb89848

--

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



[issue17086] backport cross-build patches to the 2.7 branch

2013-01-30 Thread Matthias Klose

New submission from Matthias Klose:

I would like to check in a backport of the cross build patches on Thu or Fri, 
so that these can be checked for the upcoming 2.7.4 release.  The backport was 
made using the current state of the cross build support on the 3.3 branch.

The patch is tested with native builds on linux, and a cross build targeting 
arm-linux-gnueabihf.

--
assignee: doko
files: cross-2.7.diff
keywords: patch
messages: 180998
nosy: benjamin.peterson, doko
priority: normal
severity: normal
status: open
title: backport cross-build patches to the 2.7 branch
versions: Python 2.7
Added file: http://bugs.python.org/file28914/cross-2.7.diff

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



[issue17087] Improve the repr for regular expression match objects

2013-01-30 Thread Raymond Hettinger

New submission from Raymond Hettinger:

Experience teaching Python has shown that people have a hard time learning to 
work with match objects.  A contributing cause is the opaque repr:

 import re
 s = 'On 3/14/2013, Python celebrate Pi day.'
 mo = re.search(r'\d+/\d+/\d+', s)
 mo
_sre.SRE_Match object at 0x100456100

They could explore the match object with dir() and help() and the matchobject 
methods and attributes:

 dir(mo)
['__class__', '__copy__', '__deepcopy__', ...
 'end', 'endpos', 'expand', 'group', ... ]
 
 mo.start()
3
 mo.end()
12
 mo.group(0)
'3/14/2013'

However, this gets old when experimenting with alternative regular expressions. 
 A better solution is to improve the repr:

 re.search(r'\d+/\d+/\d+', s)
SRE Match object: start=3, stop=12, group(0)='3/14/2013'

This would make the regular expression module much easier to work with.

--
components: Library (Lib)
messages: 180999
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Improve the repr for regular expression match objects
type: enhancement
versions: Python 3.4

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



[issue17086] backport cross-build patches to the 2.7 branch

2013-01-30 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Did you mean to add that config.guess file?

--

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



  1   2   >