Hello Friends

2011-03-30 Thread Ashraf Ali
You can fine Bollywood Actresses Biography, WAllpapers & Pictures on
the following website.
www.bollywoodhotactresses.weebly.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Hello Friends

2011-03-30 Thread Ashraf Ali
you can fine bollywood actresses biography,wallpapers & pictures on
this website
www.bollywoodhotactresses.weebly.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiprocessing Pool.imap broken?

2011-03-30 Thread [email protected]
Yang,

My guess is that you are running into a problem using multiprocessing with
the interpreter. The documentation states that Pool may not work correctly
in this case.

> Note: Functionality within this package requires that the __main__ method
> be importable by the children. This is covered in *Programming 
> guidelines*however
>  it is worth pointing out here. This means that some examples, such
> as the multiprocessing.Pool examples will not work in the interactive
> interpreter.
>
Hope this helps,

Kyle



On Tue, Mar 29, 2011 at 6:51 PM, Yang Zhang  wrote:

> On Tue, Mar 29, 2011 at 6:44 PM, Yang Zhang 
> wrote:
> > I've tried both the multiprocessing included in the python2.6 Ubuntu
> > package (__version__ says 0.70a1) and the latest from PyPI (2.6.2.1).
> > In both cases I don't know how to use imap correctly - it causes the
> > entire interpreter to stop responding to ctrl-C's.  Any hints?  Thanks
> > in advance.
> >
> > $ python
> > Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
> > [GCC 4.4.3] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
>  import multiprocessing as mp
>  mp.Pool(1).map(abs, range(3))
> > [0, 1, 2]
>  list(mp.Pool(1).imap(abs, range(3)))
> > ^C^C^C^C^\Quit
> >
>
> In case anyone jumps on this, this isn't an issue with running from the
> console:
>
> $ cat /tmp/go3.py
> import multiprocessing as mp
> print mp.Pool(1).map(abs, range(3))
> print list(mp.Pool(1).imap(abs, range(3)))
>
> $ python /tmp/go3.py
> [0, 1, 2]
> ^C^C^C^C^C^\Quit
>
> (I've actually never seen the behavior described in the corresponding
> Note at the top of the multiprocessing documentation.)
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Bring out yer dead Bring out yer dead

2011-03-30 Thread harrismh777


 2.6.2
 2.5.1
  ==
 (___) \--- ( 3.2 )



Cartman: Bring out yer dead,..  bring out yer dead...

Devlpr: Here' one...  (Python27)

Cartman: ... nine pence!

Python27:   I'm not dead!

Cartman: What?

Devlpr: Nothing, here's your nine pence.

Python27:   I'm not dead!

Cartman: There, he says he's not dead...

Devlpr: yes he is

Python27:   I'm not!

Cartman: He isn't?

Devlpr: Well, he will be soon, he's very ill...

Python27:   I'm getting better!

Devlpr: no yer not, you'll be stone dead in a moment...

Cartman: I can't take 'em like that, its against regulations!

Python27:   I don't want to go on the cart!

Devlpr: Oh, don't be such a baby...

Cartman: I can't take him.

Python27:   I feel fine!

Devlpr: oh, do us a favor, 'ey?

Cartman: I can't.

Devlpr: ah, can you hang around for a couple of minutes,
it won't take long?

Cartman: I've got to get to Robinson's, they've lost nine today.

Devlpr: Well, when's your next round then?

Cartman: Thursday.

Python27:   I think I'll go for a walk !

Devlpr: You're not fooling anyone ya know...(!)

Devlpr: Look, isn't there anything you can do?

Python27:   I feel happy!  I feel happy!:)

Cartman: Club( Python27 ).__whack__

Devlpr: Oh thank you very much !

Cartman: Not at all,

Devlpr: see ya Thursday?!

Cartman: Right.

Horse(virtual).__clomping__ {Guido?}

Devlpr: who's that then...

Cartman: I don't know.

Devlpr: ... must be a king!

Cartman: Why?

Devlpr: ... hasn't got shitul-over'em.


 2.7.1
 2.6.2
 2.5.1
  ==
 (___) \--- ( 3.2 )

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


PyInstaller and error: 'support/loader/run'

2011-03-30 Thread Ale Ghelfi
I've a script of Python 2.6.6 under Ubuntu 10.10 and i would pass it to 
XP like exe.
My script use wxPython and read some files jpg that are in the same 
directory of the script.


Before to use Pyinstaller 1.4, i did:
cd /source/linux
python Make.py
make

But "make" returned this error that i didn't understand:

gcc -pthread  -I/usr/include -I/usr/include/python2.6 -I../common 
-DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing 
-g -O2 -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -DHAVE_WARNINGS 
-c getpath.c -o getpath.o

getpath.c:40: fatal error: osdefs.h: File o directory non esistente
compilation terminated.
make: *** [getpath.o] Errore 1

Anyway, after this, i did also:
python Config.py

Then:
python makespec.py -F -w MioScript.py
python Build.py (il file ottenuto dal passaggio precedente)

After Build.py, pyinstaller return this error:

checking Analysis
checking PYZ
checking PKG
checking EXE
building because outEXE2.toc missing or bad
building EXE from outEXE2.toc
Traceback (most recent call last):
  File "Build.py", line 1160, in 
main(args[0], configfilename=opts.configfile)
  File "Build.py", line 1148, in main
build(specfile)
  File "Build.py", line , in build
execfile(spec)
  File "quiz/quiz.spec", line 14, in 
console=1 )
  File "Build.py", line 663, in __init__
self.__postinit__()
  File "Build.py", line 196, in __postinit__
self.assemble()
  File "Build.py", line 748, in assemble
self.copy(exe, outf)
  File "Build.py", line 764, in copy
inf = open(fnm, 'rb')
IOError: [Errno 2] No such file or directory: 'support/loader/run'

Any ideas? Thank you very very much!!

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


invio di una stringa

2011-03-30 Thread luca72
ciao  a tutti
sniffando i dati del protocollo irc con wireshark noto che a un certo
punto per il resume di un trasferimento un noto programma manda questa
stringa:
PRIVMSG Ex|testtrasf|001 :\001DCC RESUME prova_trasferimento.pdf 58772
5016204\001
a questo punto il server risponde.
Utilizzando i socket io riesco a connettermi al server ed a inviargli
tuti i messaggi che voglio, ma quando mando il comando sopra scritto
il server non mi risponde.
 La mia domanda è \001 a cosa corrisponde?
penso che l'inghippo sia li, perche gli altri comandi che non hanno lo
\001 vengono digeriti bene?
Grazie Luca
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Guido rethinking removal of cmp from sort method

2011-03-30 Thread Antoon Pardon
On Tue, Mar 29, 2011 at 03:35:40PM -0400, Terry Reedy wrote:
> For anyone interested, the tracker discussion on removing cmp is at
> http://bugs.python.org/issue1771
> There may have been more on the old py3k list and pydev list.
> 
> One point made there is that removing cmp= made list.sort consistent
> with all the other comparision functions,
> min/max/nsmallest/nlargest/groupby that only have a key arg. How
> many would really want cmp= added everywhere?

I wouldn't have a problem with it.

I would also like to react to the following.

Guido van Rossum in msg95975 on http://bugs.python.org/issue1771 wrote:
| Also, for all of you asking for cmp back, I hope you realize that 
| sorting N values using a custom cmp function makes about N log N calls 
| calls to cmp, whereas using a custom key calls the key function only N 
| times.  This means that even if your cmp function is faster than the 
| best key function you can write, the advantage is lost as N increases 
| (which is just where you'd like it to matter most :-).

This is a play on semantics. If you need python code to compare
two items, then this code will be called N log N times, independently
of the fact how this code is presented, as a cmp function or as rich
comparison methods. So forcing people to write a key function in cases
where this will only result in the cmp code being translated to __lt__
code, accomplishes nothing. 

As far as I can see, key will only produce significant speedups, if
comparing items can then be completly done internally in the python
engine without referencing user python code.

> A minor problem problem with cmp is that the mapping between return
> values and input comparisons is somewhat arbitrary. Does -1 mean a or b to forget without constant use).

My rule of thumb is that a < b is equivallent with cmp(a, b) < 0

> A bigger problem is that it conflicts with key=. What is the result of
> l=[1,3,2]
> l.sort(cmp=lambda x,y:y-x, key=lambda x: x)
> print l
> ? (for answer, see http://bugs.python.org/issue11712 )
> 
> While that can also be learned, I consider conflicting parameters
> undesireable and better avoided when reasonably possible. So I see
> this thread as a discussion of the meaning of 'reasonably' in this
> particular case.

But what does this have to do with use cases? Does what is reasonable
depend on the current use cases without regard of possible future use
cases? Is the conflict between key and cmp a lesser problem in the
case of someone having a huge data set to sort on a computer that lacks
the resources to decorate as opposed to currently noone having such
a data set? Are we going to decide which functions/methods get a cmp
argument depening on which use cases we currently have that would need it?

This thread started with a request for use cases. But if you take this
kind of things into consideration, I don't see how use cases can then
make a big difference in the final decision.

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


Re: delete namespaces

2011-03-30 Thread Jean-Michel Pichavant

monkeys paw wrote:

How do i delete a module namespace once it has been imported?

I use

import banner

Then i make a modification to banner.py. When i import it again,
the new changes are not reflected. Is there a global variable i can
modify?

It depends on what you want to achieve.

1/ if you want to re-import your module because it contains User data 
that may have been updated, one way is to make sure all you definitions 
are at the module level and use the execfile statement. ofc the file is 
executed, so it can be done only in a trusted environment.


2/ if you want to reload your module because you changed the code and 
want to test it, the best way to do it is to write a test file that will 
do all the tests so that restarting the test is cheap. Testing from a 
newly created python process is always the best solution, if available.


3/ if you want to do the 2/ but require a painful long prologue to your 
test, then you may want to use the builtin reload. Use it with care, 
because any existing object created from the previous module will not be 
affected, they'll still hold the previous code. "reload" solves some 
problems, but bring others, especially for the newcomer.



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


Re: Fun python 3.2 one-liner

2011-03-30 Thread Martin De Kauwe
what is the character limit on a one liner :P. Very interesting
jesting apart, any more?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fun python 3.2 one-liner

2011-03-30 Thread Chris Angelico
On Wed, Mar 30, 2011 at 8:19 PM, Martin De Kauwe  wrote:
> what is the character limit on a one liner :P. Very interesting
> jesting apart, any more?

Not sure if this can be redone as a one-liner; currently it's two.


for i in range(3):
print '\n\t"'+("minor","medium","major")[i]+'
":({\n\t\t'+"\n\t\t".join([q[0]+',"'+" ".join(q[1:])+'",' for q in
[q.split("\x96")[-1].split(" ") for q in "\n".join([q.split("
",3)[i]+" "+q.split(" ",3)[3] for q in
a.split("\n")]).replace("\x92","'").split("\n")] if
q[0]!="\x97"])+'\n\t}),'

That's the code I used in IDLE to translate this:

Minor Medium Major Ring Market Price
01–18 — — Protection +1 2,000 gp
19–28 — — Feather falling 2,200 gp
61–70 01–05 — Counterspells 4,000 gp
71–75 06–08 — Mind shielding 8,000 gp
86–90 24–28 — Ram 8,600 gp
— 29–34 — Climbing, improved 10,000 gp
— 35–40 — Jumping, improved 10,000 gp
— 41–46 — Swimming, improved 10,000 gp
91–93 47–51 — Animal friendship 10,800 gp
94–96 50–56 01–02 Energy resistance, minor 12,000 gp
99–100 62–66 — Water walking 15,000 gp
— 94–97 29–32 Blinking 27,000 gp
— 98–100 33–39 Energy resistance, major 28,000 gp
— — 40–49 Protection +4 32,000 gp
— — 98 Elemental command (fire) 200,000 gp
— — 99 Elemental command (water) 200,000 gp
— — 100 Spell storing, major 200,000 gp

into something that my dice-roller can use. (In the interests of
brevity I've chopped a whole lot of the table out, but each column
contains every possible value from 01 to 100.)

Not as "cool" as the previous one, but it sure was handy!

In case you're wondering: Yes, that is Dungeons and Dragons. I run an
online D&D server. Nerd? Only slightly.

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


Re: [pyplot] using f1=figure(1)

2011-03-30 Thread eryksun ()
On Monday, March 28, 2011 12:04:02 PM UTC-4, Giacomo Boffi wrote:
>
> >>> f1=figure(1)
> >>> f2=figure(2)
> >>> f1
> 
> >>> f2
> 
> >>> plot(sin(linspace(0,10)),figure=f1)
> []
> >>> plot(cos(linspace(0,10)),figure=f2)
> []
> >>> show()

You can set the current figure to fig1 with the following:

figure(fig1.number)
plot(...)

Alternatively, you can use the plot methods of a particular axes:

fig1 = figure()
ax1 = axes()
fig2 = figure()
ax2 = axes()

ax1.plot(...)
ax2.plot(...)

It works the same for subplots:

fig1 = figure()
ax11 = subplot(211)
ax12 = subplot(212)
fig2 = figure()
ax21 = subplot(211)
ax22 = subplot(212)
 
ax12.plot(...)
#etc
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bring out yer dead Bring out yer dead

2011-03-30 Thread [email protected]
On 30 mar, 09:12, harrismh777  wrote:
>       2.6.2
>       2.5.1
>    ==
>       (___)     \--- ( 3.2 )
>
> Cartman: Bring out yer dead,..  bring out yer dead...
>
> Devlpr:         Here' one...  (Python27)
>
> Cartman: ... nine pence!
>
> Python27:               I'm not dead!
>
> Cartman: What?
>
> Devlpr: Nothing, here's your nine pence.
>
> Python27:               I'm not dead!
>
> Cartman: There, he says he's not dead...
>
> Devlpr: yes he is
>
> Python27:               I'm not!
>
> Cartman: He isn't?
>
> Devlpr: Well, he will be soon, he's very ill...
>
> Python27:               I'm getting better!
>
> Devlpr: no yer not, you'll be stone dead in a moment...
>
> Cartman: I can't take 'em like that, its against regulations!
>
> Python27:               I don't want to go on the cart!
>
> Devlpr: Oh, don't be such a baby...
>
> Cartman: I can't take him.
>
> Python27:               I feel fine!
>
> Devlpr: oh, do us a favor, 'ey?
>
> Cartman: I can't.
>
> Devlpr: ah, can you hang around for a couple of minutes,
>         it won't take long?
>
> Cartman: I've got to get to Robinson's, they've lost nine today.
>
> Devlpr: Well, when's your next round then?
>
> Cartman: Thursday.
>
> Python27:               I think I'll go for a walk !
>
> Devlpr: You're not fooling anyone ya know...(!)
>
> Devlpr: Look, isn't there anything you can do?
>
> Python27:               I feel happy!  I feel happy!    :)
>
> Cartman: Club( Python27 ).__whack__
>
> Devlpr: Oh thank you very much !
>
> Cartman: Not at all,
>
> Devlpr: see ya Thursday?!
>
> Cartman: Right.
>
>         Horse(virtual).__clomping__     {Guido?}
>
> Devlpr: who's that then...
>
> Cartman: I don't know.
>
> Devlpr: ... must be a king!
>
> Cartman: Why?
>
> Devlpr: ... hasn't got shitul-over'em.
>
>       2.7.1
>       2.6.2
>       2.5.1
>    ==
>       (___)     \--- ( 3.2 )


+1 QOTW - but this will make for the longuest QOTW ever 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Directly Executable Files in Python

2011-03-30 Thread eryksun ()
On Tuesday, March 29, 2011 3:51:30 AM UTC-4, Paul Rudin wrote:
> Benjamin Kaplan  writes:
> 
> > If you can figure out a good way to compile a language like Python,
> > you'll be very rich. Yes, it is running the interpreter and then
> > running the bytecode on the interpreter. It's the same way Java and
> > .NET work.
> 
> Not exactly AIUI. .NET bytecodes do actually get compiled to executable code
> before being executed (unless things have changed recently - I haven't
> really done anything significant with .NET in the last couple of years).

Java and languages in Microsoft's CLI (common language infrastructure) are 
statically typed, so it's not exactly a straight-forward comparison. 

IIRC, IronPython programs compile to a DLR (dynamic language runtime) AST 
(abstract source tree). This represents the program as runtime method calls and 
invoked DynamicSite objects. A site creates a caching delegate that checks the 
given argument types. As it encounters new combinations of argument types, it 
compiles the operation and updates the delegate.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiprocessing Pool.imap broken?

2011-03-30 Thread eryksun ()
On Tuesday, March 29, 2011 9:44:21 PM UTC-4, Yang Zhang wrote:
> I've tried both the multiprocessing included in the python2.6 Ubuntu
> package (__version__ says 0.70a1) and the latest from PyPI (2.6.2.1).
> In both cases I don't know how to use imap correctly - it causes the
> entire interpreter to stop responding to ctrl-C's.  Any hints?  Thanks
> in advance.
> 
> $ python
> Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
> [GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import multiprocessing as mp
> >>> mp.Pool(1).map(abs, range(3))
> [0, 1, 2]
> >>> list(mp.Pool(1).imap(abs, range(3)))
> ^C^C^C^C^\Quit

It works fine for me on Win32 Python 2.7.1 with multiprocessing 0.70a1. So it's 
probably an issue with the implementation on Linux.

Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) 
[MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing as mp
>>> list(mp.Pool(1).imap(abs, range(3)))
[0, 1, 2]
>>> mp.__version__
'0.70a1'
-- 
http://mail.python.org/mailman/listinfo/python-list


learn python the hard way exercise 42 help

2011-03-30 Thread neil harper
http://pastie.org/1735028
hey guys play is confusing me, i get how next gets the first room, which
is passed when the instance of Game() is created, but how does it get
the next room?

thanks

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


Re: learn python the hard way exercise 42 help

2011-03-30 Thread eryksun ()
On Wednesday, March 30, 2011 9:48:29 AM UTC-4, neil harper wrote:
> http://pastie.org/1735028
> hey guys play is confusing me, i get how next gets the first room, which
> is passed when the instance of Game() is created, but how does it get
> the next room?
> 
> thanks

Each room is a method of Game. The returned value of each room is a reference 
to another room, depending on some condition. play() just loops the following: 
call room(); store the return reference as next; assign next to room. This 
continues until death(), which randomly insults you and quits.
-- 
http://mail.python.org/mailman/listinfo/python-list


Sudden error: SyntaxError: Non-ASCII character '\xc2' in file

2011-03-30 Thread Gnarlodious
RSS script runs fine on my dev machine but errors on the server
machine. Script was last run 3 days ago with no problem. Possible
clue: dev machine is (Mac OSX) running Python 3.1.1 while server is
running Python 3.1.3. I have not updated anything that should suddenly
cause this error starting yesterday.

The error originates at '·' which string contains a ·
character.

Complete error message is:

SyntaxError: Non-ASCII character '\xc2' in file /Library/WebServer/
Sites/Sectrum/Site/Feed.py on line 17, but no encoding declared; see
http://www.python.org/peps/pep-0263.html for details

Any help how to fix this and why it suddenly started erroring 2 days
ago...

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


logging module usage

2011-03-30 Thread mennis
I am working on a library for controlling various appliances in which
I use the logging module.  I'd like some input on the basic structure
of what I've done.  Specifically the logging aspect but more general
comments are welcome.  I'm convinced I mis-understand something but
I'm not sure what.  I've posted a version of the library at github.

[email protected]:mennis/otto.git
http://github.com/mennis/otto
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file

2011-03-30 Thread Benjamin Kaplan
On Wed, Mar 30, 2011 at 10:34 AM, Gnarlodious  wrote:
> RSS script runs fine on my dev machine but errors on the server
> machine. Script was last run 3 days ago with no problem. Possible
> clue: dev machine is (Mac OSX) running Python 3.1.1 while server is
> running Python 3.1.3. I have not updated anything that should suddenly
> cause this error starting yesterday.
>
> The error originates at '·' which string contains a ·
> character.
>
> Complete error message is:
>
> SyntaxError: Non-ASCII character '\xc2' in file /Library/WebServer/
> Sites/Sectrum/Site/Feed.py on line 17, but no encoding declared; see
> http://www.python.org/peps/pep-0263.html for details
>
> Any help how to fix this and why it suddenly started erroring 2 days
> ago...
>
> -- Gnarlie

You don't have a · character. Your computer doesn't understand
"characters". You have the byte sequence \xc2\xb7. When you have a
Unicode string (the default in Python 3), Python needs some way of
converting the byte sequence to a character sequence. The way it does
that is through the encoding. But you don't have an encoding
specified, so rather than guess, Python is falling back on the lowest
common denominator: ASCII, which doesn't understand the byte \xc2-
hence the error.

To fix this, just put the line
# coding=utf-8
at the very top of the code file.

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


Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file

2011-03-30 Thread Peter Otten
Gnarlodious wrote:

> RSS script runs fine on my dev machine but errors on the server
> machine. Script was last run 3 days ago with no problem. Possible
> clue: dev machine is (Mac OSX) running Python 3.1.1 while server is
> running Python 3.1.3. I have not updated anything that should suddenly
> cause this error starting yesterday.
> 
> The error originates at '·' which string contains a ·
> character.
> 
> Complete error message is:
> 
> SyntaxError: Non-ASCII character '\xc2' in file /Library/WebServer/
> Sites/Sectrum/Site/Feed.py on line 17, but no encoding declared; see
> http://www.python.org/peps/pep-0263.html for details
> 
> Any help how to fix this and why it suddenly started erroring 2 days
> ago...

You are trying to run your 3.x code with Python 2.x...

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


argparse csv + choices

2011-03-30 Thread Neal Becker
I'm trying to combine 'choices' with a comma-seperated list of options, so I 
could do e.g., 

--cheat=a,b

parser.add_argument ('--cheat', choices=('a','b','c'), type=lambda x: 
x.split(','), default=[])

test.py --cheat a
 error: argument --cheat: invalid choice: ['a'] (choose from 'a', 'b', 'c')

The validation of choice is failing, because parse returns a list, not an item. 
 
Suggestions?

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


Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file

2011-03-30 Thread Peter Otten
Benjamin Kaplan wrote:

> On Wed, Mar 30, 2011 at 10:34 AM, Gnarlodious 
> wrote:
>> RSS script runs fine on my dev machine but errors on the server
>> machine. Script was last run 3 days ago with no problem. Possible
>> clue: dev machine is (Mac OSX) running Python 3.1.1 while server is
>> running Python 3.1.3. I have not updated anything that should suddenly
>> cause this error starting yesterday.
>>
>> The error originates at '·' which string contains a ·
>> character.
>>
>> Complete error message is:
>>
>> SyntaxError: Non-ASCII character '\xc2' in file /Library/WebServer/
>> Sites/Sectrum/Site/Feed.py on line 17, but no encoding declared; see
>> http://www.python.org/peps/pep-0263.html for details
>>
>> Any help how to fix this and why it suddenly started erroring 2 days
>> ago...
>>
>> -- Gnarlie
> 
> You don't have a · character. Your computer doesn't understand
> "characters". You have the byte sequence \xc2\xb7. When you have a
> Unicode string (the default in Python 3), Python needs some way of
> converting the byte sequence to a character sequence. The way it does
> that is through the encoding. But you don't have an encoding
> specified, so rather than guess, Python is falling back on the lowest
> common denominator: ASCII, which doesn't understand the byte \xc2-
> hence the error.
> 
> To fix this, just put the line
> # coding=utf-8
> at the very top of the code file.

All good advice except that Python 3 defaults to UTF-8 not ASCII as its 
source encoding.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: argparse csv + choices

2011-03-30 Thread Robert Kern

On 3/30/11 10:32 AM, Neal Becker wrote:

I'm trying to combine 'choices' with a comma-seperated list of options, so I
could do e.g.,

--cheat=a,b

 parser.add_argument ('--cheat', choices=('a','b','c'), type=lambda x:
x.split(','), default=[])

test.py --cheat a
  error: argument --cheat: invalid choice: ['a'] (choose from 'a', 'b', 'c')

The validation of choice is failing, because parse returns a list, not an item.
Suggestions?


Do the validation in the type function.


import argparse

class ChoiceList(object):
def __init__(self, choices):
self.choices = choices

def __repr__(self):
return '%s(%r)' % (type(self).__name__, self.choices)

def __call__(self, csv):
args = csv.split(',')
remainder = sorted(set(args) - set(self.choices))
if remainder:
raise ValueError("invalid choices: %r (choose from %r)" % 
(remainder, self.choices))

return args


parser = argparse.ArgumentParser()
parser.add_argument('--cheat', type=ChoiceList(['a','b','c']), default=[])
print parser.parse_args(['--cheat=a,b'])
parser.parse_args(['--cheat=a,b,d'])

--
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

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


Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file

2011-03-30 Thread eryksun ()
On Wednesday, March 30, 2011 10:34:46 AM UTC-4, Gnarlodious wrote:
> 
> The error originates at '·' which string contains a ·
> character.
> 
> Complete error message is:
> 
> SyntaxError: Non-ASCII character '\xc2' in file /Library/WebServer/
> Sites/Sectrum/Site/Feed.py on line 17, but no encoding declared; see
> http://www.python.org/peps/pep-0263.html for details

A middle dot is Unicode \x00\xb7, which maps to UTF-8 \xc2\xb7. According to 
PEP 3120 the default source encoding for Python 3.x is UTF-8. (I'll take their 
word for it, since I'm still using 2.7). Are you declaring an ASCII encoding 
(e.g. # coding: ascii)? If not, are you sure that you're running in 3.x?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: delete namespaces

2011-03-30 Thread Terry Reedy

On 3/30/2011 5:10 AM, Jean-Michel Pichavant wrote:


3/ if you want to do the 2/ but require a painful long prologue to your
test, then you may want to use the builtin reload. Use it with care,
because any existing object created from the previous module will not be
affected, they'll still hold the previous code. "reload" solves some
problems, but bring others, especially for the newcomer.


Guido removed it in 3.x because it is badly flawed and he could see any 
way to sensibly fix it.


--
Terry Jan Reedy

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


Get USB ID of a serial port through pyserial?

2011-03-30 Thread John Nagle

  Is there some way to get the USB ID of a serial port through
pyserial on Linux and/or Windows?  USB serial port devices have
device names determined by when they were plugged in.  So, if
you have more than one USB serial device, you need the USB device's
built-in ID to figure out what's out there.

  Is there a way to get that info portably?

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


Re: delete namespaces

2011-03-30 Thread Tim Golden

On 30/03/2011 8:03 PM, Terry Reedy wrote:

On 3/30/2011 5:10 AM, Jean-Michel Pichavant wrote:


3/ if you want to do the 2/ but require a painful long prologue to your
test, then you may want to use the builtin reload. Use it with care,
because any existing object created from the previous module will not be
affected, they'll still hold the previous code. "reload" solves some
problems, but bring others, especially for the newcomer.


Guido removed it in 3.x because it is badly flawed and he could see any
way to sensibly fix it.


Well, "moved" rather than "removed":


Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52)
Type "help", "copyright", "credits" or "license"

import imp
imp.reload








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


Re: Data files for tests

2011-03-30 Thread Ethan Furman

Steven D'Aprano wrote:
I have a package with some tests. The tests are not part of the package 


Do you mean they are not importable, as in

--> from spam import tests

or they are not distributed?  Because it seems to me that distributing 
them would be worthwhile to at least some of the folks downloading your 
package (assuming you distribute it).


For myself, I do keep my tests in a folder in the package itself -- 
keeps it out of the way (any necessary files also go there).


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


py 2.7.1 & openssl

2011-03-30 Thread V N
I installed openssl-1.0.0d.tar.gz on my RHEL 5 box using:
 ./config --prefix=/usr/local --openssldir=/usr/local/openssl
shared zlib
 make
 sudo make install

Then I installed python 2.7.1 using
 PYHOME=/usr/local/Python-2.7.1; export PYHOME
 LD_RUN_PATH=$PYHOME/lib; export LD_RUN_PATH
 LDFLAGS="-L /usr/local/lib64 -L /usr/local/lib"; export
LDFLAGS
 CPPFLAGS="-I /usr/local/include -I /usr/local/include/
openssl"; export CPPFLAGS
 ./configure --enable-shared --prefix=$PYHOME > log_cfg 2>&1
 make > log_mk 2>&1
 sudo make install > log_mk_i 2>&1

I am trying to install
sudo $PYHOME/bin/python bin/ez_setup.py

and I get the following error:

Traceback (most recent call last):
  File "bin/ez_setup.py", line 67, in 
except ImportError: from md5 import md5
  File "/usr/local/Python-2.7.1/lib/python2.7/md5.py", line 10, in

from hashlib import md5
  File "/usr/local/Python-2.7.1/lib/python2.7/hashlib.py", line 136,
in 
globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Python-2.7.1/lib/python2.7/hashlib.py", line 71, in
__get_builtin_constructor
import _md5
ImportError: No module named _md5

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


FBI wants public help solving encrypted notes from murder mystery

2011-03-30 Thread Joe Snodgrass

FBI cryptanalysis hasn’t decrypted notes from 1999 murder mystery

http://tinyurl.com/4d56zsz

The FBI is seeking the public's help in breaking the encrypted code
found in two notes discovered on the body of a murdered man in 1999.

The FBI says that officers in St. Louis, Missouri discovered the body
of 41-year-old Ricky McCormick on June 30, 1999 in a field and the
clues regarding the homicide were two encrypted notes found in the
victim's pants pockets.

The FBI says that despite extensive work by its Cryptanalysis and
Racketeering Records Unit (CRRU), and the American Cryptogram
Association, the meanings of those two coded notes remain a mystery
and McCormick's murderer has never been found. One has to wonder
though, if the FBI can't figure this out, who can? But I digress.

>From the FBI: "The more than 30 lines of coded material use a
maddening variety of letters, numbers, dashes, and parentheses.
McCormick was a high school dropout, but he was able to read and write
and was said to be 'street smart.' According to members of his family,
McCormick had used such encrypted notes since he was a boy, but
apparently no one in his family knows how to decipher the codes, and
it's unknown whether anyone besides McCormick could translate his
secret language. Investigators believe the notes in McCormick's
pockets were written up to three days before his death."

"Standard routes of cryptanalysis seem to have hit brick walls," said
CRRU chief Dan Olson in a statement. To move the case forward,
examiners need another sample of McCormick's coded system-or a similar
one-that might offer context to the mystery notes or allow valuable
comparisons to be made. Or, short of new evidence, Olson said, "Maybe
someone with a fresh set of eyes might come up with a brilliant new
idea."

The FBI says it has always relied on public tips and other assistance
to solve crimes though breaking a code may represent a special
circumstance.

For larger images of the notes go here. [LINK]

If you have an idea how to break the code, have seen similar codes, or
have any information about the Ricky McCormick case, write to CRRU at
the following address:

FBI Laboratory
Cryptanalysis and Racketeering Records Unit
2501 Investigation Parkway
Quantico, VA 22135
Attn: Ricky McCormick Case

There is no reward being offered, just the knowledge that you may be
solving an intriguing murder mystery, the FBI stated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FBI wants public help solving encrypted notes from murder mystery

2011-03-30 Thread Fons Adriaensen
On Wed, Mar 30, 2011 at 01:25:54PM -0700, Joe Snodgrass wrote:

> For larger images of the notes go here. [LINK]

[LINK]  ???

-- 
FA


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


Re: FBI wants public help solving encrypted notes from murder mystery

2011-03-30 Thread harrismh777

Fons Adriaensen wrote:

[LINK]  ???


http://www.net-security.org/secworld.php?id=10823


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


Next Melbourne PUG meeting 6pm Monday 4th of April @ RMIT

2011-03-30 Thread Richard Jones
Hi all,

Sorry for the late post this week. The next meeting is next Monday,
the 4th of April at RMIT.

The room has changed! After the double-booking last week we've been
moved to 12.07.02 (building 12, level 7, room 2).

Tennessee's going to talk to us about an approach to benchmarking that
he's been working on.

If you have some experience with benchmarking or profiling Python
code, perhaps you have something you can share?

I'm going to talk about PyWeek number 12, which starts this coming
Sunday morning :-)

Full meeting info at http://j.mp/mpug


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


Dictionary Descriptors

2011-03-30 Thread Raymond Hettinger
On the python-ideas list, someone made a wild proposal to add
descriptors to dictionaries.

None of the respondents seemed to realize that you could (not should,
just could) already implement this using hooks already present in the
language.  I'm posting an example here because I thought you all might
find it to be both interesting and educational.

For more details on how it works and how it relates to descriptors,
see http://mail.python.org/pipermail/python-ideas/2011-March/009657.html

Raymond

 sample code 

class MyDict(object):
def __init__(self, mapping):
self.mapping = mapping
def __getitem__(self, key):
value = self.mapping[key]
if hasattr(value, '__get__'):
print('Invoking descriptor on', key)
return value.__get__(key)
print('Getting', key)
return value
def __setitem__(self, key, value):
self.mapping[key] = value

class Property:
def __init__(self, getter):
self.getter = getter
def __get__(self, key):
return self.getter(key)

if __name__ == '__main__':
md = MyDict({})
md['x'] = 10
md['_y'] = 20
md['y'] = Property(lambda key: md['_'+key])
print(eval('x+y+1', {}, md))

 output 

Getting x
Invoking descriptor on y
Getting _y
31
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fun python 3.2 one-liner

2011-03-30 Thread Raymond Hettinger
On Mar 30, 2:19 am, Martin De Kauwe  wrote:
> what is the character limit on a one liner :P. Very interesting
> jesting apart, any more?

Sure, here are three one-liners using itertools.groupby() to emulate
some Unix pipelines:

  sort letters | uniq   # list unique values
  sort letters | uniq -c# count unique values
  sort letters | uniq -d# find duplicates

>>> from itertools import groupby

>>> [k for k, g in groupby(sorted('abracadabra'))]
['a', 'b', 'c', 'd', 'r']

>>> [(k, len(list(g))) for k, g in groupby(sorted('abracadabra'))]
[('a', 5), ('b', 2), ('c', 1), ('d', 1), ('r', 2)]

>>> [k for k, g in groupby(sorted('abracadabra')) if len(list(g)) > 1]
['a', 'b', 'r']


Raymond


P.S.  Of course, there are many ways to do this.

>>> sorted(set('abracadabra'))
['a', 'b', 'c', 'd', 'r']

>>> sorted(Counter('abracadabra').items())
[('a', 5), ('b', 2), ('c', 1), ('d', 1), ('r', 2)]

>>> sorted(k for k,c in Counter('abracadabra').items() if c > 1)
['a', 'b', 'r']
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learn python the hard way exercise 42 help

2011-03-30 Thread Raymond Hettinger
On Mar 30, 6:48 am, neil harper  wrote:
> http://pastie.org/1735028
> hey guys play is confusing me, i get how next gets the first room, which
> is passed when the instance of Game() is created, but how does it get
> the next room?

It might help show calling patterns if you added print statements to
the while loop:

   def play(self):
next = self.start
while True:
room = getattr(self, next)
print "--- Calling the method:", room, "---"
next = room()
print "--- That method returned:", next, "---"

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


Re: popular programs made in python?

2011-03-30 Thread Raymond Hettinger
On Mar 29, 7:32 am, Neil Alt  wrote:
> i mean made with python only, not just a small part of python.

BitTorrent was a huge success.


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


Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file

2011-03-30 Thread Gnarlodious
On Mar 30, 9:28 am, Peter Otten wrote:

> You are trying to run your 3.x code with Python 2.x...

You're right. Exactly why this started happening I don't know.

Thanks.

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


Re: delete namespaces

2011-03-30 Thread Raymond Hettinger
[monkeys paw]
> > How do i delete a module namespace once it has been imported?
 . . .
> > Then i make a modification to banner.py. When i import it again,
> > the new changes are not reflected.

[Terry Reedy]
> The best thing, if possible, is to restart the program.
> If you develop banner.py with adequate tests, you will want to restart
> the test anyway, and you should not need to modify much thereafter.

This is excellent advice.

You're much better-off starting fresh each time.


Raymond

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


Re: Directly Executable Files in Python

2011-03-30 Thread Raymond Hettinger
On Mar 28, 8:37 pm, Jordan Meyer  wrote:
> Is it possible to make a directly executable (such as .exe on Windows) file 
> from scripts written in Python? So as to prevent the end-user from having to 
> download an interpreter to run the program.

http://docs.python.org/faq/programming.html#how-can-i-create-a-stand-alone-binary-from-a-python-script


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


Re: Why aren't copy and deepcopy in __builtins__?

2011-03-30 Thread Raymond Hettinger
On Mar 27, 8:29 pm, John Ladasky  wrote:
> Simple question.  I use these functions much more frequently than many
> others which are included in __builtins__.  I don't know if my
> programming needs are atypical, but my experience has led me to wonder
> why I have to import these functions.

I asked Guido about this once and he said that he didn't
consider them to be part of the core.  He worried that
they would be overused by beginners and they would be
a distraction from learning plain, simple Python which
doesn't often need either copy() or deepcopy().

AFAICT, he was right.  I've seen large projects where
deepcopy and copy where not used even once.

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


Re: best python games?

2011-03-30 Thread Raymond Hettinger
On Mar 25, 7:39 pm, sogeking99  wrote:
> hey guys, what are some of the best games made in python? free games
> really. like pygames stuff. i want to see what python is capable of.
>
> cant see any good one on pygames site really, though they have nothing
> like sort by rating or most downloaded as far as i can tell

At Pycon, I saw some impressive looking games written
during the PyWeek, Python Game Programming Challenge
http://www.pyweek.org/

I think they're fine examples of what Python is capable of.


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


Re: popular programs made in python?

2011-03-30 Thread eryksun ()
On Tuesday, March 29, 2011 10:32:26 AM UTC-4, Neil Alt wrote:
> i mean made with python only, not just a small part of python.

I think it's uncommon for an application to be programmed entirely in Python. 
It's common to use C/C++ to accelerate performance critical parts of the code. 
I don't see that as a weakness of Python. The developer uses whichever tools 
work best for the task at hand.

Calibre is a popular e-book manager/converter created by Kovid Goyal. It's 
mostly written in Python, with some C extensions for speedups (e.g. SQLite 
database access) and interfacing to OS APIs for fonts, USB devices, etc:

http://bazaar.launchpad.net/~kovid/calibre/trunk/files


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


running Python2 Python3 parallel concurrent

2011-03-30 Thread harrismh777

Greetings,

The purpose of this communique is to document a process for 
installing python2.7.1 in parallel with python3.2 on a concurrent 
desktop with independent idle and python path structure.


Each version (python2, python3) will be installed in a separate 
python shell (idle) run on a separate local install so that both 
versions are running side-by-side on the same user desktop, each python 
shell having a unique .idlerc(v) configuration dir for look&feel as well 
as separate recent files lists and separate working .py folders.


Neither of the installs should affect the other installation (nor 
idle operation), nor should the installs affect the system-wide default 
install (python2.6.2 in my case running ubuntu 9.04 jaunty). As well, 
the search paths should not overlap except at the top $HOME level. The 
over-all purpose is to be able to play with both versions together in 
order to facilitate/enable/solve concurrent development, migration, and 
debug issues between the two versions.


I trust that if the community has already solved this problem, and 
has a better way, that I may discover it and be able to adopt it to my 
own environment as well.


If you find any mistakes, please let me know.

Best regards, m harris.

The primary unordered issues for solution(s) are:

1) separate PythonX folders for .py files, $HOME/PythonX
2) separate desktop launchers to cleanly launch idleX for pythonX
3) separate .idlercX files in the home dir for IDLE pythonX
4) separate correct $HOME/local/pythonX installation folders
5) separate correct $HOME/bin/ launch scripts and sym links
6) Config from sources with correct --prefix setting
7) Local Build & Install

===
BUILD VERSIONS FROM SOURCE
===
Download the 2.7.1 and 3.2 tarballs from here:

http://www.python.org/download/

From your $HOME directory create the modules (.py) folder with:

mkdir Python3 ie.,  $HOME/Python3/

 and then create the local installation folder in $HOME/local:

mkdir local
cd local
mkdir python3 ie.,  $HOME/local/python3/

Create a $HOME/bin/ folder, if it does not already exist.

Unpack each tarball in $HOME with:

tar -xvf Python-3.2.tar.bz2 --bzip2

cd Python-3.2and then build & install with:

./configure --prefix=$HOME/local/python3
make
make install

NOTES:  Repeat these steps for each local version. It is important 
that the development headers already be installed, including the tk-dev 
package so that tkinter mod will get built enabling idle. The tarballs 
are available in several compression schemes... I chose bzip2.
The --prefix option tells the installer where pythonX will live; 
this will be a local install visible only to the development user.


===
Symbolic link(s)
===

Create a symbolic link for python in $HOME/bin/ with:

cd $HOME/bin/
ln -sf $HOME/local/python3/bin/python3 python3

note:  (python3 can now be invoked from a linux terminal)

   Repeat the steps for each version.

   You may need to set your linux path to include
   $HOME/bin/  in either .profile or .bashrc if not
   already in place. This is usually already set on
   most modern linux distros if ~/bin/ exists.

===
Launcher Scripts
===

Create the bash launcher script used for setting the
PYTHONPATH and starting the python3 script. Use a text
editor of your choice to create a text file in $HOME/bin/
called  Python3-IDE  containing these three lines:

#!/bin/sh
export PYTHONPATH=$HOME/Python3
exec $HOME/bin/idle-python3 -n

Now, create the python script for importing and launching
the PyShell from idlelib; use a text editor to create a
text file in $HOME/bin/ called  idle-python3  containing:

#!/home//bin/python3

from idlelib.PyShell import main
if __name__ == '__main__':
main()

The first line /home// is $HOME, but may have to
be spelled out in the script above. Now, set both scripts
executeable with:

chmod 0754 $HOME/bin/Python3-IDE
chmod 0754 $HOME/bin/idle-python3

Notes:  Repeat for each version. Summary; each version will
have its own launcher script ( PythonX-IDE ) and each will
have its own python idle starter script ( idle-pythonX ).

The launcher script is the 'called' file from the Desktop
launcher icon, which sets the PYTHONPATH. The python idle
starter script correctly starts the interpreter and then
initiates the PyShell (python idle shell) import main and
run.


Re: FBI wants public help solving encrypted notes from murder mystery

2011-03-30 Thread David Bernier

Joe Snodgrass wrote:


FBI cryptanalysis hasn’t decrypted notes from 1999 murder mystery

http://tinyurl.com/4d56zsz

The FBI is seeking the public's help in breaking the encrypted code
found in two notes discovered on the body of a murdered man in 1999.

The FBI says that officers in St. Louis, Missouri discovered the body
of 41-year-old Ricky McCormick on June 30, 1999 in a field and the
clues regarding the homicide were two encrypted notes found in the
victim's pants pockets.

The FBI says that despite extensive work by its Cryptanalysis and
Racketeering Records Unit (CRRU), and the American Cryptogram
Association, the meanings of those two coded notes remain a mystery
and McCormick's murderer has never been found. One has to wonder
though, if the FBI can't figure this out, who can? But I digress.

 From the FBI: "The more than 30 lines of coded material use a
maddening variety of letters, numbers, dashes, and parentheses.
McCormick was a high school dropout, but he was able to read and write
and was said to be 'street smart.' According to members of his family,
McCormick had used such encrypted notes since he was a boy, but
apparently no one in his family knows how to decipher the codes, and
it's unknown whether anyone besides McCormick could translate his
secret language. Investigators believe the notes in McCormick's
pockets were written up to three days before his death."

"Standard routes of cryptanalysis seem to have hit brick walls," said
CRRU chief Dan Olson in a statement. To move the case forward,
examiners need another sample of McCormick's coded system-or a similar
one-that might offer context to the mystery notes or allow valuable
comparisons to be made. Or, short of new evidence, Olson said, "Maybe
someone with a fresh set of eyes might come up with a brilliant new
idea."

The FBI says it has always relied on public tips and other assistance
to solve crimes though breaking a code may represent a special
circumstance.

[...]

There are two JPG images (note1.jpg and note2.jpg) at the web page:

< http://www.fbi.gov/news/stories/2011/march > .

As they say there:
" View larger versions (right click and save the files to enlarge further)."
i.e. :
Right click on first image and "Save image as ..." using the browser,
"" ""   on second image and "Save image as ..." using the browser.

I used the GIMP (GNU Image Manipulation Program) to
enlarge and otherwise manipulate the images.  But each
is only about 50 to 80 kilobytes ...

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


Re: FBI wants public help solving encrypted notes from murder mystery

2011-03-30 Thread Stretto



"Joe Snodgrass"  wrote in message 
news:[email protected]...


FBI cryptanalysis hasn’t decrypted notes from 1999 murder mystery

http://tinyurl.com/4d56zsz

The FBI is seeking the public's help in breaking the encrypted code
found in two notes discovered on the body of a murdered man in 1999.

The FBI says that officers in St. Louis, Missouri discovered the body
of 41-year-old Ricky McCormick on June 30, 1999 in a field and the
clues regarding the homicide were two encrypted notes found in the
victim's pants pockets.

The FBI says that despite extensive work by its Cryptanalysis and
Racketeering Records Unit (CRRU), and the American Cryptogram
Association, the meanings of those two coded notes remain a mystery
and McCormick's murderer has never been found. One has to wonder
though, if the FBI can't figure this out, who can? But I digress.

From the FBI: "The more than 30 lines of coded material use a
maddening variety of letters, numbers, dashes, and parentheses.
McCormick was a high school dropout, but he was able to read and write
and was said to be 'street smart.' According to members of his family,
McCormick had used such encrypted notes since he was a boy, but
apparently no one in his family knows how to decipher the codes, and
it's unknown whether anyone besides McCormick could translate his
secret language. Investigators believe the notes in McCormick's
pockets were written up to three days before his death."

"Standard routes of cryptanalysis seem to have hit brick walls," said
CRRU chief Dan Olson in a statement. To move the case forward,
examiners need another sample of McCormick's coded system-or a similar
one-that might offer context to the mystery notes or allow valuable
comparisons to be made. Or, short of new evidence, Olson said, "Maybe
someone with a fresh set of eyes might come up with a brilliant new
idea."

The FBI says it has always relied on public tips and other assistance
to solve crimes though breaking a code may represent a special
circumstance.

For larger images of the notes go here. [LINK]

If you have an idea how to break the code, have seen similar codes, or
have any information about the Ricky McCormick case, write to CRRU at
the following address:

FBI Laboratory
Cryptanalysis and Racketeering Records Unit
2501 Investigation Parkway
Quantico, VA 22135
Attn: Ricky McCormick Case

There is no reward being offered, just the knowledge that you may be
solving an intriguing murder mystery, the FBI stated.


No other information about the guy? It might help. If the note is of any use 
then people and places would be in it. If that is the case then it would 
help to know where he lived and some of the names of people he knows.


The note seems like it may not be just encrypted but a sort of 
compression(or rather shorthand/jargon) was used. Was the guy a drug dealer? 
It could be a list of "clients" or information about where he sold drugs(the 
numbers look like street addresses or amounts.


If these kinda notes were so common from this guy then surely the FBI should 
have many more?


Seems like the FBI could do more if they wanted it really solved... 


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


Re: Guido rethinking removal of cmp from sort method

2011-03-30 Thread Steven D'Aprano
On Wed, 30 Mar 2011 11:06:20 +0200, Antoon Pardon wrote:

> As far as I can see, key will only produce significant speedups, if
> comparing items can then be completly done internally in the python
> engine without referencing user python code.

Incorrect. You don't even need megabytes of data to see significant 
differences. How about a mere 1000 short strings?


[steve@wow-wow ~]$ python2.6
Python 2.6.6 (r266:84292, Dec 21 2010, 18:12:50)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from random import shuffle
>>> data = ['a'*n for n in range(1000)]
>>> shuffle(data)
>>> from timeit import Timer
>>>
>>> t_key = Timer('sorted(data, key=lambda a: len(a))',
... 'from __main__ import data')
>>> t_cmp = Timer('sorted(data, cmp=lambda a,b: cmp(len(a), len(b)))',
... 'from __main__ import data')
>>>
>>> min(t_key.repeat(number=1000, repeat=5))
0.89357517051696777
>>> min(t_cmp.repeat(number=1000, repeat=5))
7.6032949066162109


That's almost ten times slower.

Of course, the right way to do that specific sort is:

>>> t_len = Timer('sorted(data, key=len)', 'from __main__ import data')
>>> min(t_len.repeat(number=1000, repeat=5))
0.64559602737426758

which is even easier and faster. But even comparing a pure Python key 
function to the cmp function, it's obvious that cmp is nearly always 
slower.

Frankly, trying to argue that cmp is faster, or nearly as fast, is a 
losing proposition. In my opinion, the only strategy that has even a 
faint glimmer of hope is to find a convincing use-case where speed does 
not matter.

Or, an alternative approach would be for one of the cmp-supporters to 
take the code for Python's sort routine, and implement your own sort-with-
cmp (in C, of course, a pure Python solution will likely be unusable) and 
offer it as a download. For anyone who knows how to do C extensions, this 
shouldn't be hard: just grab the code in Python 2.7 and make it a stand-
alone function that can be imported. 

If you get lots of community interest in this, that is a good sign that 
the solution is useful and practical, and then you can push to have it 
included in the standard library or even as a built-in.

And if not, well, at least you will be able to continue using cmp in your 
own code.



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


Re: FBI wants public help solving encrypted notes from murder mystery

2011-03-30 Thread Graham Cooper
On Mar 31, 12:18 pm, "Stretto"  wrote:
> "Joe Snodgrass"  wrote in message
>
> news:[email protected]...
>
>
>
>
>
>
>
> > FBI cryptanalysis hasn’t decrypted notes from 1999 murder mystery
>
> >http://tinyurl.com/4d56zsz
>
> > The FBI is seeking the public's help in breaking the encrypted code
> > found in two notes discovered on the body of a murdered man in 1999.
>
> > The FBI says that officers in St. Louis, Missouri discovered the body
> > of 41-year-old Ricky McCormick on June 30, 1999 in a field and the
> > clues regarding the homicide were two encrypted notes found in the
> > victim's pants pockets.
>
> > The FBI says that despite extensive work by its Cryptanalysis and
> > Racketeering Records Unit (CRRU), and the American Cryptogram
> > Association, the meanings of those two coded notes remain a mystery
> > and McCormick's murderer has never been found. One has to wonder
> > though, if the FBI can't figure this out, who can? But I digress.
>
> > From the FBI: "The more than 30 lines of coded material use a
> > maddening variety of letters, numbers, dashes, and parentheses.
> > McCormick was a high school dropout, but he was able to read and write
> > and was said to be 'street smart.' According to members of his family,
> > McCormick had used such encrypted notes since he was a boy, but
> > apparently no one in his family knows how to decipher the codes, and
> > it's unknown whether anyone besides McCormick could translate his
> > secret language. Investigators believe the notes in McCormick's
> > pockets were written up to three days before his death."
>
> > "Standard routes of cryptanalysis seem to have hit brick walls," said
> > CRRU chief Dan Olson in a statement. To move the case forward,
> > examiners need another sample of McCormick's coded system-or a similar
> > one-that might offer context to the mystery notes or allow valuable
> > comparisons to be made. Or, short of new evidence, Olson said, "Maybe
> > someone with a fresh set of eyes might come up with a brilliant new
> > idea."
>
> > The FBI says it has always relied on public tips and other assistance
> > to solve crimes though breaking a code may represent a special
> > circumstance.
>
> > For larger images of the notes go here. [LINK]
>
> > If you have an idea how to break the code, have seen similar codes, or
> > have any information about the Ricky McCormick case, write to CRRU at
> > the following address:
>
> > FBI Laboratory
> > Cryptanalysis and Racketeering Records Unit
> > 2501 Investigation Parkway
> > Quantico, VA 22135
> > Attn: Ricky McCormick Case
>
> > There is no reward being offered, just the knowledge that you may be
> > solving an intriguing murder mystery, the FBI stated.
>
> No other information about the guy? It might help. If the note is of any use
> then people and places would be in it. If that is the case then it would
> help to know where he lived and some of the names of people he knows.
>
> The note seems like it may not be just encrypted but a sort of
> compression(or rather shorthand/jargon) was used. Was the guy a drug dealer?
> It could be a list of "clients" or information about where he sold drugs(the
> numbers look like street addresses or amounts.
>
> If these kinda notes were so common from this guy then surely the FBI should
> have many more?
>
> Seems like the FBI could do more if they wanted it really solved..



I can use my psychic powers to solve the crime!

I did a test on the Australian Channel 9 News website a few months
ago...

Given a sequence of photos tell who is a notorious criminal and who is
a professional surfer!

I got every one right!  My psychic channels were spot on, e.g. "had a
big magazine following" -> SURFER



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


Forcing absolute package imports in 2.7?

2011-03-30 Thread Michael Parker
Hi all,

I'm reading Learning Python 4th Edition by Lutz. In the section on
relative package imports, he says: "In Python 3.0, the `import
modname` statement is always absolute, skipping the containing
package’s directory. In 2.6, this statement form still performs
relative imports today (i.e., the package’s directory is searched
first), but these will become absolute in Python 2.7, too.`

But in my own testing I'm not seeing this behavior. Was it not
included in 2.7 for fear of breaking too many programs?

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


Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file

2011-03-30 Thread Terry Reedy

On 3/30/2011 7:58 PM, Gnarlodious wrote:

On Mar 30, 9:28 am, Peter Otten wrote:


You are trying to run your 3.x code with Python 2.x...


You're right. Exactly why this started happening I don't know.


I believe recent Mac OSX comes with some 2.x installed as the default 
Python.


--
Terry Jan Reedy

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


Re: Fun python 3.2 one-liner

2011-03-30 Thread Gregory Ewing

Martin De Kauwe wrote:

what is the character limit on a one liner :P.


For PEP 8 compliance, 80 characters. :-)

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


Learn Python the Hardway exercise 11 question 4

2011-03-30 Thread Joseph Sanoyo
print "How old are you?", age = raw_input()
print "How tall are you?", height = raw_input()
print "How much do you weigh?", weight = raw_input()
print "So, you're %r old, %r tall and %r heavy." % ( age, height,
weight)
Note:
Notice that we put a , (comma) at the end of each print line. This is
so that print doesn’t end the line with a newline and go to the next
line.
What You Should See
Extra Credit
1. Go online and find out what Python’s raw_input does.
$ python ex11.py How old are you?
35 How tall are you?
6'2" How much do you weigh? 180lbs
So, you're '35' old, '6\'2"' tall and '180lbs' heavy.

Related to escape sequences, try to find out why the last line has
’6\’2"’ with that \’ sequence. See how the single-quote needs to be
escaped because otherwise it would end the string?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: delete namespaces

2011-03-30 Thread Chris Angelico
On Thu, Mar 31, 2011 at 11:11 AM, Raymond Hettinger  wrote:
> [monkeys paw]
>> > How do i delete a module namespace once it has been imported?
>  . . .
>> > Then i make a modification to banner.py. When i import it again,
>> > the new changes are not reflected.
>
> [Terry Reedy]
>> The best thing, if possible, is to restart the program.
>> If you develop banner.py with adequate tests, you will want to restart
>> the test anyway, and you should not need to modify much thereafter.
>
> This is excellent advice.
>
> You're much better-off starting fresh each time.

Each language should be used for its strengths, not its weaknesses :)
If you're using Python, keep it light and simple and then just restart
the program. If you want to reload stuff without restarting, grab
Pike. There's no point fighting your language!

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


Re: delete namespaces

2011-03-30 Thread Ritesh Nadhani
On Tue, Mar 29, 2011 at 6:14 PM, monkeys paw  wrote:
> How do i delete a module namespace once it has been imported?
>
> I use
>
> import banner
>
> Then i make a modification to banner.py. When i import it again,
> the new changes are not reflected. Is there a global variable i can
> modify?
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Have a look at:

http://washort.twistedmatrix.com/2011/01/introducing-exocet.html

-- 
Ritesh
http://www.beamto.us
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FBI wants public help solving encrypted notes from murder mystery

2011-03-30 Thread David Bernier

Stretto wrote:



"Joe Snodgrass"  wrote in message
news:[email protected]...


FBI cryptanalysis hasn’t decrypted notes from 1999 murder mystery

http://tinyurl.com/4d56zsz

The FBI is seeking the public's help in breaking the encrypted code
found in two notes discovered on the body of a murdered man in 1999.

The FBI says that officers in St. Louis, Missouri discovered the body
of 41-year-old Ricky McCormick on June 30, 1999 in a field and the
clues regarding the homicide were two encrypted notes found in the
victim's pants pockets.

The FBI says that despite extensive work by its Cryptanalysis and
Racketeering Records Unit (CRRU), and the American Cryptogram
Association, the meanings of those two coded notes remain a mystery
and McCormick's murderer has never been found. One has to wonder
though, if the FBI can't figure this out, who can? But I digress.

From the FBI: "The more than 30 lines of coded material use a
maddening variety of letters, numbers, dashes, and parentheses.
McCormick was a high school dropout, but he was able to read and write
and was said to be 'street smart.' According to members of his family,
McCormick had used such encrypted notes since he was a boy, but
apparently no one in his family knows how to decipher the codes, and
it's unknown whether anyone besides McCormick could translate his
secret language. Investigators believe the notes in McCormick's
pockets were written up to three days before his death."

"Standard routes of cryptanalysis seem to have hit brick walls," said
CRRU chief Dan Olson in a statement. To move the case forward,
examiners need another sample of McCormick's coded system-or a similar
one-that might offer context to the mystery notes or allow valuable
comparisons to be made. Or, short of new evidence, Olson said, "Maybe
someone with a fresh set of eyes might come up with a brilliant new
idea."

The FBI says it has always relied on public tips and other assistance
to solve crimes though breaking a code may represent a special
circumstance.

For larger images of the notes go here. [LINK]

If you have an idea how to break the code, have seen similar codes, or
have any information about the Ricky McCormick case, write to CRRU at
the following address:

FBI Laboratory
Cryptanalysis and Racketeering Records Unit
2501 Investigation Parkway
Quantico, VA 22135
Attn: Ricky McCormick Case

There is no reward being offered, just the knowledge that you may be
solving an intriguing murder mystery, the FBI stated.


No other information about the guy? It might help. If the note is of any
use then people and places would be in it. If that is the case then it
would help to know where he lived and some of the names of people he knows.

The note seems like it may not be just encrypted but a sort of
compression(or rather shorthand/jargon) was used. Was the guy a drug
dealer? It could be a list of "clients" or information about where he
sold drugs(the numbers look like street addresses or amounts.

If these kinda notes were so common from this guy then surely the FBI
should have many more?

Seems like the FBI could do more if they wanted it really solved...


First of all, out of respect for the deceased, Ricky McCormick and
in keeping with a spirit of fairness, I must say that what follows
may be pure coincidence, perhaps a 10% chance of mistaken identity
and a 90% chance of not-mistaken identity.

Background on a Joplin, Missouri 1982 killing/murder
the person killed:   Darrell Ruestman
the killer:  Alan J. Bannister

The prosecution's theory was that AJ Bannister murdered Darrell Ruestman.
This led to AJ Bannister's murder conviction, which was upheld
on appeal.

But see this if you wish for another theory:
< http://pubs.socialistreviewindex.org.uk/sr214/usletter.htm > .

In any case, Darrell Ruestman was killed in 1982.

From the case:  BANNISTER v. DELO,
< 
http://mo.findacase.com/research/wfrmDocViewer.aspx/xq/fac.%2FFDCT%2FWMO%2F1995%2F19950915_019.WMO.htm/qx 
>


This court opinion mentions three affidavits:
1. Wooten Affidavit
2. Taylor Affidavit
3. Trombley Affidavit  (writer and film maker)

In the Trombley Affidavit, one finds:
"Finally, Trombley's statement about what Bannister says happened directly 
contradicts the testimony of Linda McCormick, Ruestman's girlfriend, who was in 
the trailer at the time of the murder and testified that she heard no 
conversations before hearing the shot. See Tr. III at 49, 65. "


and also:

"For instance, Trombley links McCormick to Wooten and Wooten to Ruestman's 
murder (thereby conflicting with Wooten's affidavit). However, Trombley also 
connects Wooten and Bannister. See affidavit at 9. These facts could support the 
State's theory that Wooten, acting as a middleman for McCormick, hired Bannister 
to murder Ruestman just as easily as they support Trombley's accidental shooting 
theory."


From another web page:
"On August 20, 1982, Darrell Ruestman was living in a 

Re: delete namespaces

2011-03-30 Thread rusi
On Mar 30, 6:14 am, monkeys paw  wrote:
> How do i delete a module namespace once it has been imported?
>
> I use
>
> import banner
>
> Then i make a modification to banner.py. When i import it again,
> the new changes are not reflected. Is there a global variable i can
> modify?

It seems you are asking about modules and namespaces whereas you
actually want to ask about how to optimize your development
environment -- Yes?
IOW a programmer normally starts with a vague idea, moves to/through
increasing details with the implementation moving from incomplete to
buggy to finished.

Modules (and shrink wrapping in general) is good in the later stages
and a nuisance in the earlier.
As an alternative if you use emacs and python-mode then you can hack
away with C-c C-c (py-execute-buffer) without the problem you
describe.  Then module-arize when done.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Guido rethinking removal of cmp from sort method

2011-03-30 Thread harrismh777

Antoon Pardon wrote:

On Sun, Mar 13, 2011 at 12:59:55PM +, Steven D'Aprano wrote:

The removal of cmp from the sort method of lists is probably the most
disliked change in Python 3. On the python-dev mailing list at the
moment, Guido is considering whether or not it was a mistake.

If anyone has any use-cases for sorting with a comparison function that
either can't be written using a key function, or that perform really
badly when done so, this would be a good time to speak up.


How about a list of tuples where you want them sorted first item in ascending
order en second item in descending order.


Greetings,

Not sure here, but thought you folks might want to have another 
viewpoint from someone who is maybe not so close to the trees as to be 
able to comment effectively on the forest.


Many of you (Guido included) have lost significant sight of a 
critical object oriented philosophical pillar (but not all of you, thank 
goodness). To cut right to the heart of it--- NEVER change an advertised 
interface. Change the implementation to your little hearts desire, but 
never alter an advertised interface (code is based on it, books are 
based on it, tutorials are based on it, college comp sci courses are 
based on it... etc). If cmp parm is utilized and is helpful or perceived 
as useful and existing code requires it then for crying out loud leave 
it alone. I think your overall worship of Guido as Python King has left 
many of you with nobbled thinking.


On the other hand, this debate and constant bickering is a serious 
rehash of an ancient discussion without any new points--- irritating. 
Take a look at issue 1771  http://bugs.python.org/issue1771 
particularly msg #s 95975 and 95982  but no, read the whole 
thing it is very clear that Guido wants to restructure the python 
language for consistency and elegance (and who can blame him?). He makes 
some very good arguments for the justification of removing the cmp 
keyword from list.sort() and builtin.sorted()/   but, that is not the 
point... he is breaking a fundamental law of object oriented 
programming... don't break and advertised interface (particularly if it 
is useful and people are actually making use of it!).

This is insane folks.

Python is one of the most elegant OO languages to gain popular 
appeal and wide-spread use. This sad broken move from 2.x to 3.x has the 
potential of ruining the language for everyone. Many of us dropped JAVA 
(compile once debug everywhere) because it is complicated, a pita to 
use, slow, and actually doesn't port too well on any platform... and 
here we go again with python. How do the developers of python ever 
expect folks to be able to make use of the language into the future when 
every time we turn around the interface is broken or being debated in 
flux?  Many of us want to use the new 3.2+ version, but no one is going 
to ship it pre-installed (probably for many years) because of this 
issue. There is no way to easily migrate, nor backport, and everyone is 
going to be forced to develop code (and have to maintain code) on two 
distinct branches (for many years to come). I suspect that people are 
just going to stick with back versions for a long time.

We need to get a grip on this, people.

Guido does not need a use case; he just needs to restore the 
interface that everyone expects. Put up a message to start to use key= 
instead, and plan deprecation for something like five years out... this 
just seems like such a no-brainer to me. But then, maybe its just that 
I'm too inexperienced to know any better.  


In the mean time... I'm playing around with 3.2 and really liking 
it... hoping that the world will actually be using it someday.


Kind regards,
m harris

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