Re: Is this secure?

2010-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2010 18:39:53 -0800, Paul Rubin wrote:

> Steven D'Aprano  writes:
>> Paul, if you were anyone else, I'd be sneering uncontrollably about
>> now, but you're not clueless about cryptography, so what have I missed?
>> Why is reducing the number of distinct letters by more than 50%
>> anything but a disaster? This makes the task of brute-forcing the
>> password exponentially easier.
> 
> Reducing the number of distinct letters by 50% decreases the entropy per
> character by 1 bit.  

You say that as if 1 bit of entropy isn't much :)

Given a random six character password taken out of an alphabet of 52 
characters, it takes over nine billion attempts to brute force it. 
Reducing the alphabet by 50% cuts that down to less than 200 million. To 
make up for that loss of 1 bit of entropy, you need two extra characters 
in your password.


> That stuff about mixing letters and digits and
> funny symbols just makes the password a worse nuisance to remember and
> type, for a small gain in entropy that you can compute and make up for.

Well, everybody has their own ways of remembering passwords, and I'd much 
prefer to remember an eight character password with "funny symbols" that 
I chose myself, than a six character password with nothing but letters 
that was chosen for me.

Of course, I flatter myself that I know how to choose good passwords, and 
I hate remembering long random strings even from a reduced alphabet (e.g. 
I hate memorizing eight digit phone numbers, and am completely incapable 
of remembering ten digit mobile phone numbers).



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


Re: Creating variables from dicts

2010-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2010 20:44:10 -0800, Luis M. González wrote:

> On Feb 24, 1:15 am, Steven D'Aprano
>  wrote:
>> On Tue, 23 Feb 2010 19:47:22 -0800, Luis M. González wrote:
>> > On Feb 23, 10:41 pm, Steven D'Aprano
>> >  wrote:
>> >> On Tue, 23 Feb 2010 15:41:16 -0800, Luis M. González wrote:
>> >> > By the way, if you want the variables inside myDict to be free
>> >> > variables, you have to add them to the local namespace. The local
>> >> > namespace is also a dictionary "locals()". So you can update
>> >> > locals as follows:
>>
>> >> >     locals().update( myDictionary )
>>
>> >> No you can't. Try it inside a function.
>>
>> >> --
>> >> Steven
>>
>> > Sure. Inside a function I would use globals() instead. Although I
>> > don't know if it would be a good practice...
>>
>> Er, how does using globals change the local variables?
>>
>> --
>> Steven
> 
> Hmmm well, you tell me!

I'm not the one that said you can update locals! You said it. I said you 
can't, because you *can't*. The docs warn that you can't change locals, 
and if you try it, you will see that the docs are right.


>>> def test():
... x = 1
... locals().update(x = 2)
... print x
...
>>>
>>> test()
1





> As I said, I don't know if this is the recomended way...

It's not recommended because it doesn't work.


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


Re: python shell crashing on paste

2010-02-23 Thread Michel Claveau - MVP
Hi! 

Where (directory) are you, when the problem come?
Have you try with UAC disabled?

@+
--  
MCI



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


Re: The future of "frozen" types as the number of CPU cores increases

2010-02-23 Thread sjdevn...@yahoo.com
On Feb 23, 8:03 pm, Nobody  wrote:
> On Mon, 22 Feb 2010 22:27:54 -0800, sjdevn...@yahoo.com wrote:
> > Basically, multiprocessing is always hard--but it's less hard to start
> > without shared everything.  Going with the special case (sharing
> > everything, aka threading) is by far the stupider and more complex way
> > to approach multiprocssing.
>
> Multi-threading hardly shares anything (only dynamically-allocated
> and global data), while everything else (the entire stack) is per-thread.
>
> Yeah, I'm being facetious. Slightly.

I'm afraid I may be missing the facetiousness here.

The only definitional difference between threads and processes is that
threads share memory, while processes don't.

There are often other important practical implementation details, but
sharing memory vs not sharing memory is the key theoretical
distinction between threads and processes.  On most platforms, whether
or not you want to share memory (and abandon memory protection wrt the
rest of the program) is the key factor a programmer should consider
when deciding between threads and processes--the only time that's not
true is when the implementation forces ancillary details upon you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can't Access ANY url from python (errno 61)

2010-02-23 Thread MattB
On Feb 20, 7:00 pm, Steven D'Aprano  wrote:
> On Sat, 20 Feb 2010 18:28:16 +, Martin P. Hellwig wrote:
> > On 02/20/10 00:20, MattB wrote:
> > 
>
> >> Also, based on Martin's comment, I just wanted to make you all aware
> >> that I intend no misuse, but rather am just trying to learn, as I'm a
> >> programming noob.
> > 
> > It wasn't my intention to imply that, rather the opposite, that if some
> > BOFH would see your action as misuse (some admins are pretty trigger
> > happy), you would expect them to contact you directly (I would). Even
> > though you are on a wireless there are ways to track you down. For
> > example I would search my log to see if I can make an association
> > between a login to one of my servers and your mac address.
>
> This may be what you would do, but in my experience, it is more likely
> that the admin would be far too busy and/or lazy to try to track you down
> unless (1) they wanted to give you a warning prior to expulsion, or (2)
> they needed to know who you were prior to laying charges.
>
> In my experience they're far more likely to just hit the problem with a
> hammer by blocking you as much as is technically possible.
>
> > BTW, I always followed the philosophy that learning is much more fun if
> > you can brake/blow something up. Thus on my networks all students had a
> > lot of freedom to do whatever they think was appropriate but they where
> > aware that every action on my network was monitored and logged.
>
> Unfortunately this is the exception rather than the rule, I think.
>
> --
> Steven

All -- problem solved.  Following Lie's suggestions, and the links
from those pages, I went hunting around in my /library/preferences/
SystemConfiguration/.  I opened all of the 6 or 7 files that were in
there, and all looked as if they contained info directly related to my
airport card -- networks, server names, etc.  So I copied them to a
backup folder and then deleted them. Then I rebooted.

Then I opened IDLE and was able to raise URLs again.  I'm not sure
what it was about those files (or maybe a specific one) -- does anyone
have any ideas?

Thanks for your help and suggestions while I tried to figure this out.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bay Area PUG Meeting Thursday in Mountain View, CA

2010-02-23 Thread Aahz
In article <4b84a825.1030...@invalid.com>,
W. eWatson  wrote:
>On 2/23/2010 2:50 PM, Aahz wrote:
>> In article,
>> W. eWatson  wrote:
>>>
>>> Anyone here going to the meeting,Subject? As far as I can tell, it meets
>>>from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to
>>> be an informal group dinner at 6 pm at some place yet unknown. Comments?
>>
>> Subscribe to http://mail.python.org/mailman/listinfo/baypiggies
>
>Thanks. I'd appreciate it if you tell me what topic is. I belong to too 
>many mail lists. Thursday will be my first meeting. Perhaps I'll change 
>my mind about ML after a meeting. Can you describe anything more than 
>the topic? Do they have books, videos, tutorials (live), casual Q/A, 
>person-to-person chat before the speaker?

Sorry, I don't know offhand; using the mailing list is your best bet.
(BayPIGgies is usually not a high-traffic list.)
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this secure?

2010-02-23 Thread Lawrence D'Oliveiro
In message <7xwry39tpi@ruckus.brouhaha.com>, Paul Rubin wrote:

> More generally still, passwords regardless of their entropy content are
> a sucky way to encapsulate cryptographic secrets.

They’re a shared secret. How else would you represent a shared secret, if 
not with a shared secret?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating variables from dicts

2010-02-23 Thread Luis M . González
On Feb 24, 1:15 am, Steven D'Aprano
 wrote:
> On Tue, 23 Feb 2010 19:47:22 -0800, Luis M. González wrote:
> > On Feb 23, 10:41 pm, Steven D'Aprano
> >  wrote:
> >> On Tue, 23 Feb 2010 15:41:16 -0800, Luis M. González wrote:
> >> > By the way, if you want the variables inside myDict to be free
> >> > variables, you have to add them to the local namespace. The local
> >> > namespace is also a dictionary "locals()". So you can update locals
> >> > as follows:
>
> >> >     locals().update( myDictionary )
>
> >> No you can't. Try it inside a function.
>
> >> --
> >> Steven
>
> > Sure. Inside a function I would use globals() instead. Although I don't
> > know if it would be a good practice...
>
> Er, how does using globals change the local variables?
>
> --
> Steven

Hmmm well, you tell me!
As I said, I don't know if this is the recomended way...

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


Re: Bay Area PUG Meeting Thursday in Mountain View, CA

2010-02-23 Thread W. eWatson

On 2/23/2010 2:50 PM, Aahz wrote:

In article,
W. eWatson  wrote:


Anyone here going to the meeting,Subject? As far as I can tell, it meets
from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to
be an informal group dinner at 6 pm at some place yet unknown. Comments?


Subscribe to http://mail.python.org/mailman/listinfo/baypiggies


Thanks. I'd appreciate it if you tell me what topic is. I belong to too 
many mail lists. Thursday will be my first meeting. Perhaps I'll change 
my mind about ML after a meeting. Can you describe anything more than 
the topic? Do they have books, videos, tutorials (live), casual Q/A, 
person-to-person chat before the speaker?

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


Re: Bay Area PUG Meeting Thursday in Mountain View, CA

2010-02-23 Thread W. eWatson

On 2/23/2010 2:50 PM, Aahz wrote:

In article,
W. eWatson  wrote:


Anyone here going to the meeting,Subject? As far as I can tell, it meets
from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to
be an informal group dinner at 6 pm at some place yet unknown. Comments?


Subscribe to http://mail.python.org/mailman/listinfo/baypiggies


Thanks. I'd appreciate it if you tell me what topic is. I belong to too 
many mail lists. Thursday will be my first meeting. Perhaps I'll change 
my mind about ML after a meeting. Can you describe anything more than 
the topic? Do they have books, videos, tutorials (live), casual Q/A, 
person-to-person chat before the speaker?

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


Re: Creating variables from dicts

2010-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2010 19:47:22 -0800, Luis M. González wrote:

> On Feb 23, 10:41 pm, Steven D'Aprano
>  wrote:
>> On Tue, 23 Feb 2010 15:41:16 -0800, Luis M. González wrote:
>> > By the way, if you want the variables inside myDict to be free
>> > variables, you have to add them to the local namespace. The local
>> > namespace is also a dictionary "locals()". So you can update locals
>> > as follows:
>>
>> >     locals().update( myDictionary )
>>
>> No you can't. Try it inside a function.
>>
>> --
>> Steven
> 
> Sure. Inside a function I would use globals() instead. Although I don't
> know if it would be a good practice...

Er, how does using globals change the local variables?



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


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Grant Edwards
On 2010-02-24, Robert Kern  wrote:

>> comp.lang.python.spam_prevention_discussion
>
> Which doesn't exist and never will. Sorry, but
> meta-discussions about the group are typically on-topic for
> all groups with some few exceptions (e.g.  non-discussion,
> binary-only groups with associated .d groups, for instance).

Since now we are discussing meta-discussions, is this now a
meta-meta-discussion?

-- 
Grant



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


Re: Is this secure?

2010-02-23 Thread Paul Rubin
Lie Ryan  writes:
> If an attacker knows the that the random number generator have an
> extreme skew and he knows the distribution of the letters, how much
> advantage would it give the attacker? My initial guess is that the more
> skewed the letters are, the better the advantage, since an attacker
> using brute-force can write his program to prefer the most likely letters?

A useable (conservative) estimate is that the attacker's workload is 1/p
where p is the probability of the most likely password.  That basically
says the password strength can be measured by the min-entropy.
Cryptographers often use that approach.  If you want to be more precise,
you can do a conditional probability calculation assuming the attacker
works down the list of possible passwords in order of decreasing
probability, stopping when they hit the right one.

More generally still, passwords regardless of their entropy content are
a sucky way to encapsulate cryptographic secrets.  We keep using them
because every alternative has drawbacks of its own.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Rick Dooling
On Feb 23, 1:08 pm, Gib Bogle  wrote:

> It isn't useful to respond to a serious question with OS bigotry.

Okay, I'll go with what Aahz said:

> I've seen similar issues on Win7.
> AFAIK, this has nothing to do with Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating variables from dicts

2010-02-23 Thread Luis M . González
On Feb 23, 10:41 pm, Steven D'Aprano
 wrote:
> On Tue, 23 Feb 2010 15:41:16 -0800, Luis M. González wrote:
> > By the way, if you want the variables inside myDict to be free
> > variables, you have to add them to the local namespace. The local
> > namespace is also a dictionary "locals()". So you can update locals as
> > follows:
>
> >     locals().update( myDictionary )
>
> No you can't. Try it inside a function.
>
> --
> Steven

Sure. Inside a function I would use globals() instead.
Although I don't know if it would be a good practice...

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


Re: Is this secure?

2010-02-23 Thread Lie Ryan
On 02/24/10 14:09, Robert Kern wrote:
> On 2010-02-23 20:43 , Steven D'Aprano wrote:
>> On Wed, 24 Feb 2010 02:40:13 +, Steven D'Aprano wrote:
>>
>>> On Tue, 23 Feb 2010 15:36:02 +0100, mk wrote:
>>>
 The question is: is this secure? That is, can the string generated this
 way be considered truly random?
>>>
>>> Putting aside the philosophical question of what "truly random" means, I
>>> presume you mean that the letters are uniformly distributed. The answer
>>> to that is, they don't like uniformly distributed.
>>
>> Er, they don't *look* uniformly distributed.
>>
>> (Of course, being random, perhaps they are and I just got unlucky.)
> 
> You'd have to be very, *very* unlucky to get a sample of that size so
> far from uniformly distributed if the generating process actually were
> uniform.
> 
> Of course, uniformity isn't really necessary. You just need enough
> entropy in the distribution (amongst other things like protection of the
> seed from being known or guessed). A skewed distribution of characters
> is perfectly fine provided that you had enough characters in the
> password to meet the desired entropy requirement. A skewed distribution
> does require more characters to meet a specified entropy requirement
> than a uniform distribution, of course.
> 
> That said, for a naive strategy like "pick an independent random
> character, repeat", you should just use a uniform distribution. It makes
> the analysis easier. Worthwhile generators that give skewed
> distributions usually do so for a good reason, like generating
> pronounceable passwords.

If an attacker knows the that the random number generator have an
extreme skew and he knows the distribution of the letters, how much
advantage would it give the attacker? My initial guess is that the more
skewed the letters are, the better the advantage, since an attacker
using brute-force can write his program to prefer the most likely letters?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this secure?

2010-02-23 Thread Robert Kern

On 2010-02-23 20:43 , Steven D'Aprano wrote:

On Wed, 24 Feb 2010 02:40:13 +, Steven D'Aprano wrote:


On Tue, 23 Feb 2010 15:36:02 +0100, mk wrote:


The question is: is this secure? That is, can the string generated this
way be considered truly random?


Putting aside the philosophical question of what "truly random" means, I
presume you mean that the letters are uniformly distributed. The answer
to that is, they don't like uniformly distributed.


Er, they don't *look* uniformly distributed.

(Of course, being random, perhaps they are and I just got unlucky.)


You'd have to be very, *very* unlucky to get a sample of that size so far from 
uniformly distributed if the generating process actually were uniform.


Of course, uniformity isn't really necessary. You just need enough entropy in 
the distribution (amongst other things like protection of the seed from being 
known or guessed). A skewed distribution of characters is perfectly fine 
provided that you had enough characters in the password to meet the desired 
entropy requirement. A skewed distribution does require more characters to meet 
a specified entropy requirement than a uniform distribution, of course.


That said, for a naive strategy like "pick an independent random character, 
repeat", you should just use a uniform distribution. It makes the analysis 
easier. Worthwhile generators that give skewed distributions usually do so for a 
good reason, like generating pronounceable passwords.


--
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: Is this secure?

2010-02-23 Thread Paul Rubin
mk  writes:
>> You might look at the sitewww.diceware.comfor an approach to this,
>> which you can implement with a program.  The docs there are pretty
>> thoughtful and may help you understand the relevant issues.
>
> Thanks. But I would also be grateful for indicating what is wrong/ugly
> in my code.

The stuff about converting 4 random bytes to a decimal string and then
peeling off 2 digits at a time is pretty awful, and notice that since
2**32 is 4294967296, in the cases where you get 10 digits, the first
2-digit pair is never higher than 42.  There are also some effects on
the lower digits.  The total entropy loss probably isn't fatal but as
described, it's ugly.

I'd write your code something like this:

nletters = 5

def randomword(n):
with open('/dev/urandom') as f:
return ''.join([chr(ord('a')+ord(c)%26) for c in f.read(n)])

print randomword(nletters)

I wouldn't rely on a 5 letter combination for a high security
application, but it might be ok for some low security purposes.  Two
random 5-letter combinations separated by a hyphen will be much better,
and is probably easier to type than a solid block of 10 letters.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this secure?

2010-02-23 Thread Paul Rubin
Steven D'Aprano  writes:
> Putting aside the philosophical question of what "truly random" means, I 
> presume you mean that the letters are uniformly distributed. The answer 
> to that is, they don't like uniformly distributed.

That is a good point, the way those letters are generated (through the
decimal conversion stuff), they won't be all that uniform.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this secure?

2010-02-23 Thread Paul Rubin
Steven D'Aprano  writes:
> Paul, if you were anyone else, I'd be sneering uncontrollably about now, 
> but you're not clueless about cryptography, so what have I missed? Why is 
> reducing the number of distinct letters by more than 50% anything but a 
> disaster? This makes the task of brute-forcing the password exponentially 
> easier.

Reducing the number of distinct letters by 50% decreases the entropy per
character by 1 bit.  That stuff about mixing letters and digits and
funny symbols just makes the password a worse nuisance to remember and
type, for a small gain in entropy that you can compute and make up for.
The main thing you have to make sure is that the min-entropy is
sufficient for your purposes, and it's generally more convenient to do
that by making the password a little bit longer than by imposing
contortions on the person typing it.  Ross Anderson's "Security
Engineering" chapter about passwords is worth reading too:

  http://www.cl.cam.ac.uk/~rja14/Papers/SE-03.pdf

When I mentioned entropy loss to the OP though, I mostly meant loss from
getting rid of the letter z.  The (binary) Shannon entropy of the
uniform probability distribution on 26 letters is 4.7004397 bits; on 25
letters, it's 4.6438561 bits.  The difference isn't enough to give an
attacker that much advantage.

I like the diceware approach to passphrase generation and I've been
using it for years.  www.diceware.com explains it in detail and the docs
there are quite well-thought-out and informative.  Keep in mind that the
entropy needed for an online password (attacker has to make a server
query for every guess, and hopefully gets locked out after n wrong
tries) and an offline one (attacker has something like a hash of the
password and can run a completely offline search) are different.

Here is a program that I use sometimes:

from math import log
dictfile = '/usr/share/dict/words'

def genrandom(nbytes):
with open('/dev/urandom') as f:
return int(f.read(nbytes).encode('hex'), 16)

def main():
wordlist = list(x.strip() for x in open(dictfile) if len(x) < 7)
nwords = len(wordlist)
print "%d words, entropy=%.3f bits/word"% (
nwords, log(nwords, 2))
print '-'.join(wordlist[genrandom(10)%nwords] for i in xrange(6))

main()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Robert Kern

On 2010-02-23 20:22 , Lie Ryan wrote:

On 02/24/10 12:38, Steven D'Aprano wrote:

On Wed, 24 Feb 2010 00:06:09 +0100, Daniel Fetchinson wrote:


Hmm.  I wonder if all the spam is coming from the NG side.  I'll have
to look at that.  One of the reasons that I stopped reading UseNet over
ten years ago was because of the diminishinig S/N ratio.  I have always
felt that it was a mistake to gateway this group.


And this has to do with python programming in what way?



I think the question of whether or not comp.lang.python is being spammed,
and if so, what we can do about it, is a good question to raise on
comp.lang.python.

Where else do you think it should be discussed?


comp.lang.python.spam_prevention_discussion


Which doesn't exist and never will. Sorry, but meta-discussions about the group 
are typically on-topic for all groups with some few exceptions (e.g. 
non-discussion, binary-only groups with associated .d groups, for instance).


--
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: Is this secure?

2010-02-23 Thread Steven D'Aprano
On Wed, 24 Feb 2010 02:40:13 +, Steven D'Aprano wrote:

> On Tue, 23 Feb 2010 15:36:02 +0100, mk wrote:
> 
>> The question is: is this secure? That is, can the string generated this
>> way be considered truly random?
> 
> Putting aside the philosophical question of what "truly random" means, I
> presume you mean that the letters are uniformly distributed. The answer
> to that is, they don't like uniformly distributed.

Er, they don't *look* uniformly distributed.

(Of course, being random, perhaps they are and I just got unlucky.)


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


Re: Is this secure?

2010-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2010 15:36:02 +0100, mk wrote:

> The question is: is this secure? That is, can the string generated this
> way be considered truly random?

Putting aside the philosophical question of what "truly random" means, I 
presume you mean that the letters are uniformly distributed. The answer 
to that is, they don't like uniformly distributed.

This isn't a sophisticated statistical test, it's the equivalent of a 
back-of-the-envelope calculation: I generated 100,000 random strings with 
your code, and counted how often each letter appears:

If the letters are uniformly distributed, you would expect all the 
numbers to be quite close, but instead they range from 15063 to 25679:

{'a': 15063, 'c': 20105, 'b': 15100, 'e': 25465, 'd': 25458, 'g': 25597, 
'f': 25589, 'i': 25045, 'h': 25679, 'k': 22945, 'j': 25531, 'm': 16187, 
'l': 16252, 'o': 16076, 'n': 16012, 'q': 16069, 'p': 16119, 's': 16088, 
'r': 16087, 'u': 15951, 't': 16081, 'w': 16236, 'v': 15893, 'y': 15834, 
'x': 15956}

Eye-balling it, it looks vaguely two-humped, one hump around 15-16K, the 
second around 22-25K. Sure enough, here's a quick-and-dirty graph:

a  | ***
b  | ***
c  | ***
d  | ***
e  | ***
f  | 
g  | 
h  | 
i  | ***
j  | 
k  | **
l  | **
m  | **
n  | *
o  | **
p  | **
q  | **
r  | **
s  | **
t  | **
u  | *
v  | *
w  | **
x  | *
y  | *


The mean of the counts is 19056.72, and the mean deviation is 3992.28. 
While none of this is statistically sophisticated, it does indicate to me 
that your function is nowhere even close to uniform. It has a very strong 
bias.



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


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Lie Ryan
On 02/24/10 12:38, Steven D'Aprano wrote:
> On Wed, 24 Feb 2010 00:06:09 +0100, Daniel Fetchinson wrote:
> 
>>> Hmm.  I wonder if all the spam is coming from the NG side.  I'll have
>>> to look at that.  One of the reasons that I stopped reading UseNet over
>>> ten years ago was because of the diminishinig S/N ratio.  I have always
>>> felt that it was a mistake to gateway this group.
>>
>> And this has to do with python programming in what way?
> 
> 
> I think the question of whether or not comp.lang.python is being spammed, 
> and if so, what we can do about it, is a good question to raise on 
> comp.lang.python.
> 
> Where else do you think it should be discussed?

comp.lang.python.spam_prevention_discussion
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: When will Python go mainstream like Java?

2010-02-23 Thread George Sakkis
On Feb 23, 3:49 pm, mk  wrote:

> Well I for one wouldn't want Python to go exactly Java way, see this:
>
> http://www.itjobswatch.co.uk/charts/permanent-demand-trend.aspx?s=jav...
>
> This is the percentage of job offers in UK where the keyword "Java" appears.
>
> Same for C#, it looks like C# is eating Java's lunch now:
>
> http://www.itjobswatch.co.uk/charts/permanent-demand-trend.aspx?s=csh...

This seems to be a UK-specific trend; in the US (and most other
countries I know of) Java is still going strong, e.g.
http://www.indeed.com/jobtrends?q=java%2C+c%23&l=

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


Re: The future of "frozen" types as the number of CPU cores increases

2010-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2010 20:53:37 -0500, sstein...@gmail.com wrote:

>> Have you tried parallelpython?
>> 
>> http://www.parallelpython.com/
> 
> I had not, have you used this successfully?

Not personally, no.



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


Re: Is this secure?

2010-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2010 11:19:59 -0800, Paul Rubin wrote:

> mk  writes:
>> I need to generate passwords and I think that pseudo-random generator
>> is not good enough, frankly. So I wrote this function:... The question
>> is: is this secure? That is, can the string generated this way be
>> considered truly random? (I abstract from not-quite-perfect nature of
>> /dev/urandom at the moment; I can always switch to /dev/random which is
>> better)
> 
> urandom is fine and the entropy loss from the numeric conversions and
> eliminating 'z' in that code before you get letters out is not too bad.

What?

You're going from a possible alphabet of 62 (excluding punctuation) or 94 
(inc punctuation available on an American keyboard) distinct letters down 
to 25, and you say that's "not too bad"?

Paul, if you were anyone else, I'd be sneering uncontrollably about now, 
but you're not clueless about cryptography, so what have I missed? Why is 
reducing the number of distinct letters by more than 50% anything but a 
disaster? This makes the task of brute-forcing the password exponentially 
easier.

Add the fact that the passwords are so short (as little as two characters 
in my tests) and this is about as far from secure as it is possible to be.



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


Re: Is this secure?

2010-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2010 15:36:02 +0100, mk wrote:

> Hello,
> 
> I need to generate passwords and I think that pseudo-random generator is
> not good enough, frankly. So I wrote this function:
[snip]
> (yes I know that this way generated string will not contain 'z' because
> 99/4 + 97 = 121 which is 'y')

You're worried about the security of the PRNG but then generate a TWO to 
FIVE character lowercase password with no digits, punctuation or the 
letter 'z'? That's priceless!

Python's PRNG is not suitable for producing cryptographically strong 
streams of random bytes, but it is perfectly strong enough for generating 
good passwords.



> The question is: is this secure? 

No. 

You are wasting your time trying to fix something which isn't a problem, 
and introducing a much bigger problem instead. You are MUCH MUCH MUCH 
better off with a six or ten character password taken from upper and 
lowercase letters, plus digits, plus punctuation, than a four digit 
password taken from lowercase letters only. Even if the first case has 
some subtle statistical deviation from uniformity, and the second is 
"truly random" (whatever that means), it doesn't matter.

Nobody is going to crack your password because the password generator is 
0.01% more likely to generate a "G" than a "q". But they *will* brute-
force your password if you have a four digit password taken from a-y only.



> That is, can the string generated this
> way be considered truly random? 

Define truly random.



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


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Aahz
In article ,
W. eWatson  wrote:
>
>My claim is that if one creates a program in a folder that reads a file 
>in the folder it and then copies it to another folder, it will read  the 
>data file in the first folder, and not a changed file in the new folder. 
>I'd appreciate it if some w7 users could try this, and let me know what 
>they find.
>
>My experience is that if one checks the properties of the copied file, 
>it will point to the original py file and execute it and not the copy.

I've no time to verify your specific claim and have no readily available
proof for mine, but I've seen similar issues on Win7.  AFAIK, this has
nothing to do with Python.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: formatting a number as percentage

2010-02-23 Thread Lawrence D'Oliveiro
In message <6819f2f8-7a9e-4ea4-a936-c4e00394b...@g28g2000yqh.googlegroups.com>, 
vsoler wrote:

> I'm trying to print .7 as 70%

Just to be perverse:

(lambda x : (lambda s : s[:s.index(".")] + s[s.index(".") + 1:] + 
"%")("%.2f" % x).lstrip("0"))(.7)

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


compiling python question

2010-02-23 Thread Mag Gam
I am trying to compile python with Tk bindings. Do I need to do
anything special for python to detect and enable Tk?

This is mainly for matplotlib's TkAgg. It seems my compiled version of
python isn't finding the module _tkagg
-- 
http://mail.python.org/mailman/listinfo/python-list


PAPER PRESENTATIONS AND SEMIMAR TOPICS.

2010-02-23 Thread all in one
PAPER PRESENTATIONS AND SEMIMAR TOPICS.
CHECK OUR VAST PAPER PRESENTATIONS AND SEMIMAR TOPICS INCLUDING
PROJECTS FOR FREE AT
http://presentationsandseminars.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The future of "frozen" types as the number of CPU cores increases

2010-02-23 Thread sstein...@gmail.com

On Feb 23, 2010, at 8:30 PM, Steven D'Aprano wrote:

> On Tue, 23 Feb 2010 10:35:38 -0800, John Nagle wrote:
> 
>> The issue being discussed was scaling Python for CPUs with many cores.
>> With Intel shipping 4 cores/8 hyperthread CPUs, the 6/12 part working,
>> and the 8/16 part coming along, this is more than a theoretical issue.
> 
> Have you tried parallelpython?
> 
> http://www.parallelpython.com/

I had not, have you used this successfully?

Thanks,

S

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


Re: Creating variables from dicts

2010-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2010 15:41:16 -0800, Luis M. González wrote:

> By the way, if you want the variables inside myDict to be free
> variables, you have to add them to the local namespace. The local
> namespace is also a dictionary "locals()". So you can update locals as
> follows:
> 
> locals().update( myDictionary )

No you can't. Try it inside a function.




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


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Steven D'Aprano
On Wed, 24 Feb 2010 00:06:09 +0100, Daniel Fetchinson wrote:

>> Hmm.  I wonder if all the spam is coming from the NG side.  I'll have
>> to look at that.  One of the reasons that I stopped reading UseNet over
>> ten years ago was because of the diminishinig S/N ratio.  I have always
>> felt that it was a mistake to gateway this group.
> 
> And this has to do with python programming in what way?


I think the question of whether or not comp.lang.python is being spammed, 
and if so, what we can do about it, is a good question to raise on 
comp.lang.python.

Where else do you think it should be discussed?



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


Re: When will Java go mainstream like Python?

2010-02-23 Thread Lie Ryan
On 02/24/10 12:08, Nobody wrote:
> On Wed, 24 Feb 2010 12:22:05 +1300, Lawrence D'Oliveiro wrote:
> 
>>> Java - The JVM code been hacked to death by Sun engineers (optimised)
>>> Python - The PVM code has seen speed-ups in Unladen or via Pyrex..
>>> ad-infinitum but nowhere as near to JVM
>>
>> Python is still faster, though. I think a key reason is that its VM supports 
>> reference-counting, which the Java folks never quite got the grasp of.
> 
> So how does Python handle circular references?

There is an optional garbage collector built into the interpreter. Look
at here on how it works: http://python.ca/nas/python/gc/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's Going on between Python and win7?

2010-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2010 09:34:00 -0500, Jerry Hill wrote:

> On Mon, Feb 22, 2010 at 8:25 PM, W. eWatson 
> wrote:
>> So what's the bottom line? This link notion is completely at odds with
>> XP, and produces what I would call something of a mess to the unwary
>> Python/W7 user. Is there a simple solution?
> 
> I know people went off on a tangent talking about symbolic links and
> hard links, but it is extremely unlikely that you created something like
> that by accident.  Windows just doesn't create those without you doing
> quite a bit of extra work.  It certainly doesn't create them when you
> drag & drop files around through the normal interface.

I find it far more likely that Windows 7 makes it easy for the user to 
accidentally produce links rather than copies, rather than that Python 
suddenly has developed a bug where it opens a completely different file 
to the one you ask for.

But more likely still is some confusion regarding paths.

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


Re: The future of "frozen" types as the number of CPU cores increases

2010-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2010 10:35:38 -0800, John Nagle wrote:

> The issue being discussed was scaling Python for CPUs with many cores.
> With Intel shipping 4 cores/8 hyperthread CPUs, the 6/12 part working,
> and the 8/16 part coming along, this is more than a theoretical issue.

Have you tried parallelpython?


http://www.parallelpython.com/


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


Re: What's Going on between Python and win7?

2010-02-23 Thread Lie Ryan
On 02/23/10 05:30, W. eWatson wrote:
> On 2/22/2010 8:29 AM, Grant Edwards wrote:
>> On 2010-02-22, W. eWatson  wrote:
>>
>>> Last night I copied a program from folder A to folder B.
>>
>> [tail of various windows breakages elided]
>>
>>> Comments?
>>
>> Switch to Linux?
>>
>> Or at least install Cygwin?
>>
> Yes, definitely not related, but maybe some W7 user has a similar
> experience here. It seems a natural place to look, since it should be
> reasonably common.

IMHO that doesn't justify.

The advice to move the discussion to a windows-specific group is not
just about reducing off-topic discussion[1], but because there isn't
that much Windows (Seven) users in this newsgroup. Most comp.lang.python
users either uses linux, unix, macs, or older version of windows, and
are not familiar with the specifics of Windows 7.

It would be nice though, if you reposted the solution you found from
another forum here to benefit other python Windows 7 users.

[1] pretty much anything computer-related is not entirely off-topic in
c.l.py because of the wide range of situations people uses python in
(I've seen general algorithmic questions, text-editor wars, problems
with 3rd party module, jython/ironpython internals, etc discussed in
here; many of those gets quite welcomed even though technically off-topic)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bizarre arithmetic results

2010-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2010 05:48:09 -0800, Mark Dickinson wrote:

> On Feb 23, 8:11 am, Steven D'Aprano
>  wrote:
>> Making spaces significant in that fashion is mind-bogglingly awful.
>> Let's look at a language that does this:
>>
>> [st...@sylar ~]$ cat ws-example.rb
>> def a(x=4)
>>     x+2
>> end
>>
>> b = 1
>> print (a + b), (a+b), (a+ b), (a +b), "\n"
>>
>> [st...@sylar ~]$ ruby ws-example.rb
>> 7773
> 
> Hmm.  That's pretty nasty, all right.  Not that Python can claim to be
> immune to such behaviour:
> 
 3 .real
> 3
 3. real
>   File "", line 1
> 3. real
>   ^
> SyntaxError: invalid syntax
> 
> 
> Though the fact that one of the cases raises an exception (rather than
> silently giving some different behaviour) ameliorates things a bit.

It ameliorates it *completely* -- you won't get silent errors in Python 
because you add or delete whitespace around a dot.


"I find it amusing when novice programmers believe their main job is 
preventing programs from crashing. ... More experienced programmers 
realize that correct code is great, code that crashes could use 
improvement, but incorrect code that doesn't crash is a horrible 
nightmare."

http://www.pphsg.org/cdsmith/types.html


The edge case occurs because dot does double-duty as an operator and as 
part of float literals. However, float literals never include whitespace:

>>> 1.5
1.5
>>> 1 . 5
  File "", line 1
1 . 5
^
SyntaxError: invalid syntax

and likewise for 1. 5 and 1 .5 -- the only way to get a float literal 
with a decimal point is by not including whitespace in it. So there is 
never any ambiguity about floats. You can even do this:

>>> 1.5.__str__()
'1.5'


And since . is an operator outside of float literals, you can do this:

>>> import sys
>>> sys . platform
'linux2'


although why you'd want to escapes me :)

This actually is a feature, since it is useful when calling methods on 
int literals. However this is a very rare thing to do.



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


Re: MODULE FOR I, P FRAME

2010-02-23 Thread Rhodri James

On Tue, 23 Feb 2010 10:39:21 -, DANNY  wrote:


@James I am thinkinhg about effect of errors that are within the
sequence of P frames. Where the P frames have only the information
about the changes in previous frames, so that errors are present until
the next I frame. So I would like to see how is this seen in different
GoP sized clips.


Ah, I see.  What I'd suggest you do is to encode your video clip at  
various GOP sizes (you'll want some quite extreme ones for comparison),  
then write a little program that reads in the file byte by byte and  
randomly corrupts the data as it goes through.  "tsplay" from the tstools  
suite that I mentioned earlier will do that for you (because it was very  
handy for testing the robustness of our decoders).  Then watch the results  
using VLC or similar.


My recollection is that when the image isn't static, P frames tend to have  
enough intra-coded blocks that corrupted video data doesn't have as much  
effect as you might think.  I've dealt with streams that had ten seconds  
or more between I frames, and starting at a random spot (simulating  
changing channel on your digital TV) builds up an intelligible (if  
obviously wrong) image surprisingly quickly.


PS: my first name is Rhodri, not James.  Don't worry, it catches a lot of  
people out.


--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: When will Java go mainstream like Python?

2010-02-23 Thread Nobody
On Wed, 24 Feb 2010 12:22:05 +1300, Lawrence D'Oliveiro wrote:

>> Java - The JVM code been hacked to death by Sun engineers (optimised)
>> Python - The PVM code has seen speed-ups in Unladen or via Pyrex..
>> ad-infinitum but nowhere as near to JVM
> 
> Python is still faster, though. I think a key reason is that its VM supports 
> reference-counting, which the Java folks never quite got the grasp of.

So how does Python handle circular references?

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


Re: python dowload

2010-02-23 Thread Ethan Furman

monkeys paw wrote:

NEW QUESTION if y'all are still reading:

Is there an integer increment operation in Python? I tried
using i++ but had to revert to 'i = i + 1'


Nope, but try i += 1.

~Ethan~


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


Re: The future of "frozen" types as the number of CPU cores increases

2010-02-23 Thread Nobody
On Mon, 22 Feb 2010 22:27:54 -0800, sjdevn...@yahoo.com wrote:

> Basically, multiprocessing is always hard--but it's less hard to start
> without shared everything.  Going with the special case (sharing
> everything, aka threading) is by far the stupider and more complex way
> to approach multiprocssing.

Multi-threading hardly shares anything (only dynamically-allocated
and global data), while everything else (the entire stack) is per-thread.

Yeah, I'm being facetious. Slightly. If you're going to write
multi-threaded code, it's a good idea to wean yourself off of using global
variables and shared mutable state. 

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


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Lie Ryan
On 02/24/10 11:21, Aahz wrote:
> In article ,
> D'Arcy J.M. Cain  wrote:
>> On Tue, 23 Feb 2010 02:54:25 -0800 (PST)
>> Joan Miller  wrote:
>>>
>>> *Sorry by this message off topic, but this is too important*
>>
>> Is it just me or has the spew from gmail on this list radically
>> increased in the last week?  Anyone else considering blocking all gmail
>> posts to this list?
> 
> Joan Miller is a regular poster; this is off-topic, but it's not spam.

Does being a regular poster exempts you from having your post considered
as spam? That's an
http://en.wikipedia.org/wiki/Ad_hominem#Inverse_ad_hominem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spam from gmail

2010-02-23 Thread Ben Finney
a...@pythoncraft.com (Aahz) writes:

> Joan Miller is a regular poster; this is off-topic, but it's not spam.

Non sequitur. Spam is spam, not by who authors or posts it, but by its
distribution (to many people, e.g. via a forum like this one) and its
content (off-topic and unsolicited).

The message is important, its poster is a regular here; that doesn't
stop the message being spam when posted here.

-- 
 \   “Everyone is entitled to their own opinions, but they are not |
  `\entitled to their own facts.” —US Senator Pat Moynihan |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Aahz
In article ,
D'Arcy J.M. Cain  wrote:
>On Tue, 23 Feb 2010 02:54:25 -0800 (PST)
>Joan Miller  wrote:
>>
>> *Sorry by this message off topic, but this is too important*
>
>Is it just me or has the spew from gmail on this list radically
>increased in the last week?  Anyone else considering blocking all gmail
>posts to this list?

Joan Miller is a regular poster; this is off-topic, but it's not spam.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
-- 
http://mail.python.org/mailman/listinfo/python-list


python shell crashing on paste

2010-02-23 Thread Leo
I just upgraded to Windows 7 (yes, I know) and I've been having a
really strange problem with running python (2.6.4, installed from the
python.org installer) from the command line.

If I open the interpreter, and then paste in a long string,
conhost.exe crashes. This doesn't happen when pasting the string just
in the command line so its something with the python interpreter.

Here's the details of the windows crash:

Log Name:  Application
Source:Application Error
Event ID:  1000
Task Category: (100)
Level: Error
Keywords:  Classic
Description:
Faulting application name: conhost.exe, version: 6.1.7600.16385, time
stamp: 0x4a5bc271
Faulting module name: conhost.exe, version: 6.1.7600.16385, time
stamp: 0x4a5bc271
Exception code: 0xc005
Fault offset: 0x48ca
Faulting process id: 0x1aa8
Faulting application start time: 0x01cab4e450b97766
Faulting application path: C:\Windows\system32\conhost.exe
Faulting module path: C:\Windows\system32\conhost.exe
Report Id: 9c6afd6c-20d7-11df-bbd8-e390d387a902

Has anyone else seen anything like this? Any suggestions on how to
even start figuring this out?

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


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Ned Deily
In article <20100223182923.4d259d12.da...@druid.net>,
 "D'Arcy J.M. Cain"  wrote:
> And just to bring this back on topic, I did do a test and found that
> splitting my mailbox between Python mailing list messages and Python
> newsgroup messages did not indicate that that was a good barometer of
> spaminess.  There are also quite a few decent posts from gmail.com so
> blocking by that domain isn't going to be the problem solver either.

Try following the list using gmane (either via NNTP, RSS, or the web).  
gmane does a pretty good job of filtering the spam.

http://dir.gmane.org/gmane.comp.python.general

-- 
 Ned Deily,
 n...@acm.org

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


Re: Creating variables from dicts

2010-02-23 Thread Luis M . González
On Feb 23, 7:56 pm, Luis M. González  wrote:
> On Feb 23, 5:53 pm, vsoler  wrote:
>
>
>
>
>
> > Hi,
>
> > I have two dicts
>
> > n={'a', 'm', 'p'}
> > v={1,3,7}
>
> > and I'd like to have
>
> > a=1
> > m=3
> > p=7
>
> > that is, creating some variables.
>
> > How can I do this?
>
> You are probably coming from another language and you're not used to
> python's data structures.
> If you want a list of items, you use tuples or lists. Examples:
>
>     ('a', 'm', 'p') ---> this is a tuple, and it's made with
> parenthesis ()
>     ['a', 'm', 'p'] ---> this is a list, and it's made with brackets
> []
>
> Check the documentation to see the difference between tuples and
> lists.
> For now, lets just use lists and forget about tuples...
> Now if you want a sequence of items ordered a key + value pairs, use a
> dictionary, as follows:
>
>     {'name': 'joe', 'surname': 'doe', 'age': 21} ---> this is a dict,
> and it's made with curly braces {}.
>
> Curly braces are also used to create sets, but you don't need them now
> (check the documentation to learn more about sets).
> So going back to your question, you should have two lists, as follows:
>
>     n = ['a', 'm', 'p']
>     v = [1,3,7]         --> note that I used brackets [], not curly
> braces {}.
>
> And now you can build a dict formed by the keys in "n" and the values
> in "v":
>
>     myDict = {}           --> this is an new empty dictionary
>     for k,v in zip(n,v):
>         myDict[k] = v
>
> This results in this dictionary: {'a': 1, 'p': 7, 'm': 3}.
>
> Hope this helps...
> Luis

By the way, if you want the variables inside myDict to be free
variables, you have to add them to the local namespace.
The local namespace is also a dictionary "locals()".
So you can update locals as follows:

locals().update( myDictionary )

This way, all the key-value pairs inside myDict become free variables.
Wich is the same as declaring them as follows:

a = 1
p = 7

etc...

Luis



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


Re: Creating variables from dicts

2010-02-23 Thread Tim Chase

Luis M. González wrote:

If you want a list of items, you use tuples or lists. Examples:

('a', 'm', 'p') ---> this is a tuple, and it's made with
parenthesis ()


Actually, a tuple is made with commas...the parens are just there 
to clarify the order of operations and make it easier to read :)


  >>> x = 1,2,3
  >>> x
  (1, 2, 3)

-tkc





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


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Chris Colbert
this image is appropriate:

http://4.bp.blogspot.com/_pS7sKjlzwFg/SwhG1S901pI/Eiw/XSm93RIY2WE/s400/kelso-burn.jpg

On Tue, Feb 23, 2010 at 6:06 PM, Daniel Fetchinson <
fetchin...@googlemail.com> wrote:

> >> >> Is it just me or has the spew from gmail on this list radically
> >> >> increased in the last week?  Anyone else considering blocking all
> gmail
> >> >> posts to this list?
> >> >
> >> > I did that a long time ago for all of the Usenet groups I read
> >> > and all but one of the mailing lists I read.
> >>
> >> Wait, I misread the posting.  I block everything from
> >> google.groups, not everything from gmail.
> >
> > Yes, I did that a long time ago as well.  But now there seems to be
> > more and more actual spam coming from gmail.com itself.  It may just be
> > a minor blip on the spam graph but I'm keeping my eye on it.
> >
> > Most mailing lists that I am on are pretty good at filtering spam
> > before it gets to the list.  The only spam I ever see on my NetBSD
> > lists are the ones that I moderate and I block them before anyone else
> > sees them.  A little more pain for me in return for a lot less pain for
> > everyone else.  I guess that's not possible on a list that is gatewayed
> > to UseNet like this one is.
> >
> > Hmm.  I wonder if all the spam is coming from the NG side.  I'll have
> > to look at that.  One of the reasons that I stopped reading UseNet over
> > ten years ago was because of the diminishinig S/N ratio.  I have always
> > felt that it was a mistake to gateway this group.
>
> And this has to do with python programming in what way?
>
> You, sir, are incredibly funny :)
>
> Just 5 minutes ago you declared in a nearby thread that
>
> > It isn't about the Python programming language so it is off topic.  So
> > what if some members have an interest?  We have interest in a lot of
> > things.  We all have interest in the hardware that our programs run on
> > but questions about hardware are also off topic.
> >
> > Perhaps you don't quite grasp the point of topical discussion groups.
> > They are a way of letting individuals decide for themselves what kind
> > of discussions they want to be involved in.  By spamming the group this
> > way you take away that freedom of choice.  It's ironic when it is done
> > in the name of freedom.
>
> Touche!
>
> Cheers,
> Daniel
>
>
> --
> Psss, psss, put it down! - http://www.cafepress.com/putitdown
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: look at the google code

2010-02-23 Thread Lawrence D'Oliveiro
In message <711cb713-4b4a-47f6-8922-ce1ada7d6...@e1g2000yqh.googlegroups.com>, 
lkcl wrote:

> we couldn't get control of that site for quite some time so
> started using sourceforget for svn, but the issue tracker on
> sourceforget is truly dreadful.

Damn. I’ve been working on my own fork  of
a long-neglected package on SourceForge .
GitHub doesn’t offer a publicly-writable bug tracker, but I was under the
impression that SourceForge did. But you’re saying it’s not worth using?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread D'Arcy J.M. Cain
On Wed, 24 Feb 2010 00:06:09 +0100
Daniel Fetchinson  wrote:
> And this has to do with python programming in what way?

Are you new?  Meta discussions about lists are generally considered
on-topic for the list.

> You, sir, are incredibly funny :)

Yes, I am.  That however is NOT on topic.  :-)

And just to bring this back on topic, I did do a test and found that
splitting my mailbox between Python mailing list messages and Python
newsgroup messages did not indicate that that was a good barometer of
spaminess.  There are also quite a few decent posts from gmail.com so
blocking by that domain isn't going to be the problem solver either.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: When will Java go mainstream like Python?

2010-02-23 Thread Lawrence D'Oliveiro
In message , Ishwor 
Gurung wrote:

> Java - The JVM code been hacked to death by Sun engineers (optimised)
> Python - The PVM code has seen speed-ups in Unladen or via Pyrex..
> ad-infinitum but nowhere as near to JVM

Python is still faster, though. I think a key reason is that its VM supports 
reference-counting, which the Java folks never quite got the grasp of.

So you see, it’s all about working smarter, not harder.

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


Re: When will Java go mainstream like Python?

2010-02-23 Thread Lawrence D'Oliveiro
In message , Martin P. Hellwig 
wrote:

> Actually I am still waiting for Java to be mainstream :-)

Too late, I think. Sun dilly-dallied over making it open source for too 
long, until it practically didn’t matter any more.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this secure?

2010-02-23 Thread Lawrence D'Oliveiro
In message , mk wrote:

> I need to generate passwords and I think that pseudo-random generator is
> not good enough, frankly. So I wrote this function:

Much simpler:

import subprocess

data, _ = subprocess.Popen \
  (
args = ("pwgen", "-nc"),
stdout = subprocess.PIPE
  ).communicate()
print data

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


Re: python dowload

2010-02-23 Thread Wes James


>
>
> NEW QUESTION if y'all are still reading:
>
> Is there an integer increment operation in Python? I tried
> using i++ but had to revert to 'i = i + 1'

i+=1


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


Re: Writing an assembler in Python

2010-02-23 Thread Lawrence D'Oliveiro
In message , 
Anh Hai Trinh wrote:

> On Feb 23, 10:08 am, Lawrence D'Oliveiro  
> wrote:
>>
>> Let me suggest an alternative approach: use Python itself as the
>> assembler. Call routines in your library to output the code. That way you
>> have a language more powerful than any assembler.
>>
>> See  for an example.
> 
> SyntaxError: Non-matching "#end if" in crosscode8.py:345

What mismatch? Line 345 is the last line of this routine:

def org(self, addr) :
"""sets the origin for defining subsequent consecutive memory 
contents."""
self.curpsect.setorigin(self.follow(addr))
self.lastaddr = self.curpsect.origin
return self # for convenient chaining of calls
#end org

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


Re: python dowload

2010-02-23 Thread monkeys paw

On 2/23/2010 3:17 PM, Tim Chase wrote:

monkeys paw wrote:

I used the following code to download a PDF file, but the
file was invalid after running the code, is there problem
with the write operation?

import urllib2
url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
a = open('adobe.pdf', 'w')


Sure you don't need this to be 'wb' instead of 'w'?


'wb' does the trick. Thanks all!

Here is the final working code, i used an index(i)
to see how many reads took place, i have to assume there is
a default buffer size:

import urllib2
a = open('adobe.pdf', 'wb')
i = 0
for line in 
urllib2.urlopen('http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'):

i = i + 1
a.write(line)

print "Number of reads: %d" % i
a.close()


NEW QUESTION if y'all are still reading:

Is there an integer increment operation in Python? I tried
using i++ but had to revert to 'i = i + 1'




for line in urllib2.urlopen(url):
a.write(line)


I also don't know if this "for line...a.write(line)" loop is doing
newline translation. If it's a binary file, you should use .read()
(perhaps with a modest-sized block-size, writing it in a loop if the
file can end up being large.)

-tkc




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


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Daniel Fetchinson
>> >> Is it just me or has the spew from gmail on this list radically
>> >> increased in the last week?  Anyone else considering blocking all gmail
>> >> posts to this list?
>> >
>> > I did that a long time ago for all of the Usenet groups I read
>> > and all but one of the mailing lists I read.
>>
>> Wait, I misread the posting.  I block everything from
>> google.groups, not everything from gmail.
>
> Yes, I did that a long time ago as well.  But now there seems to be
> more and more actual spam coming from gmail.com itself.  It may just be
> a minor blip on the spam graph but I'm keeping my eye on it.
>
> Most mailing lists that I am on are pretty good at filtering spam
> before it gets to the list.  The only spam I ever see on my NetBSD
> lists are the ones that I moderate and I block them before anyone else
> sees them.  A little more pain for me in return for a lot less pain for
> everyone else.  I guess that's not possible on a list that is gatewayed
> to UseNet like this one is.
>
> Hmm.  I wonder if all the spam is coming from the NG side.  I'll have
> to look at that.  One of the reasons that I stopped reading UseNet over
> ten years ago was because of the diminishinig S/N ratio.  I have always
> felt that it was a mistake to gateway this group.

And this has to do with python programming in what way?

You, sir, are incredibly funny :)

Just 5 minutes ago you declared in a nearby thread that

> It isn't about the Python programming language so it is off topic.  So
> what if some members have an interest?  We have interest in a lot of
> things.  We all have interest in the hardware that our programs run on
> but questions about hardware are also off topic.
>
> Perhaps you don't quite grasp the point of topical discussion groups.
> They are a way of letting individuals decide for themselves what kind
> of discussions they want to be involved in.  By spamming the group this
> way you take away that freedom of choice.  It's ironic when it is done
> in the name of freedom.

Touche!

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Signature-based Function Overloading in Python

2010-02-23 Thread Lie Ryan
On 02/24/10 05:25, Michael Rudolf wrote:
> Just a quick question about what would be the most pythonic approach in
> this.
> 
> In Java, Method Overloading is my best friend, but this won't work in
> Python:

> So - What would be the most pythonic way to emulate this?
> Is there any better Idom than:
> 
 def a(x=None):
> if x is None:
> pass
> else:
> pass

Python's idiom for this has always been to use "if arg is None:"; but
now with the (relatively) new decorator feature, though is not yet a
popular idiom, it is now possible to do something like this:

#!/usr/bin/env python

from functools import wraps

def overloaded(func):
@wraps(func)
def overloaded_func(*args, **kwargs):
for f in overloaded_func.overloads:
try:
return f(*args, **kwargs)
except TypeError:
pass
else:
# it will be nice if the error message prints a list of
# possible signatures here
raise TypeError("No compatible signatures")

def overload_with(func):
overloaded_func.overloads.append(func)
return overloaded_func

overloaded_func.overloads = [func]
overloaded_func.overload_with = overload_with
return overloaded_func

#

@overloaded
def a():
print 'a() without args'
pass

@a.overload_with
def _(n):
# note that, just like property(), the function's name in
# the "def _(n):" line can be arbitrary, the important
# name is in the "@overloads(a)" line
print 'a() with args'
pass

a()
a(4)
a(4, 5) # ERROR: no matching signature



PS: I posted the code to recipe book, for future reference:
http://code.activestate.com/recipes/577064-simple-function-overloading-with-decorator/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating variables from dicts

2010-02-23 Thread Luis M . González
On Feb 23, 5:53 pm, vsoler  wrote:
> Hi,
>
> I have two dicts
>
> n={'a', 'm', 'p'}
> v={1,3,7}
>
> and I'd like to have
>
> a=1
> m=3
> p=7
>
> that is, creating some variables.
>
> How can I do this?

You are probably coming from another language and you're not used to
python's data structures.
If you want a list of items, you use tuples or lists. Examples:

('a', 'm', 'p') ---> this is a tuple, and it's made with
parenthesis ()
['a', 'm', 'p'] ---> this is a list, and it's made with brackets
[]

Check the documentation to see the difference between tuples and
lists.
For now, lets just use lists and forget about tuples...
Now if you want a sequence of items ordered a key + value pairs, use a
dictionary, as follows:

{'name': 'joe', 'surname': 'doe', 'age': 21} ---> this is a dict,
and it's made with curly braces {}.

Curly braces are also used to create sets, but you don't need them now
(check the documentation to learn more about sets).
So going back to your question, you should have two lists, as follows:

n = ['a', 'm', 'p']
v = [1,3,7] --> note that I used brackets [], not curly
braces {}.

And now you can build a dict formed by the keys in "n" and the values
in "v":

myDict = {}   --> this is an new empty dictionary
for k,v in zip(n,v):
myDict[k] = v

This results in this dictionary: {'a': 1, 'p': 7, 'm': 3}.

Hope this helps...
Luis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] Question for you

2010-02-23 Thread Daniel Fetchinson
>> Hello, Dave;
>>
>>My name is Craig Connor and I am a senior s/w developer at Northrop
>> Grumman.
>>
>> I have a question for you. I have installed* Boost* (via the
>> Installer), and stored it into my
>>
>> C Drive inside a dir called:
>>
>> * C:\boost_1_42*
>>
>> I also installed the* Boost Jam* into a directory called:
>>
>> * C:\boost-jam-3.1.17*
>>
>> I am using 2 separate compilers in my* Win OS XP (SP3)*
>>
>> and I would like to be able to use the Python module of Boost
>>
>> in order to embed Python.h into my C++ compiler.
>>
>> The C++ compilers that I have are:
>>
>> o* Dev-cpp*, and
>>
>> o* Visual C++.net*  (of* MS Visual Studio.Net 2008*).
>>
>> Problem:
>>
>>When I compile a simple program, I keep getting the error:
>> "*pyconfig.h: No such file or directory*".
>>
>> The program I am trying to start with is (below):
>>
>> *#include *
>>
>> *#include*
>>
>> *#include*
>>
>> *using namespace std;*
>>
>> *int main( )*
>>
>> *{*
>>
>> *  cout << "Hello, Boost World!!" << endl;*
>>
>> *  boost::any a(5);*
>>
>> *  a = 7.67;*
>>
>> *  std::cout<(a)<>
>> * *
>>
>> *  system( "PAUSE" );*
>>
>> *  return 0;*
>>
>> *}*
>>
>>
>> Also:
>>
>>   I did set up my environmental config to go to the Boost dir.
>>
>> Question:
>>
>>   Do you know what am I doing wrong?
>>
>> Regards,
>>
>>Craig Connor
>>
>>720.622.2209
>>
> Hello Connor,
>
> I think you have the wrong email address - this is Python-dev, an email
> list for the development *of* Python.
>
> All the best,
>
> Michael Foord

[redirecting to python-list from python-dev]

And the fact that you are a "senior s/w developer" at Northrop Grumman
surely doesn't sound like good advertisement for said firm.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bay Area PUG Meeting Thursday in Mountain View, CA

2010-02-23 Thread Aahz
In article ,
W. eWatson  wrote:
>
>Anyone here going to the meeting,Subject? As far as I can tell, it meets 
>from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to 
>be an informal group dinner at 6 pm at some place yet unknown. Comments?

Subscribe to http://mail.python.org/mailman/listinfo/baypiggies
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem creating executable, with PyQwt

2010-02-23 Thread David Boddie
On Tuesday 23 February 2010 05:32, Gib Bogle wrote:

> David Boddie wrote:
> 
>> I have previously referred people with py2exe/PyQt issues to this page on
>> the PyQt Wiki:
>> 
>>   http://www.py2exe.org/index.cgi/Py2exeAndPyQt
>> 
>> If you can somehow convince py2exe to include the QtSvg module (and
>> presumably the libQtSvg library as well) then perhaps that will solve
>> this problem.
>> 
>> David
> 
> Thanks David, that worked a treat.  :-)

If you could update the Wiki (or maybe the py2exe Wiki, if they have one)
to say what you did, that would be useful for others in the future. Then
they'll only be one search away from the answer. :-)

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


Re: When will Python go mainstream like Java?

2010-02-23 Thread Ben Finney
Stefan Behnel  writes:

> Chris Rebert, 23.02.2010 06:45:
> > Indeed. Python is at position 7, just behind C#, in the TIOBE Index:
> > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
>
> That index is clearly flawed. A language like PHP (whatever that is
> supposed to be comparable with) can't possibly be on the rise, can it?

Why not? What do you think the TIOBE measures, and why would PHP not be
rising by that measure?

-- 
 \ “To save the world requires faith and courage: faith in reason, |
  `\and courage to proclaim what reason shows to be true.” |
_o__)—Bertrand Russell |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to transmit a crash report ?

2010-02-23 Thread Stef Mientki

On 23-02-2010 15:21, Thomas wrote:

On Feb 22, 9:27 pm, MRAB  wrote:
   

Stef Mientki wrote:
 

hello,
   
 

in my python desktop applications,
I'ld like to implement a crash reporter.
By redirecting the sys.excepthook,
I can detect a crash and collect the necessary data.
Now I want that my users sends this information to me,
and I can't find a good way of doing this.
   
 

The following solutions came into my mind:
(most of my users are on Windows, and the programs are written in Python
2.6)
   
 

1. mailto:
doesn't work if the the user didn't install a default email client,
or if the user uses a portable email client (that isn't started yet)
Besides this limits the messages to small amounts of data.
   
 

2.other mail options: smtp
AFAIK such a solution needs smtp authorization, and therefor I've to put
my username and password in the desktop application.
   

Try reading the documentation for Python's smtplib module.

You don't need to provide any password.



 

3. http-post
Although post is also limited in size,
I could store information in cookies (don't know yet how), and cookies
are sent parallel to the post message.
On the server site I can use a small php script, that stores the
post-data, cookies and/or send's a (long) email.
   
 

are there better options ?- Hide quoted text -
   

- Show quoted text -- Hide quoted text -

- Show quoted text -
 

Try http://code.activestate.com/recipes/442459/
   


Apparently there's something terrible wrong on my system, because I do 
need username and password :-(


First, a script that works without username and password.
I guess it works, because the smtp_server is the smtp server of my 
provider, and I'm in that domain of my provider,

so it won't work for a random user of my program.
  if Test ( 4 ) :
import smtplib
from email.mime.text  import MIMEText
from email.mime.multipart import MIMEMultipart

body = 'test_body'
subject  = 'test_subject'
mail_to  = 's.mien...@ru.nl'
mail_from = 'stef.mien...@gmail.com'

msg = MIMEMultipart ( 'alternative' )
msg [ 'To'  ] = mail_to
msg [ 'From'] = mail_from
msg [ 'Subject' ] = subject

part1 = MIMEText ( body, 'plain' )
msg.attach ( part1 )

smtp_server = 'mail.upcmail.nl'
session = smtplib.SMTP ( smtp_server )
session.sendmail ( mail_from, [mail_to], msg.as_string() )


Using smtp on google , works only if I support username and password:
  if Test ( 5 ) :
import smtplib
from email.mime.text  import MIMEText
from email.mime.multipart import MIMEMultipart

body = 'test_body'
subject  = 'test_subject'
mail_to  = 's.mien...@ru.nl'
mail_from = 'stef.mien...@gmail.com'

msg = MIMEMultipart ( 'alternative' )
msg [ 'To'  ] = mail_to
msg [ 'From'] = mail_from
msg [ 'Subject' ] = subject

part1 = MIMEText ( body, 'plain' )
msg.attach ( part1 )

smtp_server = 'smtp.gmail.com'
session = smtplib.SMTP ( smtp_server, 587 )
session.ehlo ( mail_from )
session.starttls ()
session.ehlo ( mail_from )
session.login (username, password )
session.sendmail ( mail_from, [mail_to], msg.as_string() )


And her a number of different tries with localhost / mail :
  if Test ( 6 ) :
import smtplib
from email.mime.text  import MIMEText
from email.mime.multipart import MIMEMultipart

body = 'test_body'
subject  = 'test_subject'
mail_to  = 's.mien...@ru.nl'
mail_from = 'stef.mien...@gmail.com'

msg = MIMEMultipart ( 'alternative' )
msg [ 'To'  ] = mail_to
msg [ 'From'] = mail_from
msg [ 'Subject' ] = subject

part1 = MIMEText ( body, 'plain' )
msg.attach ( part1 )

session = smtplib.SMTP ( 'localhost' )
"""
Traceback (most recent call last):
  File "D:\Data_Python_25\support\mail_support.py", line 375, in 
session = smtplib.SMTP ( smtp_server )
  File "P:\Python26\lib\smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
  File "P:\Python26\lib\smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
  File "P:\Python26\lib\smtplib.py", line 273, in _get_socket
return socket.create_connection((port, host), timeout)
  File "P:\Python26\lib\socket.py", line 514, in create_connection
raise error, msg
error: [Errno 10061] No connection could be made because the target 
machine actively refused it

"""
#session = smtplib.SMTP ( 'localhost', 25 )
#session = smtplib.SMTP ( 'mail', 25 )
session = smtplib.SMTP ( 'mail', 1025 )
"""
Traceback (most recent call last):
  File "D:\Data_Python_25\support\mail_support.py", line 377, in 
session = smtplib.SMTP ( 'mail', 1025 )
  File "P:\Python26\lib\smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
  File "P:\Python26\lib\smtplib.py", line 295, in connect
self.sock = self._

Re: What's Going on between Python and win7?

2010-02-23 Thread Benjamin Kaplan
On Tue, Feb 23, 2010 at 3:35 PM, Michel Claveau - MVP
 wrote:
> Hi!
>
>> Symbolic links are available in NTFS starting with Windows Vista.
>
> No.
> Hardlink come with NTFS, and already exists in W2K (and NT with specifics 
> utilities).
>
> @-salutations
> --
> Michel Claveau
>

And there's a difference between hard links and symbolic links.
Symbolic links were added to NTFS starting with Windows Vista.

http://msdn.microsoft.com/en-us/library/aa365680%28VS.85%29.aspx

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


Re: Creating variables from dicts

2010-02-23 Thread MRAB

vsoler wrote:

Hi,

I have two dicts

n={'a', 'm', 'p'}
v={1,3,7}


Those aren't dicts, they're sets.


and I'd like to have

a=1
m=3
p=7

that is, creating some variables.

How can I do this?


The real question is not how, but why?

Anyway, assuming you want them to be global variables:

globals().update(dict(zip(n, v)))

On my machine the variables didn't get the correct values because, as I
said, 'n' and 'v' are sets, so the order of the members is arbitrary.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Gib Bogle

W. eWatson wrote:

On 2/23/2010 11:14 AM, Gib Bogle wrote:

W. eWatson wrote:

On 2/23/2010 8:26 AM, Rick Dooling wrote:

No telling what Windows will do. :)

I am a mere hobbyist programmer, but I think real programmers will
tell you that it is a bad habit to use relative paths. Use absolute
paths instead and remove all doubt.

http://docs.python.org/library/os.path.html

RD

You may be right. The actual 300 line program just reads the folder
without specifying any path. I'm not that familiar with os path, but
have seen it used.


How do you invoke the program? Do you use a Command Prompt window?

IDLE, but I'm prett sure I tried it (300 lines) with Cprompt.


I don't know what you mean by "300 lines".  Have you opened a Command Prompt 
window, changed to the directory where you copied the files, and executed:

python your_prog.py
?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Bay Area PUG Meeting [Speaker] Thursday in Mountain View, CA?

2010-02-23 Thread W. eWatson

On 2/23/2010 7:49 AM, W. eWatson wrote:

Anyone here going to the meeting,Subject? As far as I can tell, it meets
from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to
be an informal group dinner at 6 pm at some place yet unknown. Comments?


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


Re: Creating variables from dicts

2010-02-23 Thread Hai Vu
On Feb 23, 12:53 pm, vsoler  wrote:
> Hi,
>
> I have two dicts
>
> n={'a', 'm', 'p'}
> v={1,3,7}
>
> and I'd like to have
>
> a=1
> m=3
> p=7
>
> that is, creating some variables.
>
> How can I do this?

I think you meant to use the square brackets [ ] instead of the curly
ones { } to define the list:

>>> n = ['a', 'b', 'c']
>>> v = [3, 5, 7]
>>> for x, y in zip(n, v):
...  exec '%s=%d' % (x, y)
...
>>> a
3
>>> b
5
>>> c
7

---
The key is the use of the exec statement, which executes the strings
"a=3", "b=5", ... as if they are python statements.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's Going on between Python and win7?

2010-02-23 Thread buggsy2
"W. eWatson"  writes:

> I noted that this search box has
> some sort of filter associated with it. Possibly, in my early stages
> of learning to navigate in Win7, I accidentally set the filter.
>
> Comments?

FYI, the only truly reliable and powerful file search utility I've found
for Windows is Agent Ransack (http://download.mythicsoft.com/agentran.exe)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating variables from dicts

2010-02-23 Thread Arnaud Delobelle
vsoler  writes:

> Hi,
>
> I have two dicts
>
> n={'a', 'm', 'p'}
> v={1,3,7}

These are sets, not dicts.

> and I'd like to have
>
> a=1
> m=3
> p=7

As sets are unordered, you may as well have

   a = 3
   m = 7
   p = 1

or any other permutation.  You need some sequences instead.  E.g.

   n = ['a', 'm', 'p']
   v = (1, 3, 7)

Then you can do:

   for name, value in zip(n, v):
   globals()[name] = value

After this the names, 'a', 'm' and 'p' will be bound to the values you
want in the global namespace.  However, it is almost always a bad idea
to do this.  Can you explain why you need to do this?

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


Milenko Kindl and America's Worst French Fries

2010-02-23 Thread Milenko Kindl
Milenko Kindl

In spite of the name, French fries are practically an American
birthright. They’re offered as the first choice side dish with nearly
every fast-food and sit-down chain meal available. But here’s the
catch: In a recent study of 7,318 New York City patrons leaving fast
food chains during the lunch hour, researchers learned that combo meals
—meaning meals with sides—averaged 1,100 calories each, which is over
half a day’s allotment. It goes to show: When your regular meals at
these restaurants are already pushing the nutritional envelope, adding
an extra 300 (or more!) empty calories can make for a dietary
disaster.

The authors of the best-selling weight-loss series Eat This, Not That!
and Cook This, Not That! have rounded up three of the worst orders of
fries available at chain restaurants across the country. We’ve also
offered up the surprising winner of the fast food French fry cook-off—
you’ll never believe which restaurant chain produces the healthiest
fried spuds!


Worst Curly Fries
Arby’s Curly Fries (Large)
640 calories
34 g fat (5 g saturated, 0 g trans)
1,460 mg sodium

Arby’s is famous for its curly fries—too bad they’re overloaded with
fat, calories and sodium. When one side dish accounts for nearly three-
quarters of your daily allotment of salt, you know there’s a problem.
As fun as these curli-Qs are, stick to the Homefry variety at Arby’s—
downsizing to a small Curly Fries will still leave you with a 410-
calorie side, which is more than many of Arby’s sandwiches!

Bonus tip: For full nutrition information for all of your favorite
chain restaurants and thousands of foods, download the bestselling Eat
This, Not That! iPhone app. It’s like having your own personal
nutritionist in your pocket at all times, and will help you avoid the
caloric calamities and guide you to the best ways to lose your belly
fast.

Eat This Instead!
Homestyle Fries (Small)
350 calories
15 g fat (2 g saturated)
720 mg sodium


Worst Wedge Fries
Jack in the Box Bacon Cheddar Wedges
715 calories
45 g fat (13 g saturated, 1 g trans)
905 mg sodium

It doesn’t take a nutritionist to identify the hazards of a grease-
soaked, cheese-slathered sack of deep-fried potatoes, but by
appearance alone, nobody could guess what’s really at stake when you
order this side from Jack’s. The American Heart Association recommends
that people cap their trans fat intake at 1 percent of total calories.
For people on a 2,000-calorie diet, that’s about 2 grams per day. See
the problem? Another issue, of course, is the overload in calories—
about one-third your daily allotment!

Bonus tip: Cheese fries are clearly an unhealthy choice. But sometimes
healthy-seeming options are just as dangerous as the obvious diet-
sinkers. For 30 jaw-dropping examples, check out The 30 Worst
Sandwiches in America.

Eat This Instead!
Grilled Chicken Strips (4) with Fire Roasted Salsa
185 calories
2 g fat (0.5 g saturated)
805 mg sodium


Worst Fries for Your Blood Pressure
Dairy Queen Chili Cheese Fries
1,240 calories
71 g fat (28 g saturated, 0.5 g trans)
2,550 milligrams sodium

This one’s a no-brainer: Chili, cheese, fried potatoes. But even a
savvy eater couldn’t possibly anticipate how bad these 3 ingredients
could be when combined by one heavy-handed fast-food company. There’s
as much sodium in this side dish as you’ll find in 15 strips of bacon.
Stick with classic ketchup and recapture nearly a day’s worth of
sodium and 930 calories.

Bonus tip: Save calories, time, and money with our free Eat This, Not
That! newsletter. Sign up today and you’ll get the Eat This, Not That!
guide to shopping once and eating for a week for free!

Eat This Instead!
French Fries (regular)
310 calories
13 g fat (2 g saturated)
640 mg sodium


Worst Regular Order of Fries
Five Guys Fries (large)
1,464 calories
71 g fat (14 g saturated)
213 mg sodium

Unfortunately, Five Guys doesn’t offer anything but fries in the side
department. Your safest bet, of course, is to skip the fries
altogether (you’d be better off adding a second patty to your burger),
but if you can’t bring yourself to eat a burger sans fries, then split
a regular order. That will still add 310 calories to your meal, but it
beats surrendering more than 75% of your day’s calories to a greasy
paper bag.

Bonus tip: Sides account for a third of our combo-meal calories—but
drinks account for a quarter of the total calories we consume each
day! Battle the liquid bulge: Avoid all drinks on this shocking list
of The Worst Drinks in the Supermarket.

Eat This Instead!
Regular Fries (1/2 serving)
310 calories
15 g fat (3 g saturated)
45 mg sodium


Worst Fries in America
Chili’s Texas Cheese Fries w/Jalapeno Ranch
1,920 calories
147 g fat (63 g saturated)
3,580 mg sodium

The only thing that comes close to redeeming this cheesy mound of lard
and grease is the fact that it’s ostensibly meant to be shared with a
few friends. Even so, you’ll collectively be taking in an entire day’s
worth of calories, three days’

Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread W. eWatson

On 2/23/2010 11:14 AM, Gib Bogle wrote:

W. eWatson wrote:

On 2/23/2010 8:26 AM, Rick Dooling wrote:

No telling what Windows will do. :)

I am a mere hobbyist programmer, but I think real programmers will
tell you that it is a bad habit to use relative paths. Use absolute
paths instead and remove all doubt.

http://docs.python.org/library/os.path.html

RD

You may be right. The actual 300 line program just reads the folder
without specifying any path. I'm not that familiar with os path, but
have seen it used.


How do you invoke the program? Do you use a Command Prompt window?

IDLE, but I'm prett sure I tried it (300 lines) with Cprompt.
--
http://mail.python.org/mailman/listinfo/python-list


Creating variables from dicts

2010-02-23 Thread vsoler
Hi,

I have two dicts

n={'a', 'm', 'p'}
v={1,3,7}

and I'd like to have

a=1
m=3
p=7

that is, creating some variables.

How can I do this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SMTPServerDisconnected

2010-02-23 Thread Jonathan Gardner
On Tue, Feb 23, 2010 at 8:47 AM, Victor Subervi  wrote:
> Hi;
> I think the last main thing I have to do on my server is get a running email
> server up. Now that I've nuked sendmail and given up on postfix, I'm back to
> trying to get qmail up and running again. Of course, there are no active
> discussion lists for *any* email server, so I have to turn here for help.
> While running a script that worked perfectly well on another server to send
> an email, I get the following error:
> A problem occurred in a Python script. Here is the sequence of function
> calls leading up to the error, in the order they occurred.
> A problem occurred in a Python script. Here is the sequence of function
> calls leading up to the error, in the order they occurred.
>  /var/www/html/globalsolutionsgroup.vi/simplemail/mail2.py
>    52 
>    53 '''
>    54 my_mail()
>    55 print '''
>    56 
> my_mail = 
>  /var/www/html/globalsolutionsgroup.vi/simplemail/mail2.py in my_mail()
>    33       to_address = ourEmail1,
>    34       subject = subject,
>    35       message = message
>    36   ).send()
>    37   Email(
> message = 'Name: beno -\nMessage: test'
>  /var/www/html/globalsolutionsgroup.vi/simplemail/simplemail.py in
> send(self=)
>   344         smtp = smtplib.SMTP()
>   345         if self.smtp_server:
>   346             smtp.connect(self.smtp_server)
>   347         else:
>   348             smtp.connect()
> smtp = , smtp.connect =  >, self = , self.smtp_server
> = 'localhost'
>  /usr/lib64/python2.4/smtplib.py in connect(self=,
> host='localhost', port=25)
>   305         if not self.sock:
>   306             raise socket.error, msg
>   307         (code, msg) = self.getreply()
>   308         if self.debuglevel > 0: print>>stderr, "connect:", msg
>   309         return (code, msg)
> code undefined, msg = 'getaddrinfo returns an empty list', self =
> , self.getreply =  >
>  /usr/lib64/python2.4/smtplib.py in getreply(self=)
>   349             if line == '':
>   350                 self.close()
>   351                 raise SMTPServerDisconnected("Connection unexpectedly
> closed")
>   352             if self.debuglevel > 0: print>>stderr, 'reply:',
> repr(line)
>   353             resp.append(line[4:].strip())
> global SMTPServerDisconnected = 
> SMTPServerDisconnected: Connection unexpectedly closed
>       args = ('Connection unexpectedly closed',)
> I cannot find the qmail logs. I assumed they'd be in either
> /var/qmail/supervise/qmail-send
> or
> /var/qmail/supervise/qmail-smtpd
> but I find no logs there.
>
> [SSH] Protocol Version 2 (OpenSSH_4.3)
> [SSH] Cipher: aes128-cbc
> Logged in (password)
> Last login: Tue Feb 23 05:24:00 2010 from 66.248.168.67
> [b...@13gems ~]$ su
> Password:
> [r...@13gems beno]# man netstat
> [r...@13gems beno]# netstat
> Active Internet connections (w/o servers)
> Proto Recv-Q Send-Q Local Address               Foreign Address
> State
> getnameinfo failed
> tcp        0    268 nrelectric.com:ssh          [UNKNOWN]:61912
> ESTABLISHED
> Active UNIX domain sockets (w/o servers)
> Proto RefCnt Flags       Type       State         I-Node Path
> unix  7      [ ]         DGRAM                    10842  /dev/log
> unix  2      [ ]         DGRAM                    10370
>  @/org/kernel/udev/udevd
> unix  2      [ ]         DGRAM                    6077731
> unix  3      [ ]         STREAM     CONNECTED     6077679
> unix  3      [ ]         STREAM     CONNECTED     6077678
> unix  2      [ ]         DGRAM                    6077675
> unix  2      [ ]         DGRAM                    11556
> unix  2      [ ]         DGRAM                    11511
> unix  2      [ ]         DGRAM                    10990
> [r...@13gems beno]#
>
> How do I trouble-shoot this?

Try connecting to the port that is supposed to accept mail messages
via telnet and issue a few SMTP commands.

-- 
Jonathan Gardner
jgard...@jonathangardner.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this secure?

2010-02-23 Thread Robert Kern

On 2010-02-23 13:59 PM, mk wrote:

On Feb 23, 7:19 pm, Paul Rubin  wrote:


The code is pretty ugly.  The main problem is you end up with a password
that's usually 5 letters but sometimes just 4 or fewer.


Well I didn't write the whole thing here, in actual use I'd write a
loop repeating the function until I have enough characters and then
I'd select a substring of specified length.

Anything else in the code that is ugly and I should correct?


I would recommend using random.SystemRandom.choice() on a sequence of acceptable 
characters. E.g. (untested)


import random
import string


characters = string.letters + string.digits + '~...@#$%^&*()-+=,;./\?><|'
# ... or whatever.

def gen_rand_string(length):
prng = random.SystemRandom()
chars = []
for i in range(length):
chars.append(prng.choice(characters))
return ''.join(chars)

--
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: What's Going on between Python and win7?

2010-02-23 Thread Michel Claveau - MVP
Hi!

> Symbolic links are available in NTFS starting with Windows Vista.

No.
Hardlink come with NTFS, and already exists in W2K (and NT with specifics 
utilities).

@-salutations
-- 
Michel Claveau 

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


Re: Signature-based Function Overloading in Python

2010-02-23 Thread Arnaud Delobelle
Michael Rudolf  writes:

> Just a quick question about what would be the most pythonic approach
> in this.
>
> In Java, Method Overloading is my best friend, but this won't work in
> Python:
>
 def a():
>   pass
 def a(x):
>   pass
 a()
> Traceback (most recent call last):
>   File "", line 1, in 
> a()
> TypeError: a() takes exactly 1 argument (0 given)
>
> So - What would be the most pythonic way to emulate this?
> Is there any better Idom than:
>
 def a(x=None):
>   if x is None:
>   pass
>   else:
>   pass
>

There are a number of frameworks for function overloading out there.  FWIW,
there is actually one in the Python sandbox (for Python 3):

http://svn.python.org/view/sandbox/trunk/Overload3K/

-- 
Arnaud

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


Re: python dowload

2010-02-23 Thread Shashwat Anand
PyPdf/pdfminer library will be of help

On Wed, Feb 24, 2010 at 1:47 AM, Tim Chase wrote:

> monkeys paw wrote:
>
>> I used the following code to download a PDF file, but the
>> file was invalid after running the code, is there problem
>> with the write operation?
>>
>> import urllib2
>> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
>> a = open('adobe.pdf', 'w')
>>
>
> Sure you don't need this to be 'wb' instead of 'w'?
>
>
>  for line in urllib2.urlopen(url):
>> a.write(line)
>>
>
> I also don't know if this "for line...a.write(line)" loop is doing newline
> translation.  If it's a binary file, you should use .read() (perhaps with a
> modest-sized block-size, writing it in a loop if the file can end up being
> large.)
>
> -tkc
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python dowload

2010-02-23 Thread sstein...@gmail.com

On Feb 23, 2010, at 2:42 PM, monkeys paw wrote:

> I used the following code to download a PDF file, but the
> file was invalid after running the code, is there problem
> with the write operation?
> 
> import urllib2
> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
> a = open('adobe.pdf', 'w')

Try 'wb', just in case.

S



> for line in urllib2.urlopen(url):
>a.write(line)
> -- 
> http://mail.python.org/mailman/listinfo/python-list

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


Re: python dowload

2010-02-23 Thread David Robinow
On Tue, Feb 23, 2010 at 2:42 PM, monkeys paw  wrote:
> I used the following code to download a PDF file, but the
> file was invalid after running the code, is there problem
> with the write operation?
>
> import urllib2
> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
> a = open('adobe.pdf', 'w')
> for line in urllib2.urlopen(url):
>    a.write(line)

If you're running Windows, try
  a = open('adobe.pdf', 'wb')

[Works for me]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: formatting a number as percentage

2010-02-23 Thread Günther Dietrich
Hans Mulder  wrote:

>> Did you try this:
>> 
> print('%d%%' % (0.7 * 100))
>> 70%
>
>That method will always round down; TomF's method will round to
>the nearest whole number:
>
> >>> print "%d%%" % (0.698 * 100)
>69%
> >>> print "{0:.0%}".format(.698)
>70%

It was intended as a hint to this way of formatting. He could also try:

>>> print('%.0f%%' % (0.698 * 100))
70%



Best regards,

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


Re: python dowload

2010-02-23 Thread Jerry Hill
On Tue, Feb 23, 2010 at 2:42 PM, monkeys paw  wrote:
> I used the following code to download a PDF file, but the
> file was invalid after running the code, is there problem
> with the write operation?
>
> import urllib2
> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
> a = open('adobe.pdf', 'w')
> for line in urllib2.urlopen(url):
>    a.write(line)

Two guesses:

First, you need to call a.close() when you're done writing to the file.

This will happen automatically when you have no more references to the
file, but I'm guessing that you're running this code in IDLE or some
other IDE, and a is still a valid reference to the file after you run
that snippet.

Second, you're treating the pdf file as text (you're assuming it has
lines, you're not writing the file in binary mode, etc.).  I don't
know if that's correct for a pdf file.  I would do something like this
instead:

Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit
(Intel)] on win32
IDLE 2.6.4

>>> import urllib2
>>> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
>>> a = open('C:/test.pdf', 'wb')
>>> data = urllib2.urlopen(url).read()
>>> a.write(data)
>>> a.close()

That seems to works for me, in that it downloads a 16 page pdf
document, and that document opens without error or any other obvious
problems.

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


Re: python dowload

2010-02-23 Thread Tim Chase

monkeys paw wrote:

I used the following code to download a PDF file, but the
file was invalid after running the code, is there problem
with the write operation?

import urllib2
url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
a = open('adobe.pdf', 'w')


Sure you don't need this to be 'wb' instead of 'w'?


for line in urllib2.urlopen(url):
 a.write(line)


I also don't know if this "for line...a.write(line)" loop is 
doing newline translation.  If it's a binary file, you should use 
.read() (perhaps with a modest-sized block-size, writing it in a 
loop if the file can end up being large.)


-tkc


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


Re: Fascism is coming to Internet

2010-02-23 Thread D'Arcy J.M. Cain
On Tue, 23 Feb 2010 20:30:03 +0100
Olof Bjarnason  wrote:
> Even if this is "Off Topic" (which I think it really isn't in any open
> source / free software-oriented mailing list), I want to agree with
> Joan.

It isn't about the Python programming language so it is off topic.  So
what if some members have an interest?  We have interest in a lot of
things.  We all have interest in the hardware that our programs run on
but questions about hardware are also off topic.

Perhaps you don't quite grasp the point of topical discussion groups.
They are a way of letting individuals decide for themselves what kind
of discussions they want to be involved in.  By spamming the group this
way you take away that freedom of choice.  It's ironic when it is done
in the name of freedom.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python dowload

2010-02-23 Thread John Bokma
monkeys paw  writes:

> I used the following code to download a PDF file, but the
> file was invalid after running the code, is there problem
> with the write operation?
>
> import urllib2
> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
> a = open('adobe.pdf', 'w')
> for line in urllib2.urlopen(url):
> a.write(line)

pdf is /not/ text. You're processing it like it's a text file (and
storing it like it's text, which on Windows is most likely a no no).

import urllib2

url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
response = urllib2.urlopen(url)
fh = open('adobe.pdf', 'wb')
fh.write(response.read())
fh.close()
response.close()

-- 
John Bokma   j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this secure?

2010-02-23 Thread Robert Kern

On 2010-02-23 13:19 PM, Paul Rubin wrote:


I find it's most practical to use a few random words (chosen from a word
list like /usr/dict/words) rather than random letters.  Words are easier
to remember and type.

You might look at the site www.diceware.com for an approach to this,
which you can implement with a program.  The docs there are pretty
thoughtful and may help you understand the relevant issues.


I like RFC 1751 for this:

http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.x.git;a=blob;f=lib/Crypto/Util/RFC1751.py;h=1c98a212c22066adabfee521b495eeb4f9d7232b;hb=HEAD

Shortened URL:

http://tr.im/Pv9B

--
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: Is this secure?

2010-02-23 Thread mk
On Feb 23, 7:19 pm, Paul Rubin  wrote:

> The code is pretty ugly.  The main problem is you end up with a password
> that's usually 5 letters but sometimes just 4 or fewer.  

Well I didn't write the whole thing here, in actual use I'd write a
loop repeating the function until I have enough characters and then
I'd select a substring of specified length.

Anything else in the code that is ugly and I should correct?

> You might look at the sitewww.diceware.comfor an approach to this,
> which you can implement with a program.  The docs there are pretty
> thoughtful and may help you understand the relevant issues.

Thanks. But I would also be grateful for indicating what is wrong/ugly
in my code.

Regards,
mk


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


python dowload

2010-02-23 Thread monkeys paw

I used the following code to download a PDF file, but the
file was invalid after running the code, is there problem
with the write operation?

import urllib2
url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
a = open('adobe.pdf', 'w')
for line in urllib2.urlopen(url):
a.write(line)
--
http://mail.python.org/mailman/listinfo/python-list


Re: formatting a number as percentage

2010-02-23 Thread vsoler
On Feb 22, 8:32 pm, Hans Mulder  wrote:
> Günther Dietrich wrote:
> > vsoler  wrote:
>
> >> I'm trying to print .7 as 70%
> >> I've tried:
>
> >> print format(.7,'%%')
> >> .7.format('%%')
>
> >> but neither works. I don't know what the syntax is...
>
> > Did you try this:
>
>  print('%d%%' % (0.7 * 100))
> > 70%
>
> That method will always round down; TomF's method will round to
> the nearest whole number:
>
>  >>> print "%d%%" % (0.698 * 100)
> 69%
>  >>> print "{0:.0%}".format(.698)
> 70%
>
> Only the OP knows which one is more appropriate for his use case.
>
> Hope this helps,
>
> -- HansM

Great!!!

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


Re: Is this secure?

2010-02-23 Thread Paul Rubin
mk  writes:
> I need to generate passwords and I think that pseudo-random generator
> is not good enough, frankly. So I wrote this function:...
> The question is: is this secure? That is, can the string generated
> this way be considered truly random? (I abstract from
> not-quite-perfect nature of /dev/urandom at the moment; I can always
> switch to /dev/random which is better)

urandom is fine and the entropy loss from the numeric conversions and
eliminating 'z' in that code before you get letters out is not too bad.
The code is pretty ugly.  The main problem is you end up with a password
that's usually 5 letters but sometimes just 4 or fewer.  Passwords that
short are vulnerable to dictionary attacks.  Longer passwords made from
random letters are difficult to remember.

I find it's most practical to use a few random words (chosen from a word
list like /usr/dict/words) rather than random letters.  Words are easier
to remember and type.

You might look at the site www.diceware.com for an approach to this,
which you can implement with a program.  The docs there are pretty
thoughtful and may help you understand the relevant issues.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fascism is coming to Internet

2010-02-23 Thread Olof Bjarnason
2010/2/23 Joan Miller :
> On 23 feb, 10:54, Joan Miller  wrote:
>> *Sorry by this message off topic, but this is too important*
>>
>> Fascism is coming fastly to Internet because is the only communication
>> way that governements (managed by the bank and multinationals) cann't
>> control
>>
>> http://www.boingboing.net/2010/02/21/acta-internet-enforc.html
>
> This is something that affects to all programmers:
>
> "This calls on all parties to ensure that "third party liability" (the
> idea that ISPs, web-hosts, application developers, mobile carriers,
> universities, apartment buildings, and other "third parties" to
> infringement are sometimes liable for their users' copyright
> infringements) is on the books in their countries. It doesn't spell
> out what that liability should be, beyond "knowingly and materially
> aiding" an infringement"
>
> http://craphound.com/acta_digital_chapter-1.pdf
> --
> http://mail.python.org/mailman/listinfo/python-list
>



Even if this is "Off Topic" (which I think it really isn't in any open
source / free software-oriented mailing list), I want to agree with
Joan.

ACTA is a *real* problem that we must fend politically. Here is a blog
post I wrote about the problem with making ISPs liable for what their
users communicate:

http://translate.google.com/translate?js=y&prev=_t&hl=en&ie=UTF-8&layout=1&eotf=1&u=http%3A%2F%2Folofb.wordpress.com%2F&sl=sv&tl=en
(sorry for the bad quality google translation -- this is an important topic!)

Note the name of the important principle: "Mere conduit".



-- 
http://olofb.wordpress.com
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python won't run

2010-02-23 Thread Nardin, Cory L.
Thanks so much for that suggestion.  I used the tool and found two
missing libraries: MSVCR90.DLL and DWMAPI.DLL.  I located and copied the
first library to my python directory (and resolved that dependency), but
I am still missing the other.  I have done a Google search and found
that DWMAPI is a Vista library.  I am have XP, so I am not sure why it
is a required dependency?  I made sure that I have all the MS updates
(presumably MS would include a new library in an update if it became a
required library) and that did not solve the problem.  Is this a bug or
should I have that library on my computer and the fact that it isn't
there is the sign of some other problem?

 

Thanks

Cory

 



From: Sridhar Ratnakumar [mailto:sridh...@activestate.com] 
Sent: Monday, February 22, 2010 11:54 AM
To: Nardin, Cory L.
Cc: python-list@python.org
Subject: Re: Python won't run

 

Have you tried using   
http://dependencywalker.com/ ?

 

-srid

 

On 2010-02-18, at 1:00 PM, Nardin, Cory L. wrote:





Quickly, I have a Mac Intel with Windows XP installed.  Tried installing
Python 2.6.4 from the binary and also ActivePython 2.6.4.10.  Both
installations acted the same.  There seemed to be no problems during
installation (used default options), but when I try to run Python I get
an error message: "This application has failed to start because the
application configuration is incorrect.  Reinstalling the application
may fix this problem."

 

Of course I searched on that error and it seems to be related to a MS
library.  In a few different places it was recommended to install the MS
Visual Studio redistributable package, which I did with no change in
outcome.  I really have no idea what to do.

 

Any help is appreciated.

 

Thanks,

Cory

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

 

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


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Gib Bogle

W. eWatson wrote:

On 2/23/2010 8:26 AM, Rick Dooling wrote:

No telling what Windows will do. :)

I am a mere hobbyist programmer, but I think real programmers will
tell you that it is a bad habit to use relative paths. Use absolute
paths instead and remove all doubt.

http://docs.python.org/library/os.path.html

RD
You may be right. The actual 300 line program just reads the folder 
without specifying any path. I'm not that familiar with os path, but 
have seen it used.


How do you invoke the program?  Do you use a Command Prompt window?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-23 Thread Timothy N. Tsvetkov
On Feb 16, 10:41 pm, Andrej Mitrovic 
wrote:
> On Feb 16, 7:38 pm, Casey Hawthorne 
> wrote:
>
> > Interesting talk on Python vs. Ruby and how he would like Python to
> > have just a bit more syntactic flexibility.
>
> >http://blog.extracheese.org/2010/02/python-vs-ruby-a-battle-to-the-de...
> > --
> > Regards,
> > Casey
>
> Gary's friend Geoffrey Grosenbach says in his blog post (which Gary
> linked to): "Python has no comparable equivalent to Ruby’s do end
> block. Python lambdas are limited to one line and can’t contain
> statements (for, if, def, etc.). Which leaves me wondering, what’s the
> point?"
>
> I'm sorry, lambda's do support if's and for's. Also, lambda's are
> expressions, not statements, but you can pass them around, keep them
> in a dictionary if you want to. And if you need more than one line of
> statements, for crying out loud use a def? And who needs those "do-
> end" blocks anyway, trying to turn Python into Pascal?

I think there are some nice use-cases for anonymous functions /
blocks. First, mentioned above, is pretty DSL. And the second is using
blocks in map/reduce functions. Yes, you can pass there a function but
I believe that in most situations it is more readable to pass a
multiline anonymous function / block than defined somewhere function
written only for a single map/reduce operation. And often when you use
reduce it is a bit more complicated then just one line function.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Gib Bogle

Rick Dooling wrote:

No telling what Windows will do. :)


It isn't useful to respond to a serious question with OS bigotry.
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >