Re: Class data being zapped by method

2006-08-08 Thread Kevin M
Figures. I'll try to complicate it sufficiently ;)


[edit] I was going to try to sum up what goes on, but I realized that I
was retyping what I already programmed in an effort to better
illustrate exactly what I'm doing. Pastebin it is. Don't fear, it's
only around 200 lines total.

Class file -- http://pastebin.4programmers.net/640
Main file -- http://pastebin.4programmers.net/639

PLEASE don't worry about any file parsing stuff. That's all working
well. The problem is that I'm getting IndexError exceptions in my
_a_count and _b_count methods when they're called from analyze(). I
added some code to increase verbosity, and it turns that the count
methods within the Test class are operating on EMPTY lists ( [] ), so
naturally they can't index anything. This is the core of the problem,
especially considering that line 98 in main.py works as expected.

Once again, thank you VERY VERY much for addressing this situation,
everyone








Gary Herron wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
> >
> > I'll cut to the chase.
> >
> > I have a class named Foo(). I create an instance of this class named
> > bar, and I set bar.data to a large list of tuples.
> >
> > Within Foo() there is a method which operates on self.data. I need to
> > call this method after I set self.data from the "outside" (bar.data),
> > which isn't a problem. However, I have found through simple debugging
> > procedures that while bar.data exists fine before the said method is
> > called, self.data within the class method is EMPTY. In my class
> > constructor I do declare self.data to be an empty list ([]), but
> > shouldn't self.data contain the populated list?
> >
> > Basically...
> >
> > --
> > class Foo():
> > __init__(self):
> > self.data = []
> > a_count(self):
> > 
> > print self.data
> > 
> >
> > bar = Foo()
> > bar.data = [(-74.0015, 1), (123.451, 18), ...]
> > print bar.data # Get what I expect
> > bar.a_count() # []
> > --
> >
> Well, ... you have not told us the whole story here. This code works as
> expected.
>
>  >>> class Foo():
> ... def __init__(self):
> ... self.data = []
> ... def a_count(self):
> ... print self.data
> ...
>  >>> bar = Foo()
>  >>> bar.data = [(-74.0015, 1), (123.451, 18)]
>  >>> print bar.data
> [(-74.0014993, 1), (123.450999, 18)]
>  >>> bar.a_count()
> [(-74.0014993, 1), (123.450999, 18)]
>  >>>
>
>
> You effort to reduce your real code to a simple demonstration of the
> problem is appreciated, but I don't think it worked in this case.
> 
> Want to try again?
> 
> 
> Gary Herron

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class data being zapped by method

2006-08-08 Thread Kevin M
Inline

> 1.) Why are you removing the .pyc file?

After I had run the script once and subsequently changed the class
file, I would run the script again, and it would use the pyc file from
the older revision of the script. I got frustrated with having to
manually delete the pyc file before rerunning the script after every
edit, so I built it in.

> 2.) Reading lines from a file is better done like so:
>
> arrLines = open('datafiles/'+filename+'.tabdata').readlines()
>
> and the 'r' flag is the default, you can omit it.

I know. In fact, this was the original code. However, I have read in
many places that if the file is *massive*, which is true in my case, it
is far more efficient to use the line-by-line implicit method I used.
On a decent machine it doesn't really make a noticeable difference, but
some of the ".tabdata" files I'm parsing are > 20MB plain text, so I
figured that warranted the alternative approach.

> 3.) You can create the Test instances like so:
>
> arrTests = [Test() for i in range(cntTests)]

Figures. I'm overzealous with the list comprehensions below, and
totally ignorant of them here...

> 4.) You don't need "saveout = sys.stdout", sys.__stdout__ is already
> this.

Cool.

> 5.) In "check = 0.6 * float(depth)" the call to float is redundant and
> can be eliminated.

Understood.

> 6.) In "sumx = sum([x[0] for x in self.data])", etc.. you can leave out
> the []'s.  There's no need to create a list, the ()'s in the call to
> sum() suffice to make a generator comprehension.

That I didn't know, and I'm glad I do now.

>
> FWIW, if you're still having trouble later I'll try to take another
> look at your code.  Print statements and debuggers are your friends,
> and John Machin's advice seems good to me.
>
> Peace,
> ~Simon

Thanks to John M's debugging code I was led to the source of my
problems, or so it seems.

I'll post a follow up from work tomorrow (EDT) stating whether or not
the issue has been completely resolved.

Thank you both very much.

Aside --

John M, I realized what you meant about splitting the code between the
class and the processing file. At first it seemed intuitive, but
stepping back, it doesn't really make sense that a test would be able
to analyze and take an inventory of *itself*. I think I'm going to
reorganize the code such that the Test class does nothing but provide a
barebones data structure with which to work.

And regarding the file separation, it's totally personal preference. It
scales well, at least.

Another Aside --

Does anybody see any major bottlenecks in the code? I'd like to be able
to speed up the program considerably. Psyco was really no help.

Again, thanks

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class data being zapped by method

2006-08-09 Thread Kevin M
Good news. I've fixed it up and all seems to be well.

Thanks, all. I've learned a lot from this :)


John Machin wrote:
> Kevin M wrote:
> > Inline
> >
> > > 1.) Why are you removing the .pyc file?
> >
> > After I had run the script once and subsequently changed the class
> > file, I would run the script again, and it would use the pyc file from
> > the older revision of the script. I got frustrated with having to
> > manually delete the pyc file before rerunning the script after every
> > edit, so I built it in.
>
> Huh? Something funny is going on here. (1) You should never need to
> delete a pyc file (2) A script run from the command line doesn't create
> a pyc file, only imported modules get that. So: What platform are you
> running it on? What version of Python? Are you running the script from
> the command line, or in an IDE? Which IDE?
>
> >
> > > 2.) Reading lines from a file is better done like so:
> > >
> > > arrLines = open('datafiles/'+filename+'.tabdata').readlines()
> > >
> > > and the 'r' flag is the default, you can omit it.
> >
> > I know. In fact, this was the original code. However, I have read in
> > many places that if the file is *massive*, which is true in my case, it
> > is far more efficient to use the line-by-line implicit method I used.
> > On a decent machine it doesn't really make a noticeable difference, but
> > some of the ".tabdata" files I'm parsing are > 20MB plain text, so I
> > figured that warranted the alternative approach.
>
> Firstly, 20MB is not massive.
> Secondly, the problem with large files is keeping a list like arrLines
> hanging about when you only need one line at a time.
> If you insist on keeping the list, get it in one hit using readlines(),
> instead of assembling it yourself manually.
>
> >
> >
> > John M, I realized what you meant about splitting the code between the
> > class and the processing file. At first it seemed intuitive, but
> > stepping back, it doesn't really make sense that a test would be able
> > to analyze and take an inventory of *itself*. I think I'm going to
> > reorganize the code such that the Test class does nothing but provide a
> > barebones data structure with which to work.
> >
> > And regarding the file separation, it's totally personal preference. It
> > scales well, at least.
>
> One class per file does *not* scale well, even when you're not being
> driven silly by having to flick backwards & forwards furiously between
> files :-)
>
> >
> > Another Aside --
> >
> > Does anybody see any major bottlenecks in the code? I'd like to be able
> > to speed up the program considerably. Psyco was really no help.
> >
>
> 1. Get it refactored and working correctly first. "except IndexError:
> pass" certainly won't help you win the Grand Prix; how many of those
> were you doing per 20MB of data?
> 2. How long does it take to run ? How long would you prefer it to take?
> How many lines x how many tests == 20 MB?
> 
> Cheers,
> John

-- 
http://mail.python.org/mailman/listinfo/python-list


F-string usage in a print()

2022-05-24 Thread Kevin M. Wilson via Python-list
future_value = 0
for i in range(years):
# for i in range(months):
   future_value += monthly_investment
   future_value = round(future_value, 2)
   # monthly_interest_amount = future_value * monthly_interest_rate
   # future_value += monthly_interest_amount
   # display the result
   print(f"Year = ", years + f"Future value = \n", future_value)When joining a 
string with a number, use an f-string otherwise, code a str() because a 
implicit convert of an int to str causes a TypeError!Well...WTF! Am I not using 
the f-string function correctly...in the above line of code???
Caddy Man

Good sense makes one slow to anger, and it is his glory tooverlook an offense.

Proverbs 19:11

-- 
https://mail.python.org/mailman/listinfo/python-list


Help, PyCharm fails to recognize my tab setting...See attached picture of the code.

2022-10-10 Thread Kevin M. Wilson via Python-list
C:\Users\kevin\PycharmProjects\Myfuturevalue\venv\Scripts\python.exe 
C:\Users\kevin\PycharmProjects\Myfuturevalue\FutureValueCal.py   File 
"C:\Users\kevin\PycharmProjects\Myfuturevalue\FutureValueCal.py", line 31    
elif (years > 50.0) or (years < 1.0) :    ^IndentationError: expected an 
indented block after 'if' statement on line 29
Process finished with exit code 1


Good sense makes one slow to anger, and it is his glory tooverlook an offense.

Proverbs 19:11

-- 
https://mail.python.org/mailman/listinfo/python-list


Pycharm IDE

2023-04-18 Thread Kevin M. Wilson via Python-list
Greetings... Kevin here:I need help, as you have guessed!I have this line: The 
Print Statement... Why complain about a 'comma', or a ')'???def play_game():
number = random.randint(1, LIMIT)
print (f'"I am thinking of a number between 1 to {LIMIT}\n")Or is this a 
setting in the IDE, I need to reassign?

Regards, Perplexed
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2

|  | Virus-free.www.avg.com |

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pycharm IDE

2023-04-18 Thread Kevin M. Wilson via Python-list
print (f'"I am thinking of a number between 1 to {LIMIT}\n")I had the 
impression that the format specifier 'f' was necessary for the print function, 
but the double quotes are for the string printed to the user, as a prompt!The 
Pycharm IDE is showing that it expects a single quotation mark or ')'! No error 
message is displayed.
Perplexed
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2 

On Tuesday, April 18, 2023 at 06:44:37 PM MDT, aapost 
 wrote:  
 
 On 4/18/23 19:18, Kevin M. Wilson wrote:
>Why complain about a 'comma', or a ')'???
>      print (f'"I am thinking of a number between 1 to {LIMIT}\n")

my version says it expects ' first (to close the fstring)
then on a new line below it, it mentions the comma and )
I believe that is just showing you after ' it expects you to end the 
print with ) as you have
or , to add additional arguments to print
-- 
https://mail.python.org/mailman/listinfo/python-list
  

|  | Virus-free.www.avg.com |

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pycharm IDE

2023-04-18 Thread Kevin M. Wilson via Python-list
Ok, I got rid of the "print (f'"I am thinking of a number between 1 to 
{LIMIT}\n")"print ("I am thinking of a number between 1 to {LIMIT}\n"),
and Pycharm stopped complaining about it... WHY??
Perplexed
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2 

On Tuesday, April 18, 2023 at 11:17:52 PM MDT, Kevin M. Wilson via 
Python-list  wrote:  
 
 print (f'"I am thinking of a number between 1 to {LIMIT}\n")I had the 
impression that the format specifier 'f' was necessary for the print function, 
but the double quotes are for the string printed to the user, as a prompt!The 
Pycharm IDE is showing that it expects a single quotation mark or ')'! No error 
message is displayed.
Perplexed
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2 

    On Tuesday, April 18, 2023 at 06:44:37 PM MDT, aapost 
 wrote:  
 
 On 4/18/23 19:18, Kevin M. Wilson wrote:
>Why complain about a 'comma', or a ')'???
>      print (f'"I am thinking of a number between 1 to {LIMIT}\n")

my version says it expects ' first (to close the fstring)
then on a new line below it, it mentions the comma and )
I believe that is just showing you after ' it expects you to end the 
print with ) as you have
or , to add additional arguments to print
-- 
https://mail.python.org/mailman/listinfo/python-list
  

|  | Virus-free.www.avg.com |

-- 
https://mail.python.org/mailman/listinfo/python-list
  

|  | Virus-free.www.avg.com |

-- 
https://mail.python.org/mailman/listinfo/python-list


PyCharm's strict PEP and not so strict?

2023-04-19 Thread Kevin M. Wilson via Python-list
Greetings,     I'm in a bit of a quandary, I want some strict syntax errors 
to be flagged, but the use of single quotes vs double quotes! NOT what I need 
from the 'checker', you dig? As I've recently returned to the IDE, and no 
longer have the
"stones" for bull, how do I set up the kind of "checking" I want?
Thank you, Kevin
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2

|  | Virus-free.www.avg.com |

-- 
https://mail.python.org/mailman/listinfo/python-list


Editing PEP-8, in particular "expected 2 blanks, found 1

2023-05-02 Thread Kevin M. Wilson via Python-list
Folks, help please! What the @#$! are these doing popping up. Code styles are 
personal, and not subject to debate.Where can I edit these out of my IDE?
Kevin
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2

|  | Virus-free.www.avg.com |

-- 
https://mail.python.org/mailman/listinfo/python-list


Disable 'style PEP' messages

2023-05-04 Thread Kevin M. Wilson via Python-list
Hi... How do I set Pycharm to find only syntax errors?!!
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2

|  | Virus-free.www.avg.com |

-- 
https://mail.python.org/mailman/listinfo/python-list


Three (3) >>> in the debug screen of PyCharm... Que Es over?!!

2023-05-04 Thread Kevin M. Wilson via Python-list


"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2

|  | Virus-free.www.avg.com |

-- 
https://mail.python.org/mailman/listinfo/python-list


Invalid literal for int() with base 10?

2023-05-25 Thread Kevin M. Wilson via Python-list
Ok, I'm not finding any info. on the int() for converting a str to an int (that 
specifies a base parameter)?! The picture is of the code I've written... And 
the base 10 paradigm involved?? years = int('y') # store for 
calculationValueError: invalid literal for int() with base 10: 'y'What is meant 
by "invalid literal"? I'm trying to convert srt to int, and I didn't know I 
needed to specify the base. Plus I haven't read anything that I need to specify 
the base for the int().
Attached is the code, showing the code and the execution of said code.
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2
-- 
https://mail.python.org/mailman/listinfo/python-list


From geeksforgeeks.org, on converting the string created by the input() to an INT

2023-05-25 Thread Kevin M. Wilson via Python-list
We can first convert the string representation of float into float using 
float() function and then convert it into an integer using int().So, why can't 
a string of an integer be converted to an integer, via 
print(int(str('23.5')))???
Perplexed






| print(int(float('23.5'))) |



"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Invalid literal for int() with base 10?

2023-05-25 Thread Kevin M. Wilson via Python-list
Ok, I'm not finding any info. on the int() for converting a str to an int (that 
specifies a base parameter)?! The picture is of the code I've written... And 
the base 10 paradigm involved?? years = int('y') # store for calculation 
ValueError: invalid literal for int() with base 10: 'y'
What is meant by "invalid literal"? I'm trying to convert str to int, and I 
didn't know I needed to specify the base. Plus I haven't read anything that I 
need to specify the base for the int().
Attached is the code, showing the code and the execution of said code.
Sorry, got pissed and didn't check all the content I sent!


"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2 

On Thursday, May 25, 2023 at 05:55:06 PM MDT, Kevin M. Wilson via 
Python-list  wrote:  
 
 Ok, I'm not finding any info. on the int() for converting a str to an int 
(that specifies a base parameter)?! The picture is of the code I've written... 
And the base 10 paradigm involved?? years = int('y') # store for 
calculationValueError: invalid literal for int() with base 10: 'y'What is meant 
by "invalid literal"? I'm trying to convert srt to int, and I didn't know I 
needed to specify the base. Plus I haven't read anything that I need to specify 
the base for the int().
Attached is the code, showing the code and the execution of said code.
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2
-- 
https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


For example: Question, moving a folder (T061RR7N1) containing a Specific file (ReadCMI), to folder: C:\\...\DUT0

2021-01-27 Thread Kevin M. Wilson via Python-list
for path, dir, files in os.walk(myDestinationFolder):
# for path, dir, files in os.walk(destfolder):
print('The path is %s: ', path)
print(files)
os.chdir(mySourceFolder)
if not os.path.isfile(myDestinationFolder + file):
#  if not os.path.isfile(destfolder + file):
print('The file is %s: ', file)
shutil.copytree(mySourceFolder, myDestinationFolder)
#  os.rename(path + '\\' + file, myDestinationFolder + file)
#  os.rename(path + '\\' + file, destfolder + file)
os.rename(path + '\\' + file, myDestinationFolder + file)
elif os.path.isfile(myDestinationFolder + file):
#  os.rename(path + '\\' + file, destfolder + file)
shutil.copytree(mySourceFolder, myDestinationFolder)
So I would very much appreciate your ideas on the above statements!Because...I 
think I've got the wrong function (os.path.isfile), when I should be (s/b) 
using a stepped approach!Note: program allows input of ID = T061RR7N1 (for 
example)1) find the folder containing "file": where folder = T061RR7N1, and 
file is "ReadCMI"; if TRUE, shutil.copytree C:\\...\T061RR7N1\ReadCMI (TO) 
C:\\...\DUT[?], where [?] is a num from 0 - 15.2) append to 
C:\\...\DUT[?]\T061RR7N1, which contains "ReadCMI"!

and would you mind telling me why this works (in every example I've found on 
the internet): r'C:\\anyfolder\\anyotherfolder\\'...what does the "r" signify? 
If it's 'read', why can't I use the 'a' for append?
KMW

"The only way to have experience is by having the experience"!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python cannot count apparently

2021-02-07 Thread Kevin M. Wilson via Python-list
Set i = 0 at the begin of the code, that way each entry starts at Logical 0 of 
the array/container/list...
"The only way to have experience is by having the experience"!
 

On Sunday, February 7, 2021, 12:56:40 PM MST, Karsten Hilbert 
 wrote:  
 
 Am Sun, Feb 07, 2021 at 07:47:03PM + schrieb Paul Bryan:

> That's not the only problem with the code. There's a missing close-
> paren and a reference to "string" which I presume was meant to be
> "myString".

I know. I wasn't going to spoil everything right away. The
sort of response we would get from OP would tell us what sort
of help might be most suitable :-)

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B
-- 
https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


Python 2.7 and 3.9

2021-02-16 Thread Kevin M. Wilson via Python-list
My employer has hundreds of scripts in 2.7, but I'm writing new scripts in 3.9! 
I'm running into 'invalid syntax' errors.I have to maintain the 'Legacy' stuff, 
and I need to mod the path et al., to execute 3.7 w/o doing damage to the 
'Legacy' stuff...IDEA' are Welcome!
KMW
John 1:4  "In him was life; and the life was the light of men."
-- 
https://mail.python.org/mailman/listinfo/python-list


Tkinter needed as a legacy version 2.7 imports the module...

2021-02-26 Thread Kevin M. Wilson via Python-list
Hey Community,    Is there a site where I might/can download a version of 
Tkinter for Python 2.7?

Seriously, KMW
John 1:4  "In him was life; and the life was the light of men."
-- 
https://mail.python.org/mailman/listinfo/python-list


Pycharm IDE: seeking an assist!

2022-03-21 Thread Kevin M. Wilson via Python-list
Greetings Python coders,
    I have installed the Pycharm IDE, and upon successfully auto 
install of the path/environment statements.
The IDE opened and displayed (bottom right corner): 
The use of Java options environment variables detected.
Such variables override IDE configuration files (*.vmoptions) and may cause 
performance and stability issues.
Please consider deleting these variables: _JAVA_OPTIONS.

Now I've opened the installed .bat files...append.bat, format.bat, inspect.bat, 
itedit.bat, and pycharm.bat!
Of the Five(5) listed above, only 'pycharm.bat' contains statements setting up 
the IDE' run environment, beyond
Seven (7) lines.

Having searched the 'pycharm.bat' file for "_JAVA_OPTIONS", and the 
'pycharm64.exe.vmoptions' file as well.
I was able to add the line '-Djava.net.preferIPv4Stack=False', reboot, and 
still no JOY. 
Message is still popping open, when the IDE first executes. No documentation 
have I found, details what
this option, the setting of...will do!

Any and all help, please!

Kevin


Good sense makes one slow to anger, and it is his glory to overlook an offense.

Proverbs 19:11
-- 
https://mail.python.org/mailman/listinfo/python-list


python-list@python.org

2022-04-13 Thread Kevin M. Wilson via Python-list





MS Edge settings are displayed in the first picture, the error I encountered is 
the second picture...not sure how I get around this!I reloaded the browser 
after checking the settings for JavaScript...confused.

Kevin


Good sense makes one slow to anger, and it is his glory tooverlook an offense.

Proverbs 19:11

-- 
https://mail.python.org/mailman/listinfo/python-list


Flubbed it in the second interation through the string: range error... HOW?

2024-05-28 Thread Kevin M. Wilson via Python-list
The following is my effort to understand how to process a string, letter, by 
letter:
def myfunc(name):        index = 0    howmax = len(name)    # while (index <= 
howmax):    while (index < howmax):        if (index % 2 == 0):            
print('letter to upper = {}, index {}!'.format(name[index], index))            
name = name[index].upper()            print('if block {} and index 
{}'.format(name[index], index))        elif (index % 2 > 0):            
print(index)            print('Start: elseif block, index is {}, letter is 
{}'.format(index, name))            # print('letter to lower = 
{}'.format(name[index]))            # print('Already lowercase do noting: name 
= {}'.format(name[index]))        index += 1        # index = name.upper()      
  
    return name        
myfunc('capitalism')
Error message:                        Not making sense, index is 1, letter s/b 
'a'letter to upper = c, index 0!
if block C and index 0
1
Start: elseif block, index is 1, letter is C
---
IndexErrorTraceback (most recent call last)
Cell In[27], line 21
 17 # index = name.upper()
 19 return name
---> 21 myfunc('capitalism')

Cell In[27], line 8, in myfunc(name)
  6 while (index < howmax):
  7 if (index % 2 == 0):
> 8 print('letter to upper = {}, index {}!'.format(name[index], 
index))
  9 name = name[index].upper()
 10 print('if block {} and index {}'.format(name[index], index))

IndexError: string index out of 
range***
So, I'm doing something... Stupid!!
***
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2
-- 
https://mail.python.org/mailman/listinfo/python-list


Fw: Flubbed it in the second interation through the string: range error... HOW?

2024-05-28 Thread Kevin M. Wilson via Python-list
The format in this email is not of my making, should someone know, how to do 
this so that it's a readable script do tell!
KMW

***
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2
 

   - Forwarded Message ----- From: Kevin M. Wilson via Python-list 
To: python-list@python.org 
Sent: Tuesday, May 28, 2024 at 10:35:23 PM MDTSubject: 
Flubbed it in the second interation through the string: range error... HOW?
 The following is my effort to understand how to process a string, letter, by 
letter:
def myfunc(name):        index = 0    howmax = len(name)    # while (index <= 
howmax):    while (index < howmax):        if (index % 2 == 0):            
print('letter to upper = {}, index {}!'.format(name[index], index))            
name = name[index].upper()            print('if block {} and index 
{}'.format(name[index], index))        elif (index % 2 > 0):            
print(index)            print('Start: elseif block, index is {}, letter is 
{}'.format(index, name))            # print('letter to lower = 
{}'.format(name[index]))            # print('Already lowercase do noting: name 
= {}'.format(name[index]))        index += 1        # index = name.upper()      
  
    return name        
myfunc('capitalism')
Error message:                        Not making sense, index is 1, letter s/b 
'a'letter to upper = c, index 0!
if block C and index 0
1
Start: elseif block, index is 1, letter is C
---
IndexError                                Traceback (most recent call last)
Cell In[27], line 21
    17        # index = name.upper()        
    19    return name        
---> 21 myfunc('capitalism')

Cell In[27], line 8, in myfunc(name)
      6 while (index < howmax):
      7    if (index % 2 == 0):
> 8        print('letter to upper = {}, index {}!'.format(name[index], 
index))
      9        name = name[index].upper()
    10        print('if block {} and index {}'.format(name[index], index))

IndexError: string index out of 
range***
So, I'm doing something... Stupid!!
***
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2
-- 
https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


pdb: How to use the 'break' parameter?

2024-08-21 Thread Kevin M. Wilson via Python-list
break (Old_MacDonald:23 | name[indx] == 'd', indx = 4), based on the doc spec 
in python.org (https://docs.python.org/3/library/pdb.html#debugger-commands)
Cell In[1], line 20
break (Old_MacDonald:23 | name[indx] == 'd', indx = 4)
  ^
  SyntaxError: invalid syntax
I got one blank white screen when I entered the exact first line of the 
python.org-->b(reak) [([filename:]lineno | function) [, condition]]

I'd be obliged for an assist... KMW
***
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python List is Not Dead

2024-12-28 Thread Kevin M. Wilson via Python-list
Excuse please, my failure. As I have not been following this discussion, why is 
the subject "Python List Is NOT Dead" a subject for discussion? Has the list 
been moving towards closing?
KMW

***
"When you pass through the waters, I will be with you: and when you pass 
through the rivers, they will not sweep over you. When you walk through the 
fire, you will not be burned: the flames will not set you ablaze."      
Isaiah 43:2
 

On Saturday, December 28, 2024 at 05:37:34 AM MST, Mohammadreza Saveji via 
Python-list  wrote:  
 
 thank you Mr. Jahangir.
you are expert in python.

On Fri, Dec 27, 2024 at 2:28 AM Cameron Simpson via Python-list <
python-list@python.org> wrote:

> On 25Dec2024 14:52, Abdur-Rahmaan Janhangeer  wrote:
> >I have been following discussions on Discourse (discuss.python.org)
> >these last times.
> >
> >I think that it definitely lacks some of the joys of the mailing list:
>
> FYI, it has a very good "mailing list" mode. I use it that was >90% of
> the time, and file both posts from Discourse and posts from python-list
> into my "python" mail folder.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list