Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Python Launcher INI File
Post: Python Launcher INI File

I cannot find the Python Launcher Configuration File (.INI) under C:\Windows or Under C:\Users\XXX\AppData\Local\ . The launcher itself is found in C:\Windows and works on command-line.
leodavinci1990 General Coding Help 1 815 Jul-30-2023, 02:41 PM
    Thread: import statement in a virtual environment
Post: import statement in a virtual environment

If I create a directory and activate a virtual environment inside it and then use PIP to install some packages. Is this the case that as long as the virtual environment is active, the import statemen...
leodavinci1990 General Coding Help 1 2,348 Mar-04-2021, 12:23 AM
    Thread: print a line break in writelines() method
Post: print a line break in writelines() method

lines=["Line 1","Line 2"] f=open(r"C:\Users\....\Documents\somefile.txt","w") f.writelines(lines) f.close() How to print a line breaker between items in lines variable (list) when placing them in th...
leodavinci1990 General Coding Help 1 6,441 Oct-12-2020, 06:07 AM
    Thread: Opening file and outputting its text content example
Post: Opening file and outputting its text content examp...

If the Python file below is run on a text file containing the following: Hello! Welcome to demofile.txt This file is for testing purposes. Good Luck! Why does it return empty spaces in the output be...
leodavinci1990 General Coding Help 1 1,875 Oct-12-2020, 05:27 AM
    Thread: opening files and output of parsing
Post: RE: opening files and output of parsing

(Oct-12-2020, 04:21 AM)leodavinci1990 Wrote: (Oct-01-2020, 02:27 AM)bowlofred Wrote: Usually you'll want to rstrip(), which by default removes any whitespace from the right end. result = [line.rs...
leodavinci1990 General Coding Help 4 2,525 Oct-12-2020, 04:33 AM
    Thread: opening files and output of parsing
Post: RE: opening files and output of parsing

(Oct-01-2020, 02:27 AM)bowlofred Wrote: Usually you'll want to rstrip(), which by default removes any whitespace from the right end. result = [line.rstrip() for line in testfile if "2" in line]
leodavinci1990 General Coding Help 4 2,525 Oct-12-2020, 04:21 AM
    Thread: slicing and indexing a list example
Post: RE: slicing and indexing a list example

(Oct-01-2020, 02:12 AM)bowlofred Wrote: In your comprehension, you've asked the list to be assembled from [w.lower(), len(w)]. So the elements are: a list, with the lowercasename first, and the leng...
leodavinci1990 General Coding Help 4 2,324 Oct-12-2020, 04:13 AM
    Thread: opening files and output of parsing
Post: opening files and output of parsing

So I have the following text file named test.txt containing the following lines: This is line 1. This is line 2. This is line 3. The following code is used to parse the file: testfile = open(r"C:\Us...
leodavinci1990 General Coding Help 4 2,525 Oct-01-2020, 02:09 AM
    Thread: slicing and indexing a list example
Post: slicing and indexing a list example

I have the following code: s = "The quick brown fox jumps over the lazy dog." words = s.split() lengths = [[w.lower(), len(w)] for w in words] for length in lengths: print(length)The output is: ['t...
leodavinci1990 General Coding Help 4 2,324 Oct-01-2020, 01:27 AM
    Thread: Changing to new Python formatting example
Post: Changing to new Python formatting example

1) Is the following changes to new style of Python Formatting correct? And if not, what is a better way to efficiently format by reduce no. of lines, etc. 2) For example, there is the f-string metho...
leodavinci1990 General Coding Help 3 2,017 Sep-21-2020, 06:48 PM
    Thread: Running scripts and location of saved interpreted user-defined classes and functions
Post: Running scripts and location of saved interpreted ...

My general inception If the scripts containing user-defined functions and user-defined classes. And the Python shell is closed. These functions and classes are no longer available to be called or to h...
leodavinci1990 General Coding Help 3 2,512 Aug-24-2020, 10:35 PM
    Thread: print() examples
Post: print() examples

print('%10s' % ('test',))What is the purpose or difference between the having the colon after the 'text' string as in code above and without it as in code below: print('%10s' % ('test')The two pieces...
leodavinci1990 General Coding Help 3 1,943 Aug-21-2020, 03:54 AM
    Thread: printing strings with format
Post: printing strings with format

Case 1: If I execute the following: print('{} {}'.format('one', 'two'))the output in the IDLE shell will be one two Case 2: But I execute the following in IDLE: >>> x = '{} {}'.format('on...
leodavinci1990 General Coding Help 1 1,585 Aug-21-2020, 01:17 AM
    Thread: print function help percentage and slash (multiple variables)
Post: RE: print function help percentage and slash (mult...

Hi. Thanks bowlfred. That was super-helpful. As I tried to search for an explanation online and this answered it. Can I have one question. What did you mean by return in "the return does not termina...
leodavinci1990 General Coding Help 3 2,468 Aug-10-2020, 02:21 AM
    Thread: print function help percentage and slash (multiple variables)
Post: print function help percentage and slash (multiple...

What is the function of adding a back slash in the following code after the percentage operator? I am testing it without the slash and it gives the same result. Please note that I know I am not curren...
leodavinci1990 General Coding Help 3 2,468 Aug-09-2020, 10:36 PM
    Thread: Python Classes
Post: Python Classes

from random import Random # library for randoms class Die(object): # define the class sides = [1,2,3,4,5,6] def __init__(self): # METHOD self.sideShowing = Die.sides[0] # PROPERTY ...
leodavinci1990 General Coding Help 1 2,079 Nov-27-2019, 07:20 AM
    Thread: Recursion
Post: RE: Recursion

(Nov-21-2019, 11:03 AM)sumana Wrote: def power(base,exp): if(exp==1): return(base) if(exp!=1): return(base*power(base,exp-1)) base=int(input("Enter base: ")) exp=int(input("Enter exponential value: ...
leodavinci1990 General Coding Help 7 2,770 Nov-27-2019, 07:16 AM
    Thread: Recursion
Post: Recursion

def power(n,p): """ Return n to the power p. Works only for positive integers """ return n*power(n,p-1) if __name__ == '__main__': print(power(2,24)) Why does this return an error?
leodavinci1990 General Coding Help 7 2,770 Nov-20-2019, 01:29 AM
    Thread: Call to a print in a defined function
Post: Call to a print in a defined function

def fib(n): # write Fibonacci series up to n """Print a Fibonacci series up to n.""" a = 0 b = 1 while a < n: print(a, end=' ') a, b = b, a+b print() # Now ca...
leodavinci1990 General Coding Help 1 1,895 Nov-20-2019, 12:40 AM
    Thread: Pass by reference vs Pass by value
Post: Pass by reference vs Pass by value

#What is the output? val=100 print(val) def changeVal(): val=99 print(val) changeVal() print(val) #What is the output? vals=[100,100,100] print(vals) def changeVals(): vals[0]=99 pri...
leodavinci1990 General Coding Help 1 2,196 Nov-19-2019, 11:55 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020