Re: Komodo, Python

2012-06-16 Thread Dieter Maurer
"Isaac@AU"  writes:

> I just started learning python. I have komodo2.5 in my computer. And I 
> installed python2.7. I tried to write python scripts in komodo. But every 
> time I run the code, there's always the error:
>
> Traceback (most recent call last):
>   File "C:\Program Files\ActiveState Komodo 2.5\callkomodo\kdb.py", line 920, 
> in
>  
> requestor, connection_port, cookie = ConnectToListener(localhost_addr, 
> port)
>
>   File "C:\Program Files\ActiveState Komodo 2.5\callkomodo\kdb.py", line 872, 
> in
>  ConnectToListener
> cookie = makeCookie()
>   File "C:\Program Files\ActiveState Komodo 2.5\callkomodo\kdb.py", line 146, 
> in
>  makeCookie
> generator=whrandom.whrandom()
> NameError: global name 'whrandom' is not defined

This is a bug in "kdb.py". I forgets to import "whrandom".

In addition it shows that the "kdb.py" code is very old. "whrandom"
is been replaced by "random" a long time ago.

--
Dieter

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


Re: Threads vs subprocesses

2012-06-16 Thread John O'Hagan
On Fri, 15 Jun 2012 16:34:57 -0400
Dennis Lee Bieber  wrote:

> On Sat, 16 Jun 2012 03:24:13 +1000, John O'Hagan
>  declaimed the following in
> gmane.comp.python.general:
> 
> 
> > I should have made it clear that I'm not using threads to speed anything up;
> > each thread produces an independently controlled, timed stream of musical
> > events. I think it would be hard to achieve that in a single process. The
> > streams need to run simultaneously without getting out of sync or dropping
> > notes, which begins to happen if there are a lot of them, or they are run
> > very fast or are very calculation-intensive to produce. 
> >
>   Sounds like something in the realm of discrete event simulation...
> which is commonly single-threaded -- a list of events & time-points
> which dispatch to event handlers as time is incremented...
> 
>   Or for your case: a time-ordered list of stream&event; issue all
> events at a given time point, then dispatch to each stream to compute
> the next event&time for that stream, which is placed into the ordered
> list. Read the first pending event, sleep until the event time is
> reached, then repeat the process.


That looks like a possible way to do all the streams in a single thread,
although it works a little differently from your outline above if I understand
you correctly, in that only the events know their start times and they are
produced by iterators which can be modified on the fly and which can be added
and removed from the overall process at any time, so it's not possible to know
in advance which iterator will produce the chronologically next event. I think
that means that any ordered list of events would have to be re-ordered after
each event is read. It might be worth a try though. I notice there is simpy for
discrete event simulation in python. I'll look into it, thanks.

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


Re: Academic citation of Python

2012-06-16 Thread Olmo Hernández Cuba
 Well, maybe something like:

 G. Van Rossum. The Python Language
 Reference Manual. Network Theory Ltd., September 2003.

 In other languages I use, the proper citation is obtained from the
 interpreter itself, and it points you to the language reference.

 Hope this helps.

 El Sat, 16 Jun 2012 14:18:48 +1000
Alec Taylor  escribió:
> I think it's more like when you see articles with a passage like:
> 
> 
> The C programming language[1] or the C++ programming language[2] are
> both
> > examples of...
> >
> 
> 
> Are both easy to find the proper reference for.
> 
> On Sat, Jun 16, 2012 at 2:13 PM, Ben Finney
> wrote:
> 
> > Mark Livingstone  writes:
> >
> > > I wish to properly cite Python in an academic paper I am writing.
> > >
> > > Is there a preferred document etc to cite?
> >
> > I think you're best positioned to answer that. Python isn't a
> > document, so what specifically are you citing it as?
> >
> > --
> >  \   “A ‘No’ uttered from deepest conviction is better and
> > greater | `\   than a ‘Yes’ merely uttered to please, or what
> > is worse, to | _o__)  avoid trouble.”
> > —Mohandas K. Gandhi | Ben Finney
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >


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


Re: Create thumbnail image (jpg/png) of PDF file using Python

2012-06-16 Thread Chris Angelico
On Fri, Jun 15, 2012 at 9:15 AM, Dennis Lee Bieber
 wrote:
>        PDF is not an "image" file format; it is a "program" describing how
> to render each page. Some of the page contents can be image bitmap data,
> but a "proper" PDF has text AS text.

Plus, JPG is very poor at handling text. It's designed for photos and
photo-like images.

I would recommend using PNG for the bitmapped side.

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


Re: is the same betweent python3 and python3.2?

2012-06-16 Thread Andrew Berg
On 6/15/2012 11:31 PM, contro opinion wrote:
> is the  /usr/lib/python-3.2.3/bin/python3 same as
> /usr/lib/python-3.2.3/bin/python3.2?
It should be. IIRC, ls -l will tell you if something is a link. You
could also run python3 and it will tell you the version.

-- 
CPython 3.3.0a4 | Windows NT 6.1.7601.17803
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Academic citation of Python

2012-06-16 Thread Mark Lawrence

On 16/06/2012 04:24, Mark Livingstone wrote:

Hello!

I wish to properly cite Python in an academic paper I am writing.

Is there a preferred document etc to cite?

Thanks in advance,

MArkL


The main website www.python.org and possibly the sites for Jython, 
IronPython and PyPY?


--
Cheers.

Mark Lawrence.

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


Re: Academic citation of Python

2012-06-16 Thread J. Cliff Dyer
That's a rather vague question.  What do you want to cite about python?
If you're just mentioning python, that shouldn't warrant a citation,
though a parenthetical note linking to python.org might be useful.

The standard documentation should be acceptable, or possibly a link to
the source code at a given revision.

Cheers,
Cliff

On Sat, 2012-06-16 at 13:24 +1000, Mark Livingstone wrote:
> Hello!
> 
> I wish to properly cite Python in an academic paper I am writing.
> 
> Is there a preferred document etc to cite?
> 
> Thanks in advance,
> 
> MArkL


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


Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-16 Thread Wolfgang Keller
On Thu, 14 Jun 2012 12:59:23 -0700 (PDT)
CM  wrote:

> On Jun 14, 2:25 pm, Wolfgang Keller  wrote:
> >
> > What is needed for domain specialists are frameworks and related
> > tools such as GUI builders that allow them to write exclusively the
> > domain-specific code (this is where a domain specialist will always
> > be better than any software developer), layout the GUI as
> > ergonomically convenient (same) and then have the framework do all
> > the rest.
> 
> Above this you also mentioned a disdain for the need for "glue code",
> which in the context of your post seemed to be binding to event
> handlers.

With "glue code" I mean any code other than that which serves to
implement purely domain-specific behaviour.

> So is there a possible way for a GUI builder to *automatically* bind
> widgets to the appropriate functions in your domain-specific code?
> It's hard to see how this would be generally possible, even with an
> AI (maybe a mind-reading AI would work).
> 
> Or maybe I'm misunderstanding something.

Probably, since there are GUI builders/frameworks available that do
what I described. I have already pointed to some for my specific type
of application (database applications) that don't even need any GUI
definition at all, since the GUI is entirely reflected from the domain
model. Which I would not consider as the most ergonomic way to define
a GUI.

Unfortunately these excellent GUI builders and frameworks all use
languages which imho are not at all suitable for domain specialists who
are not full-time software developers by training.

Sincerely,

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


Re: Academic citation of Python

2012-06-16 Thread Rich Webb
On Sat, 16 Jun 2012 14:01:12 +0100, Mark Lawrence
 wrote:

>On 16/06/2012 04:24, Mark Livingstone wrote:
>> Hello!
>>
>> I wish to properly cite Python in an academic paper I am writing.
>>
>> Is there a preferred document etc to cite?
>>
>> Thanks in advance,
>>
>> MArkL
>
>The main website www.python.org and possibly the sites for Jython, 
>IronPython and PyPY?

He's probably looking for an IEC or ANSI standard, like "Information
technology — Programming languages — C  INCITS/ISO/IEC 9899-2011[2012]
(ISO/IEC 9899-2011, IDT)". I don't think URLs qualify as standards
documents.

-- 
Rich Webb Norfolk, VA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Academic citation of Python

2012-06-16 Thread Emile van Sebille

Or copy a citation from Guido:

http://www.python.org/~guido/Publications.html

Emile


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


python 3.3 bz2 decompression testing results

2012-06-16 Thread Pauli Rikula
I tested http://python.org/ftp/python/3.3.0/python-3.3.0a4.amd64.msi
bz2 module's decompression using the bz2 -files from:
https://www.ee.oulu.fi/research/ouspg/PROTOS_Test-Suite_c10-archive

and found nothing.

I did not use anything like Valgrind though.
Should I try to run these tests again using Linux and Valgrind?

Testscript is at:
http://code.google.com/p/my-never-ending-projects/source/browse/trunk/tests/python3_3_bz2/test_decompress.py

you might find it interesting.. or not.

The test took about 2 hours and all the exceptions I got from tests
were the like these two (exceptions.txt -file which was made by the
test_decompress.py -testscript):


testcase 0: 0184e108021bf3b3f860f1c7618c.bz2
file len: 76
local testtime: 2012-06-16 18:44:25
('Traceback (most recent call last):\n',
 '  File "C:/projektit/bz2_python33_test/test_decompress.py", line 52,
in \n_ = bz2.decompress(fs)\n',
 '  File "C:\\Python33-0a4\\lib\\bz2.py", line 419, in decompress\n
raise ValueError("Compressed data ended before the "\n',
 'ValueError: Compressed data ended before the end-of-stream marker
was reached\n')

testcase 1: 01d8c11b84d738de284a8ba76226.bz2
file len: 3629
local testtime: 2012-06-16 18:44:25
('Traceback (most recent call last):\n',
 '  File "C:/projektit/bz2_python33_test/test_decompress.py", line 52,
in \n_ = bz2.decompress(fs)\n',
 '  File "C:\\Python33-0a4\\lib\\bz2.py", line 417, in decompress\n
results.append(decomp.decompress(data))\n',
 'OSError: Invalid data stream\n')
-- 
http://mail.python.org/mailman/listinfo/python-list


Python 3.3.0a4, please add ru'...'

2012-06-16 Thread jmfauth
Please consistency.

>>> sys.version
'3.3.0a4 (v3.3.0a4:7c51388a3aa7+, May 31 2012, 20:15:21) [MSC v.1600
32 bit (Intel)]'
>>> 'a'
'a'
>>> b'a'
b'a'
>>> br'a'
b'a'
>>> rb'a'
b'a'
>>> u'a'
'a'
>>> ur'a'
'a'
>>> ru'a'
SyntaxError: invalid syntax
>>>

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


Re: Academic citation of Python

2012-06-16 Thread Ben Finney
Olmo Hernández Cuba  writes:

>  Well, maybe something like:
>
>  G. Van Rossum. The Python Language
>  Reference Manual. Network Theory Ltd., September 2003.

Are you referencing material from that document? If so, go ahead and
reference that document's URL.

>  In other languages I use, the proper citation is obtained from the
>  interpreter itself, and it points you to the language reference.

But why cite the language reference, or any document, if you're not
actually referencing material in that document?

I don't see how merely writing programs in a language warrants
bibliographic citation for it. Perhaps just referring to the main URL
for the Python website?

-- 
 \ “What you have become is the price you paid to get what you |
  `\ used to want.” —Mignon McLaughlin |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Academic citation of Python

2012-06-16 Thread Terry Reedy

On 6/15/2012 11:24 PM, Mark Livingstone wrote:

Hello!

I wish to properly cite Python in an academic paper I am writing.

Is there a preferred document etc to cite?


At present, I would use something like

Rossum, Guido van, et al, *The Python Language Reference*, Python 
Software Foundation; http://docs.python.org/py3k/reference/index.html


with punctuation adjusted to your target. That url should continue to 
work as new versions are released. If you want to cite a particular 
version, http://docs.python.org/release/3.2/reference/index.html with 
3.2 replaced by x.y as appropriate.


--
Terry Jan Reedy



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


Re: Academic citation of Python

2012-06-16 Thread Christian Heimes
Am 16.06.2012 22:44, schrieb Terry Reedy:
> Rossum, Guido van, et al, *The Python Language Reference*, Python
> Software Foundation; http://docs.python.org/py3k/reference/index.html

Actually it's "van Rossum, Guido", not "Rossum, Guido van". The "van" is
part of the family name, not a middle name. It's like "da Vinci,
Leonardo" or "von Sydow, Max". On one occasion Guido complained that
Americans always get his name wrong.

Christian

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


Re: Academic citation of Python

2012-06-16 Thread Terry Reedy

On 6/16/2012 5:01 PM, Christian Heimes wrote:

Am 16.06.2012 22:44, schrieb Terry Reedy:

Rossum, Guido van, et al, *The Python Language Reference*, Python
Software Foundation; http://docs.python.org/py3k/reference/index.html


Actually it's "van Rossum, Guido", not "Rossum, Guido van". The "van" is
part of the family name, not a middle name. It's like "da Vinci,
Leonardo" or "von Sydow, Max". On one occasion Guido complained that
Americans always get his name wrong.


Thank you for the correction. I was going by an old book (1996) he 
co-wrote that just had 'Rossum' on the spine. I guess that must have 
been done without consulting him and must have annoyed him.


--
Terry Jan Reedy



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


Re: is the same betweent python3 and python3.2?

2012-06-16 Thread contro opinion
root@debian:/home/debian# find  /  -name 'python3'
/usr/lib/python-3.2.3/bin/python3
root@debian:/home/debian# /usr/lib/python-3.2.3/bin/python3
Python 3.2.3 (default, Jun 16 2012, 10:59:54)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>


it  is the same thing,think you

2012/6/16 Andrew Berg 

> On 6/15/2012 11:31 PM, contro opinion wrote:
> > is the  /usr/lib/python-3.2.3/bin/python3 same as
> > /usr/lib/python-3.2.3/bin/python3.2?
> It should be. IIRC, ls -l will tell you if something is a link. You
> could also run python3 and it will tell you the version.
>
> --
> CPython 3.3.0a4 | Windows NT 6.1.7601.17803
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Smart quote character replacement for those with deficient sed-fu.

2012-06-16 Thread smitty1e
Use case:
===
1. OSX 10.7, bunch of .tex files culled from a blog via some cruddy old Perl 
script.
.tex files are utf-8 encoded, which means the quotes and apostrophes drop out 
going through pdflatex.
2. Recommend using git to manage the .tex files, which are all in a /src 
directory in the project. If you're going to do batch edits, You Will Need to 
branch, realize you gooned up, and roll back.
3. Understood, sed is the more classical tool here, except that I could not it 
to work in my OSX terminal.

Invocation:
===
python charfix.py `ls src/*.tex`


charfix.py code:
===
# -*- coding: utf-8 -*-
import fileinput

def process(line):
print line.replace( "’", "'" ).replace( "“", '"' ).replace( "”", '"' )

if __name__=="__main__":
for line in fileinput.input( inplace=1 ):
process(line)
===

Discussion:
===
Thank you, python!
-- 
http://mail.python.org/mailman/listinfo/python-list


Is that safe to use ramdom.random() for key to encrypt?

2012-06-16 Thread Yesterday Paid
I'm making cipher program with random.seed(), random.random() as the
key table of encryption.
I'm not good at security things and don't know much about the
algorithm used by random module.

Is it really random or safe enough to keep my data safe?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is that safe to use ramdom.random() for key to encrypt?

2012-06-16 Thread Chris Angelico
On Sun, Jun 17, 2012 at 12:15 PM, Yesterday Paid
 wrote:
> I'm making cipher program with random.seed(), random.random() as the
> key table of encryption.
> I'm not good at security things and don't know much about the
> algorithm used by random module.

For security, you don't want any algorithm, you want something like
/dev/random (on Unix-like platforms).

I'm pretty sure Python includes crypto facilities. Unless it (most
oddly) lacks these batteries, I would recommend using one of them
instead.

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


Re: Pythonic cross-platform GUI desingers ?? la Interface Builder (Re: what gui designer is everyone using)

2012-06-16 Thread Chris Angelico
On Fri, Jun 15, 2012 at 7:47 AM, Dietmar Schwertberger
 wrote:
> The point is, that if you want to promote Python as replacement
> for e.g. VB, Labview etc., then an easy-to-use GUI builder is required.
> The typical GUI programs will just have an input mask, a button and one
> or two output fields.

I want to promote Linux as a replacement for Windows. But I do not see
that Linux needs to be able to run Internet Explorer in order to do
that. Maybe when people move to a replacement, they need to learn a
slightly different way of doing things; and in this case, I would
strongly recommend the "build your UI in code" method.

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


Re: Is that safe to use ramdom.random() for key to encrypt?

2012-06-16 Thread Paul Rubin
Yesterday Paid  writes:
> I'm making cipher program with random.seed(), random.random() as the
> key table of encryption...
> Is it really random or safe enough to keep my data safe?

No.  Use os.urandom instead.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is that safe to use ramdom.random() for key to encrypt?

2012-06-16 Thread Jon Clements
On Sun, 17 Jun 2012 12:31:04 +1000, Chris Angelico wrote:

> On Sun, Jun 17, 2012 at 12:15 PM, Yesterday Paid
>  wrote:
>> I'm making cipher program with random.seed(), random.random() as the
>> key table of encryption.
>> I'm not good at security things and don't know much about the algorithm
>> used by random module.
> 
> For security, you don't want any algorithm, you want something like
> /dev/random (on Unix-like platforms).
> 
> I'm pretty sure Python includes crypto facilities. Unless it (most
> oddly) lacks these batteries, I would recommend using one of them
> instead.
> 
> ChrisA

Cryptography is a complex subject - I've had the (mis)fortune to study it 
briefly.

Whatever you do - *do not* attempt to write your own algorithm. 

Python includes hashlib (forms of SHA and MD5) and uuid modules, but I 
take it a symmetric or possibly public/private key system is required - 
depending on what you want to secure, where it's stored and who needs 
access.

I generally find a separate partition with an encrypted file-system 
(which is fairly straight forward on *nix systems or I think there's a 
product out there that works with Windows), is a lot easier and puts the 
load on the filesystem/OS instead of having to be handled in your 
application is a lot simpler.

Jon

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


Re: Python 3.3.0a4, please add ru'...'

2012-06-16 Thread Steven D'Aprano
On Sat, 16 Jun 2012 10:36:42 -0700, jmfauth wrote:

> Please consistency.

There is no point asking here. Feature requests and bug reports must go 
on the tracker, or they are unlikely to be noticed or remembered by 
anyone who can fix it.

http://bugs.python.org/


Given that 3.3's feature-freeze is only days away, I strongly recommend 
that you also raise it here:

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




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


Re: Is that safe to use ramdom.random() for key to encrypt?

2012-06-16 Thread Steven D'Aprano
On Sat, 16 Jun 2012 19:15:34 -0700, Yesterday Paid wrote:

> I'm making cipher program with random.seed(), random.random() as the key
> table of encryption.
> I'm not good at security things and don't know much about the algorithm
> used by random module.


Start by reading the Fine Manual:

http://docs.python.org/library/random.html

which answers your question:

"it is not suitable for all purposes, and is completely 
unsuitable for cryptographic purposes."


Please don't write yet another broken cipher program that doesn't work. 
Use a proper one that has been mathematically analysed by professionals. 
I don't mean to cast aspersions on you, but any fool can write a cipher 
program that *they* can't break themselves. It takes many years of study 
to design a cipher that professionals can't break.

At the very least, start with PyCrypto.

http://pypi.python.org/pypi/pycrypto

If all you want is to play around obfuscating data, you might be 
interested in my toy encryption module:

http://pypi.python.org/pypi/obfuscate/

(which is also completely unsuitable for cryptographic purposes, but may 
be useful if you have some interest in the history of cryptography).



> Is it really random or safe enough to keep my data safe?

Safe from what? What is your threat model? Are you worried about your 
little sister reading your diary? Or the NSA discovering your plans to 
assassinate the President? Or something in between?

Python's random module is not cryptographically strong, which means that 
it will probably take an organisation like the NSA, MI5, ASIO, Mossad, 
etc. about 10 or 20 minutes to crack your password. But your little 
sister will probably take a hundred million years to guess it.


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


Re: Smart quote character replacement for those with deficient sed-fu.

2012-06-16 Thread Steven D'Aprano
On Sat, 16 Jun 2012 18:39:42 -0700, smitty1e wrote:

[...]
> python charfix.py `ls src/*.tex`
> 
> charfix.py code:


Thanks for that. You might like to also publish it on the ActiveState 
Python recipes site, where people are more likely to find it in the 
future.

http://code.activestate.com/recipes/langs/python/




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


Re: Is that safe to use ramdom.random() for key to encrypt?

2012-06-16 Thread Chris Angelico
On Sun, Jun 17, 2012 at 2:18 PM, Steven D'Aprano
 wrote:
> Safe from what? What is your threat model? Are you worried about your
> little sister reading your diary? Or the NSA discovering your plans to
> assassinate the President? Or something in between?
>
> Python's random module is not cryptographically strong, which means that
> it will probably take an organisation like the NSA, MI5, ASIO, Mossad,
> etc. about 10 or 20 minutes to crack your password. But your little
> sister will probably take a hundred million years to guess it.

Your little sister would quite possibly be kept off by rot13, which
everyone knows isn't cryptographically secure. All it takes is making
something look encrypted and most people won't bother to try (plus
it's the whole "this isn't public kthx" thing, which many people will
respect).

Of course, if you're just trying to fool the BOFH's technical manager,
it's even easier.

http://bofh.ch/newbofh/bofh4oct.html

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


Re: Komodo, Python

2012-06-16 Thread Ian Kelly
On Sat, Jun 16, 2012 at 3:20 AM, Dieter Maurer  wrote:
> In addition it shows that the "kdb.py" code is very old. "whrandom"
> is been replaced by "random" a long time ago.

Komodo 2.5 was released in 2003. At the time, Python was on release
2.3.  Komodo is currently on version 7.  The OP should consider
updating their IDE.
-- 
http://mail.python.org/mailman/listinfo/python-list