Re: [Tutor] need help; save web data

2008-06-29 Thread Kent Johnson
On Sat, Jun 28, 2008 at 9:54 PM, Michael Miesner <[EMAIL PROTECTED]> wrote: > Hi all- > I am trying to save the output of a web search to a local file, using > python. > Im really new to this, but I want to be able to write a program that uses > google scholar, but takes search results and saves th

[Tutor] need help; save web data

2008-06-28 Thread Michael Miesner
Hi all- I am trying to save the output of a web search to a local file, using python. Im really new to this, but I want to be able to write a program that uses google scholar, but takes search results and saves them to a local file. I am perfectly fine with playing around wtih this until I get it,

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Kelie
Mark Tolonen gmail.com> writes: > re.compile(r'^_{0,3}[A-Z](?:[A-Z0-9]|-(?!-))*[A-Z0-9]$') # if rule 4 is an > additional letter or digit > re.compile(r'^_{0,3}[A-Z](?:[A-Z0-9]|-(?!-))*(? single-letter strings are allowed > Mark, single-letter strings are allowed and your regular expression w

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Kelie
Dick Moores gmail.com> writes: > I'm not sure of your 5th condition. Do you mean, "A hyphen should not > be immediately followed by a hyphen"? Could you give examples of what > you will permit, and will not permit? Dick, your are correct. A hyphen should not be immediately followed by a hyphen.

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Mark Tolonen
"Kelie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, I'm trying to write a regular expression to filter strings that meet the following criteria: 1. Starts with 0-3 underscores; 2. Followed by one letter; 3. Then followed by 0 or more letters or digits or hyphens('-'), 4

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Lie Ryan
On Sat, 2008-06-28 at 17:39 +0200, Andre Engels wrote: > On Sat, Jun 28, 2008 at 3:21 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: > > > > I think > > > > > > _{0,3}[A-Z](\-?[A-Z0-9])+ > > > > > > will do what you are looking for. > > > > That, doesn't allow single hyphen, which his requirement al

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Andre Engels
On Sat, Jun 28, 2008 at 3:21 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: > > I think > > > > _{0,3}[A-Z](\-?[A-Z0-9])+ > > > > will do what you are looking for. > > That, doesn't allow single hyphen, which his requirement allowed as long > as it (the hypehn) is not as the first or last character.

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Lie Ryan
>> Hello, >> >> I'm trying to write a regular expression to filter strings that meet > the >> following criteria: >> >> 1. Starts with 0-3 underscores; >> 2. Followed by one letter; >> 3. Then followed by 0 or more letters or digits or hyphens('-'), >> 4. Ends with one letter or digit;

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Andre Engels
On Sat, Jun 28, 2008 at 11:15 AM, Kelie <[EMAIL PROTECTED]> wrote: > Hello, > > I'm trying to write a regular expression to filter strings that meet the > following criteria: > > 1. Starts with 0-3 underscores; > 2. Followed by one letter; > 3. Then followed by 0 or more letters or digits or hyphen

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Lie Ryan
Filter it. Use two re, one the one you've made, the other the double hyphen filter: pat2 = re.compile('.*?\-\-.*?') If the string matches this re, then the string is rejected, if it DOES NOT match (i.e. pat2.match('blah') returns None, i.e. if not pat2.match('blah')), then it is accepted. btw: Y

Re: [Tutor] need help with a regular expression

2008-06-28 Thread Dick Moores
On Sat, Jun 28, 2008 at 2:15 AM, Kelie <[EMAIL PROTECTED]> wrote: > Hello, > > I'm trying to write a regular expression to filter strings that meet the > following criteria: > > 1. Starts with 0-3 underscores; > 2. Followed by one letter; > 3. Then followed by 0 or more letters or digits or hyphens

[Tutor] need help with a regular expression

2008-06-28 Thread Kelie
Hello, I'm trying to write a regular expression to filter strings that meet the following criteria: 1. Starts with 0-3 underscores; 2. Followed by one letter; 3. Then followed by 0 or more letters or digits or hyphens('-'), 4. Ends with one letter or digit; and 5. There should not be more than o

Re: [Tutor] Need help with sockets

2008-04-19 Thread Alan Gauld
"James Duffy" <[EMAIL PROTECTED]> wrote > C# so I just need a client side program that can listen for and > display > incoming messages as well as send messages. Ive managed to make a > socket and > connect but I don't know how to setup a listen thread and a sender > function. Tale a look at

[Tutor] Need help with sockets

2008-04-19 Thread James Duffy
For a part of a program, I need to send a text string to another machine in a IM style app. I've done this in C# but never in python. The server is in C# so I just need a client side program that can listen for and display incoming messages as well as send messages. Ive managed to make a socket and

Re: [Tutor] Need help with structure unpacking module

2008-03-18 Thread ALAN GAULD
CCing the list. Please use Reply All when responding. > I am still little confused since I was under the impression, > that if a c program was able to write this binary code, > then if we know how c "packed" the data/string then > we able to decode/unpack it using python. Thats correct but y

Re: [Tutor] Need help with structure unpacking module

2008-03-18 Thread Alan Gauld
"Alan Gauld" <[EMAIL PROTECTED]> wrote >>>>>first = struct.unpack('', '\x02\x00') >> error: unpack requires a string argument of length 4 > > And here you asked for 54 characters but only gave > it two bytes. And the two byes were 02 and 00 which > are not printable characters. Oo

Re: [Tutor] Need help with structure unpacking module

2008-03-18 Thread Luke Paireepinart
Nirmal Sakthi wrote: > I am using module struct.unpack() to decode data from a binary file, > so that I can use the value in a calculation. > > I have been able to extract an integer value. > > >>>length = struct.unpack('i', '\x9c\x00\x00\x00') > >>>length = int(length[0]) > >>>

Re: [Tutor] Need help with structure unpacking module

2008-03-18 Thread Alan Gauld
"Nirmal Sakthi" <[EMAIL PROTECTED]> wrote > I want to be able to extract a string. > > I have tried, > >>>>first = struct.unpack('s', '\x02\x00') >>>>first = str(first[0]) >>>>print first >Traceback (most recent call last): > .. >error: unpack requires a string argument of

[Tutor] Need help with structure unpacking module

2008-03-18 Thread Nirmal Sakthi
I am using module struct.unpack() to decode data from a binary file, so that I can use the value in a calculation. I have been able to extract an integer value. >>>length = struct.unpack('i', '\x9c\x00\x00\x00') >>>length = int(length[0]) >>>print length 156 I want to be able

Re: [Tutor] Need help with encoder & decryption keys

2008-03-03 Thread Andreas Kostyrka
Well, actually, ssh can also protect private keys with a cryptographic pass phrase. But this is often not what is wanted as it implies that the user needs to provide the pass phrase every time it is used. (Well, that's not the complete truth, man ssh-agent, but that's completely different thing

Re: [Tutor] Need help with encoder & decryption keys

2008-03-03 Thread Andreas Kostyrka
And if it's a string constant, in many cases running strings (Unix program) on the pyc file will reveal it too. All this basically turns down to the problem, that it's hard to embed an encryption key in a program, so that it's not possible to extract it. Notice the the current crop of HDDVD/Blu

Re: [Tutor] Need help with encoder & decryption keys

2008-03-01 Thread Chris Fuller
On Friday 29 February 2008 16:30, Trey Keown wrote: > Hey all, > Been away for a while. So, I'm in the process of making a program for > encrypting and decrypting strings of text. And I was wondering how it > would be possible to perhaps keep keys in a .pyc file, and keep them > from being isolat

Re: [Tutor] Need help with encoder & decryption keys

2008-03-01 Thread Kent Johnson
Trey Keown wrote: > mmm... So, what would be an effective way to hide the data's key? > I'm kind of new to the whole encryption scene, although I've had some > experience with it whilst working on homebrew software on gaming > platforms. I don't know, I'm not a crypto expert. I guess it depends p

Re: [Tutor] Need help with encoder & decryption keys

2008-02-29 Thread Kent Johnson
Trey Keown wrote: > is it > possible to decompile things within a .pyc file? Yes, it is possible. There is a commercial service that will do this, for older versions of Python at least. To figure out a secret key kept in a .pyc file it might be enough to disassemble functions in the module; tha

Re: [Tutor] Need help with encoder & decryption keys

2008-02-29 Thread Alan Gauld
"Trey Keown" <[EMAIL PROTECTED]> wrote > from being isolated, and messages being intercepted. So... is it > possible to decompile things within a .pyc file? Yes its definitely possible and in fact not even difficult - the tools come with Python. Do not do that if you want real security. Use a s

[Tutor] Need help with encoder & decryption keys

2008-02-29 Thread Trey Keown
Hey all, Been away for a while. So, I'm in the process of making a program for encrypting and decrypting strings of text. And I was wondering how it would be possible to perhaps keep keys in a .pyc file, and keep them from being isolated, and messages being intercepted. So... is it possible to de

Re: [Tutor] Need help speeding up algorithm.

2007-10-02 Thread Terry Carroll
Ian, thanks for cleaning this up and submitting it. I was curious what its performance would be. On Wed, 26 Sep 2007, Ian Witham wrote: > while count > 0: > fivecount += count > count /= 5 This is a great improvement, and I'm embarrased that I didn't think of it myself!

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Ian Witham
On 9/26/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > > On Tue, 25 Sep 2007, Ian Witham wrote: > > def numfaczeroes(n): > """ > return the count of trailing zeroes from n! > e.g., 10! = 3628800; count of trailing zeros = 2 > """ > exponent = 1 > fivecount = 0 > while (n

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Ian Witham
On 9/26/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > > On Wed, 26 Sep 2007, Ian Witham wrote: > > > My solution still took over 5 seconds on the Sphere Judge machine. > > How much data are they throwing at you? For the sample data they provide > on the website, your first "slow" solution finishe

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Terry Carroll
On Wed, 26 Sep 2007, Ian Witham wrote: > My solution still took over 5 seconds on the Sphere Judge machine. How much data are they throwing at you? For the sample data they provide on the website, your first "slow" solution finished on my machine almost instantaneously. _

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Ian Witham
> > > from itertools import count, takewhile > > def numfaczeroes2(n): > def while_(e): > return n//(5**e) > 0 > return sum(n//(5**exponent) for exponent in takewhile(while_, > count(1))) > > > It is quite a bit slower, though; probably because of the extra function > call introd

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Kent Johnson
Terry Carroll wrote: > On Tue, 25 Sep 2007, Ian Witham wrote: > >> As I was using a list comprehension I wasn't sure how to make the >> calculations stop when the result of integer division == 0. > > I don't see how to do that, either. Someone on this list (sorry, I forget > who) once suggested

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Terry Carroll
On Tue, 25 Sep 2007, Ian Witham wrote: > As I was using a list comprehension I wasn't sure how to make the > calculations stop when the result of integer division == 0. I don't see how to do that, either. Someone on this list (sorry, I forget who) once suggested that the list comprehension shou

Re: [Tutor] Need help speeding up algorithm. (Terry Carroll)

2007-09-25 Thread Carnell, James E
Terry, I liked your answer! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Need help speeding up algorithm.

2007-09-24 Thread Ian Witham
On 9/25/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > > On Tue, 25 Sep 2007, Ian Witham wrote: > > > I am attempting to do this project > for > > the Sphere Online Judge. > > (Summary of the problem: for a given integer N, determine the number of > trailing ze

Re: [Tutor] Need help speeding up algorithm.

2007-09-24 Thread Terry Carroll
On Tue, 25 Sep 2007, Ian Witham wrote: > I am attempting to do this project for > the Sphere Online Judge. (Summary of the problem: for a given integer N, determine the number of trailing zeroes in N! For example, for N=10, N! = 3628800, so the number of t

[Tutor] Need help speeding up algorithm.

2007-09-24 Thread Ian Witham
Hello, I am attempting to do this project for the Sphere Online Judge. I think my program is getting the right answer, however it exceeds the 6s time limit on the judge machine. Here is my code: import sys testnums = [] tests = int(sys.stdin.r

Re: [Tutor] Need help on "How to Think Like a Computer Scientist: Learning with Python".

2007-08-15 Thread Luke Paireepinart
Vanneth Tea wrote: > Hello All, > > I am new to computer programming and chose to learn > Python. Now I am stuck with certain codes that I need > help. Please let me know if there is an answer list > to the exercises in "How to Think Like a Computer > Scientist: Learning with Python." > > I follo

Re: [Tutor] Need help on "How to Think Like a Computer Scientist:Learning with Python".

2007-08-15 Thread Alan Gauld
"Vanneth Tea" <[EMAIL PROTECTED]> wrote > have been stuck on a few of them which burned me up > after spending days and nights trying ... > I hope you understand the feeling when you are stuck Yep we all understand and sympathise. But before we can help you we need some more information. Like

Re: [Tutor] Need help on "How to Think Like a Computer Scientist:Learning with Python".

2007-08-15 Thread Henry Dominik
ECTED]> To: Sent: Wednesday, August 15, 2007 6:08 PM Subject: [Tutor] Need help on "How to Think Like a Computer Scientist:Learning with Python". > Hello All, > > I am new to computer programming and chose to learn > Python. Now I am stuck with certain codes that I need &

Re: [Tutor] Need help on "How to Think Like a Computer Scientist: Learning with Python".

2007-08-15 Thread Kent Johnson
Vanneth Tea wrote: > Hello All, > > I am new to computer programming and chose to learn > Python. Now I am stuck with certain codes that I need > help. Where are you stuck? We should be able to help you here if you can be more specific. It helps us to help you if you can show us - the code yo

Re: [Tutor] Need help on "How to Think Like a Computer Scientist: Learning with Python".

2007-08-15 Thread Eric Brunson
I don't know of an answer key, but feel free to post questions about what you're having trouble with and we'd be happy to discuss various approaches among the list members. Vanneth Tea wrote: > Hello All, > > I am new to computer programming and chose to learn > Python. Now I am stuck with cer

Re: [Tutor] Need help on "How to Think Like a Computer Scientist: Learning with Python".

2007-08-15 Thread bhaaluu
Greetings, I think the accepted way to get help on this list is to post the code you're having problems with, showing what you've done, the error messages you're getting, and an explanation of what you're trying to do, the input, output expected, and so forth. It is helpful for the Tutors to also

Re: [Tutor] Need help on "How to Think Like a Computer Scientist: Learning with Python".

2007-08-15 Thread Amadeo Bellotti
I don't know of any answer list but one you can ask for help here or what I do when I have a question i stop working on it for anywhere from an hour to a week and go back to it you will solve it if you solve it in your sleep well thats a whole other issue but that does happen. -Amadeo On 8/15/07,

[Tutor] Need help on "How to Think Like a Computer Scientist: Learning with Python".

2007-08-15 Thread Vanneth Tea
Hello All, I am new to computer programming and chose to learn Python. Now I am stuck with certain codes that I need help. Please let me know if there is an answer list to the exercises in "How to Think Like a Computer Scientist: Learning with Python." I followed and did good on most of the exe

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-08 Thread Dick Moores
At 06:32 PM 1/7/2007, Terry Carroll wrote: >I may add this algorithm to the cookbook. You should. Dick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-07 Thread Terry Carroll
On Sun, 7 Jan 2007, Terry Carroll wrote: > ...Say you want to get an approximation of 0.096. Well, a good first > approximation is 1/10. But 1/10 is 0.010 Um, that should be "...is 0.100" ___ Tutor maillist - Tutor@python.org http://mail.pytho

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-07 Thread Terry Carroll
On Sat, 6 Jan 2007, Dick Moores wrote: > Well, I have to admit I don't understand your code at all. But I see it > works. A continuing fraction is an expression that looks like this: 1 A + -- 1 B +

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-06 Thread Dick Moores
At 10:40 AM 1/6/2007, Dick Moores wrote: >At 11:21 PM 1/4/2007, Terry Carroll wrote: > >On Wed, 3 Jan 2007, Dick Moores wrote: > > > > > Be that as it may, farey() is an amazing program. > > > >Not to beat this subject to death, but the comment at the bottom of > >http://aspn.activestate.com/ASPN/C

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-06 Thread Dick Moores
At 11:21 PM 1/4/2007, Terry Carroll wrote: >On Wed, 3 Jan 2007, Dick Moores wrote: > > > Be that as it may, farey() is an amazing program. > >Not to beat this subject to death, but the comment at the bottom of >http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52317 about >continued fractions

Re: [Tutor] need help with sending email

2007-01-06 Thread Alan Gauld
"Luke Paireepinart" <[EMAIL PROTECTED]> wrote > do you guys buy SMS messages or is there some way to communicate > with > text message users for free? Just to blow my own companies trumpet for once, if you sign up to our new Web21C SDK you get a certain number of SMS messages/month for free as p

Re: [Tutor] need help with sending email

2007-01-06 Thread Christopher Arndt
Luke Paireepinart schrieb: > Just wondering - > do you guys buy SMS messages or is there some way to communicate with > text message users for free? There are some providers that give you a certain amount of SMS per month for free, even if you only have a prepaid SIM card. O2 Ireland is an exampl

Re: [Tutor] need help with sending email

2007-01-06 Thread Luke Paireepinart
shawn bright wrote: > this is really cool. working too, > we have one provider now that it does not work with, but i think its > them this time. > thanks for your help on this Just wondering - do you guys buy SMS messages or is there some way to communicate with text message users for free? Thank

Re: [Tutor] need help with sending email

2007-01-05 Thread shawn bright
this is really cool. working too, we have one provider now that it does not work with, but i think its them this time. thanks for your help on this shawn On 1/5/07, Christopher Arndt <[EMAIL PROTECTED]> wrote: shawn bright schrieb: > lo there all. > > i am in a tight spot because i need to sen

Re: [Tutor] need help with sending email

2007-01-05 Thread Christopher Arndt
shawn bright schrieb: > lo there all. > > i am in a tight spot because i need to send an email that it mime > encoded plain-text ( not html or anything ) > > anyone know of a good tutorial or recipe out there ? Simplified example from http://www.python.org/doc/current/lib/node162.html: # Import

Re: [Tutor] need help with sending email

2007-01-05 Thread Kent Johnson
shawn bright wrote: > right, thanks, Mike. > i can send an email fine. Some of the providers we are trying to reach > will reject anything that is not content type: text-plain > > thats what i need to know how to add. The first example on this page seems to do what you want: http://docs.python.o

Re: [Tutor] need help with sending email

2007-01-05 Thread shawn bright
l Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of shawn bright > Sent: Friday, January 05, 2007 10:18 AM > To: tutor-python > Subject: [Tutor] need help with sending email > > lo there all. > > i am in a tight spot because i need to send an email tha

Re: [Tutor] need help with sending email

2007-01-05 Thread Mike Hansen
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of shawn bright > Sent: Friday, January 05, 2007 10:18 AM > To: tutor-python > Subject: [Tutor] need help with sending email > > lo there all. > > i am in a tight spot b

[Tutor] need help with sending email

2007-01-05 Thread shawn bright
lo there all. i am in a tight spot because i need to send an email that it mime encoded plain-text ( not html or anything ) no attachements, no images, just text from a string. like message = 'some message' all the tutorials i find out there, and the cookbook recipies are for sending multipart me

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-04 Thread Terry Carroll
On Wed, 3 Jan 2007, Dick Moores wrote: > Be that as it may, farey() is an amazing program. Not to beat this subject to death, but the comment at the bottom of http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52317 about continued fractions piqued my interest. I'm no mathematician, but

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-04 Thread Dick Moores
At 08:20 AM 1/4/2007, Terry Carroll wrote: >On Wed, 3 Jan 2007, Dick Moores wrote: > > > Terry, I just noticed that farey(0.36, 10) returns (1, 3), a pretty > > big miss, IMO. The correct fraction with smallest error and maximum > > denominator of 10 is 3/8, which I'm proud to say my klunky frac.py

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-04 Thread Terry Carroll
On Wed, 3 Jan 2007, Dick Moores wrote: > Terry, I just noticed that farey(0.36, 10) returns (1, 3), a pretty > big miss, IMO. The correct fraction with smallest error and maximum > denominator of 10 is 3/8, which I'm proud to say my klunky frac.py > (

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-03 Thread Dick Moores
At 01:17 PM 1/2/2007, Terry Carroll wrote: >On Mon, 1 Jan 2007, Dick Moores wrote: > > > bestFracForMinimumError() is only a small part of a program I wrote > > long ago, called frac.py > >Dick, if your goal is to have a routine to get the fraction with the least >possible error (as opposed to lear

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-03 Thread Danny Yoo
>> Dick, if your goal is to have a routine to get the fraction with the least >> possible error (as opposed to learing how to use Decimal), have a look at >> this recipe from the Python Cookbook: >> >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52317 > > Terry, that is truly ingenio

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-03 Thread Terry Carroll
On Wed, 3 Jan 2007, Dick Moores wrote: > At 01:17 PM 1/2/2007, Terry Carroll wrote: > > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52317 > > Terry, that is truly ingenious. Is there an explication anywhere of > exactly how it works? There is in the printed copy of the Python Coo

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-03 Thread Dick Moores
At 01:17 PM 1/2/2007, Terry Carroll wrote: >On Mon, 1 Jan 2007, Dick Moores wrote: > > > bestFracForMinimumError() is only a small part of a program I wrote > > long ago, called frac.py > >Dick, if your goal is to have a routine to get the fraction with the least >possible error (as opposed to lear

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-03 Thread Dick Moores
At 10:39 AM 1/2/2007, Kent Johnson wrote: >Dick Moores wrote: >>from decimal import Decimal as D >>def bestFracForMinimumError(decimal, minimumError): >> denom = 0 >> while True: >> denom += 1 >> num = round(D(str(decimal)) * D(str(denom))) >> error = abs(str((s

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-02 Thread Terry Carroll
On Tue, 2 Jan 2007, Terry Carroll wrote: > Dick, if your goal is to have a routine to get the fraction with the least > possible error (as opposed to learing how to use Decimal), have a look at > this recipe from the Python Cookbook: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-02 Thread Terry Carroll
On Mon, 1 Jan 2007, Dick Moores wrote: > bestFracForMinimumError() is only a small part of a program I wrote > long ago, called frac.py Dick, if your goal is to have a routine to get the fraction with the least possible error (as opposed to learing how to use Decimal), have a look at this rec

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-02 Thread Kent Johnson
Dick Moores wrote: > from decimal import Decimal as D > > def bestFracForMinimumError(decimal, minimumError): > denom = 0 > while True: > denom += 1 > num = round(D(str(decimal)) * D(str(denom))) > error = abs(str((str(D(num) / D(str(denom))) - This looks back

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-02 Thread Dick Moores
from decimal import Decimal as D def bestFracForMinimumError(decimal, minimumError): denom = 0 while True: denom += 1 num = round(D(str(decimal)) * D(str(denom))) error = abs(str((str(D(num) / D(str(denom))) - D(str(decimal))) / str(D(str(decimal)) * d("100"))

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-01 Thread Dick Moores
At 05:37 AM 1/1/2007, Kent Johnson wrote: >Dick Moores wrote: >>bestFracForMinimumError() is only a small part of a program I wrote >>long ago, called frac.py >>(). I'm trying to >>rewrite it so as to get more precision by using the Decimal module, >>

Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-01 Thread Kent Johnson
Dick Moores wrote: > bestFracForMinimumError() is only a small part of a program I wrote > long ago, called frac.py > (). I'm trying to rewrite > it so as to get more precision by using the Decimal module, but am > getting nowhere. Errors all over the

[Tutor] Need help with rewriting script to use Decimal module

2007-01-01 Thread Dick Moores
bestFracForMinimumError() is only a small part of a program I wrote long ago, called frac.py (). I'm trying to rewrite it so as to get more precision by using the Decimal module, but am getting nowhere. Errors all over the place. Can some kind and kn

[Tutor] need help for using ssl in python

2006-11-14 Thread Akanksha Govil
Hi,I need to create an ssl socket. But i am getting the folowing error:Traceback (most recent call last):  File "client-Nextone.py", line 35, in ?    resp = port.editCallPlanConfig(req)  File "/home/nabanita/new_soap_zsi/NexToneSubnet_services.py", line 38, in editCallPlanConfig    self.binding.Sen

Re: [Tutor] Need Help

2006-07-11 Thread Luke Paireepinart
[snip] > It would be very cruel to not address the core reason why the student's > struggling. That's why we don't "answer" homework questions: it doesn't > address what's often a much bigger problem with the student's concepts of > programming. Thank you for this explanation, Danny. I thought

Re: [Tutor] Need Help

2006-07-11 Thread Marc Poulin
--- Terry Carroll <[EMAIL PROTECTED]> wrote: > On Tue, 11 Jul 2006, Michael P. Reilly wrote: > > > Another aspect of your assignment will be to be > able to use this > > functionality from the "command-line". This > means: without asking questions > > from the user, but input is being passed

Re: [Tutor] Need Help

2006-07-11 Thread Terry Carroll
On Tue, 11 Jul 2006, Michael P. Reilly wrote: > Another aspect of your assignment will be to be able to use this > functionality from the "command-line". This means: without asking questions > from the user, but input is being passed as arguments. John should get clarification from his instr

Re: [Tutor] Need Help

2006-07-11 Thread Kent Johnson
Shappell, John J CW2 wrote: > > Here is the assignment > > 1. You've been given an assignment by your supervisor to > program a small application to monitor the current status > of the cash account in the firm's petty cash fund (the > amount of cash kept

Re: [Tutor] Need Help

2006-07-11 Thread Michael P. Reilly
On 7/10/06, Shappell, John J CW2 <[EMAIL PROTECTED]> wrote: Here is the assignment You've been given an assignment by your supervisor to program a small application to monitor the current status of the cash account in the firm's petty cash fund (the amount of cash kept on hand in the off

Re: [Tutor] Need Help

2006-07-11 Thread Danny Yoo
> By posting the entire homework problem, John Shappell did give the > impression that he wanted us to do the problem for him, but as John > Montgomery notes he is just looking for a hint in an area where he is > stuck. That is fine for the tutor list. Since we know it is homework we > can use

Re: [Tutor] Need Help

2006-07-11 Thread Alan Gauld
> [snip assignment] > Please don't ask about homework in the future. Did your professor > tell you to submit queries to this list? If so, could you ask him > not to? it's against the policies of the tutor mailing list to give > homework help. Thats a bit extreme. We don't mind giving help on

Re: [Tutor] Need Help

2006-07-11 Thread Kent Johnson
John or Margaret Montgomery wrote: > On Tue, 11 Jul 2006 06:41:23 -0500 > Luke Paireepinart <[EMAIL PROTECTED]> wrote: > > >> Hi. >> Shappell, John J CW2 wrote: >> >>> Here is the assignment >>> >>> >> [snip assignment] >> Please don't ask about homework in the future. Did your prof

Re: [Tutor] Need Help

2006-07-11 Thread John or Margaret Montgomery
On Tue, 11 Jul 2006 06:41:23 -0500 Luke Paireepinart <[EMAIL PROTECTED]> wrote: > Hi. > Shappell, John J CW2 wrote: > > > > Here is the assignment > > > [snip assignment] > Please don't ask about homework in the future. Did your professor tell > you to submit queries to this list? If so, could

Re: [Tutor] Need Help

2006-07-11 Thread Luke Paireepinart
Hi. Shappell, John J CW2 wrote: > > Here is the assignment > [snip assignment] Please don't ask about homework in the future. Did your professor tell you to submit queries to this list? If so, could you ask him not to? it's against the policies of the tutor mailing list to give homework help.

[Tutor] Need Help

2006-07-11 Thread Shappell, John J CW2
Title: [Tutor] Need Help Here is the assignment You've been given an assignment by your supervisor to program a small application to monitor the current status of the cash account in the firm's petty cash fund (the amount of cash kept on hand in the office for incidental purch

Re: [Tutor] need help tracing a syntax error

2006-03-12 Thread Alan Gauld
> There was no actual message. The syntax error message to me > occurred in a dialog box which closed immediately. What development tool are you using? I would change it, if it doesn't display a full error trace then it is depriving you of one of the most useful tools in Python! > It's not

Re: [Tutor] need help tracing a syntax error

2006-03-11 Thread Alan Gauld
[CC'd to the list...] >> Also for the error merssage can you cut n paste the full error since >> they contain a lot of useful info, do not just give us a description of >> the error. >no error message was provided. > It only highlighted the variable in the If statement. But that's exactly what w

Re: [Tutor] need help tracing a syntax error

2006-03-11 Thread Alan Gauld
Hi, It would help us a lot if you send us a cut n paste of the actual code, not retyped versions. Particularly for syntax erros since a single wrong character might be all that's wrong and when you retype it its OK. I'm assuming you are retyping from the fact that you have uppercase keywords e

Re: [Tutor] need help tracing a syntax error

2006-03-11 Thread Danny Yoo
> I get the message > > syntax error > > > and it highlightsr2 > > in the line > > .If r2 == 1: Hi Kermit, Next time, rather than describe the error message here in paraphrase, please copy-and-paste it in. Your paraphrase of the situation here hides useful information. We would rather that

Re: [Tutor] need help tracing a syntax error

2006-03-11 Thread Python
On Sat, 2006-03-11 at 10:42 -0500, Kermit Rose wrote: > I get the message > > syntax error > > > and it highlightsr2 > > in the line > > .If r2 == 1: if should be lower case (all of the python syntax words are lower case) You will also need to change Else and Elif Int should probably b

[Tutor] need help tracing a syntax error

2006-03-11 Thread Kermit Rose
def vmod(a , b ): .r1 = b .r2 = a . m1 = 0 .m2 = 1 .q = Int(r1 / r2) .r3 = r1 - q * r2 .m3 = m1 - q * m2 .while r3 != 0: ...r1 = r2 ...m1 = m2 ...r2 = r3 ...m2 = m3 ...q = Int(r1 / r2) ...r3 = r1 - r2 * q ...m3 = m1 - m2 * q .If r2 == 1: ...If m2 < 0: .return( m2 + b) ...Else: .ret

Re: [Tutor] need help with syntax

2006-01-11 Thread bill nieuwendorp
This list is full of people ready to help, I thank you all for the time you have taken to reply. Danny now I see where readline could cause headaches,. Liam thanks for the examples they work great. The endianess will always be in Big Endian (Motorola type) for this format. I see why I should be

Re: [Tutor] need help with syntax

2006-01-11 Thread Liam Clarke
> > You mentioned earlier that you're expecting an integer, an integer, and > then a sequence of float. Don't count bytes if you can help it: let > Python's struct.calcsize() do this for you. > >http://www.python.org/doc/lib/module-struct.html > > Your machine may align bytes differently than

Re: [Tutor] need help with syntax

2006-01-11 Thread Danny Yoo
On Tue, 10 Jan 2006, bill nieuwendorp wrote: > I am trying to convert binary file to ascii > > here is the format spec > > steps = int 4 > value = int 4 > time = float 4 * steps Hi Bill, Ok, that structure seems fairly simple so far. > >>> import struct > >>> import string > >>> f = file('b

Re: [Tutor] need help with syntax

2006-01-10 Thread John Fouhy
On 11/01/06, bill nieuwendorp <[EMAIL PROTECTED]> wrote: > time = struct.unpack(">steps+f",c) > adding the f to tell structs it is in float format > > the string substitution > seems like it would work but now I cant figure out how I would add the > f on the end Did you read up on string substitu

Re: [Tutor] need help with syntax

2006-01-10 Thread bill nieuwendorp
Hi John thanks for the tips I had a bit of a typo in my first post time = struct.unpack(">steps",c) should read somthing more like time = struct.unpack(">steps+f",c) adding the f to tell structs it is in float format the string substitution seems like it would work but now I cant figure out h

Re: [Tutor] need help with syntax

2006-01-10 Thread John Fouhy
On 11/01/06, bill nieuwendorp <[EMAIL PROTECTED]> wrote: Hi Bill, Some comments --- > >>> import struct > >>> import string > >>> f = file('binary_file','rb') > >>> line = f.readline() > >>> L = tuple(line) You can do slicing (things like L[:4]) on strings as well as on lists and tuples. So th

[Tutor] need help with syntax

2006-01-10 Thread bill nieuwendorp
hello all I am new to python and this list has been helpfull so far I am trying to convert binary file to ascii here is the format spec steps = int 4 value = int 4 time = float 4 * steps so in the python terminal terminal i convert it like this >>> import struct >>> import string >>> f = file

[Tutor] Need help with wxListCtrl

2005-11-30 Thread Jacob S.
Resending due to change in subject line -- adding [Tutor] Also, I wish to point out now that I've noticed, the spacing on the diagram hasn't persisted If anyone wants a jpg or something, let me know. > Hi, long time no see. > > For you Spanish speakers: > > Yo tenía que aprender a poco españ

<    1   2   3   4   5   6   >