Re: Rant on web browsers

2011-06-21 Thread Daniel Kluev
Regarding pyjamas lib size, its actually not that big if you want only bare python, without DOM wrapper. You only need pyjslib, which is less than 30kb gzipped when compiled even with --strict (quite verbose mode). Even that could be further reduced if you drop unused by your code python features

Re: Python scoping

2011-06-21 Thread gervaz
On 21 Giu, 06:06, Ben Finney wrote: > Chris Angelico writes: > > On Tue, Jun 21, 2011 at 12:38 PM, Ben Finney > > wrote: > > > The *binding* is scoped. > > > And the binding follows the exact same rules as anything else would. > > It has scope and visibility. In terms of the OP, the binding IS

Re: something about performence

2011-06-21 Thread Vijay Murthy
I just wrote something. I could not run a profiler or analyze the timing but I felt it was effecient. Have a look and see if it helps: from itertools import * def sep_add(line1, line2): if line1 and line2: val1 = line1.split() val2 = line2.split() if (val1 and val2) an

Re: those darn exceptions

2011-06-21 Thread Steven D'Aprano
On Tue, 21 Jun 2011 01:43:39 +, Chris Torek wrote: > Exceptions are great, but... > > Sometimes when calling a function, you want to catch some or even all > the various exceptions it could raise. What exceptions *are* those? [snip much, much interactive code] TL;DR *wink* Shorter versi

Re: break in a module

2011-06-21 Thread Cameron Simpson
On 18Jun2011 03:50, Steven D'Aprano wrote: | On Sat, 18 Jun 2011 12:36:42 +1000, Cameron Simpson wrote: | > Just to throw another approach into the mix (because I was thinking | > about the "finally" word), what about: | > | > raise StopImport | > | > along the lines of generators' "raise Sto

Re: How to iterate on a changing dictionary

2011-06-21 Thread TheSaint
Terry Reedy wrote: > Other situations will need other solutions. > Like a job's completion list. Some number of workers get a job, and by time the caller sould know who and what has finished. Then a dictionary would hold number of remaining jobs. Similar a downloading list. -- goto /dev/null

Re: something about performence

2011-06-21 Thread Ken Seehart
On 6/20/2011 11:56 PM, king6c...@gmail.com wrote: > Thanks for your reply,Ken :) > I found the two files ends with the same id……so I am lazy^-^ > I tried psyco,and unfortunately it costs nearly the same time as before. > Is it true that we can only get str from files in Python? > Nope^_* . There ar

Re: basic bytecode to machine code compiler (part 3)

2011-06-21 Thread Ulrich Eckhardt
Rouslan Korneychuk wrote: > if i != pindex: > (less if x <= pivot else greater).append(x) Just curious, is there a reason why you wrote this last line that way instead of using a "normal" if/else clause? Cheers! Uli -- Domino Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Ham

ANN: Leo 4.9 final released

2011-06-21 Thread Edward K. Ream
Leo 4.9 final is now available at: http://sourceforge.net/projects/leo/files/ Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html The highlights of Leo 4.9: - The Qt gui completely replaces the Tk gui--Qt gui now has all esse

Re: new string-formatting preferred? (was "What is this syntax ?")

2011-06-21 Thread Tim Chase
On 06/20/2011 09:17 PM, Terry Reedy wrote: On 6/20/2011 8:46 PM, Tim Chase wrote: On 06/20/2011 05:19 PM, Ben Finney wrote: “This method of string formatting is the new standard in Python 3.0, and should be preferred to the % formatting described in String Formatting Operations in new code.” h

Re: How to iterate on a changing dictionary

2011-06-21 Thread Gurpreet Singh
Perhaps this is the simplest and best solution which appears in this case. Just copy the desired items to a new dictionary and discard the original one. import re myDict={'a':'alpha','b':'beta','c':'charley','d':'disney'} myNewDict={} for k,v in myDict.iteritems(): if re.search("a",v)!=None:

PSD to XHTML Conversion Services and PSD to HTML CSS Conversion Services, PSD to Joomla, Drupal, Wordpress Conversion

2011-06-21 Thread xhtml champs
PSD to XHTML Conversion, PSD to HTML CSS, Joomla, Wordpress, Drupal, CMS, VBULLETIN, PHPBB and includes convert to XHTML like PSD to XHTML, web designing services, logos and banner design, website building, animation,presentations. for more details: http://www.xhtmlchamps.com -- http://mail.pytho

Re: break in a module

2011-06-21 Thread Cameron Simpson
On 21Jun2011 20:04, I wrote: | So the caller does an: | | import foo | | as normal, with no special wrapping. And the module goes: | | spam() | if condition: | raise StopIteration | ham() | cheese() Of course, that should be StopImport, not StopIteration. Cheers, -- Cameron Simp

Web design services | website designing | hire a website designer | creative web design

2011-06-21 Thread sravan kumar
web design services, XHTML Conversion Services, Offshore outsourcing web design & SEO Expert Acedezines provides best services for your website design, search engine optimization, web design services, brochure design, flash intro animation, website designing, wordpress themes. for more details http

Emails backup in python 3.2

2011-06-21 Thread TheSaint
Hello, I'm looking for an idea how to backup emails retrieved by poplib and save them into mailbox.mbox file. The problem is the received message which is a list of bytes streams, mailbox.mbox don't expect a list. What conversion should I do? A file type io.StringIO ? decoding every bytes stream

Don't understand SequenceMatcher from difflib

2011-06-21 Thread Antoon Pardon
I have the following code I wrote. == from difflib import SequenceMatcher import sys write = sys.stdout.write warn = sys.stderr.write def program(argv): ls1 = open(argv[1]).readlines() ls2 = open(argv[2]).readlines() matcher = SequenceMatcher(l

Re: How to iterate on a changing dictionary

2011-06-21 Thread MRAB
On 21/06/2011 12:51, Gurpreet Singh wrote: Perhaps this is the simplest and best solution which appears in this case. Just copy the desired items to a new dictionary and discard the original one. import re myDict={'a':'alpha','b':'beta','c':'charley','d':'disney'} myNewDict={} for k,v in myDict

[ANN] Shed Skin 0.8

2011-06-21 Thread Mark Dufour
Hi all, I have just released version 0.8 of Shed Skin, an experimental (restricted-)Python-to-C++ compiler. Please see my blog for the full announcement: http://shed-skin.blogspot.com The Shed Skin homepage can be found here: http://shedskin.googlecode.com Thanks, Mark Dufour -- http://www.

[OT] One click, one (buggy) life...

2011-06-21 Thread DavCori80
Hi everyone, I would like to share a youtube clip...one click costs nothing while can save lives sometimes (especially mine). http://www.youtube.com/watch?v=PiCeqtGHpJI Thanks a lot and cheers. DavCori http://www.ar4tro.com/welcome.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Rant on web browsers

2011-06-21 Thread ron_m
This might help http://blog.stevenlevithan.com/archives/date-time-format -- http://mail.python.org/mailman/listinfo/python-list

Re: Is the mailing list to usenet gateway borked?

2011-06-21 Thread Peter Pearson
On 20 Jun 2011 23:49:11 GMT, Steven D'Aprano wrote: [snip] > I will treat this as a bug in Pan, and take it to the appropriate forums, > but for anyone who cares, here's one example: > > From: Steven D'Aprano > Subject: Re: What is this syntax ? > Newsgroups: comp.lang.python > References:

Re: Do we still need to inherit from "object" to create new-style classes?

2011-06-21 Thread Terry Reedy
On 6/20/2011 9:26 PM, John Salerno wrote: I can't quite seem to find the answer to this anywhere. The book I'm reading right now was written for Python 3.1 and doesn't use (object), so I'm thinking that was just a way to force new-style classes in 2.x and is no longer necessary in 3.x. Is that ri

running an existing script

2011-06-21 Thread Adam Chapman
Hi, I'm trying to put together a lot of pieces of source code in matlab, java, perl and python. Im an expert when it comes to matlab, but novice in all the others listed above. However, I have integrated the java and perl code so they can be called from matlab. I know that there is a toolbox out

Better way to iterate over indices?

2011-06-21 Thread Billy Mays
I have always found that iterating over the indices of a list/tuple is not very clean: for i in range(len(myList)): doStuff(i, myList[i]) I know I could use enumerate: for i, v in enumerate(myList): doStuff(i, myList[i]) ...but that stiff seems clunky. Are there any better ways to

Re: parse date string having "EDT"

2011-06-21 Thread Junaid P V
Thanks, My script should be platform independent, so I think filtering out time zone info is better. -- http://mail.python.org/mailman/listinfo/python-list

Re: Better way to iterate over indices?

2011-06-21 Thread Ian Kelly
On Tue, Jun 21, 2011 at 12:05 PM, Billy Mays wrote: > I know I could use enumerate: > > for i, v in enumerate(myList): >    doStuff(i, myList[i]) > > ...but that stiff seems clunky. Why not: for i, v in enumerate(myList): doStuff(i, v) -- http://mail.python.org/mailman/listinfo/python-list

Re: running an existing script

2011-06-21 Thread Ethan Furman
Adam Chapman wrote: Hi, Howdy! I'm trying to put together a lot of pieces of source code in matlab, java, perl and python. [snippety] Basically I just want to run a single script from the python command window. Once I know how to do that I can be off on my way to perform the matlab interf

Re: Better way to iterate over indices?

2011-06-21 Thread Noah Hall
On Tue, Jun 21, 2011 at 7:05 PM, Billy Mays wrote: > I have always found that iterating over the indices of a list/tuple is not > very clean: > > for i in range(len(myList)): >    doStuff(i, myList[i]) > I know I could use enumerate: > > for i, v in enumerate(myList): >    doStuff(i, myList[i]) >

Re: Better way to iterate over indices?

2011-06-21 Thread Benjamin Kaplan
On Tue, Jun 21, 2011 at 11:05 AM, Billy Mays wrote: > I have always found that iterating over the indices of a list/tuple is not > very clean: > > for i in range(len(myList)): >    doStuff(i, myList[i]) > > > > > I know I could use enumerate: > > for i, v in enumerate(myList): >    doStuff(i, myLi

Re: Better way to iterate over indices?

2011-06-21 Thread Ethan Furman
Billy Mays wrote: I have always found that iterating over the indices of a list/tuple is not very clean: for i in range(len(myList)): doStuff(i, myList[i]) Definitely not beautiful. ;) I know I could use enumerate: for i, v in enumerate(myList): doStuff(i, myList[i]) If you actu

Re: running an existing script

2011-06-21 Thread Benjamin Kaplan
On Tue, Jun 21, 2011 at 10:45 AM, Adam Chapman wrote: > Hi, > > I'm trying to put together a lot of pieces of source code in matlab, > java, perl and python. > > Im an expert when it comes to matlab, but novice in all the others > listed above. However, I have integrated the java and perl code so

How to get return values of a forked process

2011-06-21 Thread Ian
Hello all, I need some helped with forking. In my script, I fork a process. I want to get return values from the child process. This is the script that does the forking: for x in (mylist): pid = os.fork() if pid: pidList.append(pid) else: os.execv('/usr/bin/python',('/

Simple question about loading a .glade UI file

2011-06-21 Thread Anthony Papillion
Hi Everyone, So I'm tackling designing a non-CLI program using Glade. I went through some tutorials and it seems like I'm doing things right but I'm my UI won't load. Python keeps griping about "could not create glade XML object". I have a .glade file called MainWindow.glade and my main window is

Re: running an existing script

2011-06-21 Thread Ethan Furman
Adam Chapman wrote: Thanks Ethan No way could I have worked that out in my state of stress! For your second idea, would I need to type that into the python command line interface (the one that looks like a DOS window? If you are actually in a python CLI, at the top of that screen does it sa

Re: How to get return values of a forked process

2011-06-21 Thread Ian Kelly
On Tue, Jun 21, 2011 at 12:26 PM, Ian wrote: > myForkedScript has code like this: > if fail: >os._exit(1) > else: >os._exit(os.EX_OK) > > Is using os._exit() the correct way to get a return value back to the > main process? sys.exit() is the preferred way. > I thought the value 'n', pass

Re: Don't understand SequenceMatcher from difflib

2011-06-21 Thread Terry Reedy
On 6/21/2011 9:43 AM, Antoon Pardon wrote: matcher = SequenceMatcher(ls1, ls2) ... What am I doing wrong? Read the doc, in particular, the really stupid signature of the class: "class difflib.SequenceMatcher(isjunk=None, a='', b='', autojunk=True)" You are passing isjunk = ls1, a = ls2,

Re: How to get return values of a forked process

2011-06-21 Thread Ian
On Jun 21, 1:54 pm, Ian Kelly wrote: > On Tue, Jun 21, 2011 at 12:26 PM, Ian wrote: > > myForkedScript has code like this: > > if fail: > >    os._exit(1) > > else: > >    os._exit(os.EX_OK) > > > Is using os._exit() the correct way to get a return value back to the > > main process? > > sys.exit

Re: parse date string having "EDT"

2011-06-21 Thread Miki Tebeka
You might consider trying dateutil.parser.parse (http://labix.org/python-dateutil#head-c0e81a473b647dfa787dc11e8c69557ec2c3ecd2) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get return values of a forked process

2011-06-21 Thread Miki Tebeka
One way is to use pipes, have a look at http://code.activestate.com/recipes/576709/ for example. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get return values of a forked process

2011-06-21 Thread Ian Kelly
> Where did you find the Unix docs you pasted in?  I didn't find it in > the man pages.  Thank you.  Based on what you say, I will change my > os._exit() to sys.exit(). http://docs.python.org/library/os.html#os.wait http://docs.python.org/library/os.html#os.waitpid I don't know what man pages you

How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
I'm working on the Project Euler exercises and I'm stumped on problem 3: "What is the largest prime factor of the number 600851475143 ?" Now, I've actually written functions to get a list of the factors of any given number, and then another function to get the prime numbers from that list. It wor

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Ian Kelly
On Tue, Jun 21, 2011 at 1:48 PM, John Salerno wrote: > Here is what I have so far. Initially the get_factors function just > iterated over the entire range(2, n + 1), but since a number can't > have a factor greater than half of itself, I tried to shorten the > range by doing range(2, n //2), but

Re: basic bytecode to machine code compiler (part 3)

2011-06-21 Thread Rouslan Korneychuk
On 06/21/2011 06:55 AM, Ulrich Eckhardt wrote: Rouslan Korneychuk wrote: if i != pindex: (less if x<= pivot else greater).append(x) Just curious, is there a reason why you wrote this last line that way instead of using a "normal" if/else clause? Cheers! Uli No special reason. I jus

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Irmen de Jong
On 21-06-11 21:48, John Salerno wrote: I'm working on the Project Euler exercises and I'm stumped on problem 3: "What is the largest prime factor of the number 600851475143 ?" Now, I've actually written functions to get a list of the factors of any given number, and then another function to get

Re: How to get return values of a forked process

2011-06-21 Thread Chris Torek
>> On Tue, Jun 21, 2011 at 12:26 PM, Ian wrote: >>> myForkedScript has code like this: >>> if fail: >>> os._exit(1) >>> else: >>>os._exit(os.EX_OK) >>> >>> Is using os._exit() the correct way to get a return value back to the >>> main process? "The" correct way, no, but it is "a" correct

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Mel
John Salerno wrote: > I'm working on the Project Euler exercises and I'm stumped on problem > 3: > > "What is the largest prime factor of the number 600851475143 ?" [ ... ] > Here is what I have so far. Initially the get_factors function just > iterated over the entire range(2, n + 1), but since a

sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Irmen de Jong
On 21-06-11 22:10, Irmen de Jong wrote: [stuff] I didn't read the last paragraph of John's message until just now, and now realize that what I wrote is likely way too much information for what he asked. I'm sorry. Next time I'll read everything until and including the last full stop. Irmen -

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread MRAB
On 21/06/2011 20:48, John Salerno wrote: I'm working on the Project Euler exercises and I'm stumped on problem 3: "What is the largest prime factor of the number 600851475143 ?" Now, I've actually written functions to get a list of the factors of any given number, and then another function to g

Re: running an existing script

2011-06-21 Thread Adam Chapman
On Jun 21, 8:00 pm, Ethan Furman wrote: > Adam Chapman wrote: > > Thanks Ethan > > > No way could I have worked that out in my state of stress! > > > For your second idea, would I need to type that into the python command > > line interface (the one that looks like a DOS window? > > If you are act

Handling import errors

2011-06-21 Thread Guillaume Martel-Genest
What is the pythonic way to handle imports error? What is bugging me is that the imports can't be inside a function (because I use them in different places in the script and thus they have to be in the global scope). I would write something like: try: -- http://mail.python.org/mailman/listinfo/py

Handling import errors

2011-06-21 Thread Guillaume Martel-Genest
What is the pythonic way to handle imports error? What is bugging me is that the imports can't be inside a function (because I use them in different places in the script and thus they have to be in the global scope). I would write something like: try: import foo except ImportError: logging

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
On Jun 21, 3:22 pm, Irmen de Jong wrote: > On 21-06-11 22:10, Irmen de Jong wrote: > [stuff] > > I didn't read the last paragraph of John's message until just now, and > now realize that what I wrote is likely way too much information for > what he asked. > I'm sorry. Next time I'll read everythin

Re: Handling import errors

2011-06-21 Thread Tim Johnson
* Guillaume Martel-Genest [110621 12:53]: > What is the pythonic way to handle imports error? What is bugging me > is that the imports can't be inside a function (because I use them in > different places in the script and thus they have to be in the global > scope). I would write something like:

Re: Handling import errors

2011-06-21 Thread Miki Tebeka
> try: > import foo > except ImportError: > logging.error('could not import foo') > sys.exit(1) Why not just let the exception terminate the program? It will have even more information about the problem that caused foo not to load. -- http://mail.python.org/mailman/listinfo/python-lis

Re: Handling import errors

2011-06-21 Thread Mel
Guillaume Martel-Genest wrote: > What is the pythonic way to handle imports error? What is bugging me > is that the imports can't be inside a function (because I use them in > different places in the script and thus they have to be in the global > scope). Actually, you can if you declare them glo

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Irmen de Jong
On 21-6-2011 23:09, John Salerno wrote: > On Jun 21, 3:22 pm, Irmen de Jong wrote: >> On 21-06-11 22:10, Irmen de Jong wrote: >> [stuff] >> >> I didn't read the last paragraph of John's message until just now, and >> now realize that what I wrote is likely way too much information for >> what he a

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Ian Kelly
On Tue, Jun 21, 2011 at 3:09 PM, John Salerno wrote: > Don't worry, I was still unclear about what to do after reading all > the responses, even yours! But one thing that made me feel better was > that I wasn't having a Python problem as much as a *math* problem. I > changed my get_factors functio

Re: those darn exceptions

2011-06-21 Thread Chris Torek
>On Tue, 21 Jun 2011 01:43:39 +, Chris Torek wrote: >> But how can I know a priori >> that os.kill() could raise OverflowError in the first place? In article <4e006912$0$29982$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano wrote: >You can't. Even if you studied the source code, you coul

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
On Jun 21, 4:41 pm, Ian Kelly wrote: > On Tue, Jun 21, 2011 at 3:09 PM, John Salerno wrote: > > Don't worry, I was still unclear about what to do after reading all > > the responses, even yours! But one thing that made me feel better was > > that I wasn't having a Python problem as much as a *mat

Re: new string-formatting preferred? (was "What is this syntax ?")

2011-06-21 Thread Terry Reedy
On 6/21/2011 7:33 AM, Tim Chase wrote: On 06/20/2011 09:17 PM, Terry Reedy wrote: On 6/20/2011 8:46 PM, Tim Chase wrote: On 06/20/2011 05:19 PM, Ben Finney wrote: “This method of string formatting is the new standard in Python 3.0, and should be preferred to the % formatting described in Strin

Re: something about performence

2011-06-21 Thread Terry Reedy
On 6/20/2011 10:59 PM, king6c...@gmail.com wrote: > Hi, > I have two large files,each has more than 2 lines,and each line > consists of two fields,one is the id and the other a value, > the ids are sorted. > > for example: > > file1 > (uin_a y) > 1 1245 > 2 12333 > 3 324543 > 5 34645

Finding greatest prime factor, was Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Chris Angelico
On Wed, Jun 22, 2011 at 7:48 AM, John Salerno wrote: > Thanks for the all the advice everyone. Now I'm on to problem #4, and > I'm stumped again, but that's what's fun! :) So now that you've solved it, I'd like to see some fast one-liners to do the job. (Since Python cares about whitespace, it mi

Re: new string-formatting preferred? (was "What is this syntax ?")

2011-06-21 Thread Tim Chase
On 06/21/2011 05:19 PM, Terry Reedy wrote: On 6/21/2011 7:33 AM, Tim Chase wrote: http://docs.python.org/library/stdtypes.html#str.format> Is there a good link to a thread-archive on when/why/how .format(...) became "preferred to the % formatting"? That is a controversial statement. I'm no

Re: Finding greatest prime factor, was Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Chris Angelico
Oops, realized after posting that there's a bug in my code - it returns 1 for a perfect square. Need another check in the 'while' loop, thus: On Wed, Jun 22, 2011 at 8:59 AM, Chris Angelico wrote: > exec 600851475143; for (int i=2;ii) ret/=i > >  while not ret%i and ret>i: Definitely room for im

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Terry Reedy
On 6/21/2011 3:48 PM, John Salerno wrote: Absolutely not! Each problem has been designed according to a "one- minute rule", which means that although it may take several hours to design a successful algorithm with more difficult problems, an efficient implementation will allow a solution to be o

Using django ORM from web browser and from command line apps

2011-06-21 Thread News123
Hi, I'm having a django browser application. There's certain administrative tasks, that I'd like to perform from the command line (cronjob or manually). As these scripts might be huge and might consume quite some memory I'd prefer, that they were not part of the normal application and would just

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Vlastimil Brom
2011/6/21 John Salerno : > However, even after reading the Wikipedia page about prime numbers and > trial division, I'm still a little unclear as to why the square root > of the number is the upper bound of the range you need to check. > -- There are likely be some more elaborated proofs, but it s

using only the django ORM (DB access model) and nothing else.

2011-06-21 Thread News123
Hi, I have a small application running on a host without web server and without any need for django except its ORM accessing data bases without explicitely writing sql queries.) I assume there's many libraries (SQL Alchemy or others), which could do this job. and which migh have less overhead tha

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Paul Rubin
Terry Reedy writes: >> efficient implementation will allow a solution to be obtained on a >> modestly powered computer in less than one minute." > If something really takes a minute in C, > allow yourself at least 10 minutes or even more with plain CPython. No. The idea of the Euler problems is

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Paul Rubin
John Salerno writes: > However, even after reading the Wikipedia page about prime numbers and > trial division, I'm still a little unclear as to why the square root > of the number is the upper bound of the range you need to check. Suppose p is the smallest divisor of n, and p > sqrt(n). ("Diviso

Re: Using django ORM from web browser and from command line apps

2011-06-21 Thread Ian Kelly
On Tue, Jun 21, 2011 at 5:39 PM, News123 wrote: > Hi, > > I'm having a django browser application. > > There's certain administrative tasks, that I'd like to perform from the > command line (cronjob or manually). > As these scripts might be huge and might consume quite some memory I'd > prefer, th

Tkinter/scrollbar/canvas question

2011-06-21 Thread agb
Dear Pythonistas, I've been trying to write a script that results in a set of widgets in a scrollable widget. Since tkinter is "the" gui for Python (and about the only one that I can be sure will not require additional software installation), I went that route, and wrote the following: from tkint

Re: Using django ORM from web browser and from command line apps

2011-06-21 Thread News123
Hi Ian, On 06/22/2011 02:09 AM, Ian Kelly wrote: > On Tue, Jun 21, 2011 at 5:39 PM, News123 wrote: >> I'm having a django browser application. >> >> There's certain administrative tasks, that I'd like to perform from the >> command line (cronjob or manually). > It sounds like you probably want a

Re: using only the django ORM (DB access model) and nothing else.

2011-06-21 Thread News123
On 06/22/2011 01:51 AM, News123 wrote: > Hi, > > I have a small application running on a host without web server and > without any need for django except its ORM accessing data bases without > explicitely writing sql queries.) > > I assume there's many libraries (SQL Alchemy or others), which cou

Security test of embedded Python

2011-06-21 Thread Chris Angelico
I'm involved in the construction of an environment that allows end users to supply scripts which will then run on our servers. We need to be able to offer the full flexibility of a scripting language, but without the risk of compromise to our computers. To that end, we have set up a system with pre

Re: Is the mailing list to usenet gateway borked?

2011-06-21 Thread Ben Finney
Steven D'Aprano writes: > The last couple of messages on this list show > up fine on the mailman archives, but are empty posts on > comp.lang.python. Is there a problem with the mail -> usenet gateway? I don't see empty messages through Usenet. However, at around the time you reported this, I

Re: using only the django ORM (DB access model) and nothing else.

2011-06-21 Thread Ian Kelly
On Tue, Jun 21, 2011 at 6:42 PM, News123 wrote: > ### > If running myapp.py I get following output: > > yes this line is executed > Traceback (most recent call last): >  File "./myapp.py", line 11, in >    class Mini(models.Model): >  File > "/opt/my_py

Re: using only the django ORM (DB access model) and nothing else.

2011-06-21 Thread Roy Smith
In article <4e012e8d$0$23682$426a3...@news.free.fr>, News123 wrote: > Hi, > > I have a small application running on a host without web server and > without any need for django except its ORM accessing data bases without > explicitely writing sql queries.) You would do much better to ask this q

Re: Using django ORM from web browser and from command line apps

2011-06-21 Thread Ian Kelly
On Tue, Jun 21, 2011 at 6:21 PM, News123 wrote: > Out of curiousity: Do you know whether the imports would be executed for > each potential command as soon as I call manage.py or only > 'on demand'? Off the top of my head, I don't know. -- http://mail.python.org/mailman/listinfo/python-list

Re: using only the django ORM (DB access model) and nothing else.

2011-06-21 Thread News123
It seems I found a solution (refer to end of this tessage). Not sure though if there are any drawbacks or if this method of working could cause any other issues. On 06/22/2011 02:42 AM, News123 wrote: > On 06/22/2011 01:51 AM, News123 wrote: >> Hi, >> >> I have a small application running on a

Re: using only the django ORM (DB access model) and nothing else.

2011-06-21 Thread News123
On 06/22/2011 03:04 AM, Ian Kelly wrote: >> >> So I need at least a little more to make my script work. > > There's a bit of magic in the way Django finds things, and I think > you'll still need to keep the basic structure of a Django project -- > models should be in a "models.py" file located in

Re: using only the django ORM (DB access model) and nothing else.

2011-06-21 Thread News123
On 06/22/2011 03:02 AM, Roy Smith wrote: > In article <4e012e8d$0$23682$426a3...@news.free.fr>, > News123 wrote: > > > I don't see any reason you couldn't use the Model layer by itself, if > you want to. It pretty much stands on its own. Thanks a lot for confirming, I have now my small exam

Re: Using django ORM from web browser and from command line apps

2011-06-21 Thread News123
On 06/22/2011 03:08 AM, Ian Kelly wrote: > On Tue, Jun 21, 2011 at 6:21 PM, News123 wrote: >> Out of curiousity: Do you know whether the imports would be executed for >> each potential command as soon as I call manage.py or only >> 'on demand'? > > Off the top of my head, I don't know. Never min

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
::sigh:: Well, I'm stuck again and it has to do with my get_factors function again, I think. Even with the slight optimization, it's taking forever on 20! (factorial, not excitement) :) It's frustrating because I have the Python right, but I'm getting stuck on the math. The problem: "What is the

Re: Security test of embedded Python

2011-06-21 Thread Paul Rubin
Chris Angelico writes: > users to supply scripts which will then run on our servers... > The environment is Python 3.3a0 embedded in C++, running on Linux. This doesn't sound like a bright idea, given the well-known difficulty of sandboxing Python. Geordi

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Paul Rubin
John Salerno writes: > It's frustrating because I have the Python right, but I'm getting > stuck on the math > "What is the smallest positive number that is evenly divisible by all > of the numbers from 1 to 20?" The answer is lcm [1,2,3, ... 20]. You can figure out how to implement lcm. Th

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread MRAB
On 22/06/2011 02:21, John Salerno wrote: ::sigh:: Well, I'm stuck again and it has to do with my get_factors function again, I think. Even with the slight optimization, it's taking forever on 20! (factorial, not excitement) :) It's frustrating because I have the Python right, but I'm getting stu

Re: Security test of embedded Python

2011-06-21 Thread Chris Angelico
On Wed, Jun 22, 2011 at 12:02 PM, Paul Rubin wrote: > Chris Angelico writes: >> users to supply scripts which will then run on our servers... >> The environment is Python 3.3a0 embedded in C++, running on Linux. > > This doesn't sound like a bright idea, given the well-known difficulty > of sandb

Re: Security test of embedded Python

2011-06-21 Thread Chris Angelico
Followup: The test box has been administratively taken offline after about an hour of testing. Thank you to everyone who participated; it seems we have a lot of changes to make! Monty failed the test. But it was an incredibly successful test. And hopefully, we'll be bringing things back online for

Re: Security test of embedded Python

2011-06-21 Thread Paul Rubin
Chris Angelico writes: > I'll also be looking into Pike. Unfortunately its community is far > smaller than Python's, so security holes may be less obvious. Actually the most obvious and widespread sandboxed language these days is Javascript. There's several embeddable implementations. Maybe you

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Mel
John Salerno wrote: > ::sigh:: Well, I'm stuck again and it has to do with my get_factors > function again, I think. Even with the slight optimization, it's > taking forever on 20! (factorial, not excitement) :) It's frustrating > because I have the Python right, but I'm getting stuck on the math

Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread Benjamin Kaplan
On Tue, Jun 21, 2011 at 4:30 PM, Terry Reedy wrote: > On 6/21/2011 3:48 PM, John Salerno wrote: > >> Absolutely not! Each problem has been designed according to a "one- >> minute rule", which means that although it may take several hours to >> design a successful algorithm with more difficult prob

Re: Security test of embedded Python

2011-06-21 Thread Benjamin Kaplan
On Tue, Jun 21, 2011 at 7:40 PM, Paul Rubin wrote: > Chris Angelico writes: >> I'll also be looking into Pike. Unfortunately its community is far >> smaller than Python's, so security holes may be less obvious. > > Actually the most obvious and widespread sandboxed language these days > is Javasc

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
On Jun 21, 9:09 pm, Paul Rubin wrote: > John Salerno writes: > > It's frustrating because I have the Python right, but I'm getting > > stuck on the math > > "What is the smallest positive number that is evenly divisible by all > > of the numbers from 1 to 20?" > > The answer is lcm [1,2,3, ..

Re: Security test of embedded Python

2011-06-21 Thread Chris Angelico
On Wed, Jun 22, 2011 at 1:09 PM, Benjamin Kaplan wrote: > Use Pyjamas with that and now you have your sandboxed Python :) > Not a day goes past without a reminder that I haven't yet explored Pyjamas! :) Monty's back online now in a restricted environment. I'm going to a meeting in a couple of ho

Unicode codepoints

2011-06-21 Thread Saul Spatz
Hi, I'm just starting to learn a bit about Unicode. I want to be able to read a utf-8 encoded file, and print out the codepoints it encodes. After many false starts, here's a script that seems to work, but it strikes me as awfully awkward and unpythonic. Have you a better way? def codePoints

Re: Security test of embedded Python

2011-06-21 Thread Paul Rubin
Chris Angelico writes: > Meanwhile, I'm looking into V8 and whether we can do everything we > need to that way, and how much dev time it's going to take me to > change languages... If you want to run Python, one obvious approach is a controlled-execution wrapper like Geordi uses. -- http://mail.

Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)?

2011-06-21 Thread John Salerno
On Jun 21, 10:02 pm, Mel wrote: > John Salerno wrote: > > ::sigh:: Well, I'm stuck again and it has to do with my get_factors > > function again, I think. Even with the slight optimization, it's > > taking forever on 20! (factorial, not excitement)  :) It's frustrating > > because I have the Pytho

Re: Tkinter/scrollbar/canvas question

2011-06-21 Thread Saul Spatz
It works if you change it like so: from tkinter import * class ShowList(Frame): def __init__(self, root): Frame.__init__(self, root) self.grid() self.draw_widgets() def draw_widgets(self): cframe = Frame(self)

Re: Unicode codepoints

2011-06-21 Thread Chris Angelico
On Wed, Jun 22, 2011 at 1:37 PM, Saul Spatz wrote: > Hi, > > I'm just starting to learn a bit about Unicode. I want to be able to read a > utf-8 encoded file, and print out the codepoints it encodes.  After many > false starts, here's a script that seems to work, but it strikes me as > awfully

  1   2   >