Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: Retrieve word from string
Post: RE: Retrieve word from string
There are several ways to do this. One is to use string find() method and then check where the next space is. Another way is to use regular expressions, which will be faster if you have a large text a... |
|
sgrey |
General Coding Help |
4 |
550 |
Jan-21-2024, 05:57 AM |
|
|
Thread: python script is hanging while calling a procedure in database
Post: RE: python script is hanging while calling a proce...
- What interface are you using to manage the database? Does it hang or experience slowness?
- Did you try another language, does it also hangs or just python?
- Is your table large or did you indexes ... |
|
sgrey |
General Coding Help |
4 |
614 |
Jan-17-2024, 10:16 AM |
|
|
Thread: i scored 1/8 on python assessment where did i mess up?
Post: RE: i scored 1/8 on python assessment where did i ...
From what I am reading, you got quite a fair grade. Ok, here we go. First, let's look at your assignment specification.
goal: Stack plates, one on top of another
You have to build a version of a data ... |
|
sgrey |
General Coding Help |
5 |
771 |
Jan-16-2024, 02:07 AM |
|
|
Thread: Why doesn't list require global keyword?
Post: RE: Why doesn't list require global keyword?
(Jan-15-2024, 11:06 PM)johnywhy Wrote: i think that's the key to immutability. But you still didn't explain why dictionaries are mutable.Because that's what their nature is. Dictionary is a collecti... |
|
sgrey |
General Coding Help |
9 |
947 |
Jan-15-2024, 11:47 PM |
|
|
Thread: Passing writable arguments to functions.
Post: RE: Passing writable arguments to functions.
(Jan-15-2024, 08:04 PM)Gribouillis Wrote: (Jan-15-2024, 05:38 PM)sgrey Wrote: pass by assignment, which is not even fully correct, but I guess does highlight the concept in way.I think "pass by as... |
|
sgrey |
General Coding Help |
11 |
1,141 |
Jan-15-2024, 11:32 PM |
|
|
Thread: Passing writable arguments to functions.
Post: RE: Passing writable arguments to functions.
Yea, I was surprised as well, because there isn't really such a way to pass arguments. They are basically passing references by value, but they are grouping this with mutability semantics and calling ... |
|
sgrey |
General Coding Help |
11 |
1,141 |
Jan-15-2024, 05:38 PM |
|
|
Thread: Passing writable arguments to functions.
Post: RE: Passing writable arguments to functions.
I wouldn't call them pass by assignment either, but it's written in the documentation this way https://docs.python.org/3/faq/programmin...-reference
Quote:Remember that arguments are passed by assignm... |
|
sgrey |
General Coding Help |
11 |
1,141 |
Jan-15-2024, 05:14 PM |
|
|
Thread: Why doesn't list require global keyword?
Post: RE: Why doesn't list require global keyword?
(Jan-15-2024, 01:35 AM)johnywhy Wrote: (Jan-15-2024, 12:34 AM)sgrey Wrote: if you say x = 101 you cannot modify 0
Unclear. x is mutable. I can say
x+=1no, what this does is x = x + 1. You are ass... |
|
sgrey |
General Coding Help |
9 |
947 |
Jan-15-2024, 02:07 AM |
|
|
Thread: Why doesn't list require global keyword?
Post: RE: Why doesn't list require global keyword?
(Jan-15-2024, 12:02 AM)johnywhy Wrote: Why doesn't appending to a global list require the global keyword, but modifying a scalar variable does?
numbers = []
dog = 5
def enter_number(x):
numbers.a... |
|
sgrey |
General Coding Help |
9 |
947 |
Jan-15-2024, 12:34 AM |
|
|
Thread: Python code to set column width
Post: RE: Python code to set column width
(Jan-14-2024, 07:52 AM)1418 Wrote: Can you tell me what additional library I need, cheers
First you can try this answer
writer = pd.ExcelWriter('/path/to/output/file.xlsx')
df.to_excel(writer, shee... |
|
sgrey |
General Coding Help |
11 |
1,521 |
Jan-14-2024, 07:56 AM |
|
|
Thread: Python code to set column width
Post: RE: Python code to set column width
(Jan-14-2024, 07:41 AM)1418 Wrote: sgrey, I tried both these without success. I'm using Visual Studio, are you suggesting I need to download additional libraries? Or should I use Pycharm?
Error:insp... |
|
sgrey |
General Coding Help |
11 |
1,521 |
Jan-14-2024, 07:48 AM |
|
|
Thread: Python code to set column width
Post: RE: Python code to set column width
(Jan-14-2024, 06:22 AM)1418 Wrote: Thanks sgrey, I tried the below code but it didn't work, what have I done wrong, cheers
Error:inspdata.style.set_column_width({'EForm Id':100,'Contractor':100})
So... |
|
sgrey |
General Coding Help |
11 |
1,521 |
Jan-14-2024, 07:05 AM |
|
|
Thread: Python code to set column width
Post: RE: Python code to set column width
(Jan-14-2024, 05:01 AM)1418 Wrote: Thanks Larz60 but I'm new to Python so I still can't figure that out. Could you write the code to set the width for two of my columns, EForm ID & Contractor, c... |
|
sgrey |
General Coding Help |
11 |
1,521 |
Jan-14-2024, 05:44 AM |
|
|
Thread: Tab Delimited Strings?
Post: RE: Tab Delimited Strings?
you don't need to call str on a variable inside string format, so you would write it as myString = f"{idx}\t{choice}\n"
And you are correct, string format of that kind is not the most readable. There ... |
|
sgrey |
General Coding Help |
7 |
666 |
Jan-13-2024, 10:34 PM |
|
|
Thread: List Comprehension Issue
Post: RE: List Comprehension Issue
(Jan-13-2024, 10:16 PM)johnywhy Wrote: (Jan-13-2024, 10:06 PM)sgrey Wrote: in your second code you are adding list elements to a list instead of making a string. You need to iterate over them and ... |
|
sgrey |
General Coding Help |
5 |
626 |
Jan-13-2024, 10:30 PM |
|
|
Thread: List Comprehension Issue
Post: RE: List Comprehension Issue
(Jan-13-2024, 09:59 PM)johnywhy Wrote: This works:
choices = 'a', 'b', 'c'
menu = ""
for idx, choice in enumerate(choices):
menu += "\t".join((str(idx), choice, '\n'))
print(menu)
0 a
1 b
2 cThis... |
|
sgrey |
General Coding Help |
5 |
626 |
Jan-13-2024, 10:06 PM |
|
|
Thread: Tab Delimited Strings?
Post: RE: Tab Delimited Strings?
(Jan-13-2024, 09:40 PM)johnywhy Wrote: I'm just trying to assemble the string here, not print it. How to do that with f?
My terms are just str(idx) and choice, with a trailing newline.
You are just ... |
|
sgrey |
General Coding Help |
7 |
666 |
Jan-13-2024, 09:48 PM |
|
|
Thread: Tab Delimited Strings?
Post: RE: Tab Delimited Strings?
(Jan-13-2024, 09:11 PM)johnywhy Wrote: (Jan-13-2024, 09:05 PM)deanhystad Wrote: Look at str.join(). It does what I think you are asking.
Can this be simplified with f or format or any other way?
... |
|
sgrey |
General Coding Help |
7 |
666 |
Jan-13-2024, 09:30 PM |
|
|
Thread: Passing writable arguments to functions.
Post: RE: Passing writable arguments to functions.
(Jan-13-2024, 03:55 AM)deanhystad Wrote: Python doesn't pass arguments by value or reference as both depend upon a definition of "variable" that doesn't exist in Python. Everything in Python is an ... |
|
sgrey |
General Coding Help |
11 |
1,141 |
Jan-13-2024, 07:59 PM |
|
|
Thread: Passing writable arguments to functions.
Post: RE: Passing writable arguments to functions.
(Jan-12-2024, 10:50 PM)Assembler Wrote: Thanks!
My searches turned up all sorts of geekery discussing various parameter schemes, but I did not see "No, there is no way to do that." Or if I did, I... |
|
sgrey |
General Coding Help |
11 |
1,141 |
Jan-13-2024, 03:38 AM |