|
I agree 100% that Python is not elegant from a pure CS point of view. But it is much more concise than C++ and cousins. You have to scroll less (!). We have discussed the benefit of non-scrolling (vs our old brains) in C-code before.
And it does have amazing libraries. I just does the job for small programs. Beyond a few thousand lines, it becomes a nightmare to maintain, mostly due to its total lack of type-safety.
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
I've discovered a whole new reason to love C# and that is source generators. But also, I've now gotten to the point where my C# CLI apps are as short and succinct as anything similar in python, through the magic of metadata and some code I wrote. Complete with using screens, defaults, etc.
I wrote something to parse a C header file and extract relevant information. From conception to testing to delivery in two hours, about a page and a half of C# code.
Frankly, I agree with Mr. Pfeifer below. I don't need Python, I've got solid tools as it is.
And no goddammned signficant whitespace!**
** funny thing about that.
I actually use minimization in my .NET projects[^]
I do it as part of an alternative to static linking which isn't really available with C#. To save space (sometimes a meg of whitespace!), and to deliberately obscure these files and prevent me from modifying them - rather than modifying the source that they are generated from. I've gotten out of sync before. This keeps me honest.
Python can't do that. In fact, python makes code generation itself a royal pain because of the pigheaded insistence of imposing indents on you.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Nice project! It is not within my aforementioned category of Python-suitable challenges ["small quick things"]. Peace.
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
It's not but for those I have my Program.Base code which makes writing say, a CLI app to wordwrap input files into an output file this easy:
using System;
using System.Collections.Generic;
using System.IO;
internal partial class Program
{
[CmdArg(Ordinal = 0)]
static List<TextReader> Inputs = new List<TextReader>() { Console.In };
[CmdArg(Name = "output")]
static TextWriter Output = Console.Out;
[CmdArg(Name = "width", Description = "The width to wrap. Defaults based on console window size", ItemName = "columns")]
static int Width = (int)Math.Floor((double)Console.WindowWidth / 1.5);
[CmdArg(Name = "ifstale", Description = "Skip if the input file is older than the output file")]
static bool IfStale = false;
static void Run()
{
if (!IfStale || IsStale(Inputs, Output))
{
foreach (var input in Inputs)
{
string line;
while((line = input.ReadLine()) != null)
{
Output.WriteLine(WordWrap(line, Width));
}
}
} else
{
Console.Error.WriteLine("Skipped execution because the inputs did not change");
}
}
}
That parses arguments, presents a using screen, all of that mess. This is how i do "quick things."
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Add some ego and rename self to myself.
|
|
|
|
|
I don't use Python because it solves no problems that I can't solve better with other tools.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Putting my "your programming language wears army shorts", or "Scripting programs aren't programming languages". Biases aside,
I think it can come in handy for one off stuff and quick and dirty test stuff. I am working with some IoT devices that send data to a metered service (cloud). For testing/enhancing (can you say debug?)
I found a quick and dirty script for a python syslog server (yes I have a C## version but it does a bunch of parsing) that just prints what it receives.
import socketserver
class MyUDPHandler(socketserver.BaseRequestHandler):
def handle(self):
print(self.request[0].decode())
with socketserver.UDPServer(('10.0.2.4', 514), MyUDPHandler) as server:
server.serve_forever()
gets:
The temperature in Fahrenheit is:77.9 166
The temperature in Celsius is:25.5
But then, I am the lazy old fool.
Edit: I can run it on my Pi (just got a 5!)
>64
There is never enough time to do it right, but there is enough time to do it over.
|
|
|
|
|
Not really that much harder to do on an ESP32 under Arduino.
And it's $12 w/ a screen included.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
easy is one of my favorite 4 letter words.
Comes right after the 4 letter word that starts with an F.... Free.
>64
There is never enough time to do it right, but there is enough time to do it over.
|
|
|
|
|
Well, to be clear I'm not saying it's either easy or free.
But Arduino does lower the bar for entry into C++ development significantly, even if it's not the best code.
Frankly, RPis are a bit heavy handed, and are priced to match. It's a whole lot more machine than you need for most IoT purposes, and I tend to think of them more as a mini PC than an IoT widget.
The ESP32 has wifi and bluetooth built in, and can do most anything with sensors and such you can do with an RPi, sometimes better, because it's realtime, but without the $100+ price tag, the power consumption, the size, the desk space requirements while coding it, etc.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
I didn't say that Python is useless; I said that I have no use for it.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Well, I never thought you said that.
Seems to me that, on this forum, the washed like to pile on the unwashed.
Back to lurking.
>64
There is never enough time to do it right, but there is enough time to do it over.
|
|
|
|
|
theoldfool wrote: the washed like to pile on the unwashed.
I apologize for my misunderstanding.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Maybe not better, but with Python much more easier if I think about all that matrix/vector operations...
|
|
|
|
|
Possibly, if my work involved matrix/vector operations. Which it doesn't.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Because the author of the Open Source program I want to modify chose to write it in Python!
|
|
|
|
|
Was talking with a friend who leans more network engineer than programmer. They had some programming courses in college.
I'm hoping I convinced them that C#/Powershell are far more useful things to focus on than Python unless they want to shift gears and be a data scientist.
They asked if I thought Python as a first language was a hindrance. I think most absolutely so.
|
|
|
|
|
I agree that it is, since it's mostly just glue, and does so much for you, or via external libraries that too much is black boxed. Sure you can resize an image, but do you know what it's actually doing?
I used to say C# was the way to go.
Now, after watching people who aren't programmers pick and up and begin to program with something, I'm suggesting people go buy an ESP32, and start coding on that with Arduino.
It will teach you enough C++ to be dangerous, and honestly? They're fun enough to keep you motivated even with the struggles.
It won't teach you best practices, but I've seen more non-coder engineers go this route and be successful than i can count.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
I seriously want to tell new people to find whatever copy of VB they can. It's not at all like the basics (heh) don't carry. WYSIWYG is also just a powerful learning tool and we're not talking production web systems of messy genned code.
Powershell/C# for the buddy is mostly about that being really useful for network admin types.
Most everything modern, no matter what it is, there's just too much involved and it looks like such a big cookie you can't even figure where the first bite should be.
As much as the lowered bar got a bad rap (see Unity in game dev today) it was precisely because the lowering of that bar was a great and massive enabler to bring people into the fold. If you want 'em to become part of the herd they need to at least begin to identify fields of sheep.
|
|
|
|
|
I wouldn't get people started with VB6.
C# is the way to go for new development, and is not that difficult to pick up as languages go. It's just that it can do a lot so you need a roadmap or a mentor so you don't get lost in all the functionality. Actually doing stuff with it is easy.
The difference between C# and VB6, syntax aside, is with VB6 you had to beg borrow and steal your way through unmanaged APIs to do anything "off book" that VB6 wasn't designed for. There's a whole website devoted to this, for better or worse: https://vbaccelerator.com[^]
With C#, it's all there already. But that just means there's a lot of stuff too.
The trick to getting started is knowing where to start.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
I think what I like is getting at things aside console apps that you can easily see. It's small but it's also motivating/inspiring where Console.Writeline is maybe more 'meh, ok'.
The stuff with event wire up to controls and such... that stuff really plays into a bunch of more modern things.
> The trick to getting started is knowing where to start.
That's the thing... indulging a bit of time travel obliterates so many starting points.
|
|
|
|
|
I have very little experience with python, but just enough to ask?
Did you declare this inside the scope of an object?
Did you indent the def?
It looks like it does not know where to bind the function to be an attribute of a class?
|
|
|
|
|
It was someone else's code I was trying to help them with and honestly I don't remember now.
The point of my post was the error message is cryptic to the point of ridiculous because they've decided on adopting their own lexicon for describing programming constructs.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Let's couple that newspeak with having invisible characters matter! /s
|
|
|
|
|
Yeah, but I've already ranted about that in the past
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|