Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-25 Thread wxjmfauth
Le mardi 25 février 2014 00:55:36 UTC+1, Steven D'Aprano a écrit :
 
 
 
 However, you don't really want to be adding large numbers of byte strings 
 
 together, due to efficiency. Better to use % interpolation to insert them 
 
 all at once. Hence the push to add % to bytes in Python 3.
 
 

 timeit.timeit('abc' * 1000 + '\u20ac')
2.3244550589543564
 timeit.timeit(x * 1000 + y, x = 'abc'.encode('utf-8'); y = 
 '\u20ac'.encode('utf-8'))
0.9365105183684364
 timeit.timeit('\u0153' + 'abc' * 1000 + '\u20ac')
3.0469319226397715
 timeit.timeit(z + x * 1000 + y, x = 'abc'.encode('utf-8'); y = 
 '\u20ac'.encode('utf-8'); z = '\u0153'.encode('utf-8'))
1.9215464486771339
 

Interpolation will not help.

What is wrong by design will always stay wrong by design.

jmf


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


Re: Python 3.5, bytes, and %-interpolation (aka PEP 461)

2014-02-25 Thread Mark Lawrence

On 25/02/2014 08:07, wxjmfa...@gmail.com wrote:


What is wrong by design will always stay wrong by design.



Why are you making the statement that PEP 461 is wrong by design?


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


Mark Lawrence

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


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


Re: Coding a simple state machine in python

2014-02-25 Thread Mark Lawrence

On 25/02/2014 05:19, alex23 wrote:

On 25/02/2014 1:27 PM, Tim Daneliuk wrote:

On 02/24/2014 08:55 PM, William Ray Wing wrote:

On Feb 24, 2014, at 8:30 PM, Ronaldo abhishek1...@gmail.com wrote:

How do I write a state machine in python?

 

Stackoverflow has a couple of compact examples here:


Now you're making it TOO easy Bill ;)


No, the _easy_ solution is:

https://pypi.python.org/pypi?%3Aaction=searchterm=state++machinesubmit=search



Or several recipes on Activestate.

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


Mark Lawrence

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


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


Re: Python powerpoint automation using pywin32

2014-02-25 Thread Mark Lawrence

On 25/02/2014 03:52, Jaydeep Patil wrote:

On Monday, 24 February 2014 17:27:23 UTC+5:30, sffj...@gmail.com  wrote:

On Monday, 24 February 2014 11:35:08 UTC, Jaydeep Patil  wrote:


I need to create a new powerpoint presentation. I need to add images, paste 
some graphs, add texts, tables into powerpoint.







Is any link or document available which help me to do this work more effectivey 
 faster.




Always remember, PyPi is your friend.



I've not used it but the following is available which works with Microsoft's 
XML based document types. It is not automation per se (and doesn't use pywin32) 
but a library for pptx document manipulation.



https://pypi.python.org/pypi/python-pptx/



Docs are here



https://python-pptx.readthedocs.org/en/latest/



--Simon



Hi Simon,

I need to use COM interface for PowerPoint generation.

So let me know any related docs?


Regards
Jaydeep



I don't need to read double spaced stuff so please read and action this 
https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing it, 
thanks.


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


Mark Lawrence

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


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


Re: Coding a simple state machine in python

2014-02-25 Thread Peter Otten
alex23 wrote:

 On 25/02/2014 1:27 PM, Tim Daneliuk wrote:
 On 02/24/2014 08:55 PM, William Ray Wing wrote:
 On Feb 24, 2014, at 8:30 PM, Ronaldo abhishek1...@gmail.com wrote:
 How do I write a state machine in python?
  
 Stackoverflow has a couple of compact examples here:

 Now you're making it TOO easy Bill ;)
 
 No, the _easy_ solution is:
 
 
https://pypi.python.org/pypi?%3Aaction=searchterm=state++machinesubmit=search

Easy? By the time I have evaluated these I've written my own ;)

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


Re: Coding a simple state machine in python

2014-02-25 Thread Peter Otten
William Ray Wing wrote:

 
 On Feb 24, 2014, at 8:30 PM, Ronaldo abhishek1...@gmail.com wrote:
 
 How do I write a state machine in python? I have identified the states
 and the conditions. Is it possible to do simple a if-then-else sort of an
 algorithm? Below is some pseudo code:
 
 if state == ABC:
   do_something()
   change state to DEF
 
 if state == DEF
   perform_the_next_function()
 ...
 
 I have a class to which certain values are passed from a GUI and the
 functions above have to make use of those variables. How do I go about
 doing this? I have the following algorithm:
 
 class TestClass():
def __init__(self, var1, var2): #var1 and var2 are received from a GUI
   self.var1 = var1
 ...
if state == ABC
   doSomething(var1, var2)
 ..
 
 Could someone point me in the right direction? Thank you!
 
 --
 https://mail.python.org/mailman/listinfo/python-list
 
 And, to extend Tim's suggestion of a dictionary just a bit, note that
 since Python functions are happy to pass function names as arguments, you
 can use a dictionary to make a really nice compact dispatch table.  That
 is, function A does its thing, gets to a new state, and returns as one of
 its return arguments the key into the dictionary that points to the next
 function_name to be called based on that new state.
 
 Stackoverflow has a couple of compact examples here:
 
 http://stackoverflow.com/questions/715457/how-do-you-implement-a-dispatch-
table-in-your-language-of-choice

Why have the function return a name? Why not just another function?


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


Re: SSH/Telnet program to Router/switch

2014-02-25 Thread Ferrous Cranus
Τη Τετάρτη, 19 Φεβρουαρίου 2014 10:45:53 π.μ. UTC+2, ο χρήστης Wojciech Łysiak 
έγραψε:
 On 19.02.2014 09:14, Sujith S wrote:
 
  Hi,
 
  
 
  I am new to programming and python. I am looking for a python script to do 
  ssh/telnet to a network equipment ? I know tcl/perl does this using 
  expect/send. 
 
  
 
  Do we have expect available in python as well or need to use some other 
  method ?
 
 
 
 Hello,
 
  If you are looking for a way to connect to your netdevices and then
 
 execute some shell commands (with output) via ssh then google for
 
 paramiko module for python.
 
 
 
 It works on windows and linux.
 
 
 
 -- 
 
 BR,
 
 Wojtek

Hello,

What will benefit the OP to go ahead and use paramiko opposed to just use 
Putty or another perhaps even Chrome based ssh client?

Is there an advantage to that?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Coding a simple state machine in python

2014-02-25 Thread Marko Rauhamaa
Peter Otten __pete...@web.de:
 Why have the function return a name? Why not just another function?

As people have said, there are many ways to skin the cat.

A function can represent a state if it is the only type of event the
state machine must process. A regular expression parser would be an
example.

In the general case, a state machine is a matrix of M states by N types
of event. Then, one natural manner of representing a state is a nested
class:

class Lackey:
def __init__(self):
lackey = self

class Idle:
def handle_ding(self):
lackey.start_timer(10)
lackey.set_state(Dinged)

class Dinged:
def handle_dong(self):
lackey.cancel_timer()
lackey.open_door()
lackey.ask_for_name()
lackey.start_timer(20)
lackey.set_state(AwaitingName)

def handle_timeout(self):
lackey.open_door()
lackey.shoo_visitor_away()
lackey.set_state(Annoyed)

# other state classes here...
self.set_state(Idle)

def set_state(self, state):
log(Lackey(): New state: {}.format(
id(self), state.__class__.__name__))
self.state = state()

def handle_ding(self):
self.state.handle_ding()

def handle_dong(self):
self.state.handle_dong()

def handle_timeout(self):
self.state.handle_timeout()

def start_timer(self):
# etc etc


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


Re: Python powerpoint automation using pywin32

2014-02-25 Thread sffjunkie
On Tuesday, 25 February 2014 03:52:29 UTC, Jaydeep Patil  wrote:
 I need to use COM interface for PowerPoint generation.

The following will get you started

http://nbviewer.ipython.org/github/sanand0/ipython-notebooks/blob/master/Office.ipynb

Then you'll need to interpret the Microsoft MSDN docs for anything else

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.aspx

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


Re: Install python 2 and 3 in the wrong order

2014-02-25 Thread sffjunkie
On Sunday, 16 February 2014 08:13:14 UTC, Nagy László Zsolt  wrote:
  Though I don't see anything in the ActiveState builds (which are all
  I've ever used) to handle the #! type selection of the desired version.
  Just got done updating my 2.7, replacing 3.2 with 3.3, and then having to
  edit my path to make 2.7 primary... No py.exe
 I need both 2.7 and 3.3. And apparently, py.exe does not work the way it 
 should be.

Is the following any help

http://www.perlmonks.org/?node_id=998428
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Install python 2 and 3 in the wrong order

2014-02-25 Thread Mark Lawrence

On 16/02/2014 08:13, Nagy László Zsolt wrote:


And apparently, py.exe does not work the way it should be.


What does this mean?  Have you raised an issue on the bug tracker?



I would happily reinstall 3.3 to solve the problem, but before I do that
I would like to check all other related settings. So that after I
reinstall 3.3, I will exactly know what was happening.

It might be a good idea to change the installer of the 2.x series to
detect if 3.x is already installed, and handle assignments of py and pyw
files gracefully.


It might be a good idea but I can't see it happening as (at least as far 
as I'm concerned) 2.7 is past its sell by date.


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


Mark Lawrence

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


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


Python : parsing the command line options using optparse

2014-02-25 Thread Ganesh Pal
Hi Folks ,



Iam newbie to Python, Iam trying to use optparse module and write a script
that will parse the command line options ..I had to use opt parse instead
of argparse because by host Operating system  is still using python 2.6


Below is the simple program  ( Feel free to correct the error ) and 3 quick
questions on the same.


/* sample Program /


import optparse



parser = optparse.OptionParser()



parser.add_option(-p, --path, action=store,
metavar=/ifs/file_name|/ifs/dir_name, dest=path_name,

  type=string,

  help = The  file or directory path of the object in
/ifs,)



parser.add_option(-q, --operation, action=store,
metavar=XOR|ADD|SET, dest=operation_type, default='SET',

  type='choice', choices=['XOR', 'ADD', 'SET'],

  help = The corruption operation on the object [default :
%default],)





parser.add_option(-f, --offset, action=store, metavar=HEX,
dest=offset_value, default=0x41306141,

  type=long,

  help= The valid offset value [default : %default] )





parser.add_option(-n, --node, action=store,metavar=id,
dest=node_value, default= 1,

  type='int',

  help = The node id [default : %default])



parser.add_option(-l, --log, action=store_true,dest=log_file,

  help = log the isi_corrupt execution result )



parser.add_option(-c, --fixcrc, action=store_true,dest=fix_crc,

  help = The  CRC fix of the corrupted objects  )



# instruct optparse to parse the program's command line:

(options, args) = parser.parse_args()



print  options.path_name



Questions (1)


#python python-5.py --path=/ifs/1.txt --operation=XOR  --node=11 --log
-fixcrc


  Looks like the dest variable stores it in a dictionary ,


   print  options.path_name ( gives the option entered in the command
line)


   /ifs/1.txt


 I wanted to store all the options in a list like
[/ifs/1.txt,XOR,11,log_file,fix_crc]

 please suggest on the same ?







Question(2)



Why does  this program work only  with - option and not - in the above code
?



I think its not working when the type= 'choice'  or its somethimf else ?


# python-5.py -p=/ifs/1.txt -q=XOR  -f=1234 -n=1 -l

Usage: python-5.py [options]

python-5.py: error: option -q: invalid choice: '=XOR' (choose from 'XOR',
'ADD',

 'SET', 'MODIFY', 'RENAME', 'DELETE', 'KILL')



This Works ( --)

C:\Users\bahadg\Desktoppython python-5.py --path=/ifs/1.txt
--operation=XOR  --

offset=1234 --node=1 --log --fixcrc

/ifs/1.txt





Question (3)



 If I have really long metavar and the  help  looks very messy  ,is there a
way to make it look elegant.


Example :

 parser.add_option(-q, --operation, action=store,
metavar=XOR|ADD|SET|MODIFY|RENAME|DELETE|KILL|, dest=operation_type,
default='SET',

  type='choice', choices=['XOR', 'ADD', 'SET'
|'MODIFY'|'RENAME'|'DELETE'|'KILL'],

  help = The corruption operation on the object [default :
%default],)



 #python-5.py --help



Usage: python-5.py [options]

Options:

  -h, --helpshow this help message and exit

  -p /ifs/file_name|/ifs/dir_name,
--path=/ifs/file_name|/ifs/dir_name

The  file or directory path of the object in /ifs

  -q XOR|ADD|SET|MODIFY|RENAME|DELETE|KILL|,
--operation=XOR|ADD|SET|MODIFY|RENA

ME|DELETE|KILL|

The corruption operation on the object [default :
SET]

  -f HEX, --offset=HEX  The valid offset value [default : 1093689665]

  -n id, --node=id  The node id [default : 1]

  -l, --log log the isi_corrupt execution result

  -c, --fixcrc  The  CRC fix of the corrupted objects





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


Re: Python : parsing the command line options using optparse

2014-02-25 Thread Peter Otten
Ganesh Pal wrote:

 Iam newbie to Python, Iam trying to use optparse module and write a script
 that will parse the command line options ..I had to use opt parse instead
 of argparse because by host Operating system  is still using python 2.6

As you are just starting I recommend that you use argparse instead of 
optparse.

 Questions (1)
 
 
 #python python-5.py --path=/ifs/1.txt --operation=XOR  --node=11 --log
 -fixcrc
 
  Looks like the dest variable stores it in a dictionary , 

It's an instance of optparse.Values.
 
print  options.path_name ( gives the option entered in the command
 line)
 
 
/ifs/1.txt
 
 
  I wanted to store all the options in a list like
 [/ifs/1.txt,XOR,11,log_file,fix_crc]
 
  please suggest on the same ?

While you can create such a list with

[getattr(options, name) for name in [path_name, operation_type, ...]]

I don't see what the advantage over the default format would be. In fact you 
are making it harder to access a specific option that way.

 Question(2)

 Why does  this program work only  with - option and not - in the above
 code ?
 I think its not working when the type= 'choice'  or its somethimf else ?
 
 
 # python-5.py -p=/ifs/1.txt -q=XOR  -f=1234 -n=1 -l

If you are asking why short options don't work in conjunction with = -- I 
don't know, it is probably a design choice of the optparse author.
argparse accepts short options with like -f=1234

 Question (3)

  If I have really long metavar and the  help  looks very messy  ,is there
  a
 way to make it look elegant.
 
 
 Example :
 
  parser.add_option(-q, --operation, action=store,
 metavar=XOR|ADD|SET|MODIFY|RENAME|DELETE|KILL|, dest=operation_type,
 default='SET',
 
   type='choice', choices=['XOR', 'ADD', 'SET'
 |'MODIFY'|'RENAME'|'DELETE'|'KILL'],
 
   help = The corruption operation on the object [default
   :
 %default],)

You can move the choices into the help. Example using argparse :

parser.add_argument(
-q, --operation,
metavar=OP,
default='SET',
choices=['XOR', 'ADD', 'SET'],
help=The corruption operation on the object [choose from %(choices)s; 
default: %(default)s])

This becomes

  -q OP, --operation OP
The corruption operation on the object [choose from
XOR, ADD, SET; default: SET]

in the help.


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


Re: Python : parsing the command line options using optparse

2014-02-25 Thread Mark Lawrence

On 25/02/2014 15:31, Ganesh Pal wrote:

Hi Folks ,

Iam newbie to Python, Iam trying to use optparse module and write a
script that will parse the command line options ..I had to use opt parse
instead of argparse because by host Operating system  is still using
python 2.6



Do you have the needed permissions to simply drop the argparse code into 
the 2.6 stdlib?  Could you use the third party docopt instead?  It's on 
pypi and I think it's awesome :)


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


Mark Lawrence

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


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


Re: ProgrammingError: (1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'S SIZE 11.5 NEW IN BOX', '$49.99')'

2014-02-25 Thread nowebdevmyrrh
HI, I'm also getting this kind of error. 

This will show when I do the edit function
http://screencast.com/t/hGSbe1vt

and this when performing the delete
Error: You have an error in your SQL syntax; check the manual that corresponds 
to your MySQL server version for the right syntax to use near '' at line 1

What confused me more is that my website works fine on my live server and will 
only throws error when running on my wampserver. 

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


Re: ProgrammingError: (1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'S SIZE 11.5 NEW IN BOX', '$49.99')'

2014-02-25 Thread MRAB

On 2014-02-25 17:37, nowebdevmy...@gmail.com wrote:

HI, I'm also getting this kind of error.

This will show when I do the edit function
http://screencast.com/t/hGSbe1vt

and this when performing the delete
Error: You have an error in your SQL syntax; check the manual that corresponds to 
your MySQL server version for the right syntax to use near '' at line 1

What confused me more is that my website works fine on my live server and will 
only throws error when running on my wampserver.


It might have the same cause, but that's just a guess because you
haven't provided much information.
--
https://mail.python.org/mailman/listinfo/python-list


An example of Python in action!

2014-02-25 Thread Timothy W. Grove
Here is an example of Python being used with Maya for animation  
http://vimeo.com/72276442


(No prizes for guessing what sport and team I support!!!)

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


Intalling Python 2.6 on Mac OSX 10.9

2014-02-25 Thread Robert Schmidt
I am trying to install Python 2.6 because Pygame will only run on 2.6.
The configure gives only warnings.
make frameworkinstall
gcc -c -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall 
-Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE 
-DSVNVERSION=\`LC_ALL=C svnversion .`\ -o Modules/getbuildinfo.o 
./Modules/getbuildinfo.c
clang: error: no such file or directory: 'directory'

I need a hint.  Am I foolish to try and install Pygame? Is that dead?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: An example of Python in action!

2014-02-25 Thread Skip Montanaro
On Tue, Feb 25, 2014 at 12:07 PM, Timothy W. Grove tim_gr...@sil.org wrote:
 Here is an example of Python being used with Maya for animation 
 http://vimeo.com/72276442

Maya as in MayaVi, the 3D data visualizer built atop VTK?

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


First Brazilian programming MOOC with 10.000 enrolled

2014-02-25 Thread Fernando Masanori Ashikaga
Python for Zombies [1] is the first MOOC in portuguese to teach programming. 
Today we have 10.000 enrolled in 1013 cities from Brazil. We started five 
months ago. The website is a Django application.

[1] http://pycursos.com/python-para-zumbis/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: An example of Python in action!

2014-02-25 Thread Robert Kern

On 2014-02-25 18:47, Skip Montanaro wrote:

On Tue, Feb 25, 2014 at 12:07 PM, Timothy W. Grove tim_gr...@sil.org wrote:

Here is an example of Python being used with Maya for animation 
http://vimeo.com/72276442


Maya as in MayaVi, the 3D data visualizer built atop VTK?


Maya as in Maya, the 3D animation software from AutoDesk.

--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: An example of Python in action!

2014-02-25 Thread Skip Montanaro
On Tue, Feb 25, 2014 at 1:52 PM, Robert Kern robert.k...@gmail.com wrote:
 Maya as in Maya, the 3D animation software from AutoDesk.

Ugh. What an unfortunate almost-name-clash...

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


intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread mauro
 Dictionaries and sets share a few properties:
- Dictionaries keys are unique as well as sets items
- Dictionaries and sets are both unordered
- Dictionaries and sets are both accessed by key
- Dictionaries and sets are both mutables

So I wonder why operations such us intersection, union, difference, 
symmetric difference that are available for sets and are not available 
for dictionaries without going via key dictviews. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Nick Timkovich
On Tue, Feb 25, 2014 at 2:32 PM, mauro ma...@gmail.com wrote:

 So I wonder why operations such us intersection, union, difference,
 symmetric difference that are available for sets and are not available
 for dictionaries without going via key dictviews.

How would the set operations apply to the dictionary values?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Skip Montanaro
On Tue, Feb 25, 2014 at 2:32 PM, mauro ma...@gmail.com wrote:
 So I wonder why operations such us intersection, union, difference,
 symmetric difference that are available for sets and are not available
 for dictionaries without going via key dictviews.

What's the correct result of evaluating this expression?

{'A': 1} | {'A': 2}

I can see (at least) two possible correct answers.

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


Re: An example of Python in action!

2014-02-25 Thread Timothy W. Grove
I'm sorry, but I don't know much more than this. If you follow the link 
there is a description of how the animation was created under the video.


On 25/02/2014 18:47, Skip Montanaro wrote:

On Tue, Feb 25, 2014 at 12:07 PM, Timothy W. Grove tim_gr...@sil.org wrote:

Here is an example of Python being used with Maya for animation 
http://vimeo.com/72276442

Maya as in MayaVi, the 3D data visualizer built atop VTK?

Skip



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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Peter Otten
mauro wrote:

  Dictionaries and sets share a few properties:

 - Dictionaries keys are unique as well as sets items
 - Dictionaries and sets are both unordered
 - Dictionaries and sets are both accessed by key

but sets have no values

 - Dictionaries and sets are both mutables

but frozensets also have the operations mentioned in the subject.

 So I wonder why operations such us intersection, union, difference,
 symmetric difference that are available for sets and are not available
 for dictionaries without going via key dictviews.

How would you define them? 

E. g.

{1, 2}  {2, 3} == {2}

but

{1:a, 2:b, 3:c}  {2:b, 3:e, 4:f} == ???

The most obvious result is probably the empty dict {2:b}, i. e.

a  b is defined as dict(a.items()  b.items())

Frankly, I don't do that a lot. So what's your use-case?


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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Peter Otten
Peter Otten wrote:

 the empty dict {2:b}

Make that half-empty ;)

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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Tim Chase
On 2014-02-25 14:40, Skip Montanaro wrote:
 What's the correct result of evaluating this expression?
 
 {'A': 1} | {'A': 2}
 
 I can see (at least) two possible correct answers.

I would propose at least four:

  {'A': 1}   # choose the LHS
  {'A': 2}   # choose the RHS
  {'A': (1,2)} # a resulting pair of both
  set(['A']) # you did set-ops, so you get a set

If dicts were to support set ops, the last one would be my preferred
result.

I just had to perform set operations on a pair of dicts earlier this
week, shrugged, and did things the manual/explicit way:

  a_dict = dict(...)
  b_dict = dict(...)
  a_set = set(a_dict)
  b_set = set(b_dict)
  added_keys = b_set - a_set
  removed_keys = a_set - b_set
  same_keys = a_set  b_set
  diff_keys = a_set ^ b_set
  all_keys = a_set | b_set

It would save some space if I didn't have to duplicate all the keys
into sets (on the order of 10-100k small strings), instead being able
to directly perform the set-ops on the dicts.  But otherwise, it was
pretty readable  straight-forward.

-tkc



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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Ben Finney
Peter Otten __pete...@web.de writes:

 mauro wrote:

  - Dictionaries and sets are both accessed by key

 but sets have no values

Or rather, sets *only* have values. Dictionaries have keys, sets do not
have keys.

-- 
 \ “If nature has made any one thing less susceptible than all |
  `\others of exclusive property, it is the action of the thinking |
_o__)  power called an idea” —Thomas Jefferson |
Ben Finney

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


Re:intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Dave Angel
 mauro ma...@gmail.com Wrote in message:
  Dictionaries and sets share a few properties:
 - Dictionaries keys are unique as well as sets items
 - Dictionaries and sets are both unordered
 - Dictionaries and sets are both accessed by key
 - Dictionaries and sets are both mutables
 
 So I wonder why operations such us intersection, union, difference, 
 symmetric difference that are available for sets and are not available 
 for dictionaries without going via key dictviews. 
 

I certainly wouldn't be able to guess what they should be defined
 to do, since there are several equally obnoxious possibilities.
 

For instance,  take union for example.  What should be the result
 when you union two dicts that have the same key but different
 values for that key?


-- 
DaveA

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


Re: Intalling Python 2.6 on Mac OSX 10.9

2014-02-25 Thread Mark Lawrence

On 25/02/2014 18:28, Robert Schmidt wrote:

I am trying to install Python 2.6 because Pygame will only run on 2.6.
The configure gives only warnings.
make frameworkinstall
gcc -c -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall 
-Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE 
-DSVNVERSION=\`LC_ALL=C svnversion .`\ -o Modules/getbuildinfo.o 
./Modules/getbuildinfo.c
clang: error: no such file or directory: 'directory'

I need a hint.  Am I foolish to try and install Pygame? Is that dead?



This same question was answered on another thread 16 hours ago.

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


Mark Lawrence

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


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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Peter Otten
Tim Chase wrote:

 On 2014-02-25 14:40, Skip Montanaro wrote:
 What's the correct result of evaluating this expression?
 
 {'A': 1} | {'A': 2}
 
 I can see (at least) two possible correct answers.
 
 I would propose at least four:
 
   {'A': 1}   # choose the LHS
   {'A': 2}   # choose the RHS
   {'A': (1,2)} # a resulting pair of both
   set(['A']) # you did set-ops, so you get a set
 
 If dicts were to support set ops, 

They do in 2.7 and 3.x.

 the last one would be my preferred
 result.
 
 I just had to perform set operations on a pair of dicts earlier this
 week, shrugged, and did things the manual/explicit way:
 
   a_dict = dict(...)
   b_dict = dict(...)
   a_set = set(a_dict)
   b_set = set(b_dict)
   added_keys = b_set - a_set
   removed_keys = a_set - b_set
   same_keys = a_set  b_set
   diff_keys = a_set ^ b_set
   all_keys = a_set | b_set

 a = dict.fromkeys(ab)
 b = dict.fromkeys(bc)
 a.viewkeys() - b.viewkeys()
set(['a'])
 a.viewkeys()  b.viewkeys()
set(['b'])
 a.viewkeys() ^ b.viewkeys()
set(['a', 'c'])
 a.viewkeys() | b.viewkeys()
set(['a', 'c', 'b'])

For 3.x replace viewkeys() with keys().

 It would save some space if I didn't have to duplicate all the keys
 into sets (on the order of 10-100k small strings), instead being able
 to directly perform the set-ops on the dicts.  But otherwise, it was
 pretty readable  straight-forward.
 
 -tkc


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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread mauro

 
 {'A': 1} | {'A': 2}

 I would propose at least four:
 
   {'A': 1}   # choose the LHS 
   {'A': 2}   # choose the RHS 
   {'A': (1,2)} # a resulting pair of both 
   set(['A']) # you did set-ops, so you get a set

The implementation should define if LHS or RHS and user should change the 
order of operands depending on what he wants. 

Your example (as well as a many questions in stackoverflow.com) shows 
that there is some need for these operations, that implemented in C in 
python library will be by far more CPU and memory efficient than 
implemented as you did. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread mauro
Il Tue, 25 Feb 2014 22:02:01 +, mauro ha scritto:


 {'A': 1} | {'A': 2}

 I would propose at least four:
 
   {'A': 1}   # choose the LHS {'A': 2}   # choose the RHS {'A': (1,2)}
   # a resulting pair of both set(['A']) # you did set-ops, so you get a
   set
 
 The implementation should define if LHS or RHS and user should change
 the order of operands depending on what he wants.
 
 Your example (as well as a many questions in stackoverflow.com) shows
 that there is some need for these operations, that implemented in C in
 python library will be by far more CPU and memory efficient than
 implemented as you did.

posting error, this entry was supposed to be a reply to Tim Chase's 
comment.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Tim Chase
On 2014-02-25 22:54, Peter Otten wrote:
 Tim Chase wrote:
  If dicts were to support set ops, 
 
 They do in 2.7 and 3.x.
 
  a.viewkeys() - b.viewkeys()
 set(['a'])
  a.viewkeys()  b.viewkeys()
 set(['b'])
  a.viewkeys() ^ b.viewkeys()
 set(['a', 'c'])
  a.viewkeys() | b.viewkeys()
 set(['a', 'c', 'b'])
 
 For 3.x replace viewkeys() with keys().

I missed this getting added in the 2.7 release.  Thanks for the
introduction to .viewkeys()/.keys() as they could prove quite handy.

-tkc





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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread mauro

 
 {1, 2}  {2, 3} == {2}
 
In my mind the intersection is evaluated on keys, so the resulting dict 
should be the empty one
 but
 
 {1:a, 2:b, 3:c}  {2:b, 3:e, 4:f} == ???
my output will be
{2:b, 3:e} 
or
{2:b, 3:c} 

depending on the implementation choice.  
 
 The most obvious result is probably the empty dict {2:b}, i. e.
 
 a  b is defined as dict(a.items()  b.items())
 
 Frankly, I don't do that a lot. So what's your use-case?
I do not have an use case, but I've seen that many people ask for these 
operations for example in stackoverflow.com

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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Duncan Booth
Tim Chase python.l...@tim.thechases.com wrote:

   a_dict = dict(...)
   b_dict = dict(...)
   a_set = set(a_dict)
   b_set = set(b_dict)
   added_keys = b_set - a_set
   removed_keys = a_set - b_set
   same_keys = a_set  b_set
   diff_keys = a_set ^ b_set
   all_keys = a_set | b_set
 
 It would save some space if I didn't have to duplicate all the keys
 into sets (on the order of 10-100k small strings), instead being able
 to directly perform the set-ops on the dicts.  But otherwise, it was
 pretty readable  straight-forward.
 
It doesn't matter whether they were small strings or full-length novels, 
creating a set from a dict doesn't duplicate any strings.


-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Mark Lawrence

On 25/02/2014 22:11, mauro wrote:




{1, 2}  {2, 3} == {2}


In my mind the intersection is evaluated on keys, so the resulting dict
should be the empty one

but

{1:a, 2:b, 3:c}  {2:b, 3:e, 4:f} == ???

my output will be
{2:b, 3:e}
or
{2:b, 3:c}

depending on the implementation choice.


The most obvious result is probably the empty dict {2:b}, i. e.

a  b is defined as dict(a.items()  b.items())

Frankly, I don't do that a lot. So what's your use-case?

I do not have an use case, but I've seen that many people ask for these
operations for example in stackoverflow.com



Please ask one of the many people on stackoverflow to raise an 
enhancement request here bugs.python.org complete with a patch that 
changes code, docs and tests and then everybody will be happy, won't they.


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


Mark Lawrence

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


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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Tim Chase
On 2014-02-25 22:21, Duncan Booth wrote:
  It would save some space if I didn't have to duplicate all the
  keys into sets (on the order of 10-100k small strings), instead
  being able to directly perform the set-ops on the dicts.  But
  otherwise, it was pretty readable  straight-forward.
  
 It doesn't matter whether they were small strings or full-length
 novels, creating a set from a dict doesn't duplicate any strings.  

pre-my-new-learning-about .viewkeys() it sounds like set(my_dict)
would have the overhead of storing an additional reference to a
string per set-entry (rather than duplicating every string).
With .viewkeys()/.keys(), it sounds like that overhead would go away.

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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Tim Chase
On 2014-02-25 22:21, Duncan Booth wrote:
  It would save some space if I didn't have to duplicate all the
  keys into sets (on the order of 10-100k small strings), instead
  being able to directly perform the set-ops on the dicts.  But
  otherwise, it was pretty readable  straight-forward.

 It doesn't matter whether they were small strings or full-length
 novels, creating a set from a dict doesn't duplicate any strings.

pre-my-new-learning-about .viewkeys() it sounds like set(my_dict)
would have the overhead of storing an additional reference to a
string per set-entry (rather than duplicating every string).
With .viewkeys()/.keys(), it sounds like that overhead would go away.

-tkc



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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Oscar Benjamin
On 25 February 2014 22:36, Tim Chase python.l...@tim.thechases.com wrote:
 On 2014-02-25 22:21, Duncan Booth wrote:
  It would save some space if I didn't have to duplicate all the
  keys into sets (on the order of 10-100k small strings), instead
  being able to directly perform the set-ops on the dicts.  But
  otherwise, it was pretty readable  straight-forward.
 
 It doesn't matter whether they were small strings or full-length
 novels, creating a set from a dict doesn't duplicate any strings.

 pre-my-new-learning-about .viewkeys() it sounds like set(my_dict)
 would have the overhead of storing an additional reference to a
 string per set-entry (rather than duplicating every string).
 With .viewkeys()/.keys(), it sounds like that overhead would go away.

You lose the redundant hash-table by using the keys view. The set hash
table takes 20-40 bytes per entry on this computer (according to
sys.getsizeof). On the same system a short string takes a similar
amount of memory. The .keys() view object apparently takes 24 bytes in
total so yes it's a reasonable memory saving if the dicts or of any
significant size.

However the .keys() objects are not necessarily as well optimised so
it may be faster to convert to sets for some operations. One example I
found some time ago is that for sets A  B will iterate over the
smaller set but for dicts A.keys()  B.keys() would always go over the
left-hand set (or right-hand - I don't remember). This makes a
considerable difference if one set is significantly larger than the
other.


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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread MRAB

On 2014-02-25 21:27, Ben Finney wrote:

Peter Otten __pete...@web.de writes:


mauro wrote:

 - Dictionaries and sets are both accessed by key

but sets have no values


Or rather, sets *only* have values. Dictionaries have keys, sets do not
have keys.


But a dictionary can have duplicate values, a set cannot.
--
https://mail.python.org/mailman/listinfo/python-list


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Ben Finney
MRAB pyt...@mrabarnett.plus.com writes:

 On 2014-02-25 21:27, Ben Finney wrote:
  Peter Otten __pete...@web.de writes:
 
  mauro wrote:
 
   - Dictionaries and sets are both accessed by key
 
  but sets have no values
 
  Or rather, sets *only* have values. Dictionaries have keys, sets do
  not have keys.
 
 But a dictionary can have duplicate values, a set cannot.

Yes. Your “but” implies you think that contradicts my statement; it
doesn't. So I'm not sure what point you're making.

-- 
 \ “Alternative explanations are always welcome in science, if |
  `\   they are better and explain more. Alternative explanations that |
_o__) explain nothing are not welcome.” —Victor J. Stenger, 2001-11-05 |
Ben Finney

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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Steven D'Aprano
On Tue, 25 Feb 2014 15:03:51 -0600, Tim Chase wrote:

 On 2014-02-25 14:40, Skip Montanaro wrote:
 What's the correct result of evaluating this expression?
 
 {'A': 1} | {'A': 2}
 
 I can see (at least) two possible correct answers.
 
 I would propose at least four:
 
   {'A': 1}   # choose the LHS
   {'A': 2}   # choose the RHS
   {'A': (1,2)} # a resulting pair of both 

Should that value be a tuple, a list or a set?


   set(['A']) # you did set-ops, so you get a set

Option 5: raise an exception if the values are different.

Option 6: or the values, so that the LHS value is used only if it is 
truthy, otherwise the RHS value is used. That is:

{'A': leftdict['A'] or rightdict['A']}


I don't really understand the use-case behind Option 6, but there is a 
recent thread on python-id...@python.org where somebody proposed that as 
the Obviously One True And Correct behaviour for dict intersection.



 If dicts were to support set ops, the last one would be my preferred
 result.

What, getting a set back?

No, I disagree. If you want a set, it's easy to do:

dicta.keys() | dictb.keys()

(In Python 2, use viewkeys instead.)


gives you a set of the intersection of the keys. The only point of having 
dicts support set-like operations directly is if you get a dict back.

All of these operations are quite simple to write, so personally I would 
recommend people just add their own helper function with the behaviour 
they prefer.


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


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread MRAB

On 2014-02-25 23:14, Ben Finney wrote:

MRAB pyt...@mrabarnett.plus.com writes:


On 2014-02-25 21:27, Ben Finney wrote:
 Peter Otten __pete...@web.de writes:

 mauro wrote:

  - Dictionaries and sets are both accessed by key

 but sets have no values

 Or rather, sets *only* have values. Dictionaries have keys, sets do
 not have keys.

But a dictionary can have duplicate values, a set cannot.


Yes. Your “but” implies you think that contradicts my statement; it
doesn't. So I'm not sure what point you're making.


The keys of a dictionary must be unique, like a set. The values of a
dictionary don't have to be unique, unlike a set.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Help father help son / Install Version 2.6 on Mac OSX 10.9

2014-02-25 Thread Cameron Simpson
On 24Feb2014 21:57, Ned Deily n...@acm.org wrote:
 In article 
 CAPTjJmp-UDAdJz=28ywCggkepFcTTJ-=9rEvtpsXO_Vgup=q...@mail.gmail.com,
  Chris Angelico ros...@gmail.com wrote:
  On Tue, Feb 25, 2014 at 4:28 PM,  quequ...@gmail.com wrote:
   Trying to install Python 2.6 because PyGames says it will only install if 
   Python 2.6 is present.
  
  Are you sure you need 2.6 and not 2.7? This suggests 2.7 works:
  
  http://pygame.org/wiki/MacCompile
 
 And, in any case, Apple ships OS X 10.9 with copies of both Python 2.7 
 and 2.6:
 
 /usr/bin/python2.7
 /usr/bin/python2.6

And there's always MacPorts for your multiversion needs:

  python24 @2.4.6_10 (lang)
  python25 @2.5.6_4 (lang)
  python26 @2.6.9 (lang)
  python27 @2.7.6 (lang)
  python31 @3.1.5 (lang)
  python32 @3.2.5 (lang)
  python33 @3.3.4 (lang)
  python34 @3.4.0rc1 (lang)

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

The ZZR-1100 remains the big, fast, versatile bike for the rider with a
regular pillion passenger or the desire to humiliate just about every
other road user who attempted to match its straight line acceleration. - REVS
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Steven D'Aprano
On Tue, 25 Feb 2014 23:07:28 +, MRAB wrote:

 On 2014-02-25 21:27, Ben Finney wrote:

 Or rather, sets *only* have values. Dictionaries have keys, sets do not
 have keys.

 But a dictionary can have duplicate values, a set cannot.

It is usual to talk about the things stored in dicts and sets using 
slightly different terminology:

  - mappings such as dicts have *key/value pairs*

  - sets have *elements*

The elements of a set are most closely related to the keys of a mapping, 
not the values. Set elements are unique, just like mapping keys. 
Specifically, the keys in a mapping make up a set; the values in a 
mapping do not.

When talking specifically about Python dicts and sets, there is an 
additional restriction: both set elements and dict keys have to be 
hashable.

English being a little sloppy at times, sometimes we also talk about the 
*values of a set*, but here value is being used as a synonym for 
element and not as a technical term for the thing which mappings 
associate with a key.



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


Re: python

2014-02-25 Thread Karthik Reddy
Thank you,

but from by reaserch i got these requirements ..

Python, django, Twisted, MySQL, PyQt, PySide, xPython.

 *Technical proficiency with Python and Django.
 *Technical proficiency in JavaScript.
 *Experience with MySQL / PgSQL.
 *Unix/Linux expertise.
 *Experience with MVC design patterns and solid algorithm skills.

Core Python, DJango Framework, Web2Py, Google App engine, CherryPy ( Basic 
Introduction)

The problem for me is whether i have to learn all these technologies to work as 
a python developer..



  
On Tuesday, February 25, 2014 12:58:15 AM UTC+5:30, CM wrote:
 On Monday, February 24, 2014 3:31:11 AM UTC-5, Karthik Reddy wrote:
 
  I worked as a weblogic administrator and now i am changing to development 
  and i am very much interested in python . please suggest me what 
  are the things i need to learn more  rather than python to get an I.T job. 
  I came to know about  Django but i am in a confusion please help me 
  .
 
 
 
 I recommend you look at job advertisements in areas you'd like to work (both
 
 areas of the world and areas within IT) and see what they seem to want.
 
 
 
 Also, consider more informative subject lines to future posts.  :D
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Functions help

2014-02-25 Thread Cameron Simpson
On 24Feb2014 13:59, Mark Lawrence breamore...@yahoo.co.uk wrote:
 On 24/02/2014 04:01, ru...@yahoo.com wrote:
 On 02/23/2014 08:21 PM, Mark Lawrence wrote:
 On 24/02/2014 02:55, Benjamin Kaplan wrote:
 On Sun, Feb 23, 2014 at 5:39 PM, alex23 wuwe...@gmail.com wrote:
 On 24/02/2014 11:09 AM, Mark Lawrence wrote:
 On 24/02/2014 00:55, alex23 wrote:
for _ in range(5):
func()
 the obvious indentation error above
 
 Stupid cutpaste :(
 
 Your message came through fine for me (viewing as mailing list in
 gmail). Mark's client must be dropping spaces.
 
 I'm reading gmane.comp.python.general using Thunderbird 24.3.0 on Windows 7.
 
 The original message was properly indented on Google Groups.
 Perhaps you should switch to GG or some non-broken client that
 doesn't mangle whitespace.
 
 MRAB has confirmed that as always Thunderbird is working perfectly,
 thank you.

He confirmed it worked for him. And yet your copy rendered incorrectly.
MRAB pointed at a possible cause (mixed TABs and spaces).

 But you can stick with your bug ridden, badly flawed
 tool as long as you like, just expect me to keep complaining until
 google fixes it, or people stop using it, or people follow the
 instructions that were put up on a Python web site to prevent the
 bugs showing up.

Methinks rurpy's GG suggestion was bait aimed specificly at you.
I recognised it as sarcasm (or parody?).

Relax.
-- 
Cameron Simpson c...@zip.com.au

Scott Fansler wrote:
 Give me a break with this thread!! So what if another rider doesn't
 wave?? Who the hell cares!?!? I wave to other riders from my HD when the
 thought/moment is there. If they wave back cool, if not, so what. Maybe
 they didn't see me, maybe they're pissed at their boss or spouse or life
 in general and are out for a putt to clear out the BS and don't care to
 wave back. Big deal. Have you seen EVERY motorcyle that EVER rode past
 you going the other way?? Don't think so. Stop posing  ride, wave or no
 wave.
 2 cents
Somebody get the pliers, this one's hooked deep.  We'll need some more
bait too.
You might want to fiddle with drag setting on your reel too.
- Tim Simpson t...@peop.tdsnet.com in rec.moto
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: intersection, union, difference, symmetric difference for dictionaries

2014-02-25 Thread Tim Chase
On 2014-02-25 23:10, Steven D'Aprano wrote:
 On Tue, 25 Feb 2014 15:03:51 -0600, Tim Chase wrote:
 
  On 2014-02-25 14:40, Skip Montanaro wrote:
  What's the correct result of evaluating this expression?
  
  {'A': 1} | {'A': 2}
  
  I can see (at least) two possible correct answers.
  
  I would propose at least four:
  
{'A': 1}   # choose the LHS
{'A': 2}   # choose the RHS
{'A': (1,2)} # a resulting pair of both 
 
 Should that value be a tuple, a list or a set?

I'd say a tuple: it has order (thus not a set), and it's a fixed
record of (LHS, RHS), not mutable as a list would suggest.

 Option 5: raise an exception if the values are different.

Inconvenient in many use cases, but certainly another possibility

 Option 6: or the values, so that the LHS value is used only if it
 is truthy, otherwise the RHS value is used. That is:
 
 {'A': leftdict['A'] or rightdict['A']}
 
 
 I don't really understand the use-case behind Option 6

I can imagine a use case for it, but certainly not the *default*
behavior.  Yick.

  If dicts were to support set ops, the last one would be my
  preferred result.
 
 What, getting a set back?
 
 No, I disagree. If you want a set, it's easy to do:
 
 dicta.keys() | dictb.keys()
 
 (In Python 2, use viewkeys instead.)

Now that I'm aware of .viewkeys()/.keys() (herein vk/k for brevity)
thanks to Peter Otten's post, that does what I most commonly want for
set-ops-on-dicts.  I'd just consider this a promotion, since

  for k in my_dict:
pass

is the same as

  for k in my_dict.keys(): # or .iterkeys() in 2.x
pass

I'd find it intuitive to have set-ops behave similarly, defaulting
to vk/k.

 All of these operations are quite simple to write, so personally I
 would recommend people just add their own helper function with the
 behaviour they prefer.

And with vk/k, I now fall pretty firmly in agreement with you (except
for the aforementioned possibility of having a dict's currently-unused
set-ops use the results of vk/k as well).

-tkc



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


Re: Functions help

2014-02-25 Thread Cameron Simpson
On 23Feb2014 18:55, Benjamin Kaplan benjamin.kap...@case.edu wrote:
 On Sun, Feb 23, 2014 at 5:39 PM, alex23 wuwe...@gmail.com wrote:
  On 24/02/2014 11:09 AM, Mark Lawrence wrote:
  On 24/02/2014 00:55, alex23 wrote:
   for _ in range(5):
   func()
 
  the obvious indentation error above
 
  Stupid cutpaste :(
 
 Your message came through fine for me (viewing as mailing list in
 gmail). Mark's client must be dropping spaces.

My copy was fine too. I'm reading it via the python-list mailing
list, with mutt.
-- 
Cameron Simpson c...@zip.com.au

Deep into the monitor peering, long I sat there wond'ring, fearing,
Doubting, while the disk kept churning, turning yet to churn some more.

Save! I said, You cursed mother! Save my data from before!
One thing did the phosphors answer, only this and nothing more,
Just, Abort, Retry, Ignore?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Functions help

2014-02-25 Thread Ethan Furman

On 02/23/2014 08:01 PM, ru...@yahoo.com wrote:

On 02/23/2014 08:21 PM, Mark Lawrence wrote:

On 24/02/2014 02:55, Benjamin Kaplan wrote:

On Sun, Feb 23, 2014 at 5:39 PM, alex23 wuwe...@gmail.com wrote:

On 24/02/2014 11:09 AM, Mark Lawrence wrote:

On 24/02/2014 00:55, alex23 wrote:

   for _ in range(5):
   func()

the obvious indentation error above


Stupid cutpaste :(


Your message came through fine for me (viewing as mailing list in
gmail). Mark's client must be dropping spaces.


I'm reading gmane.comp.python.general using Thunderbird 24.3.0 on Windows 7.


The original message was properly indented on Google Groups.
Perhaps you should switch to GG or some non-broken client that
doesn't mangle whitespace.


LOL!  How long have you waited to say that?  ;)

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


[issue20246] buffer overflow in socket.recvfrom_into

2014-02-25 Thread Christian Heimes

Christian Heimes added the comment:

This issue has already been assigned CVE-2014-1912

Reference:

http://www.openwall.com/lists/oss-security/2014/02/12/16
https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2014-1912

--

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



[issue20246] buffer overflow in socket.recvfrom_into

2014-02-25 Thread Chris Rebert

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


--
nosy: +cvrebert

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



[issue20727] Improved roundrobin itertools recipe

2014-02-25 Thread Gareth Rees

Gareth Rees added the comment:

If 100 doesn't work for you, try a larger number.

--

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



[issue20727] Improved roundrobin itertools recipe

2014-02-25 Thread Gareth Rees

Gareth Rees added the comment:

I suspect I messed up the timing I did yesterday, because today I find that 100 
isn't large enough, but here's what I found today (in Python 3.3):

 from timeit import timeit
 test = [tuple(range(300))] + [()] * 100
 timeit(lambda:list(roundrobin1(*test)), number=1) # old recipe
8.386148632998811
 timeit(lambda:list(roundrobin2(*test)), number=1) # new recipe
16.757110453007044

The new recipe is more than twice as slow as the old in this case, and its 
performance gets relatively worse as you increase the number 300.

I should add that I do recognise that the new recipe is better for nearly all 
cases (it's simpler as well as faster), but I want to point out an important 
feature of the old recipe, namely that it discards iterables as they are 
finished with, giving it worst-case O(n) performance (albeit slow) whereas the 
new recipe has worst case O(n^2). As we found out with hash tables, worst-case 
O(n^2) performance can be a problem when inputs are untrusted, so there are use 
cases where people might legitimately prefer an O(n) solution even if it's a 
bit slower in common cases.

--

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



[issue20766] reference leaks in pdb

2014-02-25 Thread Xavier de Gaye

New submission from Xavier de Gaye:

After the pdb 'continue' command, the signal module owns a reference to 
Pdb.sigint_handler. On the next instantiation of pdb, the signal module owns a 
reference to a new sigint_handler method that owns a reference to the previous 
sigint_handler. As a consequence, the first pdb instance is never freed (as 
well as the frames that are referenced by this pdb instance). The following 
test demonstrates the problem that is fixed by the attached patch.

Run the following script:

# START of refleak.py
import sys, gc, pdb

i = 1
while i:
pdb.set_trace()
x = 1
gc.collect(); print(sys.gettotalrefcount())

# END of refleak.py


With the following pdb commands:

$ python refleak.py
 /tmp/test/refleak.py(6)module()
- x = 1
(Pdb) continue
95898
 /home/xavier/tmp/test/refleak.py(5)module()
- pdb.set_trace()
(Pdb) continue
95983
 /tmp/test/refleak.py(6)module()
- x = 1
(Pdb) continue
96068
 /tmp/test/refleak.py(5)module()
- pdb.set_trace()
(Pdb) i = 0
(Pdb) continue
96153

--
components: Library (Lib)
files: refleak.patch
keywords: patch
messages: 212171
nosy: georg.brandl, xdegaye
priority: normal
severity: normal
status: open
title: reference leaks in pdb
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file34220/refleak.patch

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



[issue20246] buffer overflow in socket.recvfrom_into

2014-02-25 Thread koobs

Changes by koobs koobs.free...@gmail.com:


--
nosy: +koobs

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



[issue20763] old sys.path_hooks importer does not work with Python 3.4.0rc1

2014-02-25 Thread Berker Peksag

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


--
nosy: +eric.snow

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



[issue20765] Pathlib docs fail to mention with_name, with_suffix

2014-02-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Interesting. According to the Mercurial logs, they were never actually 
documented...

--
assignee: docs@python - pitrou

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



[issue20621] Issue with zipimport in 3.3.4 and 3.4.0rc1

2014-02-25 Thread Paul Moore

Paul Moore added the comment:

Should this be mentioned in the 3.3.5 changelog 
(http://docs.python.org/3.3/whatsnew/changelog.html)?

--

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



[issue20727] Improved roundrobin itertools recipe

2014-02-25 Thread Gareth Rees

Gareth Rees added the comment:

But now that I look at the code more carefully, the old recipe also has O(n^2) 
behaviour, because cycle(islice(nexts, pending)) costs O(n) and is called O(n) 
times. To have worst-case O(n) behaviour, you'd need something like this:

from collections import deque

def roundrobin3(*iterables):
roundrobin('ABC', 'D', 'EF') -- A D E B F C
nexts = deque(iter(it).__next__ for it in iterables)
while nexts:
try:
while True:
yield nexts[0]()
nexts.rotate(-1)
except StopIteration:
nexts.popleft()

 from timeit import timeit
 test = [tuple(range(1000))] + [()] * 1000
 timeit(lambda:list(roundrobin1(*test)), number=100) # old recipe
5.184364624001319
 timeit(lambda:list(roundrobin2(*test)), number=100) # new recipe
5.139592286024708
 timeit(lambda:list(roundrobin3(*test)), number=100)
0.16217014100402594

--

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



[issue20766] reference leaks in pdb

2014-02-25 Thread Xavier de Gaye

Xavier de Gaye added the comment:

 the first pdb instance is never freed

The first pdb instance is (and all the other pdb instances) never freed until 
the call to PyOS_FiniInterrupts() in Py_Finalize().

--

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



[issue20767] Some python extensions can't be compiled with clang 3.4

2014-02-25 Thread Antoine Brodin.FreeBSD

New submission from Antoine Brodin.FreeBSD:

Hi,

On FreeBSD -current,  clang 3.4 is now the default compiler.
Clang 3.4 rejects -R/path/to/lib flag (previously in version 3.3 it just 
ignored it).

This leads to some errors with some python extensions:

cc -shared -O2 -pipe -fno-strict-aliasing 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/_sqlite/cache.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/_sqlite/connection.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/_sqlite/cursor.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/_sqlite/microprotocols.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/_sqlite/module.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/_sqlite/prepare_protocol.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/_sqlite/row.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/_sqlite/statement.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/_sqlite/util.o -L/usr/local/lib 
-R/usr/local/lib -lsqlite3 -o 
build/lib.freebsd-11.0-CURRENT-amd64-2.7/_sqlite3.so
cc: error: unknown argument: '-R/usr/local/lib'
error: command 'cc' failed with exit status 1


cc -shared -O2 -pipe -DLDAP_DEPRECATED -fno-strict-aliasing 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/LDAPObject.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/ldapcontrol.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/common.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/constants.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/errors.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/functions.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/schema.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/ldapmodule.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/message.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/version.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/options.o 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/berval.o -L/usr/local/lib 
-L/usr/lib -R/usr/local/lib -R/usr/lib -lldap_r -o 
build/lib.freebsd-11.0-CURRENT-amd64-2.7/_ldap.so
cc: error: unknown argument: '-R/usr/local/lib'
cc: error: unknown argument: '-R/usr/lib'
error: command 'cc' failed with exit status 1


cc -shared -O2 -pipe -fno-strict-aliasing 
build/temp.freebsd-11.0-CURRENT-amd64-2.7/Modules/_bsddb.o -L/usr/local/lib 
-R/usr/local/lib -o build/lib.freebsd-11.0-CURRENT-amd64-2.7/bsddb3/_pybsddb.so 
-ldb-4.3
cc: error: unknown argument: '-R/usr/local/lib'
error: command 'cc' failed with exit status 1


I found the patch below to help, it is for function runtime_library_dir_option 
in Lib/distutils/unixccompiler.py
-Wl,-rpath works for both gcc and clang on freebsd

--- ./Lib/distutils/unixccompiler.py.orig
+++ ./Lib/distutils/unixccompiler.py
@@ -228,6 +228,8 @@
 if sys.platform[:6] == darwin:
 # MacOSX's linker doesn't understand the -R flag at all
 return -L + dir
+elif sys.platform[:7] == freebsd:
+return -Wl,-rpath= + dir
 elif sys.platform[:5] == hp-ux:
 if self._is_gcc(compiler):
 return [-Wl,+s, -L + dir]

--
components: Distutils
messages: 212176
nosy: Antoine.Brodin.FreeBSD, koobs
priority: normal
severity: normal
status: open
title: Some python extensions can't be compiled with clang 3.4
versions: Python 2.7

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



[issue20767] Some python extensions can't be compiled with clang 3.4

2014-02-25 Thread STINNER Victor

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


--
nosy: +doko, loewis, thomas-petazzoni

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



[issue20767] Some python extensions can't be compiled with clang 3.4

2014-02-25 Thread koobs

Changes by koobs koobs.free...@gmail.com:


--
versions: +Python 3.3, Python 3.4, Python 3.5

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



[issue20767] Some python extensions can't be compiled with clang 3.4

2014-02-25 Thread koobs

koobs added the comment:

Details on how clang 3.4 changes behaviour for compiler flags: 

http://llvm.org/releases/3.4/tools/clang/docs/ReleaseNotes.html#new-compiler-flags

--

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



[issue20768] pyconfig.h #defines macros in global namespace

2014-02-25 Thread Felipe Sateler

New submission from Felipe Sateler:

I reported the following in the debian bug tracker[1], and it was requested 
that I report it here.

pyconfig.h has definitions like the following:

#define HAVE_DIRENT_H 1
#define HAVE_DLFCN_H 1

These are the general form feature test macros take in practically any
software project. This means that when building a python module these
feature macros conflict. In the best scenario, you get a redefinition
warning. In the worst scenario, the build breaks because of inconsistent
#defines between the module and pyconfig.h.

Please either don't include pycongfig.h from Python.h, or appropiately
namespace the test macros (PYTHON_HAVE_* or something like that).


[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=738726

--
components: Installation
messages: 212178
nosy: fsateler
priority: normal
severity: normal
status: open
title: pyconfig.h #defines macros in global namespace
versions: Python 2.7, Python 3.4

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



[issue20246] buffer overflow in socket.recvfrom_into

2014-02-25 Thread R. David Murray

R. David Murray added the comment:

We don't currently have the capability to set an email trigger when the type is 
set to security.  That should be submitted as a request on the meta tracker.  
(It will require a new reactor, which is easy, and a tweak to the database 
schema, which I don't offhand remember how to deploy, but it shouldn't be hard.)

--
nosy: +ezio.melotti

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



[issue20768] pyconfig.h #defines macros in global namespace

2014-02-25 Thread Matthias Klose

Matthias Klose added the comment:

no, I requested that you propose a patch.  And the question why you need to 
include Python.h everywhere where it could do harm is unanswered too.

--
nosy: +doko

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



[issue20763] old sys.path_hooks importer does not work with Python 3.4.0rc1

2014-02-25 Thread R. David Murray

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


--
nosy: +larry
priority: normal - release blocker

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



[issue20768] pyconfig.h #defines macros in global namespace

2014-02-25 Thread Felipe Sateler

Felipe Sateler added the comment:

I'm sorry but I definitely don't have time or knowledge about python
to propose a patch (simply removing pyconfig.h clearly doesn't work).

As to the question, please clarify. I have a python module, which
includes Python.h, which includes pyconfig.h. I don't include Python.h
everywhere. My build system does use several HAVE_* macros. It seems
as if no breakage has occurred, but this is not guaranteed. And I
shouldn't need to tiptoe around other libraries feature test macros,
especially when they infringe on the global namespace.

-- 

Saludos,
Felipe Sateler

--

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



[issue20727] Improved roundrobin itertools recipe

2014-02-25 Thread David Lindquist

David Lindquist added the comment:

Thanks Gareth for your analysis. Very informative!

--

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



[issue20763] old sys.path_hooks importer does not work with Python 3.4.0rc1

2014-02-25 Thread jan matejek

Changes by jan matejek jmate...@suse.cz:


--
nosy: +matejcik

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



[issue20768] pyconfig.h #defines macros in global namespace

2014-02-25 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 25.02.2014 15:29, Felipe Sateler wrote:
 
 I'm sorry but I definitely don't have time or knowledge about python
 to propose a patch (simply removing pyconfig.h clearly doesn't work).
 
 As to the question, please clarify. I have a python module, which
 includes Python.h, which includes pyconfig.h. I don't include Python.h
 everywhere. My build system does use several HAVE_* macros. It seems
 as if no breakage has occurred, but this is not guaranteed. And I
 shouldn't need to tiptoe around other libraries feature test macros,
 especially when they infringe on the global namespace.

Those HAVE_* macros are mostly standard autoconf macros, which you'll
find in lots of libraries, not just Python.

You can use them in your Python module as well, and of course,
add more autoconf macros as needed using a separate .h file.

C doesn't have namespaces like C++ does, so the only possible change
would be to prefix all of those macros with PY_. Since this is the
first time I've ever heard anyone complain about those macros,
I doubt that this is a general problem. People are usually happy
with building on the autoconf tests we already have in Python.

--
nosy: +lemburg

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



[issue18978] Allow urllib.request.Request subclasses to override method

2014-02-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1afbd851d1c1 by R David Murray in branch 'default':
whatsnew: Request.method can be overridden in subclasses (#18978).
http://hg.python.org/cpython/rev/1afbd851d1c1

--

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



[issue20767] Some python extensions can't be compiled with clang 3.4

2014-02-25 Thread Raymond Hettinger

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


--
priority: normal - high

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



[issue20767] Some python extensions can't be compiled with clang 3.4

2014-02-25 Thread Matthias Klose

Matthias Klose added the comment:

this looks safe from my point of view.

However the real problem is that you unconditionally add a runtime path for a 
standard system path.  I think the better way to fix this is not to pass the -L 
and -R arguments at all if the library is found in a system path.

--

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



[issue18818] Empty PYTHONIOENCODING is not the same as nonexistent

2014-02-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8ac9c3754d33 by R David Murray in branch 'default':
whatsnew: encoding is now optional in PYTHONIOENCODING (#18818)
http://hg.python.org/cpython/rev/8ac9c3754d33

--

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



[issue20769] Reload() description is unclear

2014-02-25 Thread Roy Smith

New submission from Roy Smith:

http://docs.python.org/2/library/functions.html#reload says:

It is legal though generally not very useful to reload built-in or dynamically 
loaded modules, except for sys, __main__ and __builtin__.

It is unclear what the except for ... part is referring to.  Is it not legal 
to reload those modules?  Or is it not very useful to reload them?

--
assignee: docs@python
components: Documentation
messages: 212187
nosy: docs@python, roysmith
priority: normal
severity: normal
status: open
title: Reload() description is unclear
versions: Python 2.7

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



[issue20767] Some python extensions can't be compiled with clang 3.4

2014-02-25 Thread Antoine Brodin.FreeBSD

Antoine Brodin.FreeBSD added the comment:

For the python-ldap extension, this seems to be a buglet in its setup.cfg, it 
lists /usr/lib in library_dirs and /usr/include in library_dirs

For the others, /usr/local/lib is not in the default library search path (only 
/lib and /usr/lib) so at least -L has to be specified.

--

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



[issue20763] old sys.path_hooks importer does not work with Python 3.4.0rc1

2014-02-25 Thread Brett Cannon

Brett Cannon added the comment:

The problem is that the PEP 451 switch accidentally cut out compatibility code 
for PathEntryFinder.find_module() since Python 3.3 started the transition to 
find_loader(). Adding a bit of code to 
http://hg.python.org/cpython/file/8ac9c3754d33/Lib/importlib/_bootstrap.py#l1865
 and a test will fix it.

--

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



[issue20763] old sys.path_hooks importer does not work with Python 3.4.0rc1

2014-02-25 Thread Brett Cannon

Brett Cannon added the comment:

I should also mention that subclassing importlib.abc.PathEntryFinder solves 
this coding problem.

--

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



[issue19619] Blacklist base64, hex, ... codecs from bytes.decode() and str.encode()

2014-02-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9975f827eefd by Serhiy Storchaka in branch '3.3':
Fix typo (issue #19619).
http://hg.python.org/cpython/rev/9975f827eefd

--

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



[issue20770] Inform caller of smtplib STARTTLS failures

2014-02-25 Thread And Clover

New submission from And Clover:

When an SMTP server responds to the STARTTLS command with an error, the 
smtplib.SMTP.starttls() method does not raise an exception, as it would if TLS 
negotiation itself failed. Consequently naïve callers of the function may 
assume that a TLS connection has actually been established and continue to send 
sensitive mail through the interface.

In reality starttls() returns a tuple of response code and message from which 
the fail state can be detected, but this is not documented and no caller code 
I've met does anything with it.

Either:

1. Treat it as a doc bug for 3.4. The return value should be documented and 
callers warned that they need to check that value[0]==220 before assuming they 
have negotiated TLS. Or,

2. starttls() should raise SMTPResponseException for responses other than 220 
in a future Python version, especially if moving towards validate-by-default. 
Possibly only raise an exception if the SSLContext.verify_mode is REQUIRED?

--
components: Library (Lib)
messages: 212192
nosy: aclover
priority: normal
severity: normal
status: open
title: Inform caller of smtplib STARTTLS failures
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4

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



[issue20767] Some python extensions can't be compiled with clang 3.4

2014-02-25 Thread Martin v . Löwis

Martin v. Löwis added the comment:

doko: how do you know the addition of the -R option is unconditional? and whom 
do you refer to by you who is adding the option?

In any case, the patch is independent of whether the option is added 
unconditionally, and I agree that the patch looks safe. The question is whether 
it should be extended to the other *BSDs as well.

--

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



[issue20770] Inform caller of smtplib STARTTLS failures

2014-02-25 Thread And Clover

And Clover added the comment:

This could potentially be considered a security issue as it would allow a MitM 
attacker to sabotage the STARTTLS and get the rest of the content in the clear.

I don't personally consider it too serious as I doubt anyone is (a) relying on 
the security of this for lowly mail and (b) has the rest of the context stuff 
set up to validate the TLS connection properly anyhow, but there's an argument 
for sec bug.

--

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



[issue20404] Delayed exception using non-text encodings with TextIOWrapper

2014-02-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is backported to 3.3 patch.

--
nosy: +georg.brandl
Added file: 
http://bugs.python.org/file34221/issue20404_check_valid_textio_codec-3.3.patch

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



[issue20246] buffer overflow in socket.recvfrom_into

2014-02-25 Thread Chris Rose

Chris Rose added the comment:

Is there an ETA for a 2.7.7 release with this fix?

--
nosy: +offby1

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



[issue20769] Reload() description is unclear

2014-02-25 Thread R. David Murray

R. David Murray added the comment:

The python3 docs say:

It is legal though generally not very useful to reload built-in or dynamically 
loaded modules (this is not true for e.g. sys, __main__, builtins and other key 
modules where reloading is frowned upon).

So, it is the former...sort of.  You don't get an error when you reload them, 
so implying that it is not legal is an odd phrasing.  Probably that sentence 
should be clarified in both the python2 and python3 docs.

--
nosy: +brett.cannon, eric.smith, r.david.murray

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



[issue20769] Reload() description is unclear

2014-02-25 Thread R. David Murray

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


--
Removed message: http://bugs.python.org/msg212197

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



[issue20769] Reload() description is unclear

2014-02-25 Thread R. David Murray

R. David Murray added the comment:

The python3 docs say:

It is legal though generally not very useful to reload built-in or dynamically 
loaded modules (this is not true for e.g. sys, __main__, builtins and other key 
modules where reloading is frowned upon).

So, it is the former...sort of.  You don't get an error when you reload them, 
so implying that it is not legal is an odd phrasing.  Probably that sentence 
should be clarified in both the python2 and python3 docs.

--

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



[issue20771] Download Talkray...

2014-02-25 Thread Alfonso Andalon Jr.

New submission from Alfonso Andalon Jr.:

Download this http://talkray.com/dl/ee

--
messages: 212199
nosy: Alfonso.Andalon.Jr.
priority: normal
severity: normal
status: open
title: Download Talkray...

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



[issue20771] Download Talkray...

2014-02-25 Thread Zachary Ware

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


--
Removed message: http://bugs.python.org/msg212199

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



[issue20771] spam

2014-02-25 Thread Zachary Ware

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


--
nosy:  -Alfonso.Andalon.Jr.
resolution:  - invalid
stage:  - committed/rejected
status: open - closed
title: Download Talkray... - spam

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



[issue20770] Inform caller of smtplib STARTTLS failures

2014-02-25 Thread R. David Murray

R. David Murray added the comment:

I agree that there is an argument for classifying this as a low-impact security 
bug.  Whether or not it is so classified will affect how we fix it.  I'll email 
the psrt about it.

--
nosy: +r.david.murray

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



[issue20770] Inform caller of smtplib STARTTLS failures

2014-02-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

It probably isn't a good idea to break the API, but this should certainly be 
documented.

--
nosy: +pitrou

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



[issue20770] Inform caller of smtplib STARTTLS failures

2014-02-25 Thread Barry A. Warsaw

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


--
nosy: +barry

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



[issue20501] fileinput module will read whole file into memory when using fileinput.hook_encoded

2014-02-25 Thread Zachary Ware

Zachary Ware added the comment:

 Can anyone please test the patch on Windows?

It seems to work; memory usage is much lower with the patch than without using 
an 8 MB file.  I don't notice any behavioral change with the patch; if there's 
anything specific to look for on that front, give me a test script in either 
English or Python :)

--
nosy: +zach.ware

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



  1   2   >