Re: [Tutor] Mutable data type in python

2015-10-03 Thread C Smith
On Sat, Oct 3, 2015 at 11:55 AM, Alan Gauld wrote: > On 03/10/15 19:10, C Smith wrote: >>> >>> Here is my modified version which I think works as you want: >>> >>> def findMinDepthPath(n): >>> if n <= 0: raise ValueError >>>

Re: [Tutor] Mutable data type in python

2015-10-03 Thread C Smith
> Here is my modified version which I think works as you want: > > def findMinDepthPath(n): > if n <= 0: raise ValueError > elif n==1: > return 0 > elif n==2 or n==3: > return 1 > else: > d1 = findMinDepthPath(n-1)+1 > d2 = d3 = (d1+1) # initialize to

Re: [Tutor] Python type confusion?

2015-09-28 Thread C Smith
On Mon, Sep 28, 2015 at 4:13 PM, C Smith wrote: > On Mon, Sep 28, 2015 at 1:27 PM, Ken Hammer wrote: >> A simple "type" problem? >> >> The following code works as a py file with the XX'd lines replacing the two >> later "raw_input" lines. >

Re: [Tutor] Python type confusion?

2015-09-28 Thread C Smith
On Mon, Sep 28, 2015 at 1:27 PM, Ken Hammer wrote: > A simple "type" problem? > > The following code works as a py file with the XX'd lines replacing the two > later "raw_input" lines. > Why do the "raw_input" lines yield a TypeError: 'str' object is not callable? > Same result if I use/omit >

Re: [Tutor] Help

2014-09-18 Thread C Smith
Check this guy's youtube channel. He has very basic examples. His username is thenewboston On Wed, Sep 17, 2014 at 4:36 PM, Art Pelletier wrote: > > I am a beginner with pythons programming I would like to see if their is a > site that has samples programs that I can practice on. > Sent from m

Re: [Tutor] Using subprocess on a series of files with spaces

2014-08-01 Thread C Smith
rote: > >>You may have already have solved your problem, unfortunately my >>emails are coming in slowly and out of order, but I have a suggestion: >> >>On Thu, Jul 31, 2014 at 03:53:48PM -0400, C Smith wrote: >>> I am on OSX, which needs to escape spaces in fil

Re: [Tutor] Using subprocess on a series of files with spaces

2014-08-01 Thread C Smith
4:38 AM, Ben Finney wrote: > Peter Otten <__pete...@web.de> writes: > >> C Smith wrote: >> >> > Nice, these are useful tools. I have been building something with >> > just basic stuff and avoiding learning any libraries. If I wanted to >> > get s

Re: [Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
wrote: > C Smith wrote: > > I'd throw in a check to verify that filename is indeed a flac: > >> or more accurately >> import os, subprocess, re >> directory = '/abs/path' >> for track, filename in enumerate(os.listdir(directory), 1): >&

Re: [Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
or more accurately import os, subprocess, re directory = '/abs/path' for track, filename in enumerate(os.listdir(directory), 1): pathname = os.path.join(directory, filename) subprocess.call(['ffmpeg', '-i', pathname, filename[:-5]+'.mp3']) On Thu,

Re: [Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
thanks, got it import os, subprocess, re directory = 'abs/path' for track, filename in enumerate(os.listdir(directory), 1): pathname = os.path.join(directory, filename) subprocess.call(['ffmpeg', '-i', pathname, filename+str(track)+'.mp3']) On Thu,

Re: [Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
Huh, that is quite an annoyance about changing the order though. Any ideas about that? I will look into it further in the meantime... On Thu, Jul 31, 2014 at 6:57 PM, C Smith wrote: > Works now, thanks! > > On Thu, Jul 31, 2014 at 6:57 PM, C Smith wrote: >> woops, I see it pathn

Re: [Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
Works now, thanks! On Thu, Jul 31, 2014 at 6:57 PM, C Smith wrote: > woops, I see it pathname != filename > > On Thu, Jul 31, 2014 at 6:55 PM, C Smith wrote: >>>for track, filename in enumerate(os.listdir(directory), 1): >> It seems kinda counter-intuitive to hav

Re: [Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
woops, I see it pathname != filename On Thu, Jul 31, 2014 at 6:55 PM, C Smith wrote: >>for track, filename in enumerate(os.listdir(directory), 1): > It seems kinda counter-intuitive to have track then filename as > variables, but enumerate looks like it gets passed the filename

Re: [Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
> emails are coming in slowly and out of order, but I have a suggestion: > > On Thu, Jul 31, 2014 at 03:53:48PM -0400, C Smith wrote: >> I am on OSX, which needs to escape spaces in filenames with a backslash. > > Same as any other Unix, or Linux, or, indeed, Windows. > >

Re: [Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
. So, I am still wondering about that too. On Thu, Jul 31, 2014 at 6:20 PM, C Smith wrote: > Okay I messed up with slash instead of backslash, so the re.sub() > works, but I am still curious about the previous question. > > On Thu, Jul 31, 2014 at 6:14 PM, C Smith wrote: >> Ev

Re: [Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
Okay I messed up with slash instead of backslash, so the re.sub() works, but I am still curious about the previous question. On Thu, Jul 31, 2014 at 6:14 PM, C Smith wrote: > Even when I am using: > re.sub('/s', '\\/s', filename) > I am still getting the same outp

Re: [Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
e Python interpreter strip off backslashes or something with strings? On Thu, Jul 31, 2014 at 5:53 PM, C Smith wrote: >>Change: > > >>subprocess.call(['ffmpeg', '-i', filename, str(track)+'.mp3']) > >>to: > >>subprocess.call(['ffmpeg

Re: [Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
passed to the shell without escaping the spaces. >Why not using ffmpeg without jumping into Python. It's well documented, check >Google. I guess you mean that the ability to change multiple files with ffmpeg is possible. I hadn't considered that but I would rather do it with Python,

[Tutor] Using subprocess on a series of files with spaces

2014-07-31 Thread C Smith
I am on OSX, which needs to escape spaces in filenames with a backslash. There are multiple files within one directory that all have the same structure, one or more characters with zero or more spaces in the filename, like this: 3 Song Title XYZ.flac. I want to use Python to call ffmpeg to convert

Re: [Tutor] Why is Quick Search at docs.Python.org so useless?

2014-07-05 Thread C Smith
I agree very much. I feel like I might have a learning disability when I try to reference the official Python docs for something that seems like it should be a very common task. On Sat, Jul 5, 2014 at 1:31 PM, Deb Wyatt wrote: > I am betting that a big reason newbies don't go straight to document

Re: [Tutor] What are your favourite unofficial resources

2014-06-30 Thread C Smith
Learning Python Design Patterns, by Gennadiy Zlobin Let us know when your book is done! On Mon, Jun 30, 2014 at 7:05 AM, Bob Williams wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 29/06/14 23:41, Alan Gauld wrote: >> I'm looking for tips for an appendix to a book that I'm workin

Re: [Tutor] Doubts about installing python3.1 in squeeze

2014-05-22 Thread C Smith
You can't use apt-get or similar to install 3.1. You will need to virtualenv. On Thu, May 22, 2014 at 12:22 PM, Alex Kleider wrote: > On 2014-05-22 06:17, Markos wrote: >> >> Hi, >> >> I'm learning Python and I'm using Debian 6.0 (squeeze) >> >> The installed version is 2.6.6. (python -V) >> >> I

Re: [Tutor] Doubts about installing python3.1 in squeeze

2014-05-22 Thread C Smith
Sorry, typing is hard. *You will need to use virtualenv On Thu, May 22, 2014 at 2:40 PM, C Smith wrote: > You can't use apt-get or similar to install 3.1. > You will need to virtualenv. > > On Thu, May 22, 2014 at 12:22 PM, Alex Kleider wrote: >> On 2014-05-22 06:17, M

Re: [Tutor] While truth

2014-05-20 Thread C Smith
Of course that isn't very useful code. I thought it might be a useful quick test for someone learning how while loops treat different values. On Tue, May 20, 2014 at 2:46 PM, Danny Yoo wrote: > On Tue, May 20, 2014 at 11:44 AM, C Smith > wrote: >> You can test out a condition

Re: [Tutor] While truth

2014-05-20 Thread C Smith
You can test out a condition like this in IDLE like so: while 6: print "yes its true" break while 0: print "yes its true" break while -1: print "yes its true" break emptyList = [] while emtpyList: print "yes its true" break This way you don't have to deal with

Re: [Tutor] Translator - multiple choice answer

2014-05-14 Thread C Smith
This might be useful for reading values from a text value into a dictionary: https://stackoverflow.com/questions/17775273/how-to-read-and-store-values-from-a-text-file-into-a-dictionary-python On Wed, May 14, 2014 at 7:00 PM, Danny Yoo wrote: >> Program read TXT file (c:\\slo3.txt) >> In this fil

Re: [Tutor] for the error about 'import site' failed; use -v for traceback

2014-05-14 Thread C Smith
What are you trying to do? On Wed, May 14, 2014 at 12:24 PM, C Smith wrote: > That looks pretty normal. I don't see any errors. > > On Wed, May 14, 2014 at 5:42 AM, Tao Zhu wrote: >> Hi everyone, >> when I use python, the problem occured. when I used the command "

Re: [Tutor] for the error about 'import site' failed; use -v for traceback

2014-05-14 Thread C Smith
That looks pretty normal. I don't see any errors. On Wed, May 14, 2014 at 5:42 AM, Tao Zhu wrote: > Hi everyone, > when I use python, the problem occured. when I used the command "python -v", > the results are listed as follows. could you tell me what wrong? > > $ python -v > # installing zipimpo

Re: [Tutor] Real world experience

2014-05-12 Thread C Smith
I think that is going to be my new wallpaper. On Mon, May 12, 2014 at 8:25 PM, Martin A. Brown wrote: > > Hello, > > 10 Pick one favorite specific topic, any topic (XML parsing; Unix > process handling; databases). The topic matters for you. > Learn it deeply. Keep learning it. The

Re: [Tutor] Real world experience

2014-05-12 Thread C Smith
Freeside is more makers. I haven't gone but have known people that have. You might find some arduino supposedly, but not much coding otherwise and you have to pay membership fees. It is more social than technical, I think. And your car will probably be broken into. I will check out the python-atlan

Re: [Tutor] Real world experience

2014-05-12 Thread C Smith
Thanks to everyone. >> practice. That programming doesn't have to be a solitary thing needs >> to be strongly emphasized, because the media likes to exaggerate, >Yes, This can't be stressed too much. Industrial coding is a team activity not >a solo process. This is particularly good advice for

Re: [Tutor] Real world experience

2014-05-11 Thread C Smith
to the industry. > > If you want to pursue a career in IT, you need to finish high school. You > would be wise to get a degree. > > My $0.02. > > Tim > > > On Sun, May 11, 2014 at 7:12 PM, C Smith > wrote: >> >> I have never known anyone that works i

[Tutor] Real world experience

2014-05-11 Thread C Smith
I have never known anyone that works in this industry. I got one job transforming xml (should have used xslt, ended up using sed and python regex scripts) where the guy asked me how much I wanted and I threw 200 bucks out there because I could get a room for two weeks at that cost. He just laughed

Re: [Tutor] Help with Python

2014-05-11 Thread C Smith
Hey Glen, include the error you are getting. It will make answering your question easier. How are you running this program, in an IDE? On Sat, May 10, 2014 at 11:16 PM, Glen Chan wrote: > Hello, I am a student trying to figure out Python. I am getting errors that > I don't know how to fix. What d

Re: [Tutor] How inefficient is this code?

2014-05-07 Thread C Smith
I guess intuiting efficiency doesn't work in Python because it is such high-level? Or is there much more going on there? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How inefficient is this code?

2014-05-07 Thread C Smith
eturn (or reaches the end of its body), the > for loop ends. > > This is called a generator function, and is a really nice way to > simplify and optimize your loops. > > You can read more about generators here: > https://wiki.python.org/moin/Generators > > > On Wed,

[Tutor] How inefficient is this code?

2014-05-07 Thread C Smith
A topic came up on slashdot concerning "intermediate" programming, where the poster expressed the feeling that the easy stuff is too easy and the hard stuff is too hard. Someone did point out that 'intermediate' programming would still involve actually selling code or at least some professional ex

Re: [Tutor] Stephen Mik-Novice Python Programmer(Version 3.4.0)Can't get help using Dictionaries, Lists to 'Hangman Game Problem"

2014-05-05 Thread C Smith
ode, pseudo code,worries about > using Dictionaries,Lists.embedded while lists,for loops: > Thank you,. C. Smith for responding to my help plea on Python-Tutor.org. One > version of the "Hang Man" problem is listed in the textbook,but it doesn't > use Dictionaries,Lists,embedded w

Re: [Tutor] Alice_in_wonderland Question

2014-05-04 Thread C Smith
>ordered_keys = word_count.keys() >sorted(ordered_keys) sorted() does not modify the list, but returns a sorted version of the list for me on Python 2.7 my_sorted_list = sorted(ordered_keys) This will alphabetize all of the words, regardless of frequency. >print ("All the words and their frequenc

Re: [Tutor] Stephen Mik-Novice Python Programmer(Version 3.4.0)Can't get help using Dictionaries, Lists to 'Hangman Game Problem"

2014-05-04 Thread C Smith
Hey, you will want to include some code to show your progress so far. Can you write a basic program and then work the requirements into it? Do you have some idea of where to start? Are you supposed to modify a completed version of "hangman" that is in your text, or come up with an original 'hangman

Re: [Tutor] append vs list addition

2014-05-04 Thread C Smith
Sorry. I meant for example: list1 = [1,2,3] list2 = [3,4,5] newList = list1 + list2 versus for x in list2: list1.append(x) Which is the preferred way to add elements from one list to another? On Sun, May 4, 2014 at 7:36 AM, Dave Angel wrote: > C Smith Wrote in message: >> &

[Tutor] append vs list addition

2014-05-04 Thread C Smith
I had always assumed that append() was more efficient, but some recent discussions seem to point at that it is the same as append(). Which is preferable and why? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https:

[Tutor] Fwd: Logical error?

2014-05-02 Thread C Smith
The first loop tests for the last element of fullPath to have today's date. The second loop tests the first element in fullPath, if it is not today, you will end up running sys.exit() when you hit the else clause in second loop. On Fri, May 2, 2014 at 6:38 PM, C Smith wrote: > The fi

Re: [Tutor] Stephen Mik-Almost Brand New to Python 3.4.0-"Guess My Number" program is syntactically correct but will not run as expected

2014-04-28 Thread C Smith
, 2014 at 1:59 PM, C Smith wrote: > > > The reason this is happening here is you need to import sys. >> > > I don't know why you would think importing sys would fix this. > > docs say it accepts from sys.stdin > > > On Mon, Apr 28, 2014 at 1:55 PM,

Re: [Tutor] Stephen Mik-Almost Brand New to Python 3.4.0-"Guess My Number" program is syntactically correct but will not run as expected

2014-04-28 Thread C Smith
The reason this is happening here is you need to import sys. > I don't know why you would think importing sys would fix this. docs say it accepts from sys.stdin On Mon, Apr 28, 2014 at 1:55 PM, Philip Dexter wrote: > > > On Mon, 28 Apr 2014, C Smith wrote: >

Re: [Tutor] Stephen Mik-Almost Brand New to Python 3.4.0-"Guess My Number" program is syntactically correct but will not run as expected

2014-04-28 Thread C Smith
I should probably clarify that this list is mainly for python2.7, correct me if I am wrong. On Mon, Apr 28, 2014 at 1:49 PM, C Smith wrote: > That is definitely more useful information in answering your questions. > Whenever you see the error you are getting: > > Nam

Re: [Tutor] Stephen Mik-Almost Brand New to Python 3.4.0-"Guess My Number" program is syntactically correct but will not run as expected

2014-04-28 Thread C Smith
That is definitely more useful information in answering your questions. Whenever you see the error you are getting: NameError: name 'smv_guessNumber' is not defined That means you are using a variable, in this case 'smv_guessNumber', that has not been created yet. The reason this is happening he

Re: [Tutor] converting strings to float: strange case

2014-04-28 Thread C Smith
.split() will split things based on whitespace or newlines. Do you know that your file is only going to contain things that should convert to floats? If you post your entire code, the error you have included will be more helpful as it points to a certain line. The last line in your code has (stri)

Re: [Tutor] Help needed

2014-04-26 Thread C Smith
ere is some other function that can be used to > display the output in desired order but don't see it possible thats why was > wondering if any of you Python gurus have any inputs for me :-) > > > > On Sat, Apr 26, 2014 at 12:36 PM, C Smith wrote: > >> err, set also

Re: [Tutor] Help needed

2014-04-26 Thread C Smith
err, set also is unordered. I can see you are using set for a reason, but has no concept of order. On Sat, Apr 26, 2014 at 3:20 PM, C Smith wrote: > Just glancing at your work, I see you have curly braces around what looks > like it should be a list. If you are concerned with the order o

Re: [Tutor] Help needed

2014-04-26 Thread C Smith
Just glancing at your work, I see you have curly braces around what looks like it should be a list. If you are concerned with the order of your output, dictionaries do not have a concept of order. On Sat, Apr 26, 2014 at 3:16 PM, Suhana Vidyarthi wrote: > Hi Danny, > > Let me give you a high le

Re: [Tutor] Difficulty in getting logged on to python.org; want to resubscribe at the beginner level; finding "While" Loops in Python 3.4.0 to be extremely picky

2014-04-25 Thread C Smith
You can get python 3.4 to work on your mac, but it has 2.5 or 2.4 which the OS uses and things can get very messed up if you don't know what you are doing. You should use virtualbox to run virtual OS's on your mac without messing up your main computer. You should probably describe what kind of err

Re: [Tutor] What can I do if I'm banned from a website??

2012-10-10 Thread c smith
how could someone know enough to write their own web-scraping program and NOT know that this is not about python or how to get around this problem? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.o

Re: [Tutor] Filename match on file extensions

2012-10-02 Thread c smith
Would this be a time when regex is necessary? Maybe: \b[^.]*quarantine[^.]*\.[a-zA-Z]*\b ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] python help?

2012-10-01 Thread c smith
It is hard to see things like images and attachments. I think purely html is preferred, but i would have to look over 'the list rules' again. You should look into dictionaries as the structure to hold your info. ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] HELP!

2012-10-01 Thread c smith
Is the only problem that your code is giving unexpected results, or that it doesnt run or what? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] html checker

2012-10-01 Thread c smith
yourlisthere.pop() will return the last element in the list and change the list so it no longer contains the element. yourlisthere.push(x) will add x to the end of the list. Works on more than just lists ___ Tutor maillist - Tutor@python.org To unsubscr

Re: [Tutor] html checker

2012-10-01 Thread c smith
You will not find much help in getting a program to 'just work' regardless of your own experience. My advice would be to try and run small parts at a time to pinpoint where the problem is. Are you opening and reading the file properly? Are you iterating over the read file properly? Does your html c

Re: [Tutor] Running a script in the background

2012-09-01 Thread c smith
You are thinking of && & is what you want ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] help with a recursive function

2011-09-27 Thread c smith
hi list, i understand the general idea of recursion and if I am following well written code I can understand how it works, but when I try to write it for myself I get a bit confused with the flow. I was trying to turn an ackerman function into python code for practice and I tried writing it like th

[Tutor] making lists of prime numbers

2011-09-14 Thread c smith
hi list, i am trying the MIT opencourseware assignments. one was to find the 1000th prime. since this isn't actually my homework, I modified the solution as I would like to collect lists of primes and non-primes up to N, also some log() ratio to one comparison. here is what I came up with on paper:

[Tutor] how obsolete is 2.2, and a pickle question

2011-09-07 Thread c smith
I found a book at the local library that covers python but it's 2.2. I already have been using 2.7 for basic stuff and would like to know if it's worth my time to read this book. Are there any glaring differences that would be easy to point out, or is it too convoluted? Also, am I correct in thinki

[Tutor] how obsolete is 2.2?

2011-09-07 Thread c smith
I found a book at the local library that covers python but it's 2.2. I already have been using 2.7 for basic stuff and would like to know if it's worth my time to read this book. Are there any glaring differences that would be easy to point out, or is it too convoluted? Also, am I correct in thinki

Re: [Tutor] Sorting of files based on filesize

2005-04-11 Thread C Smith
--request for a method of sorting disk files based on size so as to fill backup disks-- You may want to check out the karp.py routine posted at http://aspn.activestate.com/ASPN/Mail/Message/python-Tutor/749797 Right now it is coded to split N numbers into 2 groups that have sums as nearly identi

Re: [Tutor] Flatten

2005-04-11 Thread C Smith
Sorry for the delay in answering. Bill Mill wrote: [cut] 1) you should special-case dictionaries: > >> x = [1, 2, [3, 4, 5, [[6, 7], 8]], 'abc', 9, [10, 11], {'test': 12}] > >> flatten(x) > >> x [1, 2, 3, 4, 5, 6, 7, 8, 'abc', 9, 10, 11, 'test'] OK, now it only handles lists and tuples 2) What's

Re: [Tutor] str.split and quotes

2005-04-08 Thread C Smith
Tony wrote: With Python 2.4 I get these results (all imports are factored out, all givethe same result except for CSV which strips the "s) with timeit.py: Just a note here in terms of results.  Although the results are all the same and they work for the case where there is single quoted phrase wit

[Tutor] flatten

2005-04-07 Thread C Smith
After posting the suggestion about splitting a string that contained a quoted string, I looked back at my (at least I think it’s mine) flatten routine and didn’t see anything like it at ASPN. Before I would post it there, does anyone see any problems with this non-recursive approach? I know

Re: [Tutor] str.split and quotes

2005-04-06 Thread C Smith
I wish it would leave the stuff in quotes in tact: If you first split on your delimiter (which must have a matching one) you will obtain a list in which every odd position contains a string that was quoted. Step through the result and split the ones that are not quoted ones but don't do anythin

Re: [Tutor] one line code

2005-04-04 Thread C Smith
From: "Alan Gauld" <[EMAIL PROTECTED]> With other words I'd like to tell Python: Convert into a float if possible, otherwise append anyway. [ (type(x) == type(5) and float(x) or x) for x in mylist ] This is a perfect opportunity to give the reminder that the conversion functions are also types tha

Re: [Tutor] I am puzzled - help needed

2005-03-31 Thread C Smith
I need to rewrite the high_low.py program (see below) to use the last two digits of time at that moment to be the "random number". Be sure you understand what format the time number has and that you understand the problem statement. Here are two time values: 1112306463.0 1112306463.01 Do you se

Re: [Tutor] Math Question

2005-03-29 Thread C Smith
On Tuesday, Mar 22, 2005, at 15:34 America/Chicago, [EMAIL PROTECTED] wrote: When I adjust coumadin doses I normal have to use whole or half pills of the medicien the patient already has. Fer Instance, if a pt takes 5mg of coumadin a day, that's 35mg of coumadin week and suppose I do a test that

[Tutor] Re: If elif not working in comparison

2005-03-29 Thread C Smith
> gerardo arnaez wrote: > >> On Mon, 28 Mar 2005 09:27:11 -0500, orbitz >> wrote: >> >>> Floats are inherintly inprecise. So if thigns arn't working like you >>> expect don't be surprised if 0.15, 0.12, and 0.1 are closer to the same >>> number than you think. >> >> >> >> Are you telling me tha

Re: [Tutor] Float precision untrustworthy~~~

2005-03-29 Thread C Smith
On Monday, Mar 28, 2005, at 22:11 America/Chicago, [EMAIL PROTECTED] wrote: [cut] the mere fact that floats are difficult to check with equality has bitten me more than anything I've met yet in python. [cut] I understand what you are talking about, but I tend toward just making it one of the thin

Re: [Tutor] primes - sieve of odds

2005-03-23 Thread C Smith
Now it would be fine to have an *equally fast* infinite prime number generator. Has anybody any suggestions? [cut] What follows is an attempt based on the previous tutor-evolved sieve that extends the range in which to find the next prime by a factor of 2 over the last known prime. A similar alg

Re: [Tutor] primes - sieve of odds

2005-03-23 Thread C Smith
On Wednesday, Mar 23, 2005, at 04:00 America/Chicago, [EMAIL PROTECTED] wrote: Now it would be fine to have an *equally fast* infinite prime number generator. Has anybody any suggestions? I think when you add the condition of it being an infinite generator, you are changing the rules and can't e

Re: [Tutor] primes - sieve of odds

2005-03-22 Thread C Smith
Hi Gregor, I had done the same thing. I also noted that assigning (or inserting) an element into a list is faster than creating a new list: l.insert(0,2) is faster than l = [2]+l. ### def sieve (maximum): if maximum < 2: return [] limit = int(maximum**0.5) nums = range(1,maximum+

Re: [Tutor] Looking for a Pythonic way to pass variable

2005-03-22 Thread C Smith
On Tuesday, Mar 22, 2005, at 05:01 America/Chicago, [EMAIL PROTECTED] wrote: I met a similar question. what if one has L = [[1,2],[3,4]], K = [100, 200] How to 'zip' a List like [[1,2,100], [3,4,200]]? I would do something like: ### for i in range(len(L)): L[i].append(K[i]) ### /c _

Re: [Tutor] primes

2005-03-17 Thread C Smith
On Thursday, Mar 17, 2005, at 17:49 America/Chicago, [EMAIL PROTECTED] wrote: On my system, it took 415 seconds to generate a list of primes < 50,000 using range, but only 386 seconds if I use the same code, but with xrange instead. If you only calculate y up to sqrt(x) you will see a dramatic

Re: [Tutor] creating a tab delimited filename

2005-03-16 Thread C Smith
Hi Jacob, Watch out with your code, ### if i==1000: i=0 else: i=i+1 ### Since this test is done after you have stored your data you are actually going to store 1001 pieces of data. i starts at 0 you store 0 you do your test and i is incremented {that's set 1} i is 1 you store

Re: [Tutor] creating a tab delimited filename

2005-03-15 Thread C Smith
On Tuesday, Mar 15, 2005, at 05:01 America/Chicago, [EMAIL PROTECTED] wrote: how am i going to change the filename automaticaly? for example: #every 5 minutes, i am going to create a file based on the data above for i in range(100) output_file = file('c:/output' +.join(i) +'.txt

Re: [Tutor] help

2005-03-13 Thread C Smith
On Sunday, Mar 13, 2005, at 05:01 America/Chicago, [EMAIL PROTECTED] wrote: if this is not a program please teach me what is a program and what i need to know to write them and if this is a program teach me how to write better programs i can use outside of the python shell... OK, how about this

Re: [Tutor] working with new classes

2005-03-09 Thread C Smith
Thanks to Sean and Kent for replies. I found a site that provided some good examples, too, at http://www.cafepy.com/articles/python_attributes_and_methods/ ch03s02.html Here's a blurb from the title page: wep page excerpt Shalabh Chaturvedi Copyright © 2004 Shalabh Chaturvedi This book

[Tutor] working with new classes

2005-03-08 Thread C Smith
Hello, After learning about the new class behavior, I am trying to implement a circular type list where, for example, you can compare the nth value to the "(n+1)th" value without worrying about going past the end of the list. (An old approach might be to create a function that converts a given

[Tutor] Re: Printing two elements in a list

2004-12-19 Thread C Smith
Jacob S. wrote: Would this work for you? a = ['Name = stuff','CGTATAGCTAGCTA','Name = stuff','CGATATGCCGGCTA'] for index,thing in enumerate(a): if "Name=" in thing: del a[index] I know, that it might be slow, but I thought that maybe it would hold its own because it doesn't have to imp