[Perl Golf] Round 1

2012-02-05 Thread Alec Taylor
One sentence can contain one or more strings next to each-other, which
can be joined to make another word.

e.g.:

"to get her" == "together"
"an other" == "another"
"where about" == "whereabouts"

&etc

Solve this problem using as few lines of code as possible[1].

Good luck!

[1] Don't use external non-default libraries; non-custom word-lists excepted
-- 
http://mail.python.org/mailman/listinfo/python-list


PyCrypto builds neither with MSVC nor MinGW

2012-02-05 Thread Alec Taylor
PIL, PyCrypto and many other modules require a C compiler and linker.

Unfortunately neither install on my computer, with a PATH with the following:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
C:\libraries\MinGW\msys\1.0\bin
C:\libraries\MinGW
C:\Python27\Scripts

Output from G:\pycrypto>vcvarsall.bat
Setting environment for using Microsoft Visual Studio 2010 x86 tools.

Error output from G:\pycrypto>python setup.py build --compiler msvc
http://pastebin.com/nBsuXDGg

Error output from G:\pycrypto>python setup.py build --compiler mingw32
1> log1 2> log2
Log1: http://pastebin.com/yG3cbdZv
Log2: http://pastebin.com/qvnshPeh

Will there ever be support for newer MSVC versions? - Also, why
doesn't even MinGW install PyCrypto for me?

Thanks for all suggestions,

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


Help about dictionary append

2012-02-05 Thread Anatoli Hristov
Hi there,

I`m again confused and its the dictionary. As dictionary does not support
append I create a variable list with dictionary key values and want to add
new values to it and then copy it again to the dictionary as I dont know
other methods.

mydict =
{'Name':('Name1','Name2','Name3'),'Tel':('02','03','04')}

Then I use the key "Name" from the dict

name = mydict['Name']
and
tel = mydict['Tel']

then I want to add at the end new values and doing:

name.append('Name4')

and I get and error that TUPLE object has no attribute Append !!!

But how to add new Values to a dictionary then ?

I know its kind of basics in python, but I was seeking in the python
website and even google and could not realise that.

Thank you for your suggestions

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


Re: Help about dictionary append

2012-02-05 Thread Chris Angelico
On Mon, Feb 6, 2012 at 2:13 AM, Anatoli Hristov  wrote:
> Hi there,
>
> I`m again confused and its the dictionary. As dictionary does not support
> append I create a variable list with dictionary key values and want to add
> new values to it and then copy it again to the dictionary as I dont know
> other methods.

A dictionary maps a key to exactly one value. If you want multiples,
you do pretty much what you've done here...

> mydict =
> {'Name':('Name1','Name2','Name3'),'Tel':('02','03','04')}
>...
> and I get and error that TUPLE object has no attribute Append !!!
>
> But how to add new Values to a dictionary then ?

... but instead of using parentheses and creating a Tuple, use square
brackets and create a List:

mydict = {'Name':['Name1','Name2','Name3'],'Tel':['02','03','04']}

Then you can append to it, and it will work just fine!

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


Re: Help about dictionary append

2012-02-05 Thread James Broadhead
On 5 February 2012 15:13, Anatoli Hristov  wrote:
> Hi there,
>
> I`m again confused and its the dictionary. As dictionary does not support
> append I create a variable list with dictionary key values and want to add
> new values to it and then copy it again to the dictionary as I dont know
> other methods.
>
> mydict =
> {'Name':('Name1','Name2','Name3'),'Tel':('02','03','04')}
>

dicts are intended to be used differently from this;
more like:

name_tel = {}
name_tel['Name1'] = 02
name_tel['Name2'] = 03
print name_tel['Name1']

... where Name is the key used to retrieve the value (the telephone number).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyCrypto builds neither with MSVC nor MinGW

2012-02-05 Thread Christian Heimes
Am 05.02.2012 15:40, schrieb Alec Taylor:
> PIL, PyCrypto and many other modules require a C compiler and linker.
> 
> Unfortunately neither install on my computer, with a PATH with the following:
> 
> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
> C:\libraries\MinGW\msys\1.0\bin
> C:\libraries\MinGW
> C:\Python27\Scripts

MSVC 10 is not supported, you need VC 9 (2008).

Christian

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


Re: Help about dictionary append

2012-02-05 Thread Andrew Berg
On 2/5/2012 9:13 AM, Anatoli Hristov wrote:
> and I get and error that TUPLE object has no attribute Append !!!
You defined mydict['name'] as a tuple, and tuples are immutable. Using a
tuple means that you don't ever want the values to change.

> But how to add new Values to a dictionary then ?
This has nothing to do with dictionaries. If you want to add, delete, or
change items, use a list (or a set if there aren't supposed to be any
duplicates). Information on built-in types is here:

http://docs.python.org/library/stdtypes.html (2.7)
http://docs.python.org/py3k/library/stdtypes.html (3.2)

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Common LISP-style closures with Python

2012-02-05 Thread Alan Ristow

On 02/05/2012 05:19 AM, Antti J Ylikoski wrote:


Yes, I do know that, but then it would not be a closure :-)


Forgive me if this is terribly naive, but what is the advantage of using 
a closure as opposed to, say, some other function that returns the same 
value in the same context, but is not a closure?


Alan

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


Re: PyCrypto builds neither with MSVC nor MinGW

2012-02-05 Thread Alec Taylor
A 4 year old compiler?

I also have MSVC11 installed. Can the python project add support for
that so that we aren't waiting 5 years between compiler support?

On Mon, Feb 6, 2012 at 2:23 AM, Christian Heimes  wrote:
> Am 05.02.2012 15:40, schrieb Alec Taylor:
>> PIL, PyCrypto and many other modules require a C compiler and linker.
>>
>> Unfortunately neither install on my computer, with a PATH with the following:
>>
>> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
>> C:\libraries\MinGW\msys\1.0\bin
>> C:\libraries\MinGW
>> C:\Python27\Scripts
>
> MSVC 10 is not supported, you need VC 9 (2008).
>
> Christian
>
> --
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyCrypto builds neither with MSVC nor MinGW

2012-02-05 Thread Steven D'Aprano
On Mon, 06 Feb 2012 03:42:08 +1100, Alec Taylor wrote:

> A 4 year old compiler?

Compilers aren't like milk. They don't go off after a few weeks. A good 
compiler/operating system combination should still be usable after 4 or 
14 years. The compiler I'm using is six years old, and I expect that it 
will continue to get patches and upgrades without breaking backwards 
compatibility for the next six years.


> I also have MSVC11 installed. Can the python project add support for
> that so that we aren't waiting 5 years between compiler support?

Are you volunteering to provide that support? I'm sure it would be 
appreciated.


P.S. Please don't top-post.


> On Mon, Feb 6, 2012 at 2:23 AM, Christian Heimes 
> wrote:
>> Am 05.02.2012 15:40, schrieb Alec Taylor:
>>> PIL, PyCrypto and many other modules require a C compiler and linker.
>>>
>>> Unfortunately neither install on my computer, with a PATH with the
>>> following:
>>>
>>> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
>>> C:\libraries\MinGW\msys\1.0\bin
>>> C:\libraries\MinGW
>>> C:\Python27\Scripts
>>
>> MSVC 10 is not supported, you need VC 9 (2008).
>>
>> Christian


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


Re: [Perl Golf] Round 1

2012-02-05 Thread Heiko Wundram

Am 05.02.2012 12:49, schrieb Alec Taylor:

Solve this problem using as few lines of code as possible[1].


Pardon me, but where's "the problem"? If your intention is to propose "a 
challenge", say so, and state the associated problem clearly.


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


Re: Help about dictionary append

2012-02-05 Thread Anatoli Hristov
Thanks Chris,

It works fine, I see it will take time till I understand all the syntax :(

A.H

On Sun, Feb 5, 2012 at 4:20 PM, Chris Angelico  wrote:

> On Mon, Feb 6, 2012 at 2:13 AM, Anatoli Hristov  wrote:
> > Hi there,
> >
> > I`m again confused and its the dictionary. As dictionary does not support
> > append I create a variable list with dictionary key values and want to
> add
> > new values to it and then copy it again to the dictionary as I dont know
> > other methods.
>
> A dictionary maps a key to exactly one value. If you want multiples,
> you do pretty much what you've done here...
>
> > mydict =
> > {'Name':('Name1','Name2','Name3'),'Tel':('02','03','04')}
> >...
> > and I get and error that TUPLE object has no attribute Append !!!
> >
> > But how to add new Values to a dictionary then ?
>
> ... but instead of using parentheses and creating a Tuple, use square
> brackets and create a List:
>
> mydict =
> {'Name':['Name1','Name2','Name3'],'Tel':['02','03','04']}
>
> Then you can append to it, and it will work just fine!
>
> Chris Angelico
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Common LISP-style closures with Python

2012-02-05 Thread Ian Kelly
On Sat, Feb 4, 2012 at 9:19 PM, Antti J Ylikoski  wrote:
>> I'm not sure how naughty this is, but the same thing can be done without
>> using
>> nonlocal by storing the local state as an attribute of the enclosed
>> function
>> object:
>>
>> ...
>
> Yes, I do know that, but then it would not be a closure :-)

Sure it is.  Where do you think it looks up the function object?

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Perl Golf] Round 1

2012-02-05 Thread Ben Finney
Alec Taylor  writes:

> One sentence can contain one or more strings next to each-other, which
> can be joined to make another word.
>
> e.g.:
>
> "to get her" == "together"
> "an other" == "another"
> "where about" == "whereabouts"
>
> &etc

Yes, that's true.

> Solve this problem using as few lines of code as possible[1].

Easy::

True

> Good luck!

What do I win?

-- 
 \“All opinions are not equal. Some are a very great deal more |
  `\   robust, sophisticated, and well supported in logic and argument |
_o__) than others.” —Douglas Adams |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Perl Golf] Round 1

2012-02-05 Thread Neal Becker
Heiko Wundram wrote:

> Am 05.02.2012 12:49, schrieb Alec Taylor:
>> Solve this problem using as few lines of code as possible[1].
> 
> Pardon me, but where's "the problem"? If your intention is to propose "a
> challenge", say so, and state the associated problem clearly.
> 

But this really misses the point.  Python is not about coming up with some 
clever, cryptic, one-liner to solve some problem.  It's about clear code.  If 
you want clever, cryptic, one-liner's stick with perl.

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


MySQLdb not allowing hyphen

2012-02-05 Thread Emeka
Hello All,

I noticed that MySQLdb not allowing hyphen may be way to prevent injection
attack.
I have something like below:

"insert into reviews(message, title)values('%s', '%s')" %( "We don't know
where to go","We can't wait till morrow" )

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 't know where to go.

How do I work around this error?

Regards,
Emeka
-- 
*Satajanus  Nig. Ltd


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


Re: MySQLdb not allowing hyphen

2012-02-05 Thread Chris Rebert
On Sun, Feb 5, 2012 at 2:41 PM, Emeka  wrote:
>
> Hello All,
>
> I noticed that MySQLdb not allowing hyphen may be way to prevent injection
> attack.
> I have something like below:
>
> "insert into reviews(message, title)values('%s', '%s')" %( "We don't know
> where to go","We can't wait till morrow" )
>
> 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 't know where to go.
>
> How do I work around this error?

Don't use raw SQL strings in the first place. Use a proper
parameterized query, e.g.:

cursor.execute("insert into reviews(message, title) values (%s, %s)",
("We don't know where to go", "We can't wait till morrow"))

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


Re: [Perl Golf] Round 1

2012-02-05 Thread Heiko Wundram

Am 05.02.2012 23:15, schrieb Neal Becker:

Heiko Wundram wrote:

Am 05.02.2012 12:49, schrieb Alec Taylor:

Solve this problem using as few lines of code as possible[1].


Pardon me, but where's "the problem"? If your intention is to propose "a
challenge", say so, and state the associated problem clearly.


But this really misses the point.  Python is not about coming up with some
clever, cryptic, one-liner to solve some problem.  It's about clear code.  If
you want clever, cryptic, one-liner's stick with perl.


You're only allowed to bash him for one-liners as soon as he formulates 
something that in some way or another resembles a programming challenge, 
and not some incoherent listing of words without actual intent... ;-)


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


Re: MySQLdb not allowing hyphen

2012-02-05 Thread Emeka
Dennis , Chris

Thanks so much!



On Mon, Feb 6, 2012 at 1:23 AM, Dennis Lee Bieber wrote:

> On Mon, 6 Feb 2012 00:41:24 +0200, Emeka  wrote:
>
> >Hello All,
> >
> >I noticed that MySQLdb not allowing hyphen may be way to prevent injection
> >attack.
>
> What hyphen?
>
> >I have something like below:
> >
> >"insert into reviews(message, title)values('%s', '%s')" %( "We don't know
> >where to go","We can't wait till morrow" )
> >
> 
> >How do I work around this error?
>
> Very simple... DON'T QUOTE PLACEHOLDERS AND USE MySQLdb
> parameterized queries.
>
> csr.execute("insert into reviews (message, title) values (%s, %s)",
>(   "We don't know where to go",
>"We can't wait till  morrow"   )   )
>
>The whole purpose of parameterized queries is that the .execute()
> logic will SAFELY wrap the supplied values with quotes AND escape any
> problem characters within the value.
>
>The reason you got an error was not a hyphen (there are no hyphens
> in your example) but rather that you closed the quote. Your generated
> SQL was:
>
> insert into reviews (message, title) values ('We don't know where to
> go', 'We can't wait till morrow')
>
> which means a string of:
>"We don"
> SQL garbage
> t know where to go
> string
>", "
> SQL garbage
>We can
> and another string
>"t wait till morrow"
> --
>Wulfraed Dennis Lee Bieber AF6VN
>wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
*Satajanus  Nig. Ltd


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


Python and TAP

2012-02-05 Thread Matej Cepl
I have just finished listening to the FLOSS Weekly podcast #200 
(http://twit.tv/show/floss-weekly/200) on autotest, where I've learned 
about the existence of TAP (http://testanything.org/). A standardization 
of testing seems to be so obviously The Right Thing™, that it is strange 
that I don't see much related movement in the Python world (I know only 
about http://git.codesimply.com/?p=PyTAP.git;a=summary or 
git://git.codesimply.com/PyTAP.git, which seems to be very very simple 
and only producer).


What am I missing? Why nobody seems to care about joining TAP standard?

Best,

Matěj
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyCrypto builds neither with MSVC nor MinGW

2012-02-05 Thread Terry Reedy

On 2/5/2012 6:23 PM, Dennis Lee Bieber wrote:

On Mon, 6 Feb 2012 03:42:08 +1100, Alec Taylor
wrote:


A 4 year old compiler?

I also have MSVC11 installed. Can the python project add support for
that so that we aren't waiting 5 years between compiler support?


3.3 will almost certainly be built with VS2010.

--
Terry Jan Reedy

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


difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Matej Cepl

Hi,

I have this working function:

   def as_xml(self):
out = etree.Element("or")
for k in sorted(self.keys()):
out.append(etree.Element("hostname",
attrib={'op': '=', 'value': random.choice(self[k])}))

# ... return somehow string representing XML

and this unit test

   def test_XML_print(self):
random.seed(1)
expected = ... # expected XML
observed = self.data.as_xml()
self.assertEqual(observed, expected,
 "Verbose print (including PCI IDs)")

Strange thing is that this unit tests correctly with python3, but fails 
with python2. The problem is that apparently python3 random.choice picks 
different element of self[k] than the one python2 (at least, both of 
them are constant in their choice).


Is it known that there is this difference? Is there a way how to make 
both random.choice select the same?


Best,

Matěj
--
http://mail.python.org/mailman/listinfo/python-list


Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Steven D'Aprano
On Mon, 06 Feb 2012 02:27:38 +0100, Matej Cepl wrote:

> Strange thing is that this unit tests correctly with python3, but fails
> with python2. The problem is that apparently python3 random.choice picks
> different element of self[k] than the one python2 (at least, both of
> them are constant in their choice).

Confirmed:

steve@runes:~$ python2.6 -c "from random import choice, seed; seed(1); 
print choice(range(1000))"
134
steve@runes:~$ python3.2 -c "from random import choice, seed; seed(1); 
print(choice(list(range(1000"
137

steve@runes:~$ python2.6 -c "from random import choice, seed; seed(42); 
print choice(range(1000))"
639
steve@runes:~$ python3.2 -c "from random import choice, seed; seed(42); 
print(choice(list(range(1000"
654


> Is it known that there is this difference? Is there a way how to make
> both random.choice select the same?

Reading the docs, I would expect that when using an int as seed, you 
should get identical results. There is no mention that the PRNG has 
changed between 2.6 and 3.2; both should use the given int as seed. There 
is a change of behaviour when using strings/bytes/bytearrays, and 
Python3.2 provides a "version=N" argument to seed to set the old 
behaviour. But this doesn't apply to integer seeds.

I call this a bug.

It appears to be a bug in 3.2, because 3.1 gives the same results as 2.6:

steve@runes:~$ python3.1 -c "from random import choice, seed; seed(42); 
print(choice(list(range(1000"
639
steve@runes:~$ python3.1 -c "from random import choice, seed; seed(1); 
print(choice(list(range(1000"
134


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


Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Terry Reedy

On 2/5/2012 11:01 PM, Steven D'Aprano wrote:


Reading the docs, I would expect that when using an int as seed, you
should get identical results.


That is similar to expecting hash to be consistent from version to version.


There is no mention that the PRNG has changed between 2.6 and 3.2;


There is at best an informal policy. This was discussed in
http://bugs.python.org/issue9025
Antoine argued that if there were a written policy, it should be limited 
to bug-fix releases within a version. I agree.



It appears to be a bug in 3.2, because 3.1 gives the same results as 2.6:


This change is a side effect of fixing the bug of non-uniformity 
discussed in that issue. In any case, in 2.7 and probably 3.1:


def choice(self, seq):
"""Choose a random element from a non-empty sequence."""
return seq[int(self.random() * len(seq))]  # raises IndexError

whereas in 3.2:

def choice(self, seq):
"""Choose a random element from a non-empty sequence."""
try:
i = self._randbelow(len(seq))
except ValueError:
raise IndexError('Cannot choose from an empty sequence')
return seq[i]

The change was announced in What's New in 3.2

random
The integer methods in the random module now do a better job of 
producing uniform distributions. Previously, they computed selections 
with int(n*random()) which had a slight bias whenever n was not a power 
of two. Now, multiple selections are made from a range up to the next 
power of two and a selection is kept only when it falls within the range 
0 <= x < n. The functions and methods affected are randrange(), 
randint(), choice(), shuffle() and sample().


--
Terry Jan Reedy

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


help function and operetors overloading

2012-02-05 Thread Mohsen Pahlevanzadeh
Dear all,

You know python has many functions for operators overloading such as
__add__, __radd__, __invert__, __eq__ and so on.
How i see the complete list of them with help function?

Yours,
Mohsen


signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Common LISP-style closures with Python

2012-02-05 Thread Antti J Ylikoski

On 5.2.2012 22:58, Ian Kelly wrote:

On Sat, Feb 4, 2012 at 9:19 PM, Antti J Ylikoski  wrote:

I'm not sure how naughty this is, but the same thing can be done without
using
nonlocal by storing the local state as an attribute of the enclosed
function
object:

...


Yes, I do know that, but then it would not be a closure :-)


Sure it is.  Where do you think it looks up the function object?

Cheers,
Ian


OK, thank you for correcting me.

Andy

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


Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Steven D'Aprano
On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote:

> On 2/5/2012 11:01 PM, Steven D'Aprano wrote:
> 
>> Reading the docs, I would expect that when using an int as seed, you
>> should get identical results.
> 
> That is similar to expecting hash to be consistent from version to
> version.

No. hash is not intended to be consistent across versions, or even across 
runs of the interpreter. Of course it may be, but that's not an implicit 
or explicit promise. Seeding a pseudo-random number generator, on the 
other hand, is explicitly for generating the same repeatable, consistent 
set of results. That's what seed is *for*.

It is even documented that way:

http://docs.python.org/py3k/library/random.html#notes-on-reproducibility

although the docs weasel out of promising anything other than 
random.random() will be predictable.

When the Mersenne Twister was introduced, the old Wichman-Hill PRNG was 
provided for those who needed repeatability. (I see it's gone now, but if 
people haven't migrated their code from 2.3 yet, shame on them.)


>> There is no mention that the PRNG has changed between 2.6 and 3.2;
> 
> There is at best an informal policy. This was discussed in
> http://bugs.python.org/issue9025
> Antoine argued that if there were a written policy, it should be limited
> to bug-fix releases within a version. I agree.

I think this thread demonstrates that there are people who depend on 
repeatability of the random number routines, and not just for 
random.random().

I think it is ironic (and annoying) that the same release of Python that 
introduced a version argument to seed() to provide a backward compatible 
seeding algorithm, also introduced a backward incompatible change to 
choice().

This, plus Raymond Hettinger's comments on the bug report, make me think 
that the change in behaviour of randrange and choice is not deliberate 
and should be treated as a bug. Raymond made a strong case arguing for 
repeatability, and then approved a bug fix that broke repeatability. I 
doubt that was deliberate.


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


Re: help function and operetors overloading

2012-02-05 Thread Chris Rebert
On Sun, Feb 5, 2012 at 9:48 PM, Mohsen Pahlevanzadeh
 wrote:
> Dear all,
>
> You know python has many functions for operators overloading such as
> __add__, __radd__, __invert__, __eq__ and so on.
> How i see the complete list of them with help function?

I don't know if there's a help() entry for them. The docs have a full
list of those "special method names":
http://docs.python.org/reference/datamodel.html#special-method-names

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


Re: [Perl Golf] Round 1

2012-02-05 Thread Chris Angelico
On Mon, Feb 6, 2012 at 10:03 AM, Heiko Wundram  wrote:
> You're only allowed to bash him for one-liners as soon as he formulates
> something that in some way or another resembles a programming challenge, and
> not some incoherent listing of words without actual intent... ;-)

Nah, one-liners are fun. Look, here's a Python one-liner that
generates a month's worth of emails:

t = ('a', [23]); t[1] += [42]

*ducks for cover*

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


Re: PyCrypto builds neither with MSVC nor MinGW

2012-02-05 Thread Chris Angelico
On Mon, Feb 6, 2012 at 12:26 PM, Terry Reedy  wrote:
> On 2/5/2012 6:23 PM, Dennis Lee Bieber wrote:
>>
>> On Mon, 6 Feb 2012 03:42:08 +1100, Alec Taylor
>> wrote:
>>
>>> A 4 year old compiler?
>>>
>>> I also have MSVC11 installed. Can the python project add support for
>>> that so that we aren't waiting 5 years between compiler support?
>
>
> 3.3 will almost certainly be built with VS2010.

I suppose there's no chance of moving to a free compiler? For my
Windows work, I've generally used the Open Watcom compiler; that's not
to say it's the best, but it does the job, and it's free software.

But no, I'm not offering. Way way too many jobs that I already have
queued, sorry!

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


Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Terry Reedy

On 2/6/2012 12:56 AM, Steven D'Aprano wrote:

On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote:


On 2/5/2012 11:01 PM, Steven D'Aprano wrote:


Reading the docs, I would expect that when using an int as seed, you
should get identical results.


That is similar to expecting hash to be consistent from version to
version.


No. hash is not intended to be consistent across versions, or even across


Oh, but it was. Changing it will break tests, including some in the 
Python test suite.


...

This, plus Raymond Hettinger's comments on the bug report, make me think
that the change in behaviour of randrange and choice is not deliberate


As I said, it was a necessary consequence of a bug fix.


and should be treated as a bug. Raymond made a strong case arguing for
repeatability, and then approved a bug fix that broke repeatability. I
doubt that was deliberate.


It was deliberate that randrange was changed to an even distribution 
from a slightly uneven distribute. That implies a change in the pattern. 
That was known and the main subject of discussion. As Antoine said, 
making functions exactly repeatable across versions means not fixing 
bugs or otherwise improving them. This statement is not limited to the 
random module.


You have persuaded me that the doc should be more explicit that while 
the basic random.random sequence will be kept repeatable with seed set 
(except perhaps after a changeover of several releases), the convenience 
transformations can be changed if improvements are needed or thought 
sufficiently desirable.


--
Terry Jan Reedy

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


Re: help function and operetors overloading

2012-02-05 Thread Terry Reedy

On 2/6/2012 12:48 AM, Mohsen Pahlevanzadeh wrote:

Dear all,

You know python has many functions for operators overloading such as
__add__, __radd__, __invert__, __eq__ and so on.
How i see the complete list of them with help function?


>>> import operator
>>> help(operator)
Help on built-in module operator:
...

--
Terry Jan Reedy

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


Re: PyCrypto builds neither with MSVC nor MinGW

2012-02-05 Thread Terry Reedy

On 2/6/2012 1:53 AM, Chris Angelico wrote:

On Mon, Feb 6, 2012 at 12:26 PM, Terry Reedy  wrote:

On 2/5/2012 6:23 PM, Dennis Lee Bieber wrote:


On Mon, 6 Feb 2012 03:42:08 +1100, Alec Taylor
wrote:


A 4 year old compiler?

I also have MSVC11 installed. Can the python project add support for
that so that we aren't waiting 5 years between compiler support?



3.3 will almost certainly be built with VS2010.


I suppose there's no chance of moving to a free compiler?


VC express is free-as-in-beer. The whole V. Studio is free to core 
developers. MS may not *like* open-source software, but they have 
decided they would like it even less if everyone compiled it with non-MS 
compilers.



Windows work, I've generally used the Open Watcom compiler; that's not
to say it's the best, but it does the job, and it's free software.


Would it build CPython, including the +- dependent libraries like 
tcl/tk? How would the speed compare?



But no, I'm not offering. Way way too many jobs that I already have
queued, sorry!


I guess the answer will have to wait ;-).

--
Terry Jan Reedy

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