Re: [Tutor] ignoring diacritical signs

2013-12-02 Thread eryksun
On Mon, Dec 2, 2013 at 3:08 PM, Albert-Jan Roskam wrote: > > What is the difference between lower and casefold? > > casefold(...) > S.casefold() -> str > > Return a version of S suitable for caseless comparisons. > "Alala alala".casefold() == "Alala alala".lower() > True In 3.3, Unic

Re: [Tutor] Help with python

2013-12-02 Thread Steven D'Aprano
On Mon, Dec 02, 2013 at 04:33:27PM -0600, Blake wrote: > I'm writing a program to calculate totals and change for a menu, and > I'm having a few issues. If you could help me, it would be greatly > appreciated. Would you like us to guess what issues you are having? Let me look into my crystal

Re: [Tutor] Help with python

2013-12-02 Thread Mark Lawrence
On 02/12/2013 22:33, Blake wrote: I'm writing a program to calculate totals and change for a menu, and I'm having a few issues. If you could help me, it would be greatly appreciated. A little more data would help :) Some code, the OS and Python versions and the precise nature of the issues

[Tutor] Help with python

2013-12-02 Thread Blake
I'm writing a program to calculate totals and change for a menu, and I'm having a few issues. If you could help me, it would be greatly appreciated. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.pyth

Re: [Tutor] ignoring diacritical signs

2013-12-02 Thread spir
On 12/02/2013 04:53 PM, Steven D'Aprano wrote: Also, the above function leaves LATIN CAPITAL LETTER O WITH STROKE as Ø instead of stripping the stroke. I'm not sure whether that is an oversight or by design. Likewise for the lowercase version. You might want to do some post-processing: There's

Re: [Tutor] Alternatives to append() for "growing" a list

2013-12-02 Thread Danny Yoo
> > > I was told by someone (as a comment) that a code snippet such as this > "would make Pythonistas talk my ear off about how evil the append()" > function is: > > I think this thread demonstrates: we don't need an excuse to talk your ears off. :P Using append() is fine. If anything, the comm

Re: [Tutor] Hash map and dictionaries

2013-12-02 Thread Danny Yoo
> > It is also said that in a list of may be 10,000 elements(specifically > integers), hash maps would be a better option to find the occurrence of > repetitive integers > There's a lot of passive voice here, so I have no idea who you mean by this. Attribution would be nice; otherwise, it almost

Re: [Tutor] ignoring diacritical signs

2013-12-02 Thread Albert-Jan Roskam
On Mon, 12/2/13, Steven D'Aprano wrote: Subject: Re: [Tutor] ignoring diacritical signs To: tutor@python.org Date: Monday, December 2, 2013, 4:53 PM On Mon, Dec 02, 2013 at 06:11:04AM -0800, Albert-Jan Roskam wrote: > Hi, > > I created the code below because I want to compare two fiel

Re: [Tutor] need a hint

2013-12-02 Thread Alan Gauld
On 02/12/13 15:18, Wolfgang Maier wrote: You can do so by turning the entries in senateInfo from a list of strings (states) into a list of tuples (first name, state) like this: senateInfo[lastName] = [(firstName, state)] or for pre-existing entries: senateInfo[lastName].append((fi

Re: [Tutor] ignoring diacritical signs

2013-12-02 Thread Mark Lawrence
On 02/12/2013 15:53, Steven D'Aprano wrote: On Mon, Dec 02, 2013 at 06:11:04AM -0800, Albert-Jan Roskam wrote: Hi, I created the code below because I want to compare two fields while ignoring the diacritical signs. Why would you want to do that? That's like comparing two fields while ignoring

Re: [Tutor] /tutorial/controlflow.html "break statement"

2013-12-02 Thread Flynn, Stephen (L & P - IT)
> The script studied was : > > for n in range(2, 10): > for x in range(2, n): > if n % x == 0: > print(n, 'equals', x, '*', n//x) > break > else: > print(n, 'is a prime number') The code above is not what you ran below, in idle. Look at the in

Re: [Tutor] ignoring diacritical signs

2013-12-02 Thread Steven D'Aprano
Oh, I forgot... On Mon, Dec 02, 2013 at 06:11:04AM -0800, Albert-Jan Roskam wrote: >         if self.ignorecase: >             value = value.lower() The right way to do case-insensitive comparisons is to use casefold, not lower. Unfortunately, casefold is only available in Python 3.3 and on, so

Re: [Tutor] ignoring diacritical signs

2013-12-02 Thread Steven D'Aprano
On Mon, Dec 02, 2013 at 06:11:04AM -0800, Albert-Jan Roskam wrote: > Hi, > > I created the code below because I want to compare two fields while > ignoring the diacritical signs. Why would you want to do that? That's like comparing two fields while ignoring the difference between "e" and "i", o

[Tutor] /tutorial/controlflow.html Apologies

2013-12-02 Thread Pierre-Michel Averseng
Hmmm, I beg your pardon ! (Yes, this is the correct code. Look closely: the else clause belongs to the for loop, *not* the if statement.) When used with a loop, the else

Re: [Tutor] need a hint

2013-12-02 Thread Wolfgang Maier
Alan Gauld btinternet.com> writes: > > On 02/12/13 11:03, Wolfgang Maier wrote: > > > ... and since you want to be able to resolve ambiguous last names based on > > first names, you will have to store not just the states, but also the first > > names. > > You can do so by turning the entries in

[Tutor] /tutorial/controlflow.html "break statement"

2013-12-02 Thread Pierre-Michel Averseng
Hello, what do you think about the results given by IDLE3 with a script studied recently in T. Digest Vol 117, issue 70 & seq. ? I'm working with Linux (Debian family => i.e Linux Mint LMDE : [please, could you excuse my poor English... ? Thanks ! ;^)) ] Linux hojulien 3.10-2-486 #1 D

Re: [Tutor] need a hint

2013-12-02 Thread Alan Gauld
On 02/12/13 11:03, Wolfgang Maier wrote: ... and since you want to be able to resolve ambiguous last names based on first names, you will have to store not just the states, but also the first names. You can do so by turning the entries in senateInfo from a list of strings (states) into a list of

Re: [Tutor] Expenses

2013-12-02 Thread Steven D'Aprano
On Mon, Dec 02, 2013 at 02:49:03PM +, Alan Gauld wrote: > On 02/12/13 11:58, Kelly Netterville wrote: > >Expenses [...] > Is there any point to this random set of data? > Do you have a question for us? No. It's a mistake, sent by accident here instead of to Kelly's college tutor. -- Steven

Re: [Tutor] Loop over floating point values

2013-12-02 Thread Mark Lawrence
On 02/12/2013 12:27, Dave Angel wrote: On Mon, 2 Dec 2013 16:28:38 +1000, Amit Saha wrote: Indeed, that's a good point. Surprisingly, C does it just fine: # include int main(int argc, char **argv) { float x = 0.0; while(x<1) { x += 0.1; printf("%f\n", x); }

Re: [Tutor] Expenses

2013-12-02 Thread Alan Gauld
On 02/12/13 11:58, Kelly Netterville wrote: Expenses Student Loans SM 422 SM 151.78 Fedloan 401.48 (97.52) UHEAA 508.44 (82.80) Gas 700 to 1000 (depending on how often I need to go to WF) Prescriptions $26 Geico $97 Groceries $250 - 300 every 2 weeks ($600/mth) Mortgage $1207 Recent Auto Rep

Re: [Tutor] Expenses

2013-12-02 Thread Tim Golden
On 02/12/2013 14:49, Alan Gauld wrote: > Is there any point to this random set of data? > Do you have a question for us? I assumed it was a mis-posted email that should have gone to some house-share group email but instead went to python-tutor. The OP's probably lying low out of embarrassment :)

Re: [Tutor] Loop over floating point values

2013-12-02 Thread Dave Angel
On Mon, 2 Dec 2013 22:57:30 +1000, Amit Saha wrote: You missed the fact that I am printing the value of x *after* incrementing it. You're quite right, sorry. I'm too accustomed to the usual c idiom, which would increment the value at the end of the loop. -- DaveA

[Tutor] ignoring diacritical signs

2013-12-02 Thread Albert-Jan Roskam
Hi, I created the code below because I want to compare two fields while ignoring the diacritical signs. I thought it'd be cool to overload __eq__ for this. Is this a good approach, or have I been fixated too much on using the __eq__ special method? # -*- coding: utf-8 -*- class Equalize(obj

Re: [Tutor] need a hint

2013-12-02 Thread spir
On 12/02/2013 03:25 AM, Byron Ruffin wrote: The following program works and does what I want except for one last problem I need to handle. The program reads a txt file of senators and their associated states and when I input the last name it gives me their state. The problem is "Udall". There

Re: [Tutor] Loop over floating point values

2013-12-02 Thread Amit Saha
On Mon, Dec 2, 2013 at 10:27 PM, Dave Angel wrote: > On Mon, 2 Dec 2013 16:28:38 +1000, Amit Saha wrote: >> >> Indeed, that's a good point. Surprisingly, C does it just fine: > > > >> # include > > > >> int main(int argc, char **argv) >> { >> float x = 0.0; >> while(x<1) >> { >> x

Re: [Tutor] Loop over floating point values

2013-12-02 Thread Dave Angel
On Mon, 2 Dec 2013 16:28:38 +1000, Amit Saha wrote: Indeed, that's a good point. Surprisingly, C does it just fine: # include int main(int argc, char **argv) { float x = 0.0; while(x<1) { x += 0.1; printf("%f\n", x); } return 0; } gives the following ou

[Tutor] Expenses

2013-12-02 Thread Kelly Netterville
Expenses Student Loans SM 422 SM 151.78 Fedloan 401.48 (97.52) UHEAA 508.44 (82.80) Gas 700 to 1000 (depending on how often I need to go to WF) Prescriptions $26 Geico $97 Groceries $250 - 300 every 2 weeks ($600/mth) Mortgage $1207 Recent Auto Repair $1474 $194 $700 (tires) $600 upcoming (Tra

Re: [Tutor] need a hint

2013-12-02 Thread Wolfgang Maier
Oscar Benjamin gmail.com> writes: > > On 2 December 2013 02:25, Byron Ruffin g.austincc.edu> wrote: > > > > The following program works and does what I want except for one last problem > > I need to handle. The program reads a txt file of senators and their > > associated states and when I in

Re: [Tutor] need a hint

2013-12-02 Thread Oscar Benjamin
On 2 December 2013 02:25, Byron Ruffin wrote: > > The following program works and does what I want except for one last problem > I need to handle. The program reads a txt file of senators and their > associated states and when I input the last name it gives me their state. > The problem is "Udal

[Tutor] need a hint

2013-12-02 Thread Byron Ruffin
The following program works and does what I want except for one last problem I need to handle. The program reads a txt file of senators and their associated states and when I input the last name it gives me their state. The problem is "Udall". There are two of them. The txt file is read by lin

Re: [Tutor] Loop over floating point values

2013-12-02 Thread Steven D'Aprano
On Mon, Dec 02, 2013 at 04:28:38PM +1000, Amit Saha wrote: > On Sun, Dec 1, 2013 at 7:26 PM, Steven D'Aprano wrote: > > Such floating point loops are tricky to get right, thanks to rounding of > > floats. Observe: > > > > py> x = 0.0 > > py> while x < 1.0: > > ... x += 0.1 > > ... > > py> x =

Re: [Tutor] Hash map and dictionaries

2013-12-02 Thread Steven D'Aprano
On Sun, Dec 01, 2013 at 09:10:42PM +0530, Reuben wrote: > Hi > > Question 1: > - > I would like to know the concept of hash map. Additionally, I got to know > that hash maps are equivalent to dictionaries in python. > > I would like to understand the relationship between dictiona

Re: [Tutor] truncated dictionary return

2013-12-02 Thread Wolfgang Maier
richard kappler gmail.com> writes: > > > Now I'm completely lost. While opening the serial port outside the function sounds like a good idea, I'm thinking that might not work unless I am mistaken. The sensorRead function once it's called would then basically own the serial port barring other tr