Re: from xx import yy

2017-11-17 Thread Bob van der Poel
In mod1 set var to a value. Lets use 5. Now, in mod2 we do: from mod1 import var And, yes, var is equal to 5. But, to the folks like me who are not complete pythonistas, we'd think it worked and was wonderful. But, if we change the variable in mod1 whit a function in mod1, the value doesn

Re: reading text in pdf, some working sample code

2017-11-22 Thread Bob van der Poel
xt) > -- > https://mail.python.org/mailman/listinfo/python-list > Sorry if I'm late to this party, but I use pdf2txt for this. Works just fine. It has options for different encodings, page range, etc. On Linux just "apt install python-pdfminer" to install. -- Li

Save and load initialized class

2017-12-08 Thread Bob van der Poel
o my program. Doing z=json.load (open("mybuffer", "r")) loads a dictionary ... which makes sense since that is what I saved. So, can I now reset the values in Opts from a saved dictionary? Best, -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob v

Re: Save and load initialized class

2017-12-10 Thread Bob van der Poel
t; > > -- > Steve > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van

Re: Problem with timeit

2017-12-15 Thread Bob van der Poel
easurements differ drastically from mine (and my manual > measurements match what I'd expect given results of timeit/time.time > whereas yours don't...). > > Paul > -- > https://mail.python.org/mailman/listinfo/python-list > -- Listen to my FREE CD at http://www.me

Re: Where are the moderators?

2018-01-18 Thread Bob van der Poel
mane.org (without the news prefix) does work. -- **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Re: Python "Bad syntax"

2018-02-05 Thread Bob van der Poel
t; item = get_next_item() > if not item: >break > process_item(item) > > Here 'wrong syntax' occurs after the "break". > > How is it possible? Bad version of Python? Which version to use? > >

Re: To clarify how Python handles two equal objects

2023-01-13 Thread Bob van der Poel
ect, with possible multiple > names to it. We can change the object, using one of the names. That is one > and only one operation on one and only one object. Since the different > names refer to the same object, that change will of course be visible > through all of them. > >> Note that 'name' in that sentence doesn't just refer to variables (mx1, > arr1, ...) but also things like indexed lists (mx1[0], mx1[[0][0], ...), > loop variables, function arguments. > >> > >> The correct mental model is important here, and I do think you're on > track or very close to it, but the way you phrase things does give me that > nagging feeling that you still might be just a bit off. > >> > >> -- > >> "Peace cannot be kept by force. It can only be achieved through > understanding." > >> -- Albert Einstein > >> > >> -- > >> https://mail.python.org/mailman/listinfo/python-list > >> > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Re: editor recommendations?

2021-02-26 Thread Bob van der Poel
web browsing was "a > thing", but I'm sure he found a way to do that inside emacs also. > Of course there is a mode for that: https://www.emacswiki.org/emacs/CategoryWebBrowser -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel **

Re: Spot the invalid syntax

2018-03-08 Thread Bob van der Poel
> ============ > Ian Pilcher arequip...@gmail.com > "I grew up before Mark Zuckerberg invented friendship" > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Re: Calling Matlab (2016a) function from Python(3.6)

2018-03-29 Thread Bob van der Poel
an/listinfo/python-list -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread Bob van der Poel
a few times in the past. I used lots of hex over the years, but don't recall ever using octal ... except in frustrating moments when I needed to change permission bits. -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Re: what does := means simply?

2018-05-17 Thread Bob van der Poel
On Thu, May 17, 2018, 8:45 PM Ben Finney, wrote: > Steven D'Aprano writes: > > > If you want to *really* see code that is hard to port, you should try > > porting an Inform 7 program to another language. Any other language. > > Does porting Inform 7 code to Inform 6 count? They are very differen

Re: Indented multi-line strings

2018-05-23 Thread Bob van der Poel
e 'first > line\nlast line\n'. > > If you want additional indentation, then provide a string literal: > > def func(): > foobar > data = >> '': > first line > last line > foobar > > for 'f

Re: Calling an instance method defined without any 'self' parameter

2018-10-04 Thread Bob van der Poel
ve code, is > there any way to call foo? > > Python 2.7 > > > Thanks, > -- > https://mail.python.org/mailman/listinfo/python-list > Use the magic of staticmethod :) class A: @staticmethod def foo(): ... do foo stuff Hope this helps. -- **** Listen to my FREE CD

Are all items in list the same?

2019-01-07 Thread Bob van der Poel
that this won't scale all that well. Am I missing something? -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Re: Are all items in list the same?

2019-01-08 Thread Bob van der Poel
is > > empty, 'all' will return True anyway. > > Neat! I expected that a[0] would be executed in that case, > but it is not. > > -- > Neil Cerutti > -- > https://mail.python.org/mailman/listinfo/python-list > -- Listen to my FREE CD at http://w

Re: get the terminal's size

2019-01-14 Thread Bob van der Poel
Please, is there something similar for python2 ? > > Cheers > -- > Alex > -- > https://mail.python.org/mailman/listinfo/python-list > try this: http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python -- Listen to my FREE CD at http://www.mellowood.c

Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Bob van der Poel
>MaxNum = N2 > > > elif N1 > >MaxNum = N3 > > > > No. Assuing that you meant to include colons where I think you did, what > > if (N1, N2, N3) == (5, 4, 6)? > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > -- > https://mail.python.org/mailman/listinfo/python-list > Isn't the easiest way to do this is: sorted( [n1,n2,n3] )[-1] to get the largest value? -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Re: Implement C's Switch in Python 3

2019-02-03 Thread Bob van der Poel
t! > > > >>> That said, I am aware that I am not in any way a "normal person". > >>> Using month names as per your other example is probably a fair > >>> compromise with other humans. > > In this life, one does have to make allowances... >

Re: Implement C's Switch in Python 3

2019-02-03 Thread Bob van der Poel
On Sun, Feb 3, 2019 at 2:15 PM Chris Angelico wrote: > On Mon, Feb 4, 2019 at 8:02 AM Bob van der Poel wrote: > > > > I'm surprised that no one has yet addressed the year 1 problem. > Hopefully we're doing numeric, not alpha sorts on the stuff before the 1st >

More CPUs doen't equal more speed

2019-05-23 Thread Bob van der Poel
nd, but that is just a guess. Maybe I need to set my sights on bigger, slower programs to see a difference :) -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowo

Re: More CPUs doen't equal more speed

2019-05-23 Thread Bob van der Poel
ny > time, so if it's processor-intensive, it's better to use multiprocessing. > > Of course, if it's already maxing out the disk, then using more cores > won't make it faster. > -- > https://mail.python.org/mailman/listinfo/python-list > -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Re: More CPUs doen't equal more speed

2019-05-24 Thread Bob van der Poel
Ahh, 2 really excellent ideas! I'm reading about parallel right now. And, I know how to use make, so I really should have thought of -j as well. Thanks for the ideas. On Fri, May 24, 2019 at 12:02 AM Christian Gollwitzer wrote: > Am 23.05.19 um 23:44 schrieb Paul Rubin: > > Bo

Re: More CPUs doen't equal more speed

2019-05-24 Thread Bob van der Poel
no one else has brought it up yet, that rather > than manually creating threads and/or process pools for all these > things, this is exactly what the standard concurrent.futures module is > for. It's a fairly brilliant wrapper around all this stuff, and I feel > like it often

Re: More CPUs doen't equal more speed

2019-05-26 Thread Bob van der Poel
On Sun, May 26, 2019 at 11:05 AM Grant Edwards wrote: > On 2019-05-23, Chris Angelico wrote: > > On Fri, May 24, 2019 at 5:37 AM Bob van der Poel > wrote: > >> > >> I've got a short script that loops though a number of files and > >> processes them

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Bob van der Poel
decided that using the work of others was more productive. I've been using parallel with good success. Depends on how much you need to share with the different components. For details see https://www.gnu.org/software/parallel/ -- **** Listen to my FREE CD at http://www.mellowood.ca/music/c

Unicode filenames

2019-12-06 Thread Bob van der Poel
oping for a guideline! Thanks. -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Re: Unicode filenames

2019-12-07 Thread Bob van der Poel
On Sat, Dec 7, 2019 at 4:00 AM Barry Scott wrote: > > > > On 6 Dec 2019, at 18:17, Bob van der Poel wrote: > > > > I have some files which came off the net with, I'm assuming, unicode > > characters in the names. I have a very short program which takes the

Re: Unicode filenames

2019-12-07 Thread Bob van der Poel
On Sat, Dec 7, 2019 at 12:47 PM DL Neil via Python-list < python-list@python.org> wrote: > On 8/12/19 5:50 AM, Bob van der Poel wrote: > > On Sat, Dec 7, 2019 at 4:00 AM Barry Scott > wrote: > >>> On 6 Dec 2019, at 18:17, Bob van der Poel wrote: > >>>

Re: Python, Be Bold!

2020-01-02 Thread Bob van der Poel
/python-list > -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Function to avoid a global variable

2020-04-26 Thread Bob van der Poel
Does this make as much sense as anything else? I need to track calls to a function to make sure it doesn't get called to too great a depth. I had a global which I inc/dec and then check in the function. Works fine, but I do need to keep a global around just for this. So ... instead I wrote a short

Re: Function to avoid a global variable

2020-04-27 Thread Bob van der Poel
e in a function? Is there a PEP? Best, On Sun, Apr 26, 2020 at 8:47 PM Chris Angelico wrote: > On Mon, Apr 27, 2020 at 1:39 PM Bob van der Poel wrote: > > > > Does this make as much sense as anything else? I need to track calls to a > > function to make sure it doesn't

Re: Function to avoid a global variable

2020-04-27 Thread Bob van der Poel
t; On 4/27/20 10:39 AM, Bob van der Poel wrote: > > Thanks Chris! > > > > At least my code isn't (quite!) as bad as the xkcd example :) > > > > Guess my "concern" is using the initialized array in the function: > > > >def myfunct(a, b, c=a

Re: Function to avoid a global variable

2020-05-01 Thread Bob van der Poel
turn f > return deco > > @static(called=0) > def other_function(): > me.called += 1 > ... > > Obviously the name "me" can't be used, as it'd break a bunch of code, > but conceptually this would be incredibly helpful. It'd also be a >

Re: Issue with Python module downloads from Library for a beginner Python coder.

2020-08-02 Thread Bob van der Poel
les from Python's > standard library? Or do you mean installing third party libraries > using pip? > > > ...But now I am not able to open IDLE after multiple tries. > > Have you looked in your start menu in the list of installed programs > for Python? If it is there d

Re: .replace() to replace elements in a Pandas DataFrame

2020-08-05 Thread Bob van der Poel
rame, df. > > > > > > > > A strange thing is that it worked perfectly in the same Jupyter > > > notebook > > > > this morning. > > > > But all of a sudden, it started not doing the replacement any > more. > > > >

Environment vars

2020-11-25 Thread Bob van der Poel
Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Re: Environment vars

2020-11-25 Thread Bob van der Poel
On Wed, Nov 25, 2020 at 10:59 AM Chris Angelico wrote: > On Thu, Nov 26, 2020 at 4:36 AM Bob van der Poel wrote: > > > > I've got a program which accepts an optional env variable listing a > single > > or multiple directory for the app to use. I've done a

Re: Environment vars

2020-11-25 Thread Bob van der Poel
On Wed, Nov 25, 2020 at 11:00 AM dn via Python-list wrote: > On 26/11/2020 05:46, Bob van der Poel wrote: > > I've got a program which accepts an optional env variable listing a > single > > or multiple directory for the app to use. I've done a bit of a search

Re: Environment vars

2020-11-25 Thread Bob van der Poel
On Wed, Nov 25, 2020 at 12:43 PM Eryk Sun wrote: > On 11/25/20, Bob van der Poel wrote: > > I've got a program which accepts an optional env variable listing a > single > > or multiple directory for the app to use. > > In Unix one would use colon as the preferred de

Re: Environment vars

2020-11-25 Thread Bob van der Poel
On Wed, Nov 25, 2020 at 2:22 PM dn via Python-list wrote: > > Ahha! Didn't know about os.pathsep. Seems simple enough to use that and > be > > done with it. > > > > I'm just using str.split() just now. Is there a os.splitpath()? I don't > see > > anything in the docs. > > > https://docs.python.or

Re: Environment vars

2020-11-27 Thread Bob van der Poel
On Fri, Nov 27, 2020 at 1:41 PM dn via Python-list wrote: > On 26/11/2020 05:46, Bob van der Poel wrote: > > I've got a program which accepts an optional env variable listing a > single > > or multiple directory for the app to use. I've done a bit of a search

Funny error message

2020-12-31 Thread Bob van der Poel
line 1, in NameError: name 'z' is not defined I understand "z in not defined" ... but what's with the warnings? -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

Re: Funny error message

2021-01-01 Thread Bob van der Poel
peated over and over again after every error. Could this be a bug in requests? On Fri, Jan 1, 2021 at 3:03 AM Peter Otten <__pete...@web.de> wrote: > On 31/12/2020 23:46, Bob van der Poel wrote: > > > When I run python from the command line and generate an error I get the >

Re: Funny error message

2021-01-01 Thread Bob van der Poel
On Thu, Dec 31, 2020 at 9:25 PM DL Neil via Python-list < python-list@python.org> wrote: > On 1/1/21 11:46 AM, Bob van der Poel wrote: > > When I run python from the command line and generate an error I get the > > following: > > > > Python 3.8.5 (default, Jul

Re: Funny error message

2021-01-01 Thread Bob van der Poel
ink!). > > > That is where "python3.8 -m pip install --user" puts the packages you > install. > > Barry > > > > Okay ... I'll take your word for it. But, I really don't think I've every run that command :) -- **** Listen to my FREE CD at http:/

Re: Funny error message

2021-01-01 Thread Bob van der Poel
On Fri, Jan 1, 2021 at 12:17 PM DL Neil via Python-list < python-list@python.org> wrote: > On 1/2/21 6:35 AM, Bob van der Poel wrote: > > Found it! > > Well done! > > > >> I had the proper urllib3 installed. But, in my .local/lib/ a > previous > >

Re: Funny error message

2021-01-01 Thread Bob van der Poel
that it's not 100%. > > There are multiple reasons for this, but the first time that code is > run, a .pyc will (presumably) be created - and we're back to > considerations of Python environments, Python cf C, perhaps even > > Oh no! Not these damned dragons again :) But, seriously. No, I have no idea of moving installed stuff around between /usr /.local and /usr/local. There lies no dragons but madness :) I meant that I will pay more attention as to what the installer(s) are doing. Thanks for the input. -- Listen to my FREE CD at http://www.mellowood.ca/music/cedars Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: b...@mellowood.ca WWW: http://www.mellowood.ca -- https://mail.python.org/mailman/listinfo/python-list

MMA - Musical MIDI Accompaniment, Beta 0.12

2004-12-03 Thread Bob van der Poel
solo voice methods, and general cleanups/fixes. Comments appreciated! -- Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: [EMAIL PROTECTED] WWW: http://mypage.uniserve.com/~bvdp -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software

MIDI (was - Re: BASIC vs Python)

2004-12-22 Thread Bob van der Poel
to enter notes and play them back. After trying out half a dozen of these, I ended rolling my own solution in just 400 lines of Python, plus a Python module to read/write MIDI files. Regards, Jan Just as a side note, I remember reading somewhere that the Casio WK3000 Keyboard uses Python. N

Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel
> For a one-liner: > >    x[slice(*map(int, x[1:-1].split(':')))] Thanks. Almost works :) For s="[2]" and s="[1:2]" it's fine. But, if I have s = "[:2]" then I get: >>> x[slice(*[int(i) for i in s.strip("[]").split(":")])] Traceback (most recent call last): File "", line 1, in ValueError:

Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel
> Of course, you could also do something like this: > >      eval('x' + s) > or >      eval(str(x) + s) > Yes, I have user inputed 's'. So, if I can't get the generalized list version from Robert working I'll have to use this. Speed is not a big deal in this. As to malicious input, I could pretty

Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel
On Sep 2, 4:16 pm, "Rhodri James" wrote: > On Wed, 02 Sep 2009 23:57:48 +0100, Bob van der Poel   > wrote: > > > > >> Of course, you could also do something like this: > > >>      eval('x' + s) > >> or > >>      e

Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel
On Sep 2, 4:43 pm, "Jan Kaliszewski" wrote: > 03-09-2009 o 00:55:10 Bob van der Poel wrote: > > > > >> For a one-liner: > > >>    x[slice(*map(int, x[1:-1].split(':')))] > > > Thanks. > > > Almost works :) > > >

Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel
On Sep 2, 5:16 pm, Steven D'Aprano wrote: > On Wed, 02 Sep 2009 16:41:34 -0700, Bob van der Poel wrote: > > > But, translating 1, 2 or 3 ints into a valid splice isn't quit that > > easy? I could figure each value, and convert them to either int or None > > (key

Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel
On Sep 2, 4:27 pm, Ethan Furman wrote: > Bob van der Poel wrote: > > > > >>For a one-liner: > > >>   x[slice(*map(int, x[1:-1].split(':')))] > > > Thanks. > > > Almost works :) > > > For s="[2]" and s="[1:2]"

Re: Creating slice notation from string

2009-09-03 Thread Bob van der Poel
On Sep 2, 8:52 pm, Steven D'Aprano wrote: > On Wed, 02 Sep 2009 17:32:09 -0700, Bob van der Poel wrote: > > > Actually, nither this or Jan's latest is working properly. I don't know > > if it's the slice() function or what (I'm using python 2.5). But