Re: Is this secure?

2010-02-24 Thread Paul Rubin
Steven D'Aprano writes: > 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 tw

Re: MODULE FOR I, P FRAME

2010-02-24 Thread DANNY
On Feb 24, 3:11 am, "Rhodri James" wrote: > 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 pre

Why tarfile.TarFile.gzopen is not in the online documentation?

2010-02-24 Thread Baptiste Lepilleur
I stumbled uppon this and find it somewhat odd: some class methods of TarFile and TarInfo do not appears in either the online documentation or search while they have a doc string: http://docs.python.org/search.html?q=gzopen http://docs.python.org/library/tarfile.html?highlight=tarfile#tarfile.TarF

Re: Use eval() safely?

2010-02-24 Thread Dieter Maurer
Steven D'Aprano writes on 22 Feb 2010 06:07:05 GMT: > ... > It's *especially* not safe if you put nothing in the globals dict, > because Python kindly rectifies that by putting the builtins into it: > > >>> eval("__builtins__.keys()", {}, {}) > ['IndexError', 'all', 'help', 'vars', ... 'Overflo

Re: Pure virtual functions in Python?

2010-02-24 Thread Jean-Michel Pichavant
Arnaud Delobelle wrote: lallous writes: Hello How can I do something similar to pure virtual functions in C++ ? Let us consider this: class C1: # Pure virtual def cb(self, param1, param2): """ This is a callback @param param1: ... @param param2:

while loop with the condition used in the body

2010-02-24 Thread Ulrich Eckhardt
Hi! I'm looking for a way to write code similar to this C code: while(rq = get_request(..)) { handle_request(rq); } Currently I'm doing while True: rq = get_request(...) if not rq: break handle_request(rq) in Python 2.6. Any suggestions how to rewrite tha

Re: while loop with the condition used in the body

2010-02-24 Thread Arnaud Delobelle
Ulrich Eckhardt wrote: > Hi! > > I'm looking for a way to write code similar to this C code: > > while(rq = get_request(..)) { > handle_request(rq); > } > > Currently I'm doing > > while True: > rq = get_request(...) > if not rq: > break > handle_request(rq)

Re: while loop with the condition used in the body

2010-02-24 Thread Peter Otten
Ulrich Eckhardt wrote: > I'm looking for a way to write code similar to this C code: > > while(rq = get_request(..)) { > handle_request(rq); > } > > Currently I'm doing > > while True: > rq = get_request(...) > if not rq: > break > handle_request(rq) > >

Re: Signature-based Function Overloading in Python

2010-02-24 Thread Jean-Michel Pichavant
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: >>> def a(): pass >>> def a(x): pass >>> a() Traceback (most recent call last): File "", line 1, in

Re: Why tarfile.TarFile.gzopen is not in the online documentation?

2010-02-24 Thread Lars Gustäbel
On Wed, Feb 24, 2010 at 09:37:19AM +0100, Baptiste Lepilleur wrote: > I stumbled uppon this and find it somewhat odd: some class methods of > TarFile and TarInfo do not appears in either the online documentation or > search while they have a doc string: > > http://docs.python.org/search.html?q=gzo

Re: while loop with the condition used in the body

2010-02-24 Thread Duncan Booth
Peter Otten <__pete...@web.de> wrote: > Ulrich Eckhardt wrote: > >> I'm looking for a way to write code similar to this C code: >> >> while(rq = get_request(..)) { >> handle_request(rq); >> } >> > Assuming get_request(...) is called with the same arguments on each > iteration and uses

Re: while loop with the condition used in the body

2010-02-24 Thread Peter Otten
Duncan Booth wrote: > Peter Otten <__pete...@web.de> wrote: > >> Ulrich Eckhardt wrote: >> >>> I'm looking for a way to write code similar to this C code: >>> >>> while(rq = get_request(..)) { >>> handle_request(rq); >>> } >>> >> Assuming get_request(...) is called with the same argum

Re: Creating variables from dicts

2010-02-24 Thread Luis M . González
On Feb 24, 4:08 am, Steven D'Aprano wrote: > 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, 2

Re: Creating variables from dicts

2010-02-24 Thread Luis M . González
On Feb 24, 7:44 am, Luis M. González wrote: > On Feb 24, 4:08 am, Steven D'Aprano > > > > > > wrote: > > 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: > > >> >

"selma blair" "salma hayek" "salma hayek hot" "salma hayek wallpapers" "hollywood sexiest scenes" "hollywood blue films" "hollywood movies free download" on http://sexyandpretty-girls.blogspot.com/

2010-02-24 Thread Naeem
"selma blair" "salma hayek" "salma hayek hot" "salma hayek wallpapers" "hollywood sexiest scenes" "hollywood blue films" "hollywood movies free download" on http://sexyandpretty-girls.blogspot.com/ "selma blair" "salma hayek" "salma hayek hot" "salma hayek wallpapers" "hollywood sexiest scenes" "ho

Re: Creating variables from dicts

2010-02-24 Thread Bruno Desthuilliers
Luis M. González a écrit : (snip) Alright, this is what the docs say about locals: "Note The built-in functions globals() and locals() return the current global and local dictionary, respectively, which may be useful to pass around for use as the second and third argument to exec(). Note The def

scope of generators, class variables, resulting in global na

2010-02-24 Thread Nomen Nescio
Hello, Can someone help me understand what is wrong with this example? class T: A = range(2) B = range(4) s = sum(i*j for i in A for j in B) It produces the exception: : global name 'j' is not defined The exception above is especially confusing since the following similar example (I jus

WANTED: Regular expressions for breaking TeX/LaTeX document into tokens

2010-02-24 Thread Jonathan Fine
Hi Does anyone know of a collection of regular expressions that will break a TeX/LaTeX document into tokens? Assume that there is no verbatim or other category code changes. Thanks Jonathan -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating variables from dicts

2010-02-24 Thread Bruno Desthuilliers
Luis M. González a écrit : 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 structur

Re: Signature-based Function Overloading in Python

2010-02-24 Thread Michael Rudolf
First: Thanks for all the replies so far, they really helped me. Am 24.02.2010 11:28, schrieb Jean-Michel Pichavant: >>> def a(x=None): if x is None: pass else: pass This is the way to do it python, and it has its advantages: 1 docstring, 1 way do do it, 1 interface.

Re: while loop with the condition used in the body

2010-02-24 Thread Ulrich Eckhardt
Peter Otten wrote: > Duncan Booth wrote: >> for rq in incoming_requests(...): >>handle_request(rq) > > ...and a likely implementation would be > > def incoming_requests(...): > while True: > rq = ... # inlined version of get_request() > if not rq: > break >

Re: Creating variables from dicts

2010-02-24 Thread Bruno Desthuilliers
Luis M. González a écrit : 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 "lo

Re: Fascism is coming to Internet

2010-02-24 Thread Joan Miller
On 23 feb, 20:16, "D'Arcy J.M. Cain" wrote: > 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 pro

Re: scope of generators, class variables, resulting in global na

2010-02-24 Thread Alf P. Steinbach
* Nomen Nescio: Hello, Can someone help me understand what is wrong with this example? class T: A = range(2) B = range(4) s = sum(i*j for i in A for j in B) It produces the exception: : global name 'j' is not defined Which Python implementation are you using? I can't reproduce the er

Artificial Neural Networks recommendation

2010-02-24 Thread Gereon Kaiping
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I'd like to use ANNs in python, especially Simple Recurrent Networks. Ideally I'd like to find a quick, pythonic module that is able to simulate different styles of network architectures including some types of recurrent networks (must: SRN/Elman

Re: Artificial Neural Networks recommendation

2010-02-24 Thread Paul Rudin
Gereon Kaiping writes: > Are there other modules for simulating ANNs? Fann has python bindings. -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating variables from dicts

2010-02-24 Thread Luis M . González
On Feb 24, 8:48 am, Bruno Desthuilliers wrote: > Luis M. Gonz lez a crit : > (snip) > > > Alright, this is what the docs say about locals: > > "Note > > The built-in functions globals() and locals() return the current > > global and local dictionary, respectively, which may be useful to pass > > a

Re: When will Python go mainstream like Java?

2010-02-24 Thread Steve Holden
At 12.34 pm on November 13, 2011 regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/ Holden Web LLC http://www.holdenweb.com/ UPCOMING EVENTS:http://holdenweb.eventbrite.com/ -- http://mail.p

Re: ANN: Leo 4.7 final released

2010-02-24 Thread Edward K Ream
On Tue, 23 Feb 2010 07:53:44 -0600, Edward K Ream wrote: A critical bug has been reported against Leo 4.7 final, and indeed all previous versions of Leo 4.7. The bug can cause loss of data in @file nodes when Leo 4.7 saves .leo files created with older versions of Leo. This bug will be fixed i

Re: When will Python go mainstream like Java?

2010-02-24 Thread Steve Holden
Stefan Behnel wrote: > 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 wit

Re: How to make an empty generator?

2010-02-24 Thread Steve Holden
John Posner wrote: > On 2/19/2010 2:25 PM, Terry Reedy wrote: >> On 2/19/2010 12:44 PM, Stephen Hansen wrote: >> >>> Much to my embarrassment, sometime last night I realized I was being a >>> complete idiot, and the 'correct' way to handle this in my scenario is >>> really just: >>> >>> def initial

Can't Connect To SMTP

2010-02-24 Thread Victor Subervi
Hi; I'm getting this 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. /var/www/html/globalsolutionsgroup.vi/simplemail/mail2.py 52 53 ''' 54 my_mail() 55 print ''' 56 my_mail = /var/www/ht

Re: Creating variables from dicts

2010-02-24 Thread Bruno Desthuilliers
Luis M. González a écrit : On Feb 24, 8:48 am, Bruno Desthuilliers wrote: Luis M. Gonz lez a crit : And what about the trick of updating globals? Is it legal? It's legal, but it's (usually) a very bad idea - at the top-level, it harms readability, and from within a function it's doubly ba

Re: How to make an empty generator?

2010-02-24 Thread John Posner
On 2/24/2010 9:07 AM, Steve Holden wrote: John Posner wrote: Note that the Py2.6.4 documentation is inconsistent. AFAICT, it conforms to Terry's definitions above in most places. But the Glossary says: generator A function which returns an iterator.<... more ...> generator expressio

Re: scope of generators, class variables, resulting in global na

2010-02-24 Thread b3ng0
On Feb 24, 5:52 am, Nomen Nescio wrote: > Hello, > > Can someone help me understand what is wrong with this example? > > class T: >   A = range(2) >   B = range(4) >   s = sum(i*j for i in A for j in B) > > It produces the exception: > > : global name 'j' is not defined > > The exception above is

Re: scope of generators, class variables, resulting in global na

2010-02-24 Thread Jon Clements
On Feb 24, 12:21 pm, "Alf P. Steinbach" wrote: > * Nomen Nescio: > > > Hello, > > > Can someone help me understand what is wrong with this example? > > > class T: > >   A = range(2) > >   B = range(4) > >   s = sum(i*j for i in A for j in B) > > > It produces the exception: > > > : global name 'j'

Re: Spam from gmail (Was: fascism)

2010-02-24 Thread Robert Kern
On 2010-02-23 22:09 PM, Grant Edwards wrote: 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, bin

Re: When will Python go mainstream like Java?

2010-02-24 Thread Peter Parker
Steve Holden wrote: At 12.34 pm on November 13, 2011 At December 21, 2012 at 11:11 am (according to the Maya calendar) -- http://mail.python.org/mailman/listinfo/python-list

Re: scope of generators, class variables, resulting in global na

2010-02-24 Thread Arnaud Delobelle
Nomen Nescio wrote: > Hello, > > Can someone help me understand what is wrong with this example? > > class T: > A = range(2) > B = range(4) > s = sum(i*j for i in A for j in B) > > It produces the exception: > > : global name 'j' is not defined It's due to scoping rules for classes and/or

Re: When will Python go mainstream like Java?

2010-02-24 Thread Martin P. Hellwig
On 02/24/10 16:05, Peter Parker wrote: Steve Holden wrote: At 12.34 pm on November 13, 2011 At December 21, 2012 at 11:11 am (according to the Maya calendar) On August 29, 1997, Java became mainstream. In a panic, Microsoft tried to embrace, extend and exterminate the system, prompting Sun

parametrizing a sqlite query

2010-02-24 Thread Sebastian Bassi
c.execute("SELECT bin FROM bins WHERE qtl LIKE '%:keys%'",{'keys':keywords}) This query returns empty. When it is executed, keywords = 'harvest'. To check it, I do it on the command line and it works as expected: sqlite> SELECT bin FROM bins WHERE qtl LIKE '%harvest%'; 11C 11D 12F I guess there

Re: SMTPServerDisconnected

2010-02-24 Thread Victor Subervi
On Tue, Feb 23, 2010 at 4:53 PM, Jonathan Gardner < jgard...@jonathangardner.net> wrote: > 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 o

Re: SMTPServerDisconnected

2010-02-24 Thread Victor Subervi
On Tue, Feb 23, 2010 at 4:53 PM, Jonathan Gardner < jgard...@jonathangardner.net> wrote: > 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 o

Re: How to make an empty generator?

2010-02-24 Thread John Posner
generator An iterator produced by a generator function or a generator expression. -John +1. Can someone submit a documentation patch, please? Will do. -John [sorry if this is a dup] Done: #8012 "Revise generator-related Glossary entries" -John -- http://mail.python.org/mailman/listinfo/

Re: Is this secure?

2010-02-24 Thread mk
On 2010-02-24 03:50, Paul Rubin wrote: 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. Yikes! I

Re: parametrizing a sqlite query

2010-02-24 Thread Jon Clements
On Feb 24, 5:07 pm, Sebastian Bassi wrote: > c.execute("SELECT bin FROM bins WHERE qtl LIKE '%:keys%'",{'keys':keywords}) > > This query returns empty. When it is executed, keywords = 'harvest'. > To check it, I do it on the command line and it works as expected: > > sqlite> SELECT bin FROM bins W

Re: parametrizing a sqlite query

2010-02-24 Thread Jon Clements
On Feb 24, 5:21 pm, Jon Clements wrote: > On Feb 24, 5:07 pm, Sebastian Bassi wrote: > > > c.execute("SELECT bin FROM bins WHERE qtl LIKE '%:keys%'",{'keys':keywords}) > > > This query returns empty. When it is executed, keywords = 'harvest'. > > To check it, I do it on the command line and it wo

Re: When will Python go mainstream like Java?

2010-02-24 Thread mk
On 2010-02-24 03:26, George Sakkis 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

Re: How to measure elapsed time under Windows?

2010-02-24 Thread Gabriel Genellina
En Sat, 13 Feb 2010 17:29:45 -0300, Tim Roberts escribió: "Gabriel Genellina" wrote: The original problem was with the RDTSC instruction on multicore CPUs; different cores may yield different results because they're not synchronized at all times. Not true. The synchronization issue has two

Re: Intra-package C extensions with freeze.py

2010-02-24 Thread mk
On 2010-01-13 20:52, Pascal Chambon wrote: I've managed to solve that by manually "monkey patching" sys.modules, before fusemodule's actual import. But this looks like an unsatisfying solution, to me. Geez.. Does anyone have a clue about how to freeze a python program cleanly, in case such i

Re: WANTED: Regular expressions for breaking TeX/LaTeX document into tokens

2010-02-24 Thread Wes James
On Wed, Feb 24, 2010 at 5:03 AM, Jonathan Fine wrote: > Hi > > Does anyone know of a collection of regular expressions that will break a > TeX/LaTeX document into tokens?  Assume that there is no verbatim or other > category code changes. I'm not sure how this does it, but it might help: http://

Re: A tool for find dependencies relationships behind Python projects

2010-02-24 Thread Victor Lin
On 2月23日, 上午12時32分, Hellmut Weber wrote: > Hi Victor, > I would be intereseted to use your tool ;-) > > My system is Sabayon-5.1 on Lenovo T61. > Trying for the first time easy_install I get the following error: > > > > r...@sylvester ~ # easy_install gluttony > Searching for

Re: Is this secure?

2010-02-24 Thread Steve Holden
mk wrote: > On 2010-02-24 03:50, Paul Rubin wrote: >> 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 high

Re: Is this secure?

2010-02-24 Thread Michael Rudolf
Am 24.02.2010 18:23, schrieb mk: Even then I'm not getting completely uniform distribution for some reason: d 39411 l 39376 f 39288 a 39275 s 39225 r 39172 p 39159 t 39073 k 39071 u 39064 e 39005 o 39005 n 38995 j 38993 h 38975 q 38958 c 38938 b 38906 g 38894 i 38847 m 38819 v 38712 z 35321 y 352

Noob raw_input question

2010-02-24 Thread Abigail
Yesterday I downloaded and installed Python 3.1 and working through some examples but I have hit a problem >>> a = raw_input("Enter a number" ) Traceback (most recent call last): File "", line 1, in a = raw_input("Enter a number" ) NameError: name 'raw_input' is not defined>>>a = raw_input

Re: Is this secure?

2010-02-24 Thread mk
On 2010-02-24 18:59, Steve Holden wrote: Aw shucks when will I learn to do the stuff in 3 lines well instead of 20, poorly. :-/ When you've got as much experience as Paul? And how much experience does Paul have? (this is mostly not a facile question) For my part, my more serious effort (o

Re: parametrizing a sqlite query

2010-02-24 Thread Diez B. Roggisch
Am 24.02.10 18:07, schrieb Sebastian Bassi: c.execute("SELECT bin FROM bins WHERE qtl LIKE '%:keys%'",{'keys':keywords}) This query returns empty. When it is executed, keywords = 'harvest'. To check it, I do it on the command line and it works as expected: sqlite> SELECT bin FROM bins WHERE qt

Re: Noob raw_input question

2010-02-24 Thread Chris Rebert
On Wed, Feb 24, 2010 at 9:39 AM, Abigail wrote: > Yesterday I downloaded and installed Python 3.1 and working through some > examples but I have hit a problem > a = raw_input("Enter a number" ) > Traceback (most recent call last): >  File "", line 1, in >    a = raw_input("Enter a number" )

What's the word on using """ to comment-out?

2010-02-24 Thread kj
I think I remember, early in my learning of Python, coming across the commandment "THOU SHALT NOT USE TRIPLE-QUOTES TO COMMENT-OUT LINES OF CODE", or something to that effect. But now I can't find it! Is my memory playing me a trick? After all, from what I've seen since then, the practice of

Re: Noob raw_input question

2010-02-24 Thread Robert Kern
On 2010-02-24 11:39 AM, Abigail wrote: Yesterday I downloaded and installed Python 3.1 and working through some examples but I have hit a problem a = raw_input("Enter a number" ) Traceback (most recent call last): File "", line 1, in a = raw_input("Enter a number" ) NameError: name 'ra

Re: Noob raw_input question

2010-02-24 Thread John Posner
On 2/24/2010 12:39 PM, Abigail wrote: Yesterday I downloaded and installed Python 3.1 and working through some examples but I have hit a problem a = raw_input("Enter a number" ) Traceback (most recent call last): File "", line 1, in a = raw_input("Enter a number" ) NameError: name 'raw

Re: Noob raw_input question

2010-02-24 Thread Steve Holden
Abigail wrote: > Yesterday I downloaded and installed Python 3.1 and working through some > examples but I have hit a problem > a = raw_input("Enter a number" ) > Traceback (most recent call last): > File "", line 1, in > a = raw_input("Enter a number" ) > NameError: name 'raw_input'

Re: Noob raw_input question

2010-02-24 Thread Abigail
Thank You -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this secure?

2010-02-24 Thread mk
On 2010-02-24 18:56, Michael Rudolf wrote: The reason is 256 % 26 != 0 256 mod 26 equals 22, thus your code is hitting a-v about 10% (256/26 is approx. 10) more often than w-z. writing secure code is hard... I'm going to switch to PHP: Python world wouldn't lose much, but PHP would gain a lo

Re: Is this secure?

2010-02-24 Thread Robert Kern
On 2010-02-24 12:35 PM, mk wrote: While with this: def gen_rand_word(n): with open('/dev/urandom') as f: return ''.join([chr(ord('a') + ord(x) % 26) for x in f.read(n) if ord(x) < 235]) a 3852 ... 1. I'm systematically getting 'a' outlier: have no idea why for now. 2. This is somewhat bett

Re: What's the word on using """ to comment-out?

2010-02-24 Thread rantingrick
On Feb 24, 12:18 pm, kj wrote: > I think I remember, early in my learning of Python, coming across > the commandment "THOU SHALT NOT USE TRIPLE-QUOTES TO COMMENT-OUT > LINES OF CODE", or something to that effect.  But now I can't find > it! Your going to get many opinions on this subject but my s

Re: Is this secure?

2010-02-24 Thread mk
On 2010-02-24 20:01, Robert Kern wrote: I will repeat my advice to just use random.SystemRandom.choice() instead of trying to interpret the bytes from /dev/urandom directly. Oh I hear you -- for production use I would (will) certainly consider this. However, now I'm interested in the problem i

Re: What's the word on using """ to comment-out?

2010-02-24 Thread mk
Get a decent editor, like PyScripter, and press Ctrl-' (toggle comment). Regards, mk -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this secure?

2010-02-24 Thread mk
On 2010-02-24 20:01, Robert Kern wrote: I will repeat my advice to just use random.SystemRandom.choice() instead of trying to interpret the bytes from /dev/urandom directly. Out of curiosity: def gen_rand_string(length): prng = random.SystemRandom() chars = [] for i in range(length

Re: Is this secure?

2010-02-24 Thread Robert Kern
On 2010-02-24 13:09 PM, mk wrote: On 2010-02-24 20:01, Robert Kern wrote: I will repeat my advice to just use random.SystemRandom.choice() instead of trying to interpret the bytes from /dev/urandom directly. Oh I hear you -- for production use I would (will) certainly consider this. However, n

Re: Is this secure?

2010-02-24 Thread Paul Rubin
Robert Kern writes: > I will repeat my advice to just use random.SystemRandom.choice() > instead of trying to interpret the bytes from /dev/urandom directly. SystemRandom is something pretty new so I wasn't aware of it. But yeah, if I were thinking more clearly I would have suggested os.urandom

Re: Spam from gmail

2010-02-24 Thread Aahz
In article <87sk8r5v2f@benfinney.id.au>, Ben Finney wrote: >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 foru

Re: What's the word on using """ to comment-out?

2010-02-24 Thread Aahz
In article , kj wrote: > >I think I remember, early in my learning of Python, coming across the >commandment "THOU SHALT NOT USE TRIPLE-QUOTES TO COMMENT-OUT LINES OF >CODE", or something to that effect. But now I can't find it! > >Is my memory playing me a trick? Possibly. I certainly do that

Re: Is this secure?

2010-02-24 Thread Robert Kern
On 2010-02-24 13:16 PM, mk wrote: On 2010-02-24 20:01, Robert Kern wrote: I will repeat my advice to just use random.SystemRandom.choice() instead of trying to interpret the bytes from /dev/urandom directly. Out of curiosity: def gen_rand_string(length): prng = random.SystemRandom() chars = [

Re: Is this secure?

2010-02-24 Thread Paul Rubin
mk writes: > So I have little in the way of limitations of password length ...> > The main application will access the data using HTTP (probably), so > the main point is that an attacker is not able to guess passwords > using brute force. If it's HTTP instead of HTTPS and you're sending the passw

Re: Is this secure?

2010-02-24 Thread Michael Rudolf
Am 24.02.2010 19:35, schrieb mk: On 2010-02-24 18:56, Michael Rudolf wrote: The reason is 256 % 26 != 0 256 mod 26 equals 22, thus your code is hitting a-v about 10% (256/26 is approx. 10) more often than w-z. writing secure code is hard... So true. That's why one should stick to standard l

Re: Is this secure?

2010-02-24 Thread mk
On 2010-02-24 20:19, Robert Kern wrote: On 2010-02-24 13:09 PM, mk wrote: On 2010-02-24 20:01, Robert Kern wrote: I will repeat my advice to just use random.SystemRandom.choice() instead of trying to interpret the bytes from /dev/urandom directly. Oh I hear you -- for production use I would (

Re: Is this secure?

2010-02-24 Thread mk
On 2010-02-24 20:30, Michael Rudolf wrote: The reason is 256 % 26 != 0 256 mod 26 equals 22, thus your code is hitting a-v about 10% (256/26 is approx. 10) more often than w-z. writing secure code is hard... So true. That's why one should stick to standard libs when it comes to crypto or secu

Trouble with ftplib uploading to an FTP server

2010-02-24 Thread Sky Larking
This bit of code is designed to get the external IP address and hostname of a client , write it locally to a file, then upload to an FTP server. It works locally( one can see the IP number and hostname with a time stamp in /Users/admin/Documents) , but when the file is opened on the server after it

Re: Is this secure?

2010-02-24 Thread Robert Kern
On 2010-02-24 14:02 PM, mk wrote: It would appear that SystemRandom().choice is indeed best (in terms of how much the counts stray from mean in std devs), but only after seeding it with os.urandom. Calling random.seed() does not affect SystemRandom() whatsoever. You are getting perfectly acce

Re: Artificial Neural Networks recommendation

2010-02-24 Thread Andrew Davison
On Feb 24, 1:49 pm, Gereon Kaiping wrote: > - - PyNN (just a builder, requires external simulator) > –http://neuralensemble.org/trac/PyNN/ > - - Con-x (part of pyro) –http://pyrorobotics.org/?page=Conx > - - PyNeurGen (includes genetic algorithms) –http://pyneurgen.sourceforge.net/ > - - ffnet (o

Re: Is this secure?

2010-02-24 Thread Paul Rubin
mk writes: > def rand_str_custom(n): > s = os.urandom(n) > return ''.join([chr(ord('a') + ord(x) % 26) for x in s if ord(x) < 234]) Note that simply throws away some of the chars. You have to replace them, not throw them away. > rand_str_SystemRandom_seeding > mean 3845.15384615 std dev

Docstrings considered too complicated

2010-02-24 Thread Andreas Waldenburger
Hi all, a company that works with my company writes a lot of of their code in Python (lucky jerks). I've seen their code and it basically looks like this: """Function that does stuff""" def doStuff(): while not wise(up): yield scorn Now my question is this: How do I kill these people

Re: When will Java go mainstream like Python?

2010-02-24 Thread Wanja Gayk
Am 24.02.2010, 00:22 Uhr, schrieb Lawrence D'Oliveiro : 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. In synthetic microbenchma

Re: Trouble with ftplib uploading to an FTP server

2010-02-24 Thread MRAB
Sky Larking wrote: This bit of code is designed to get the external IP address and hostname of a client , write it locally to a file, then upload to an FTP server. It works locally( one can see the IP number and hostname with a time stamp in /Users/admin/Documents) , but when the file is opened o

Re: Spam from gmail

2010-02-24 Thread Steve Holden
Aahz wrote: > In article <87sk8r5v2f@benfinney.id.au>, > Ben Finney wrote: >> 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 peopl

Re: Is this secure?

2010-02-24 Thread Michael Rudolf
Am 24.02.2010 21:06, schrieb mk: I just posted a comparison with calculating std deviations for various methods - using os.urandom, SystemRandom.choice with seeding and without seeding. I saw them They all seem to have slightly different distributions. No they don't. Just run those tests a

Re: Help with lambda

2010-02-24 Thread News123
Jonathan Gardner wrote: > On Feb 18, 4:28 am, lallous wrote: >> f = [lambda x: x ** n for n in xrange(2, 5)] > > This is (pretty much) what the above code does. > f = [] n = 2 f.append(lambda x: x**n) n = 3 f.append(lambda x: x**n) n = 4 f.append(lambda x: x**n

Re: Why tarfile.TarFile.gzopen is not in the online documentation?

2010-02-24 Thread Terry Reedy
On 2/24/2010 5:14 AM, Lars Gustäbel wrote: On Wed, Feb 24, 2010 at 09:37:19AM +0100, Baptiste Lepilleur wrote: I stumbled uppon this and find it somewhat odd: some class methods of TarFile and TarInfo do not appears in either the online documentation or search while they have a doc string: http

Re: python dowload

2010-02-24 Thread Diez B. Roggisch
Am 24.02.10 00:08, schrieb 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

Re: Docstrings considered too complicated

2010-02-24 Thread Jonathan Gardner
On Wed, Feb 24, 2010 at 12:23 PM, Andreas Waldenburger wrote: > Hi all, > > a company that works with my company writes a lot of of their code in > Python (lucky jerks). I've seen their code and it basically looks like > this: > > """Function that does stuff""" > def doStuff(): >    while not wise

Re: compiling python question

2010-02-24 Thread Diez B. Roggisch
Am 24.02.10 03:00, schrieb 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? What OS? What does the configure/build process say? Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Spam from gmail

2010-02-24 Thread Arnaud Delobelle
a...@pythoncraft.com (Aahz) writes: > In article <87sk8r5v2f@benfinney.id.au>, > Ben Finney wrote: >>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

Re: Problem creating executable, with PyQwt

2010-02-24 Thread Gib Bogle
David Boddie wrote: 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

Re: Files required for porting python

2010-02-24 Thread Gib Bogle
KIRAN wrote: "I see lot of code with several files." I had to laugh at this. -- http://mail.python.org/mailman/listinfo/python-list

How to monitor memory usage within Python? (Linux)

2010-02-24 Thread kj
Is there some standard module for getting info about the process's memory usage, in a Linux/Unix system? (I want to avoid hacks that involve, e.g., scraping ps's output.) Thanks! ~K -- http://mail.python.org/mailman/listinfo/python-list

Re: scope of generators, class variables, resulting in global na

2010-02-24 Thread dontspamleo
Hi Folks, Thanks everyone for the great contributions! I understand this better now. The distinction between a shorthand for a function definition and a shorthand for a loop iteration is crucial. Also: thanks for pointing out the even the list comprehension doesn't work in py3. That was incredibl

Re: What's the word on using """ to comment-out?

2010-02-24 Thread CM
> After all, from what I've seen since then, the practice of > triple-quote-commenting (or TQC, pardon the TCA) is in fact quite > common. > > Is TQC OK after all? > > If not, what's the case against it? I have no sense of how approved it is, and don't have a strong opinion on it, but I would thin

ANN: Pyrex 0.9.8.6

2010-02-24 Thread Greg Ewing
Pyrex 0.9.8.6 is now available: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ Numerous bug fixes and a few improvements. See the CHANGES page on the web site for details. What is Pyrex? -- Pyrex is a language for writing Python extension modules. It lets you freely m

Re: How to monitor memory usage within Python? (Linux)

2010-02-24 Thread Diez B. Roggisch
Am 24.02.10 23:35, schrieb kj: Is there some standard module for getting info about the process's memory usage, in a Linux/Unix system? (I want to avoid hacks that involve, e.g., scraping ps's output.) http://code.google.com/p/pympler/ Diez -- http://mail.python.org/mailman/listinfo/python-li

  1   2   >