Re: [Tutor] Advice on multi-dimensional data storage

2016-03-20 Thread Oscar Benjamin
On 16 March 2016 at 13:21, Steven D'Aprano wrote: > On Wed, Mar 16, 2016 at 08:36:59AM +, Matt Williams wrote: >> Dear Tutors, >> >> I am looking for some advice. I have some data that has three dimensions to >> it. I would like to store it such that one could manipulate (query/ update/ >> etc

Re: [Tutor] Advice on multi-dimensional data storage

2016-03-19 Thread Steven D'Aprano
On Wed, Mar 16, 2016 at 08:36:59AM +, Matt Williams wrote: > Dear Tutors, > > I am looking for some advice. I have some data that has three dimensions to > it. I would like to store it such that one could manipulate (query/ update/ > etc.) by dimension - so it would be feasible to ask for all

Re: [Tutor] Advice on multi-dimensional data storage

2016-03-19 Thread Bob Gailer
On Mar 16, 2016 5:59 AM, "Matt Williams" wrote: > > Dear Tutors, > > I am looking for some advice. I have some data that has three dimensions to > it. I would like to store it such that one could manipulate (query/ update/ > etc.) by dimension - so it would be feasible to ask for all of the data >

Re: [Tutor] Advice on multi-dimensional data storage

2016-03-18 Thread sina sareth via Tutor
Hi thereI would like to make 2 apps I wonder if somebody has a similar codes.   They said it is easier to use Django and MySQL.Thanks 1) XML parsing into database. 2) Do the same thing but this time, get ALL the quotes and save them as separate database entries (you will have to do a for loop for

Re: [Tutor] Advice on multi-dimensional data storage

2016-03-16 Thread Alan Gauld
On 16/03/16 08:36, Matt Williams wrote: > Dear Tutors, > > I am looking for some advice. I have some data that has three dimensions to > it. I would like to store it such that one could manipulate (query/ update/ > etc.) by dimension - so it would be feasible to ask for all of the data > that shar

[Tutor] Advice on multi-dimensional data storage

2016-03-16 Thread Matt Williams
Dear Tutors, I am looking for some advice. I have some data that has three dimensions to it. I would like to store it such that one could manipulate (query/ update/ etc.) by dimension - so it would be feasible to ask for all of the data that shares a value in d1, or iterate over all of the values

Re: [Tutor] Advice on Strategy for Attacking IO Program

2015-03-29 Thread Martin A. Brown
Greetings, Here is what I am trying have my program do: • Monitor a folder for files that are dropped throughout the day • When a file is dropped in the folder the program should scan the file o IF all the contents in the file have the same length o THEN the file should be moved to a "succe

[Tutor] Advice on Strategy for Attacking IO Program

2015-03-29 Thread Saran Ahluwalia
Hello: Here is what I am trying have my program do: • Monitor a folder for files that are dropped throughout the day • When a file is dropped in the folder the program should scan the file o IF all the contents in the file have the same length o THEN the file should be moved to a "success" fo

Re: [Tutor] Advice needed by a new to Python but abit experience software dev

2014-05-04 Thread Chris “Kwpolska” Warrick
On Sat, May 3, 2014 at 1:51 AM, Muhammed Salman wrote: > Hi, > > I have to develop a simple web app. In which i have to create, update, read > and delete people. I also should be able to make people friends and best > friends with each other. Now, (obviously) I do not want you guys to do this > pr

Re: [Tutor] Advice needed by a new to Python but abit experience software dev

2014-05-04 Thread Alan Gauld
On 03/05/14 00:51, Muhammed Salman wrote: I have to develop a simple web app. ... I do not want you guys to do this project for me ;). But what I want is that maybe you guys can give me some hints about where to start and make my journey easy by giving me some good pointers on what to look for a

[Tutor] Advice needed by a new to Python but abit experience software dev

2014-05-04 Thread Muhammed Salman
Hi, I have to develop a simple web app. In which i have to create, update, read and delete people. I also should be able to make people friends and best friends with each other. Now, (obviously) I do not want you guys to do this project for me ;). But what I want is that maybe you guys can give me

Re: [Tutor] Advice on Python codes - A recursive function to output entire directory subkeys of Windows Registry

2014-02-06 Thread spir
On 02/05/2014 04:30 PM, Alan Ho wrote: Hi, I am a novice in Python, having attended a course few weeks ago and I'm working on my assignment now, and I encounter this issue when I was trying to print the entire Windows Registry (WR) sub-keys directories (trying that first with the below codes

Re: [Tutor] Advice on Python codes - A recursive function to output entire directory subkeys of Windows Registry

2014-02-05 Thread Tim Golden
On 05/02/2014 15:30, Alan Ho wrote: Hi, I am a novice in Python, having attended a course few weeks ago and I'm working on my assignment now, and I encounter this issue when I was trying to print the entire Windows Registry (WR) sub-keys directories (trying that first with the below codes with a

[Tutor] Advice on Python codes - A recursive function to output entire directory subkeys of Windows Registry

2014-02-05 Thread Alan Ho
Hi, I am a novice in Python, having attended a course few weeks ago and I'm working on my assignment now, and I encounter this issue when I was trying to print the entire Windows Registry (WR) sub-keys directories (trying that first with the below codes with adaptations from on-line research) a

Re: [Tutor] advice on global variables

2012-07-12 Thread Walter Prins
Hi Chris, James has already given a response but I can't resist also chiming in, see below: On 11 July 2012 15:30, Chris Hare wrote: > I like where this is going Walter. I guess where I am confused is this: > > the globals are not static - they are set once and then won't change during > the l

Re: [Tutor] advice on global variables

2012-07-11 Thread James Reynolds
On Wed, Jul 11, 2012 at 10:30 AM, Chris Hare wrote: > > On Jul 11, 2012, at 8:05 AM, Walter Prins wrote: > > > [snip] > > > Your original example modified as demonstration: > > > > a.py: > > > > import shared > > import b > > > > def func1(): > >print "global var in func1 = %s" % sha

Re: [Tutor] advice on global variables

2012-07-11 Thread Chris Hare
On Jul 11, 2012, at 8:05 AM, Walter Prins wrote: > [snip] > Your original example modified as demonstration: > > a.py: > > import shared > import b > > def func1(): >print "global var in func1 = %s" % shared.global_var > > class intclass: >def func2(self): >

Re: [Tutor] advice on global variables

2012-07-11 Thread Walter Prins
Hi, On 11 July 2012 01:31, Chris Hare wrote: > Thanks Alan -- I am thinking I am just gonna go with the RAM based SQLite > database …. That seems an awfully large hammer for a little global variable problem. Why can you not (as a start) just move the global(s) into their own namespace/location

Re: [Tutor] advice on global variables

2012-07-11 Thread Don Jennings
On Jul 11, 2012, at 4:48 AM, tutor-requ...@python.org wrote: > Message: 1 > Date: Tue, 10 Jul 2012 19:31:09 -0500 > From: Chris Hare > To: tutor@python.org > Subject: Re: [Tutor] advice on global variables > Message-ID: <38ebadce-c2b1-4f15-b6e1-cb725f800...@labr.net> &g

Re: [Tutor] advice on global variables

2012-07-10 Thread Chris Hare
On Jul 10, 2012, at 6:24 PM, Alan Gauld wrote: > On 11/07/12 00:16, Alan Gauld wrote: > >>> One thought was a RAM based SQLite database, but that seems >> > like a lot of work. I dunno, maybe that is the option. >> >> is definitely the best option where the "global" needs to be shared >> acros

Re: [Tutor] advice on global variables

2012-07-10 Thread Alan Gauld
On 11/07/12 00:16, Alan Gauld wrote: One thought was a RAM based SQLite database, but that seems > like a lot of work. I dunno, maybe that is the option. is definitely the best option where the "global" needs to be shared across different programs as well as different modules in a single I

Re: [Tutor] advice on global variables

2012-07-10 Thread Alan Gauld
On 10/07/12 20:11, Chris Hare wrote: I know they are bad. They are not totally bad and most real programs wind up having one or two globals, although usually those globals are top level container classes, perhaps even an Application class or similar. I am not sure how else to handle this pro

Re: [Tutor] advice on global variables

2012-07-10 Thread James Reynolds
Sent from my iPad On Jul 10, 2012, at 3:11 PM, Chris Hare wrote: > > I know they are bad. That is why I would prefer not to use it, but I am not > sure how else to handle this problem. > > In this app, the user must log in. Once authenticated, they have a userid > stored in the SQLite da

Re: [Tutor] advice on global variables

2012-07-10 Thread Prasad, Ramit
> > Just as a note, this would not really work if the variable needs to be > > changed and read from several places when the value is an immutable > > type such as numbers / strings. In that case, then you could use > > the same logic but instead place the value in a list and pass that > > and alwa

Re: [Tutor] advice on global variables

2012-07-10 Thread Alexandre Zani
On Tue, Jul 10, 2012 at 1:32 PM, Prasad, Ramit wrote: >> You should avoid using the global statement. >> >> In your case, I would think you could just add an argument to the method: >> >> class MyObj(object): >> def __init__(self, arg): >> self.arg = arg >> def my_func(self, new_ar

Re: [Tutor] advice on global variables

2012-07-10 Thread James Reynolds
On Tue, Jul 10, 2012 at 4:32 PM, Prasad, Ramit wrote: > > You should avoid using the global statement. > > > > In your case, I would think you could just add an argument to the method: > > > > class MyObj(object): > > def __init__(self, arg): > > self.arg = arg > > def my_func(self

Re: [Tutor] advice on global variables

2012-07-10 Thread Prasad, Ramit
> You should avoid using the global statement. > > In your case, I would think you could just add an argument to the method: > > class MyObj(object): > def __init__(self, arg): > self.arg = arg > def my_func(self, new_arg): > self.arg = new_arg > > to call it: > > arg =

Re: [Tutor] advice on global variables

2012-07-10 Thread Prasad, Ramit
> > > > file: a.py > > > > import b > > global_var = "global" > > > To answer your most basic question: [file b.py] > import a > a.global_var This would be a cyclical import and is bad even if it does not fail. Remove the common dependencies (in this case the global variables) and place it in a

Re: [Tutor] advice on global variables

2012-07-10 Thread James Reynolds
On Tue, Jul 10, 2012 at 3:11 PM, Chris Hare wrote: > > I know they are bad. That is why I would prefer not to use it, but I am > not sure how else to handle this problem. > > In this app, the user must log in. Once authenticated, they have a userid > stored in the SQLite database. Before split

Re: [Tutor] advice on global variables

2012-07-10 Thread Alexandre Zani
On Tue, Jul 10, 2012 at 12:11 PM, Chris Hare wrote: > > I know they are bad. That is why I would prefer not to use it, but I am not > sure how else to handle this problem. > > In this app, the user must log in. Once authenticated, they have a userid > stored in the SQLite database. Before spl

[Tutor] advice on global variables

2012-07-10 Thread Chris Hare
I know they are bad. That is why I would prefer not to use it, but I am not sure how else to handle this problem. In this app, the user must log in. Once authenticated, they have a userid stored in the SQLite database. Before splitting my app into multiple files, I used a global variable.

Re: [Tutor] advice on an app

2012-05-01 Thread Joel Goldstick
On Tue, May 1, 2012 at 5:19 AM, Khalid Al-Ghamdi wrote: > hi all, > > I'm trying to create an app that schedules 3000 to 5000 trainees' > practical exams. > > All the trainees basic info (name, badge, major, etc.) is in excel and i've > managed to convert it into a HUGE list via a csv.reader objec

[Tutor] advice on an app

2012-05-01 Thread Khalid Al-Ghamdi
hi all, I'm trying to create an app that schedules 3000 to 5000 trainees' practical exams. All the trainees basic info (name, badge, major, etc.) is in excel and i've managed to convert it into a *HUGE *list via a csv.reader object. My question is: is this the right way to go or should i use sql

Re: [Tutor] advice

2011-11-28 Thread Alan Gauld
On 28/11/11 22:05, Chris Hare wrote: Is there some way of displaying rich text files, such as RTF or HTML from within a python Tkinter widget? Not so much RTF but you can set different fonts and colours etc within the standard text widget. You could either use HTML or a subset to save your s

[Tutor] advice

2011-11-28 Thread Chris Hare
I have been searching around a bit, but not really finding anything which is meaningful. I want to embed a set of help files in my application, and display them from within the application. I could use plain text files, which would be easy to suck into a Text field, but it would be nice to in

Re: [Tutor] Advice on math

2010-06-27 Thread Modulok
>> Hello, I've enjoying learning python for the first few years, and >> appreciate all the help I have received from this list. I had some >> interest in programming and am very glad to have made python my choice >> of programming language. Since I didn't go to college for computer >> studies, I fe

Re: [Tutor] Advice on math

2010-06-26 Thread Alan Gauld
"Eduardo Vieira" wrote Right now I think I need a better understanding of logarithm, arrays (matrixes), and even probability. What links would you all recommend that would be useful for me to learn these things in a newbie-friendly way? Wikipedia? Pretty good on most things math and scienc

Re: [Tutor] Advice on math

2010-06-26 Thread Shashwat Anand
On Sun, Jun 27, 2010 at 2:50 AM, Eduardo Vieira wrote: > Hello, I've enjoying learning python for the first few years, and > appreciate all the help I have received from this list. I had some > interest in programming and am very glad to have made python my choice > of programming language. Since

[Tutor] Advice on math

2010-06-26 Thread Eduardo Vieira
Hello, I've enjoying learning python for the first few years, and appreciate all the help I have received from this list. I had some interest in programming and am very glad to have made python my choice of programming language. Since I didn't go to college for computer studies, I feel my math is k

Re: [Tutor] advice on structuring a project

2009-10-06 Thread Kent Johnson
On Tue, Oct 6, 2009 at 2:26 PM, Serdar Tumgoren wrote: > I have a set of classes that I've named models.py (following the > Django convention, though it's not technically a Django project or > app). > > Inside that file, I had initially grouped together a number of > classes, subclasses and mixin

Re: [Tutor] advice on structuring a project

2009-10-06 Thread Serdar Tumgoren
> I don't think there is a "right" answer to this question. It depends > on how the classes are used and related to each other. If the Auto > classes are related or if they are useful to more than one client, > perhaps you should make an auto_models.py to hold them. If they are > only useful to ind

[Tutor] advice on structuring a project

2009-10-06 Thread Serdar Tumgoren
Hi everyone, I was wondering if anyone could offer advice as I try to simplify a project I've been working on. I have a set of classes that I've named models.py (following the Django convention, though it's not technically a Django project or app). Inside that file, I had initially grouped toget

Re: [Tutor] advice on creating and working with a complex datastructure

2009-07-21 Thread Serdar Tumgoren
>> >> I do not think any of these meet the criteria for inheritance. None of >> them "is a" kind of any of the others. >> I refreshed on my OO terminology and I see your point -- that composition is a more appropriate fit here than inheritance. >> I don;t like the use of Filing for a class name,

Re: [Tutor] advice on creating and working with a complex datastructure

2009-07-21 Thread Wayne
On Mon, Jul 20, 2009 at 6:05 PM, Alan Gauld wrote: > "Serdar Tumgoren" wrote > >> Aha, okay, the multiple classes approach makes sense. But would these >> be nested classes, >> > > No although they would probably have attributes containing > the related lists. Thus Race might have a list of Cand

Re: [Tutor] advice on creating and working with a complex datastructure

2009-07-20 Thread Alan Gauld
"Serdar Tumgoren" wrote Aha, okay, the multiple classes approach makes sense. But would these be nested classes, No although they would probably have attributes containing the related lists. Thus Race might have a list of Candidates. And Candidate would have a list of Committees etc. perh

Re: [Tutor] advice on creating and working with a complex data structure

2009-07-20 Thread bob gailer
Serdar Tumgoren wrote: Hi everyone, I'm working with a database of campaign finance filings, and I'm trying to create a data structure that captures the fact that: - there can be multiple races - races can have multiple candidates - candidates can have multiple campaign committees - campa

Re: [Tutor] advice on creating and working with a complex data structure

2009-07-20 Thread Serdar Tumgoren
> Have you considered using classes? This looks like a fairly natural fit for > race, candidate, committee and maybe report casses Aha, okay, the multiple classes approach makes sense. But would these be nested classes, perhaps inheriting attributes from their parent classes? E.g.: class Race

Re: [Tutor] advice on creating and working with a complex data structure

2009-07-20 Thread Alan Gauld
"Serdar Tumgoren" wrote I'm working with a database of campaign finance filings, and I'm trying to create a data structure that captures the fact that: - there can be multiple races - races can have multiple candidates - candidates can have multiple campaign committees - campaign committe

Re: [Tutor] advice on creating and working with a complex data structure

2009-07-20 Thread Lucas P Melo
Serdar Tumgoren wrote: And of course, please let me know if there's a simpler approach I'm overlooking that would meet my requirements. As always, the advice is appreciated. You could just create some classes with methods to handle the insertion and deletion of those data. You could also keep

[Tutor] advice on creating and working with a complex data structure

2009-07-20 Thread Serdar Tumgoren
Hi everyone, I'm working with a database of campaign finance filings, and I'm trying to create a data structure that captures the fact that: - there can be multiple races - races can have multiple candidates - candidates can have multiple campaign committees - campaign committees can file m

Re: [Tutor] advice on regex matching for dates?

2008-12-12 Thread Lie Ryan
On Thu, 11 Dec 2008 23:38:52 +0100, spir wrote: > Serdar Tumgoren a écrit : >> Hey everyone, >> >> I was wondering if there is a way to use the datetime module to check >> for variations on a month name when performing a regex match? >> >> In the script below, I created a regex pattern that chec

Re: [Tutor] advice on regex matching for dates?

2008-12-11 Thread Serdar Tumgoren
Thanks to all for the replies! The FeedParser example is mind-bending (at least for this noob), but of course looks very powerful. And thanks for the tips on cleaning up the appearance of the code with sup-patterns. Those regex's can get hairy pretty fast.

Re: [Tutor] advice on regex matching for dates?

2008-12-11 Thread John Fouhy
On 12/12/2008, spir wrote: > I just found a simple, but nice, trick to make regexes less unlegible. > Using substrings to represent sub-patterns. E.g. instead of: [...] Another option is to use the re.VERBOSE flag. This allows you to put comments in your regular expression and use whitespace fo

Re: [Tutor] advice on regex matching for dates?

2008-12-11 Thread spir
Serdar Tumgoren a écrit : Hey everyone, I was wondering if there is a way to use the datetime module to check for variations on a month name when performing a regex match? In the script below, I created a regex pattern that checks for dates in the following pattern: "August 31, 2007". If there

Re: [Tutor] advice on regex matching for dates?

2008-12-11 Thread Kent Johnson
On Thu, Dec 11, 2008 at 2:31 PM, Serdar Tumgoren wrote: > Hey everyone, > > I was wondering if there is a way to use the datetime module to check for > variations on a month name when performing a regex match? Parsing arbitrary dates is hard, in fact the most general case is not solvable since 7/

[Tutor] advice on regex matching for dates?

2008-12-11 Thread Serdar Tumgoren
Hey everyone, I was wondering if there is a way to use the datetime module to check for variations on a month name when performing a regex match? In the script below, I created a regex pattern that checks for dates in the following pattern: "August 31, 2007". If there's a match, I can then print

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-21 Thread Dick Moores
At 01:42 PM 7/21/2008, Terry Carroll wrote: On Mon, 21 Jul 2008, Daniel Sarmiento wrote: > What about the following function? > > if x == 0: > return False > return True I don't like it, myself. You have multiple points of exit, and, yes, you can see that the fallthough is only executed if

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-21 Thread Terry Carroll
On Mon, 21 Jul 2008, Daniel Sarmiento wrote: > What about the following function? > > if x == 0: > return False > return True I don't like it, myself. You have multiple points of exit, and, yes, you can see that the fallthough is only executed if the condition is not met, but it makes you

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-21 Thread Marc Tompkins
On Mon, Jul 21, 2008 at 10:20 AM, Daniel Sarmiento <[EMAIL PROTECTED]> wrote: > What about the following function? > > if x == 0: >return False > return True > > > I am a beginner, but I think it is more clear (at least to me) what > the function does. And it is only one line longer than > > v

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-21 Thread Marc Tompkins
On Mon, Jul 21, 2008 at 10:29 AM, Marc Tompkins <[EMAIL PROTECTED]> wrote: > > How about > >> return (x!=0) >> > ? > > Short and cryptic! > Sorry - I had deleted all the old messages in the thread, and only responded to the latest. My bad - I see now that I've joined in beating a dead horse. -

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-21 Thread Daniel Sarmiento
What about the following function? if x == 0: return False return True I am a beginner, but I think it is more clear (at least to me) what the function does. And it is only one line longer than value = (x != 0) return value ___ Tutor maillist -

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-19 Thread Lowell Tackett
>From the virtual desk of Lowell Tackett --- On Sat, 7/19/08, Dick Moores <[EMAIL PROTECTED]> wrote: > From: Dick Moores <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Advice for my function, isPrime(n), please > To: "Python Tutor List" > Date: Saturday, J

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-19 Thread Dick Moores
At 04:44 AM 7/19/2008, Kent Johnson wrote: On Sat, Jul 19, 2008 at 5:03 AM, Dick Moores <[EMAIL PROTECTED]> wrote: >> > Readability counts. <-- >> >> Personally I think my way is more readable. It says what it means >> without any fluff. IMO it is explicit, readable, concise and to the >> point

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-19 Thread Kent Johnson
On Sat, Jul 19, 2008 at 5:03 AM, Dick Moores <[EMAIL PROTECTED]> wrote: >> > Readability counts. <-- >> >> Personally I think my way is more readable. It says what it means >> without any fluff. IMO it is explicit, readable, concise and to the >> point. > > Well, readability is in the eye of the

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-19 Thread Dick Moores
At 08:40 PM 7/18/2008, Kent Johnson wrote: On Fri, Jul 18, 2008 at 4:45 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > At 12:38 PM 7/18/2008, Kent Johnson wrote: >> >> On Fri, Jul 18, 2008 at 2:25 PM, Dick Moores <[EMAIL PROTECTED]> wrote: >> > At 10:03 AM 7/18/2008, Kent Johnson wrote: >> >> >> >>

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-18 Thread Kent Johnson
On Fri, Jul 18, 2008 at 4:45 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > At 12:38 PM 7/18/2008, Kent Johnson wrote: >> >> On Fri, Jul 18, 2008 at 2:25 PM, Dick Moores <[EMAIL PROTECTED]> wrote: >> > At 10:03 AM 7/18/2008, Kent Johnson wrote: >> >> >> >> On Fri, Jul 18, 2008 at 11:32 AM, Dick Moore

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-18 Thread Dick Moores
At 12:38 PM 7/18/2008, Kent Johnson wrote: On Fri, Jul 18, 2008 at 2:25 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > At 10:03 AM 7/18/2008, Kent Johnson wrote: >> >> On Fri, Jul 18, 2008 at 11:32 AM, Dick Moores <[EMAIL PROTECTED]> wrote: >> >if x == 0: >> >return False >> >else:

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-18 Thread Kent Johnson
On Fri, Jul 18, 2008 at 2:25 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > At 10:03 AM 7/18/2008, Kent Johnson wrote: >> >> On Fri, Jul 18, 2008 at 11:32 AM, Dick Moores <[EMAIL PROTECTED]> wrote: >> >if x == 0: >> >return False >> >else: >> >return True >> >> Could be just >

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-18 Thread Dick Moores
At 10:03 AM 7/18/2008, Kent Johnson wrote: On Fri, Jul 18, 2008 at 11:32 AM, Dick Moores <[EMAIL PROTECTED]> wrote: >if x == 0: >return False >else: >return True Could be just return x!=0 I see this works, but it's Greek to me. HOW does it work? And why is it better

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-18 Thread Kent Johnson
On Fri, Jul 18, 2008 at 11:32 AM, Dick Moores <[EMAIL PROTECTED]> wrote: >if x == 0: >return False >else: >return True Could be just return x!=0 or return not x > My question is about whether to test for integerhood. Without that test, > isPrime(3.7) returns true, and

[Tutor] Advice for my function, isPrime(n), please

2008-07-18 Thread Dick Moores
I'm rather please with the speed of isPrime(). Any credit, of course, goes to Alex Martelli, who wrote gmpy. from gmpy import is_prime def isPrime(n): """ Return True if n is prime, False if not prime. If n not an int or a long, return None. """ if not isinstance(n, (int, long

Re: [Tutor] Advice for a Multimedia Major [was: Counting method calls]

2007-09-23 Thread Luke Paireepinart
Daniel Kavic wrote: > Ok I have been a multimedia major for a few years now. I have tried > javascript and that was bad, Java is just too difficult, so I joined > this mailing list a while back. I have been frustrated because I just > don't get entirely how OOProgramming works and how to actu

Re: [Tutor] advice on idiom replacing if test requested

2005-12-11 Thread Brian van den Broek
Danny Yoo said unto the world upon 2005-12-11 22:13: > > On Sun, 11 Dec 2005, Brian van den Broek wrote: > > >>I have a case like this toy code: >> >>import random >>list1 = [1,2,3] >>list2 = ['a', 'b', 'c'] >>item = random.choice(list1 +list2) >>if item in list1: >> others = list2 >>else: >

Re: [Tutor] advice on idiom replacing if test requested

2005-12-11 Thread Danny Yoo
On Sun, 11 Dec 2005, Brian van den Broek wrote: > I have a case like this toy code: > > import random > list1 = [1,2,3] > list2 = ['a', 'b', 'c'] > item = random.choice(list1 +list2) > if item in list1: > others = list2 > else: > others = list1 Hi Brian, This code works, and as long

Re: [Tutor] advice on idiom replacing if test requested

2005-12-11 Thread bob
At 04:15 PM 12/11/2005, Brian van den Broek wrote: >Hi all, > >I have a case like this toy code: > >import random >list1 = [1,2,3] >list2 = ['a', 'b', 'c'] >item = random.choice(list1 +list2) >if item in list1: > others = list2 >else: > others = list1 > > >Another way occurred to me, but

[Tutor] advice on idiom replacing if test requested

2005-12-11 Thread Brian van den Broek
Hi all, I have a case like this toy code: import random list1 = [1,2,3] list2 = ['a', 'b', 'c'] item = random.choice(list1 +list2) if item in list1: others = list2 else: others = list1 Another way occurred to me, but I wonder if I'm being too cute: item = random.choice(list1 +list2)

Re: [Tutor] advice on how to start with urllib

2005-10-23 Thread nephish
Thanks a lot, this stuff is pretty easy. i got a couple of things working here. thanks for your help sk On Sun, 2005-10-23 at 13:46 +0100, Christopher Arndt wrote: > nephish schrieb: > > hey there gents, > > i am looking for a good place to start learning how to read a web page > > with pytho

Re: [Tutor] advice on how to start with urllib

2005-10-23 Thread Christopher Arndt
nephish schrieb: > hey there gents, > i am looking for a good place to start learning how to read a web page > with python and pull out bits of information for an app i am doing for > work. i have googled and looked at the docs. i looked at urllib and > httplib so i think this a place to kind

Re: [Tutor] advice on how to start with urllib

2005-10-23 Thread Kent Johnson
nephish wrote: > hey there gents, > i am looking for a good place to start learning how to read a web page > with python and pull out bits of information for an app i am doing for > work. i have googled and looked at the docs. i looked at urllib and > httplib so i think this a place to kinda

[Tutor] advice on how to start with urllib

2005-10-22 Thread nephish
hey there gents, i am looking for a good place to start learning how to read a web page with python and pull out bits of information for an app i am doing for work. i have googled and looked at the docs. i looked at urllib and httplib so i think this a place to kinda start. Does anyone know