Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: gnome-terminal
Post: RE: gnome-terminal

This worked for me: import os os.system("gnome-terminal -e 'sudo apt update'") os.system("gnome-terminal -e 'sudo apt upgrade'")But I could not link the 2 commands with && Why would you do ...
Pedroski55 General Coding Help 5 215 Yesterday, 06:11 PM
    Thread: Trying to generating multiple json files using python script
Post: RE: Trying to generating multiple json files using...

Lately, I have been learning about generators, so I thought, "I could do this with a generator or two." This is the same as above, but using a generator: import json from pathlib import Path # save...
Pedroski55 General Coding Help 4 169 Yesterday, 08:39 AM
    Thread: Trying to generating multiple json files using python script
Post: RE: Trying to generating multiple json files using...

You can try like this: import csv import json from pathlib import Path # save your Excel file as csv """ The first 7 column headers should be something like this version type productCode assetco...
Pedroski55 General Coding Help 4 169 Yesterday, 07:45 AM
    Thread: Extending list doesn't work as expected
Post: RE: Extending list doesn't work as expected

I think, outside of the class Test you would need a copy of list1 or list2, or you will alter them, but within the class, this seems to work ok without list1.copy() or list2.copy(). Oh the joys of c...
Pedroski55 General Coding Help 2 168 May-09-2024, 05:39 PM
    Thread: Use or raw string on regular expressions
Post: RE: Use or raw string on regular expressions

It is important to know that re uses its own parser to look at string expressions. Python passes a string or a raw string to re and re takes over. Try this: Quote:pattern = '\n' pattern '\n' pattern...
Pedroski55 General Coding Help 5 275 May-09-2024, 06:26 AM
    Thread: Keep getting "SyntaxError: incomplete input" but can't see why.
Post: RE: Keep getting "SyntaxError: incomplete input" ...

Funny, I did not forget line 46. The script runs as a whole in bash, no problem. I just wanted to run it in bits in Idle and I get the syntax error. Thanks for the link!
Pedroski55 General Coding Help 2 252 May-08-2024, 06:40 AM
    Thread: Keep getting "SyntaxError: incomplete input" but can't see why.
Post: Keep getting "SyntaxError: incomplete input" but ...

I am using Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] I have this file, compiler2.py shown below, from here. It is quite complex, so I am trying to understand it. To quote Dave Beazly:...
Pedroski55 General Coding Help 2 252 May-05-2024, 05:29 PM
    Thread: Visualizing musician chart performance and ranking using pandas and matplotlib
Post: RE: Visualizing musician chart performance and ran...

Yes, what I meant was: "Please supply some data for testing." I think just a sample of your csv, maybe 100 lines would suffice, but I downloaded the big csv from your Dropbox anyway, just for fun! I...
Pedroski55 Data Science 4 412 May-05-2024, 05:50 AM
    Thread: Connecting to Remote Server to read contents of a file
Post: RE: Connecting to Remote Server to read contents o...

I don't know what RDP is. The best tool ever for backing up files over the local network, or fetching files from a remote server is rsync. To use rsync you need ssh installed and working on your lap...
Pedroski55 General Coding Help 1 254 May-03-2024, 07:23 AM
    Thread: Filer and sort files by modification time in a directory
Post: RE: Filer and sort files by modification time in a...

Maybe this will help with the understanding part? from pathlib import Path import os mydir = Path('/home/pedro/tmp/') # get all files filelist = [filename for filename in mydir.iterdir() if filename...
Pedroski55 General Coding Help 5 346 May-02-2024, 07:59 AM
    Thread: How can I print from within actor(func) ??
Post: RE: How can I print from within actor(func) ??

Thanks for the reply. The problem is probably Idle. When I do this in Idle, def actor(func): # this will not print #print(f'key in _registry is {func.__name__}') def wrapper(*args, **kw...
Pedroski55 General Coding Help 2 257 May-01-2024, 05:35 AM
    Thread: How can I print from within actor(func) ??
Post: How can I print from within actor(func) ??

I have the following example from here. To help me understand what is going on, I like to put print() statements in various places, at least until everything works. func.__name__ gets the name of th...
Pedroski55 General Coding Help 2 257 Apr-30-2024, 07:51 AM
    Thread: Visualizing musician chart performance and ranking using pandas and matplotlib
Post: RE: Visualizing musician chart performance and ran...

Got some data to try out? (billboard_charts.csv perhaps!?) hot_billboard = pd.read_csv('data/billboard_charts.csv')
Pedroski55 Data Science 4 412 Apr-29-2024, 01:33 PM
    Thread: using mutable in function defintion as optional paramter
Post: RE: using mutable in function defintion as optiona...

For some reason the shopping list part reminds me of a joke: Quote:""" Wife to computer geek husband: "Buy a loaf of bread, and if they have eggs, buy 6" Husband thinks: def buy(something, eggs=Non...
Pedroski55 General Coding Help 8 524 Apr-27-2024, 04:57 PM
    Thread: Why am I getting this error from Dave Beazly's programme?
Post: RE: Why am I getting this error from Dave Beazly's...

Thanks, I will skip the offending example!
Pedroski55 General Coding Help 4 269 Apr-26-2024, 12:31 PM
    Thread: Why am I getting this error from Dave Beazly's programme?
Post: RE: Why am I getting this error from Dave Beazly's...

Sorry my comments were wrong, I mixed up inline_recursive.py and concurrent_futures_example3.py inline_recursive.py works in Idle, concurrent_futures_example3.py, the second example above, works in b...
Pedroski55 General Coding Help 4 269 Apr-26-2024, 10:32 AM
    Thread: Why am I getting this error from Dave Beazly's programme?
Post: Why am I getting this error from Dave Beazly's pro...

This is from Dave Beazly's Generators: The Final Frontier here. Part 3, the example inline_recursive.py When I run inline_recursive.py in Idle, by copying and pasting the parts into Idle, it works an...
Pedroski55 General Coding Help 4 269 Apr-26-2024, 07:38 AM
    Thread: Win or Loss Prediction
Post: RE: Win or Loss Prediction

I believe deanhystad meant, "Why not post some Python code that you have tried?" Just looking at the XL you posted, it is not clear to my befuddled brain how you arrive at "won" or "loss". (Maybe "ga...
Pedroski55 General Coding Help 4 347 Apr-25-2024, 08:08 AM
    Thread: Using xml.parsers.expat I can't get parser.ParseFile(f) to work
Post: RE: Using xml.parsers.expat I can't get parser.Par...

Thanks! Worked first time with 'rb'!
Pedroski55 General Coding Help 3 261 Apr-24-2024, 07:36 AM
    Thread: Using xml.parsers.expat I can't get parser.ParseFile(f) to work
Post: Using xml.parsers.expat I can't get parser.ParseFi...

This code comes from Dave Beazly and it is a bit old, Python 2.something. I am trying to get it to work in Python 3. This is from Part 3 : Coroutines and Event Dispatching, coexpat.py Up to now, eve...
Pedroski55 General Coding Help 3 261 Apr-24-2024, 05:33 AM

User Panel Messages

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