Re: ChatGPT Generated news poster code

2023-02-12 Thread Roland Müller via Python-list

Hello,

On 2/11/23 03:31, Greg Ewing via Python-list wrote:

For a moment I thought this was going to be a script that
uses ChatGPT to generate a random news post and post it
to Usenet...

Which would also have been kind of cool, as long as it wasn't
overused.


Actually, I like cynical humor too ... But this is too much

-Roland

--
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to completely remove Python 3.10.9 (64 bit) from Computer

2023-10-04 Thread Roland Müller via Python-list


On 25.9.2023 19.58, Pau Vilchez via Python-list wrote:

Hello Python Team,

 


I am somehow unable to completely remove Python 3.10.9 (64 Bit) from my
computer. I have tried deleting the Appdata folder then repairing and then
uninstalling but it still persists in the remove/add program function in
windows 10. I am just trying to reinstall it because I didn’t add it to
the path correctly, any help is greatly appreciated.

This is a Windows issue and not actually Python -specific. It may happen 
to every program you install.


If something is installed by the normal way using the W10 installer it 
should be removable too. If not there should be some error.


 


Very Respectfully,

 


Pau Vilchez

 

--
https://mail.python.org/mailman/listinfo/python-list


Re: Return

2021-12-09 Thread Roland Müller via Python-list

Hello,


On 12/8/21 11:29, vani arul wrote:

Thanks for your help.
I am not good at programming.My code works perfectly.But I am bit 
confused about the return values.


Binary Search Program

/def Binarysearch(a,key):
    l=0
    r=len(a)-1
    while l<=r:
    med = (l+r)//2
    if key==a[med]:
    return med
    elif key>a[med]:
    l=med+1/

/      elif keyBut in the following block,how does it return values if there is no 
return specified?



First of all please reply always to the list address!

If Python does not encounter a return statement it will continue to run 
the function.


In your example the while loop will continue until the condition 'l<=r' 
is true. If Python exits the while loop then there is a return -1.


BR,

Roland






Regards
Vani

On Wed, Dec 8, 2021 at 2:15 AM Roland Mueller 
 wrote:


Hello

ti 7. jouluk. 2021 klo 19.47 vani arul (arulvan...@gmail.com)
kirjoitti:

Hey There,
Can someone help to understand how a python function can
return value with
using return in the code?
It is not not about explicit or implicit function call.


Not sure whether I understood your question: I have a simple
example about return.
  * f() and h() explicitely return something
  * g() and h() return None

BTW, also Python documentation tool pydoc has an article about return.

#!/usr/bin/python

def f():
    return 42
def g():
    pass
def h():
    return

if __name__ == "__main__":
    print(f"f(): {f()}")
    print(f"g(): {g()}")
    print(f"h(): {h()}")

Result:
f(): 42
g(): None
h(): None

Pydoc:
$ pydoc return

BR,
Roland


Thanks
Vani
-- 
https://mail.python.org/mailman/listinfo/python-list



--
https://mail.python.org/mailman/listinfo/python-list


Re: Hot reload Flask app?

2020-10-01 Thread Roland Müller via Python-list



On 2020-10-01 16:33, sjeik_ap...@hotmail.com wrote:

Hi,
I would like to create a "/reload" view in my Flask app, so I could easily
and safely reload it when code, templates etc change. Similar to what
happens when running the app with the debug server. I am using Nginx and
Gevent on a recent Ubuntu system with Python 3.6.
My strategy would be to gracefully stop Gevent [1], then do
os.kill(os.getpid(), signal.SIGHUP). I have not yet tried this (not
working today!). Just wondering if there are best practices.
Thanks!
Albert-Jan
[1]

http://www.gevent.org/api/gevent.baseserver.html#gevent.baseserver.BaseServer.stop


Running flask app.run(debug=True) will make the Flask server watching 
the filesystem for source code changes and re-deploy your app.


https://pythonhosted.org/Flask-Debug/

-Roland

--
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-15 Thread Roland Müller via Python-list


On 10/13/20 4:14 PM, Serhiy Storchaka wrote:

13.10.20 11:52, Tony Flury via Python-list пише:

I am trying to write a simple expression to build a raw string that ends
in a single backslash. My understanding is that a raw string should
ignore attempts at escaping characters but I get this :

     >>> a = r'end\'
       File "", line 1
         a = r'end\'
       ^
    SyntaxError: EOL while scanning string literal

I interpret this as meaning that the \' is actually being interpreted as
a literal quote - is that a bug ?

r'You can\'t end raw string literal with a single "\"'

If backslash be true inner in a raw string, the above literal would end
after \'. It would be very hard to write a raw string containing both \'
and \", and even \''' and \""" (there are such strings in the stdlib).

So you have problem either with trailing backslash, or with inner
backslash followed by quotes. Both problems cannot be solved at the same
time. Python parser works as it works because initially it was easier to
implement, and now this cannot be changed because it would break some
amount of correct code.


The only solution I have found is to do this :

     >>> a = r'end' + chr(92)
     >>> a
    'end\\'
     >>> list(a)
    ['e', 'n', 'd', '\\']

or


     >>> a = r'end\\'[:-1]
     >>> list(a)
    ['e', 'n', 'd', '\\']

Neither of which are nice.

You can also write r'end' '\\'. It is not too nice, but it looks nicer
to me then two other variants.


I used the triple single quotes as delimiter:

>>> s = r'''a single quote ', a double quote "'''
>>> s

'a single quote \', a double quote "'

BR,

Roland


--
https://mail.python.org/mailman/listinfo/python-list


Re: Common objects for CLI commands with Typer

2024-10-16 Thread Roland Müller via Python-list



On 9/23/24 22:51, Dan Sommers via Python-list wrote:

On 2024-09-23 at 19:00:10 +0100,
Barry Scott  wrote:


On 21 Sep 2024, at 11:40, Dan Sommers via Python-list  
wrote:

But once your code gets big the disciple of using classes helps
maintenance. Code with lots of globals is problematic.

Even before your code gets big, discipline helps maintenance.  :-)

Every level of your program has globals.  An application with too many
classes is no better (or worse) than a class with too many methods, or a
module with too many functions.  Insert your own definitions of (and
tolerances for) "too many," which will vary in flexibility.

I think the need of classes comes when you need objects thus a set of 
variables with an identity and that may be created N times. Classes are 
object factories.


A second aspect is inheritance: classes may inherit from other classes 
and reuse existing functionality and data structures for their objects.


In cases where you only need to encapsulate a single set of data and 
functions modules are the best choice.





--
https://mail.python.org/mailman/listinfo/python-list