Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Python isdigit() and None
Post: RE: Python isdigit() and None

The == True is just redundant because if value.isdigit() is perfectly clear. The name isdigit is good because it tells you what the possible answers are (that there are only 2 possibilities of course)...
ndc85430 General Coding Help 6 187 May-06-2021, 03:06 PM
    Thread: feature request: ternary fallthroughs
Post: RE: feature request: ternary fallthroughs

Can you point us to an example in another language that does this? I've not seen it before, so must be unfamiliar with those languages.
ndc85430 News and Discussions 31 745 May-06-2021, 07:37 AM
    Thread: feature request: ternary fallthroughs
Post: RE: feature request: ternary fallthroughs

I don't get what you're trying to do either. I am half wondering if what you want is a result monad, though.
ndc85430 News and Discussions 31 745 May-05-2021, 07:31 PM
    Thread: how would you feel if ...
Post: RE: how would you feel if ...

No, they're programming languages: https://golang.org/ and e.g. https://en.m.wikipedia.org/wiki/XQuery.
ndc85430 Bar 13 451 May-02-2021, 04:54 AM
    Thread: help for use print in REPL
Post: RE: help for use print in REPL

Really, people should be learning how to program more declaratively anyway (a good talk on this: https://youtu.be/nrVIlhtoE3Y). To be fair to Java, that's done by making use of the Streams API
ndc85430 General Coding Help 10 273 Apr-30-2021, 02:23 PM
    Thread: Re-write BASH script to Python script
Post: RE: Re-write BASH script to Python script

Don't see why you'd use subprocess when there's a lot in the os and shutil modules.
ndc85430 Homework 5 151 Apr-30-2021, 02:14 PM
    Thread: Re-write BASH script to Python script
Post: RE: Re-write BASH script to Python script

What have you tried? We're not going to do the work for you.
ndc85430 Homework 5 151 Apr-30-2021, 02:07 PM
    Thread: how would you feel if ...
Post: RE: how would you feel if ...

Can't say it bothers me, having used it in Go and XQuery.
ndc85430 Bar 13 451 Apr-29-2021, 05:06 PM
    Thread: Can python open a hyperlink?
Post: RE: Can python open a hyperlink?

Clicking a link on s page makes an HTTP request to the URL. Yes, you can make HTTP requests in Python and process the responses. There are likely a number of HTTP clients you can use, but a popular on...
ndc85430 General Coding Help 3 157 Apr-28-2021, 08:18 AM
    Thread: dict+dict
Post: RE: dict+dict

One rarely needs to mutate anything ;). Another option is to use toolz.dicttoolz.merge (https://toolz.readthedocs.io/en/latest/a...oolz.merge). There's a lot of good stuff in Toolz.
ndc85430 News and Discussions 5 190 Apr-28-2021, 04:57 AM
    Thread: help on first function
Post: RE: help on first function

You aren't printing anything - you just throw away the value returned by randint. Note that without the function, the value is printed only because you're at the REPL - its job is to print out the va...
ndc85430 General Coding Help 6 268 Apr-27-2021, 04:47 PM
    Thread: Virtualenv with auto restart
Post: RE: Virtualenv with auto restart

Is it the best solution to use a virtual environment? You could run the app in a Docker container to achieve isolation.
ndc85430 News and Discussions 3 245 Apr-27-2021, 05:27 AM
    Thread: Create Dynamic For Loop
Post: RE: Create Dynamic For Loop

You might want to look at the itertools module to see if anything there is useful. I don't know from your description whether product from that module is appropriate for you.
ndc85430 General Coding Help 3 154 Apr-26-2021, 12:56 PM
    Thread: More elegant way to remove time from text lines.
Post: RE: More elegant way to remove time from text line...

Why use Python at all? Command line tools like sed are made for this sort of thing. Regular expressions (aka "regex") as shown above are also worth knowing something about. An example with sed: Outpu...
ndc85430 General Coding Help 6 409 Apr-25-2021, 05:57 AM
    Thread: Redirecting all print statements from all functions inside a class to Tkinter
Post: RE: Redirecting all print statements from all func...

Why can't you move the function out of where it is? Because it's a closure? Just have the function take the things it needs as arguments, rather than expecting them to be in the enclosing scope.
ndc85430 GUI 1 146 Apr-24-2021, 08:57 AM
    Thread: Moving specific files then unzipping/decompressing
Post: RE: Moving specific files then unzipping/decompres...

If what you have are gzip files, as the .gz extension usually indicates, there's a standard library module for those too: https://docs.python.org/3/library/gzip.html.
ndc85430 General Coding Help 2 156 Apr-24-2021, 04:25 AM
    Thread: Exception with raise and input
Post: RE: Exception with raise and input

Your code doesn't make sense - you're checking that n isn't equal to the int function, which will always be True there. As a hint on how to do it correctly: what does int do if you give it something t...
ndc85430 Homework 3 244 Apr-23-2021, 05:22 AM
    Thread: Functions and if elif problem
Post: RE: Functions and if elif problem

Of course it does. On line 9 (and the others really), your condition is wrong. You need to write month == "September" or month == "October" or month == "November". Non-empty strings evaluate to True...
ndc85430 Homework 1 189 Apr-21-2021, 04:34 AM
    Thread: How to avoid exec(), globals(), locals(), eval()
Post: RE: How to avoid exec(), globals(), locals(), eval...

You don't say why you want to do this in the first place. If you give details about the higher level problem you're actually trying to solve, there might be a more appropriate solution. In any case, a...
ndc85430 General Coding Help 10 524 Apr-20-2021, 04:12 PM
    Thread: Passing flags to python script, through a function
Post: RE: Passing flags to python script, through a func...

If creating another process is unnecessary, then exposing a function that you call from the Flask app is the right idea. Have it take as an argument the list of string arguments that you then pass to ...
ndc85430 General Coding Help 4 329 Apr-20-2021, 06:32 AM

User Panel Messages

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