Hi Paul,
Here an example how I used both functions
https://gitlab.com/snippets/1886520
Hope this helps.
--
Manfred
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, 15 Aug 2019 22:00:17 +0200
Paul St George wrote:
> Can someone please tell me how to get the absolute path to a file? I
> have tried os.path.abspath. In the code below I have a problem in the
> final line (15).
>
> #
> |import bpy||
> ||import os||
> ||
> ||texture_list = []||
> ||
>
On Fri, 16 Aug 2019 09:00:38 +1000
Cameron Simpson wrote:
> On 15Aug2019 22:52, Manfred Lotz wrote:
> >I did this:
> >from pathlib import Path
> >abs_myfile = Path('./myfile').resolve()
> >which worked fine for me.
>
> There is also os.path.realpath(file
I want to exercise how to create a package and upload it to pyi. So, I
registered with https://test.pypi.org/.
Now, when I click on https://test.pypi.org/manage/account/#account-emails
to verify my email address I get an internal server error.
Same when I try
On Sat, 24 Aug 2019 14:12:38 +0200
Manfred Lotz wrote:
> I want to exercise how to create a package and upload it to pyi. So, I
> registered with https://test.pypi.org/.
>
> Now, when I click on
> https://test.pypi.org/manage/account/#account-emails to verify my
> e
On Sat, 31 Aug 2019 16:37:23 +0200
Peter Otten <__pete...@web.de> wrote:
> Manfred Lotz wrote:
>
> > Hi there,
> > This is a beginner question.
> >
> > I learned that
> >
> > with open("foo.txt") as f:
> > lines = f.read
Hi there,
This is a beginner question.
I learned that
with open("foo.txt") as f:
lines = f.readlines()
using the with-construct is the recommended way to deal with files
making sure that close() always happens.
However, I also could do:
lines = open("foo.txt").readlines()
I have to
On Sat, 31 Aug 2019 15:43:41 +0200
Piet van Oostrum wrote:
> Max Zettlmeißl writes:
>
> > On Sat, Aug 31, 2019 at 2:22 PM Manfred Lotz
> > wrote:
> >>
> >> Could I use the latter as a substitute for the with-construct?
> >>
> >
> >
On Sun, 1 Sep 2019 16:46:44 +0100
Barry wrote:
> > On 31 Aug 2019, at 15:41, Manfred Lotz wrote:
> >
> > When you say COULD this sounds like it is a matter of luck. My
> > thinking was that USUALLY the file will be closed after the
> > statement because then the
On Thu, 22 Aug 2019 21:48:33 -0700 (PDT)
jf...@ms4.hinet.net wrote:
> Cameron Simpson於 2019年8月23日星期五 UTC+8下午12時09分54秒寫道:
> > On 22Aug2019 19:38, Jach Fong wrote:
> > >Say I like to record everything showing in the console into a file
> > >after I start a debug session, and stop it when
On Fri, 23 Aug 2019 00:42:26 -0700 (PDT)
jf...@ms4.hinet.net wrote:
> Manfred Lotz於 2019年8月23日星期五 UTC+8下午2時58分48秒寫道:
> > On Thu, 22 Aug 2019 21:48:33 -0700 (PDT)
> > jf...@ms4.hinet.net wrote:
> >
> > > Cameron Simpson於 2019年8月23日星期五
> > > UTC+8下午12時09分54
I have a function like follows
def regex_from_filepat(fpat):
rfpat = fpat.replace('.', '\\.') \
.replace('%', '.') \
.replace('*', '.*')
return '^' + rfpat + '$'
As I don't want to have the replace() functions in one line my
question is if
On Tue, 17 Sep 2019 20:59:47 +0200
Manfred Lotz wrote:
> I have a function like follows
>
> def regex_from_filepat(fpat):
> rfpat = fpat.replace('.', '\\.') \
> .replace('%', '.') \
Not related to my question but the second replace must be:
On 17 Sep 2019 19:10:29 GMT
Martin Schöön wrote:
> I have installed a bunch of packages using pip install --user and
> I went for a non-standard location for the install. Now I regret
> this and would like to wipe this and start all over again using
> the standard location. Is it enough to
On Tue, 17 Sep 2019 16:51:04 -0400
Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote:
> On 9/17/19 2:59 PM, Manfred Lotz wrote:
>
> > def regex_from_filepat(fpat):
> > rfpat = fpat.replace('.', '\\.') \
> >
On Wed, 18 Sep 2019 09:52:21 +0200
Wolfgang Maier wrote:
> On 17.09.19 20:59, Manfred Lotz wrote:
> > I have a function like follows
> >
> > def regex_from_filepat(fpat):
> > rfpat = fpat.replace('.', '\\.') \
> &g
On Wed, 18 Sep 2019 08:30:08 +0200
Peter Otten <__pete...@web.de> wrote:
> Manfred Lotz wrote:
>
> > I have a function like follows
> >
> > def regex_from_filepat(fpat):
> > rfpat = fpat.replace('.', '\\.') \
> > .replace('%',
On Thu, 19 Sep 2019 08:36:04 +0200
Peter Otten <__pete...@web.de> wrote:
> Manfred Lotz wrote:
>
> >> Not related to your question, but:
> >> You seem to try to convert a Windows wildcard pattern to a regex
> >> pattern.
> >
> > No,
On Wed, 18 Sep 2019 22:01:34 +0200
"Ralf M." wrote:
> Am 17.09.2019 um 20:59 schrieb Manfred Lotz:
> > I have a function like follows
> >
> > def regex_from_filepat(fpat):
> > rfpat = fpat.replace('.', '\\.')
Hi there,
More often I see something like this:
class Myclass:
...
but sometimes I see
class Myclass(object):
...
Question: which way is preferable?
--
Manfred
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, 07 Aug 2019 14:39:00 -0400
Dennis Lee Bieber wrote:
> On Wed, 7 Aug 2019 20:11:15 +0200, Manfred Lotz
> declaimed the following:
>
> >Hi there,
> >More often I see something like this:
> >
> >class Myclass:
> >...
> >
> >
On Sun, 21 Jul 2019 03:44:24 +1000
Chris Angelico wrote:
> On Sun, Jul 21, 2019 at 3:41 AM Manfred Lotz
> wrote:
> >
> > Hi there,
> > Pretty new to python I've got a question regarding the proper
> > shebang for Python 3.
> >
> > I use
> >
On Sat, 20 Jul 2019 14:11:21 -0400
Michael Speer wrote:
> You may want to use `#!/usr/bin/env python3` instead.
>
In my case it doesn't matter. However, I agree that your suggestion is
usually preferable.
> There is a concept in python called the virtual environment. This
> used to be done
Hi there,
Pretty new to python I've got a question regarding the proper shebang
for Python 3.
I use
#!/usr/bin/python3
which works fine.
Today I saw
#!/usr/bin/python3 -tt
and was wondering what -tt means.
Being on Fedora 30, Python 3.7.3 the man page of python3 doesn't even
mention
On Sat, 20 Jul 2019 23:28:35 +0200
Brian Oney wrote:
> Why not make a compromise? What would be a potential pitfall of the
> following spitbang?
>
> #!python
I think that per definition a path in a shebang has to be absolute.
Actually, your suggestion won't work for people who use the fish
On Sun, 21 Jul 2019 10:21:55 +1000
Cameron Simpson wrote:
> On 21Jul2019 09:31, Chris Angelico wrote:
> >On Sun, Jul 21, 2019 at 9:15 AM Cameron Simpson
> >wrote: So you mean that a tool that depends on running on a
> >consistent environment, it should use a shebang of
>
On Wed, 2 Oct 2019 04:27:14 + (UTC)
Hongyi Zhao wrote:
> Hi,
>
> See my following test:
>
> With ipython:
>
> In [1]: import
> socket
>
> In [2]: socket.gethostbyname
> ('www.vpngate.net')
>
I had a look into type checking and tried a very simple example like
the following:
#!/usr/bin/env python3
def greeting(name: str) -> str:
return 'Hello ' + name
def main():
print(greeting(1))
if __name__ == "__main__":
main()
pytype complained as expected.
BUT mypy says;
On Sat, 19 Oct 2019 21:58:23 -0700
Paul Rubin wrote:
> Manfred Lotz writes:
> > def main():
> > print(greeting(1))
> >
> > Any idea why mypy doesn't detect anything?
>
>
> "main" doesn't have a type signature so it doesn't get checked.
On Sat, 30 Nov 2019 20:42:21 -0800 (PST)
John Ladasky wrote:
> Long-time Ubuntu user here.
>
> For years, I've read warnings about not installing one's personal
> stack of Python modules on top of the system Python. It is possible
> to corrupt the OS, or so I've gathered.
>
This is nonsense
On Sun, 26 Apr 2020 15:26:58 +1200
DL Neil wrote:
> On 25/04/20 7:53 PM, Manfred Lotz wrote:
> > On Sat, 25 Apr 2020 18:41:37 +1200
> > DL Neil wrote:
> >
> >> On 25/04/20 5:16 PM, Manfred Lotz wrote:
> >>> On Fri, 24 Apr 202
I have a command like application which checks a directory tree for
certain things. If there are errors then messages will be written to
stdout.
How to test this in the best way?
One idea was for the error situations to write messages to files and
then later when running the tests to compare the
On Mon, 27 Apr 2020 18:21:39 +1200
DL Neil wrote:
...
>
> Given your replies, 'now' might be a good time to take a look at
> Pytest, and see how you could use it to help build better code - by
> building tested units/functions which are assembled into ever-larger
> tested-units... (there is a
On 24 Apr 2020 20:17:04 GMT
r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> Manfred Lotz writes:
> >I have a command like application which checks a directory tree for
> >certain things. If there are errors then messages will be written to
> >stdout.
>
> Error
On Sat, 25 Apr 2020 08:25:00 +1200
DL Neil wrote:
> On 25/04/20 6:40 AM, Manfred Lotz wrote:
> > I have a command like application which checks a directory tree for
> > certain things. If there are errors then messages will be written to
> > stdout.
> >
> >
On Sat, 25 Apr 2020 18:41:37 +1200
DL Neil wrote:
> On 25/04/20 5:16 PM, Manfred Lotz wrote:
> > On Fri, 24 Apr 2020 19:12:39 -0300
> > Cholo Lennon wrote:
> >
> >> On 24/4/20 15:40, Manfred Lotz wrote:
> >>> I have a command like application which
On 24 Apr 2020 22:18:45 GMT
r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> DL Neil writes:
> >Python's logging library enables messages to be formatted
> >accordingly, and directed differently, depending upon 'level of
> >severity'. So, as well as the flexibility mentioned before, there is
> >an
On Fri, 24 Apr 2020 19:12:39 -0300
Cholo Lennon wrote:
> On 24/4/20 15:40, Manfred Lotz wrote:
> > I have a command like application which checks a directory tree for
> > certain things. If there are errors then messages will be written to
> > stdout.
> >
> >
I unzip a zip file like follows which works fine.
with ZipFile(zip_file, 'r') as zip:
zip.extractall(tmp_dir)
The only caveat is that the unpacked files and dirs do have a current
timestamp i.e. the timestamps of the files are not preserved.
Is there a way to tell ZipFile to
On Wed, 18 Mar 2020 21:41:10 +
MRAB wrote:
> On 2020-03-18 20:38, Manfred Lotz wrote:
> > I unzip a zip file like follows which works fine.
> >
> > with ZipFile(zip_file, 'r') as zip:
> > zip.extractall(tmp_dir)
> >
> > The only caveat is t
Hi there,
I am asking myself if I should preferably use single or double quotes
for strings?
If I need a single quote in a string I would use double quotes for the
whole string and vice versa. For f-strings I mostly see double
quotes but single quotes would work as well I think.
Is there a
On Tue, 19 May 2020 13:36:54 -0500
Tim Chase wrote:
> On 2020-05-19 20:10, Manfred Lotz wrote:
> > Hi there,
> > I am asking myself if I should preferably use single or double
> > quotes for strings?
>
> I'd say your consistency matters more than which one
On Sat, 23 May 2020 09:36:13 +1200
DL Neil wrote:
> >>> I am asking myself if I should preferably use single or double
> >>> quotes for strings?
> ...
>
> > I agree to the following:
> >
> > 1. Consistency is important.
> > 2. Single quotes are less noisy.
> > 3. Triple double quotes are to
On Sat, 23 May 2020 14:46:04 -0400
Dennis Lee Bieber wrote:
> On Sat, 23 May 2020 11:03:09 -0500, Tim Chase
> declaimed the following:
>
>
> >
> >But when a string contains both, it biases towards single quotes:
> >
> > >>> "You said \"No it doesn't\""
> > 'You said "No it doesn\'t"'
I have an object which I could initialize providind an int or a str.
I am not sure which of the following is best to use
- try/except
- if type(int)...
- if isinstance(v, int)
Here a minimal example
def get_id(fromname):
# do something with `fromname`
return 0
def
On Sat, 15 Aug 2020 08:33:58 +0200
Peter Otten <__pete...@web.de> wrote:
> Chris Angelico wrote:
>
> > On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz
> > wrote:
> >>
> >> I have an object which I could initialize providind an int or a
> >>
On Sat, 15 Aug 2020 11:47:03 +0200
Sibylle Koczian wrote:
> Am 15.08.2020 um 10:14 schrieb Manfred Lotz:
> > Hi Chris,
> > Thanks a lot for you advice.
> >
> > On Sat, 15 Aug 2020 16:15:29 +1000
> > Chris Angelico wrote:
> >
> >> On Sat,
Hi Chris,
Thanks a lot for you advice.
On Sat, 15 Aug 2020 16:15:29 +1000
Chris Angelico wrote:
> On Sat, Aug 15, 2020 at 3:36 PM Manfred Lotz
> wrote:
> >
> > I have an object which I could initialize providind an int or a str.
> >
> > I am not sure which o
On Mon, 28 Sep 2020 05:20:20 +0800
Stephane Tougard wrote:
> On 2020-09-27, Manfred Lotz wrote:
> > - http://localhost:2015/tutorial/controlflow.html#pass-statements
> ...
> > (In comparison to guys like ChrisA and StefanR and others here I am
> > also a Python beg
On Mon, 28 Sep 2020 13:39:08 +0800
Stephane Tougard wrote:
> On 2020-09-28, Manfred Lotz wrote:
> > On Mon, 28 Sep 2020 05:20:20 +0800
> > Stephane Tougard wrote:
> >
> >> On 2020-09-27, Manfred Lotz wrote:
> >> > -
> >> > http://lo
On Sun, 27 Sep 2020 15:18:44 +0800
Stephane Tougard wrote:
> On 2020-09-27, 2qdxy4rzwzuui...@potatochowder.com
> <2qdxy4rzwzuui...@potatochowder.com> wrote:
> > As ChrisA noted, Python almost always Just Works without
> > declarations. If you find yourself with a lot of global and/or
> >
On Mon, 25 May 2020 19:25:08 +0100
MRAB wrote:
> On 2020-05-25 19:00, Ciarán Hudson wrote:
> > Hi,
> >
> > In the code below, which is an exercise I'm doing in class
> > inheritance, almost everything is working except outputting my
> > results, which as the function stock_count, to a csv.
On Tue, 19 May 2020 13:36:54 -0500
Tim Chase wrote:
> On 2020-05-19 20:10, Manfred Lotz wrote:
> > Hi there,
> > I am asking myself if I should preferably use single or double
> > quotes for strings?
>
> I'd say your consistency matters more than which one you choos
On Wed, 17 Jun 2020 17:34:55 +0100
Tony Flury wrote:
> On 24/04/2020 19:40, Manfred Lotz wrote:
> > I have a command like application which checks a directory tree for
> > certain things. If there are errors then messages will be written to
> > stdout.
> >
> >
On Sun, 16 Aug 2020 10:12:04 +0200
Klaus Jantzen wrote:
> Hi,
>
> the other day I came across the book "Classic Computer Science
> Problems in Python" by David Kopec.
>
> The function definitions in the examples like
>
> =
> def fib2(n: int) -> int:
> if n < 2: # base case
>
On 15 Aug 2020 14:49:48 GMT
r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> Manfred Lotz writes:
> >Here a minimal example
>
> main.py
>
> source="""
> sehr gut
> 1
> """[ 1: -1 ].split( "\n" )
>
> class grades
On Sun, 16 Aug 2020 06:09:17 -0500
Skip Montanaro wrote:
> > Typing is not required by
> > Python. However, you may find the extra error-checking helpful...
>
> I haven't used type hints much, if at all, but my understanding is
> that the "extra error-checking" of which you speak is gotten
On Sun, 16 Aug 2020 09:40:12 +0200
Manfred Lotz wrote:
> On Sat, 15 Aug 2020 12:20:48 -0400
> Dennis Lee Bieber wrote:
>
> > On Sat, 15 Aug 2020 15:31:56 +0200, Manfred Lotz
> > declaimed the following:
> >
> > >On Sat, 15 Aug 2020 11:47:
On Sat, 15 Aug 2020 12:20:48 -0400
Dennis Lee Bieber wrote:
> On Sat, 15 Aug 2020 15:31:56 +0200, Manfred Lotz
> declaimed the following:
>
> >On Sat, 15 Aug 2020 11:47:03 +0200
> >Sibylle Koczian wrote:
> >
>
> >> if the value comes from a f
I have a situation where in a directory tree I want to change a certain
string in all files where that string occurs.
My idea was to do
- os.scandir and for each file
- check if a file is a text file
- if it is not a text file skip that file
- change the string as often as it occurs in
On Tue, 10 Nov 2020 18:52:26 +1100
Mike Dewhirst wrote:
> On 10/11/2020 5:24 pm, Manfred Lotz wrote:
> > I have a situation where in a directory tree I want to change a
> > certain string in all files where that string occurs.
> >
> > My idea was to do
> >
&
On Tue, 10 Nov 2020 18:37:54 +1100
Cameron Simpson wrote:
> On 10Nov2020 07:24, Manfred Lotz wrote:
> >I have a situation where in a directory tree I want to change a
> >certain string in all files where that string occurs.
> >
> >My idea was to do
> >
On Tue, 10 Nov 2020 08:19:55 +0100
"Loris Bennett" wrote:
> Manfred Lotz writes:
>
> > I have a situation where in a directory tree I want to change a
> > certain string in all files where that string occurs.
> >
> > My idea was to do
> >
>
On Tue, 10 Nov 2020 22:08:54 +1100
Cameron Simpson wrote:
> On 10Nov2020 10:07, Manfred Lotz wrote:
> >On Tue, 10 Nov 2020 18:37:54 +1100
> >Cameron Simpson wrote:
> >> Use os.walk for trees. scandir does a single directory.
> >
> >Perhaps bette
On Tue, 10 Nov 2020 10:57:05 +0100
"Loris Bennett" wrote:
> Manfred Lotz writes:
>
> > On Tue, 10 Nov 2020 08:19:55 +0100
> > "Loris Bennett" wrote:
> >
> >> Manfred Lotz writes:
> >>
> >> > I have a situation
On 11 Nov 2020 19:21:57 GMT
r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> In my Python course I gave the assignment to define a
> counter class "Main" so that
>
> counter0 = Main()
> counter1 = Main()
> counter1.count(); counter1.count(); counter1.count()
> counter1.count(); counter1.count()
On Sat, 14 Nov 2020 05:08:07 -0600
2qdxy4rzwzuui...@potatochowder.com wrote:
> On 2020-11-14 at 10:09:32 +0100,
> Manfred Lotz wrote:
>
> > On 11 Nov 2020 19:21:57 GMT
> > r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> >
> > > In my Python co
On Mon, 24 May 2021 08:14:39 +1200
Ron.Lauzon@f192.n1.z21.fsxnet (Ron Lauzon) wrote:
> -=> hw wrote to All <=-
>
> hw> Traceback (most recent call last):
> hw>File "[...]/hworld.py", line 18, in
> hw> print(isinstance(int, float))
> hw> TypeError: isinstance() arg 2 must be a
Let us say I have a package which reads a TOML file.
I want to give the user of my package the choice to decide if he wants
to use the toml, tomlkit or rtoml package.
So, in case the user chose to use rtoml then there should be an import
only for rtoml, aso.
How could I achieve this?
--
On Sat, 6 Mar 2021 12:00:33 +0100
Manfred Lotz wrote:
> Let us say I have a package which reads a TOML file.
>
> I want to give the user of my package the choice to decide if he wants
> to use the toml, tomlkit or rtoml package.
>
> So, in case the user chose to use rtoml
On Sat, 6 Mar 2021 14:06:27 +0100
Peter Otten <__pete...@web.de> wrote:
> On 06/03/2021 12:43, Manfred Lotz wrote:
> > On Sat, 6 Mar 2021 12:00:33 +0100
> > Manfred Lotz wrote:
> >
> >> Let us say I have a package which reads a TOML file.
> >&g
On Sat, 6 Mar 2021 15:40:41 - (UTC)
Grant Edwards wrote:
> On 2021-03-06, Manfred Lotz wrote:
> > Let us say I have a package which reads a TOML file.
> >
> > I want to give the user of my package the choice to decide if he
> > wants to use the toml, tomlkit or
On Sun, 7 Mar 2021 20:38:30 -0800
Dan Stromberg wrote:
> I sometimes do things like:
>
> try:
> import rtoml as toml
> except ImportError:
> import toml
>
Also a possibility. Thanks.
> ...but I don't like it very much, because it tends to confuse static
> analyzers like pyflakes and
On Thu, 9 Dec 2021 18:18:26 +0100
"Dieter Maurer" wrote:
> Manfred Lotz wrote at 2021-12-8 12:31 +0100:
> >The are many possibilities to package a Python app, and I have to
> >admit I am pretty confused.
> >
> >Here is what I have:
> >
> >A Pyt
On Thu, 9 Dec 2021 17:34:03 +
Barry wrote:
> > On 8 Dec 2021, at 18:27, Manfred Lotz wrote:
> >
> > The are many possibilities to package a Python app, and I have to
> > admit I am pretty confused.
> >
> > Here is what I have:
> >
> &g
Hi Loris,
On Wed, 08 Dec 2021 15:38:48 +0100
"Loris Bennett" wrote:
> Hi Manfred,
>
> Manfred Lotz writes:
>
> > The are many possibilities to package a Python app, and I have to
> > admit I am pretty confused.
> >
> > Here is what I have:
&g
The are many possibilities to package a Python app, and I have to admit
I am pretty confused.
Here is what I have:
A Python command line app which requires some packages which are not in
the standard library.
I am on Linux and like to have an executable (perhaps a zip file with a
shebang;
On Thu, 9 Dec 2021 13:51:00 -0700
Mats Wichmann wrote:
> On 12/9/21 11:35, Manfred Lotz wrote:
>
> > I played with pyinstaller which worked fine. However, it builds a
> > dynamic executable and thus it is glibc version dependent. Means, I
> > have to build different
On Thu, 9 Dec 2021 21:23:58 +0100
"Peter J. Holzer" wrote:
> On 2021-12-09 19:35:37 +0100, Manfred Lotz wrote:
> > I played with pyinstaller which worked fine. However, it builds a
> > dynamic executable and thus it is glibc version dependent. Means, I
> > have
>
I don't understand how this may help. Assume somebody has a codebase of 15T
lines of Python code. How do you want to apply your method?
But perhaps I overlook things.
--
Manfred
> 27.03.2022 12:24, Manfred Lotz пишет:
>> Let's say I have a Python app and have used an undefined
On 3/27/22 18:36, Skip Montanaro wrote:
>> Let's say I have a Python app and have used an undefined method somewhere.
>> Let
>> us further assume I have not detected it thru my tests.
>>
>> Is there a way to detect it before deploying the app? pylint doesn't
>> notice it.
>>
>
> This is maybe not
On 3/27/22 18:12, Peter Otten wrote:
> On 27/03/2022 11:24, Manfred Lotz wrote:
>> Let's say I have a Python app and have used an undefined method somewhere.
>> Let
>> us further assume I have not detected it thru my tests.
>>
>> Is there a way to detect it
Let's say I have a Python app and have used an undefined method somewhere. Let
us further assume I have not detected it thru my tests.
Is there a way to detect it before deploying the app? pylint doesn't notice it.
Minimal example:
#!/usr/bin/env python3
import logging
from logging import
83 matches
Mail list logo