Re: Correct syntax for pathological re.search()

2024-10-08 Thread Alan Bawden via Python-list
Karsten Hilbert writes: Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> tex = '\sout{' >>> tex '\\sout{' >>> Am I missing something ?

Python told me a Joke

2024-09-03 Thread Alan Bawden via Python-list
surprises today... Except "maybe you meant '=='..." caught my attention. _Could_ that be what someone would want in this situation I wondered? So I tried: >>> x,2,z == [1,2,3] (1, 2, False) Now that made me laugh. - Alan [ Some people reading this will be t

Re: bring back nntp library to python3

2024-08-14 Thread Alan Gauld via Python-list
d far from the general python user community. Python has moved from the BDFL/Bazaar to the Committee/Cathedral. Probably an inevitable consequence of its current "popularity". -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gau

Re: Best use of "open" context manager

2024-07-06 Thread Alan Gauld via Python-list
s to mentally negotiate. The advantage of the original version is that you can ignore errors and read the code easily. You only need to find the except clause if you need to know how errors will be dealt with. But if comprehending the core functionality of the code you can just ignore all the error h

Re: IDLE: clearing the screen

2024-06-09 Thread Alan Gauld via Python-list
rm agnostic solution. But that didn't work for me in IDLE either. I think this is one where the best bet is to go into the IDLE code and add a Shell submenu to clear screen! Apparently it's been on the workstack at idle-dev for a long time but is considered low priority... -- Alan G Aut

Re: Terminal Emulator (Posting On Python-List Prohibited)

2024-05-19 Thread Alan Gauld via Python-list
y nightmare created by python, pip > and all the rest cannot be resolved otherwise. I've honestly never experienced this "nightmare". I install stuff and it just works. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/

Re: Terminal Emulator

2024-05-14 Thread Alan Gauld via Python-list
"batch" mode. So many options. Most of the specs are available online and there must be dozens of terminal emulators around written in C so you should have plenty of sample code to study. Good luck! -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://

Re: how to discover what values produced an exception?

2024-05-06 Thread Alan Bawden via Python-list
w the line somewhere. The fact that Python error messages often fail to mention the actual objects that caused the error has always annoyed me. I've always presumed that for some reason it just wasn't easy to do. And it's never been more than a minor annoyance to me. So the OP is not wrong for wishing for this. Other programming languages do it. Other Python programmers miss it. - Alan -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Dialogs (Posting On Python-List Prohibited)

2024-05-03 Thread Alan Bawden via Python-list
"".join \ ( repl.get(s, s) for repl in (dict(replacements),) for s in re.split("\\b(" + "|".join(re.escape(s[0]) for s in replacements) + ")\\b", text) ) How about just: repl = { "a" : "b", "c" : "d", "e" : "f", "g" : "h", } "".join(repl.get(s, s) for s in re.split(r"\b", text)) - Alan -- https://mail.python.org/mailman/listinfo/python-list

Re: How to Add ANSI Color to User Response

2024-04-10 Thread Alan Gauld via Python-list
cr.refresh(). # make it visible else: scr.addstr("Sorry, no colors available") curses.wrapper(main) HTH -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/ala

Re: xkcd.com/353 ( Flying with Python )

2024-03-30 Thread Alan Gauld via Python-list
rs. There seem to be several derivation sources including a fantasy world city suspended above a very thin, tall steeple Personally, I know SIGIL as an opensource EPUB editor! None of them seem to have any direct connection to the xkcd cartoon. -- Alan G Author of the Learn to Program web site

Re: Error in Module

2024-03-11 Thread Alan Gauld via Python-list
. Flask is a third party package that you need to install separately from Python. It does not come as standard. Have you installed Flask on the computer where you are running your project? If so, how did you download/install it? -- Alan G Author of the Learn to Program web site http://www

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Alan Gauld via Python-list
And not just Google, I just tried bing, yahoo and duckduckgo and they are all the same. Not a one listed anything from python.org on the first page... In fact it didn't even appear in the first 100 listings, although wikipedia did manage an entry, eventually. -- Alan G Author of the Learn to

Re: RE: Problem resizing a window and button placement

2024-02-27 Thread Alan Gauld via Python-list
still!) We've now moved on to the more general issue of communicating values between event handlers (although still using the width as our exemplar). Is this just academic interest or do you have a specific need for this? If we know the need we might be able to suggest a specific (and possibly be

Re: RE: RE: Problem resizing a window and button placement

2024-02-26 Thread Alan Gauld via Python-list
on_configure) root.mainloop() print("Ww Outside = <" + str(Ww) + ">") Notice that the button callback picks up the latest value of Ww. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog

Re: RE: Problem resizing a window and button placement

2024-02-26 Thread Alan Gauld via Python-list
global Ww >> Ww = root.winfo_width() >> print("Ww Inside =<"+str(Ww)+">") >> >> root = tk.Tk() >> root.bind('',on_configure) >> root.mainloop() >> >> print("Ww Outside = <"+str(Ww)+&

Re: RE: Problem resizing a window and button placement

2024-02-25 Thread Alan Gauld via Python-list
p() print("Ww Outside = <" + str(Ww) > + ">") Produces: Ww Inside = <200> Ww Inside = <200> Ww Inside = <205> Ww Inside = <205> Ww Inside = <206> Ww Inside = <206> Ww Outside = <206> HTH -- Alan G Author of the Learn to Progr

Re: Is there a way to implement the ** operator on a custom object

2024-02-09 Thread Alan Bawden via Python-list
) ie making the object behave in a dict-like way. I can't remember how this is implemented, but you can create the necessary methods to have your object produce whatever it likes. All you need to do is subclass collections.abc.Mapping, and implement __len__, __iter__, and __getitem_

PyTorch

2024-01-17 Thread Alan Zaharia via Python-list
Hello Python I Need help. it could not be found for PyTorch. It said in the Command Prompt ERROR: Could not find a version that satisfies the requirement torch (from versions: none) ERROR: No matching distribution found for torch, Can you help me? Thank You, Best, Alan. -- https

Re: Using my routines as functions AND methods

2024-01-04 Thread Alan Gauld via Python-list
on and that seemed to work just fine: >>> def g(obj, st): print(st, obj.v) ... >>> class D: ...def __init__(self,v): self.v = v ...m = g ... >>> d = D(66) >>> g(d,'val = ') val = 66 >>> d.m('v = ') v = 66 -- Alan G Author of th

Re: Using my routines as functions AND methods

2024-01-03 Thread Alan Gauld via Python-list
there is probably a catch. But sometimes the simple things just work? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list

Re: Are there any easy-to-use Visual Studio C# WinForms-like GUI designers in the Python world for Tk?

2023-12-30 Thread Alan Gauld via Python-list
I don't use a GUI builder. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list

Re: >>> %matplotlib inline results in SyntaxError: invalid syntax

2023-12-25 Thread Alan Gauld via Python-list
e Python >> 3.4.4 Shell... Python names can't start with a % (its the modulo or string formatting operator). I know nothing of the innards of matplotlib so I can only suggest a closer examination of their tutorial information. -- Alan G Author of the Learn to Program web site

Re: on writing a number as 2^s * q, where q is odd

2023-12-05 Thread Alan Bawden via Python-list
ig integers. Probably N is 56 or 48 or 32. And why 62 bits? Because the bit_count method is certainly written in C, where every step in bit_count_62 would use 64-bit integers. If you like this sort of stuff, check out the book "Hacker's Delight" by Henry Warren. See <https://

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread Alan Bawden via Python-list
jak writes: Alan Bawden ha scritto: > Julieta Shem writes: > > How would you write this procedure? > def powers_of_2_in(n): > ... > > def powers_of_2_in(n): > return (n ^ (n - 1)).bit_count() - 1 > Great solutio

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread Alan Bawden via Python-list
Julieta Shem writes: How would you write this procedure? def powers_of_2_in(n): ... def powers_of_2_in(n): return (n ^ (n - 1)).bit_count() - 1 -- https://mail.python.org/mailman/listinfo/python-list

Re: Amy known issues with tkinter /ttk on latest MacOS?

2023-11-19 Thread Alan Gauld via Python-list
nd it seems I'm not alone. That's a relief. I'll upgrade to 3.13 when it comes out and hopefully it will go away. (Another suggestion was to use the homebrew python but I don't like having any more homebrew stuff than is absolutely necessary!) Meantime I'll just have to cont

Amy known issues with tkinter /ttk on latest MacOS?

2023-11-16 Thread Alan Gauld via Python-list
M1 Mac Mini, 16GB Ram I could upgrade my Python version but I was planning on waiting for the 3.13 release to finalize first. And I doubt if that's the cause anyway. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Foll

Re: Newline (NuBe Question)

2023-11-15 Thread Alan Gauld via Python-list
s.result = "Fail" print(s.school) print(s.name) ... print(s.result) Just a thought... PS. There are neater ways to do this but you may not have covered those yet so I'll stick to basics. -- Alan G Author of the Learn to Program web site http://ww

Re: xor operator

2023-11-13 Thread Alan Gauld via Python-list
(and in encryption). But from both perspectives xor is pretty clearly defined in how it operates and not, I suspect, what the OP really wants in this case. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr

Re: Checking if email is valid

2023-11-02 Thread Alan Bawden via Python-list
uot;VRFY" command. And spammers _did_ abuse it in exactly this manner. And so pretty much every mail server in the world disabled VRFY sometime in the 90s. - Alan -- https://mail.python.org/mailman/listinfo/python-list

Re: Question(s)

2023-10-25 Thread Alan Gauld via Python-list
nd emacs both have comprehensive Python support. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list

Re: Question(s)

2023-10-24 Thread Alan Gauld via Python-list
takes up more time than programming. And there are many, many books written about how to do it. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -

Re: Question(s)

2023-10-24 Thread Alan Gauld via Python-list
d gaining experience for formal analysis and b) actually performing such an analysis of real design/code is simply not worth the effort for 99% of the programs you will write. It is much simpler and faster to just test. And test again. And again. Especially if you use automated testing tools whic

Re: Why doc call `__init__` as a method rather than function?

2023-09-15 Thread Alan Gauld via Python-list
ome shortened to the function inside a class *is* its method. In practice, the message looks like a function call. And the method consists of the function body (and/or any inherited function body). Thus every method is a function (or set of functions) but not every function is a method (or part

Re: Why do I always get an exception raised in this __init__()?

2023-09-01 Thread Alan Gauld via Python-list
ou need to use self.line self.line = chip.get_line(l) if pin... > def print_name(self): > print (self.line.name()) > > def set(self): > self.line.set_value(1) > > def clear(self): > self.line.set_value(0) A

Re: Multiple inheritance and a broken super() chain

2023-07-05 Thread Alan Gauld via Python-list
nship and not just as a kind of cheap reuse mechanism - that's when problems start. Also, mixin style MI is particularly powerful but the protocol between mixin and "subclass" needs to be carefully designed and documented. Like any powerful tool you need to understand the costs of use a

Re: Multiple inheritance and a broken super() chain

2023-07-04 Thread Alan Gauld via Python-list
GC, but then neither does it have an Object superclass so very often MI in C++ does not involve creating diamonds! And especially if the MI style is mixin based. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follo

Re: Fwd: AUTO EDITOR DIDN'T WORK

2023-06-15 Thread Alan Gauld via Python-list
onsole/terminal window by typing python at the command prompt. If you get the Python prompt: >>> Then Python is installed OK. After that it's back into auto-editor and resolve and this is not the best place to get answers for those. Resolve at least has an active support forum, s

Fwd: AUTO EDITOR DIDN'T WORK

2023-06-13 Thread Alan Gauld via Python-list
d and reinstalled about twice and still no success hence I uninstalled it. On Mon, 12 Jun 2023, 23:33 Alan Gauld via Python-list, mailto:python-list@python.org>> wrote: On 12/06/2023 10:26, Real Live FootBall Tv via Python-list wrote: > I did it because I was going to use it with another

Fwd: Re: AUTO EDITOR DIDN'T WORK

2023-06-12 Thread Alan Gauld via Python-list
s a python interpreter? ie. Did you get a >>> prompt in a terminal? and without involvement from your video editor? If so, what did you do to link it to the video editor? And what was the result? Or did Python not even start? How did you try to use it? What OS are you on? Did the installer

Re: Silly (maybe) question re imported module(s)

2023-05-19 Thread Alan Gauld
bject is not callable Ah, now I understand. cubes is a literal list defined in the module. > But that was spot on, thanks > >>>> import cube >>>> cube.cubes > [0, 1, 8, 27, 64, 125, 216, 343, 512, 729] Glad to help. -- Alan G Author of the Learn to Program

Re: Silly (maybe) question re imported module(s)

2023-05-19 Thread Alan Gauld
es\Tools\Python\Temp\cube.py >>>> cubes > [0, 1, 8, 27, 64, 125, 216, 343, 512, 729] cubes looks like it should be a function but in that case there should be parens after it. So I'm not sure how that is working! I'd expect that you need to do: import cube cu

Re: Silly (maybe) question re imported module(s)

2023-05-19 Thread Alan Gauld
" the modules. are you typing >>> import mymodule at the interactive prompt or are you using the File->Open menu to load them into the editor? (It sounds like the latter) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_

Re: What to use instead of nntplib?

2023-05-16 Thread Alan Gauld
t; required? > > See PEP 594: https://peps.python.org/pep-0594/ Thanks Cameron. A scary list; I must have a dozen projects from the late 90s still live that are using many of these! I'm glad I'm retired and won't be the one who has to fix 'em :-) -- Alan G Author o

Re: What to use instead of nntplib?

2023-05-16 Thread Alan Gauld
why nntplib is deprecated? Surely there are still a lot of nntp servers around, both inside and outside corporate firewalls? Is there a problem with the module or is it just perceived as no longer required? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazo

Re: [pygettext] --package-name and --package-version unknown

2023-05-04 Thread Alan Gauld
text does create in each > po-file. Sorry, I've never used pygettext so can't help there. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphot

Re: Python curses missing form library?

2023-04-24 Thread Alan Gauld
If you are building terminal based form-type apps the best bet seems to be urwid. I haven't used it in anger but the beginner docs I saw looked promising. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo

Re: PyCharm's strict PEP and not so strict?

2023-04-19 Thread Alan Gauld
ow to configure it (and how to plumb it into your IDE). Personally I've never felt the need for any stricter error checking than the interpreter provides so I can't offer anything beyond the generic suggestion to use a linter. -- Alan G Author of the Learn to Program web site http://www.

Re: tksheet - Copy and Paste with headers

2023-04-16 Thread Alan Gauld
o a text editor in the first instance? And Excel in the second? If all else fails you can probably write handlers and bind to Ctrl-C and Ctrl-V to do something yourself that mimics cut/paste. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan

Re: RE: Weak Type Ability for Python

2023-04-13 Thread Alan Gauld
ine all the operators (commands in Tcl-speak) in the language so redefining plus is easy. Doing it based on type is more tricky but doable. > Unfortunately, if they BOTH are flexible, how do you decide whether to add > them as numbers or concatenate them as strings? Yes, that's where it b

Re: Weak Type Ability for Python

2023-04-13 Thread Alan Gauld
ght be a rival to M$ OS/2 running NeXTstep now that would have been a platform for the 90s... both so near yet so far. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.fli

Re: Windows Gui Frontend

2023-04-01 Thread Alan Gauld
;ve seen no real evidence of that. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list

Re: Windows installer from python source code without access to source code

2023-03-31 Thread Alan Gauld
ements were before Python3 so ive no idea what it does today! But a quick check suggests it still exists and works with python3 code - last major release was in Nov 2022. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my pho

Re: Fwd: Friday finking: IDE 'macro expansions'

2023-03-18 Thread Alan Gauld
g strong, albeit at extortionately high prices: $1000~3000 for the pro versions! (But there is still a free community version with just the basics.) See http://www.embarcadero.com And it's targeted at multi-platforms now: Windows, MacOS, Android, iOS although it only runs on Window

Re: Fwd: Friday finking: IDE 'macro expansions'

2023-03-18 Thread Alan Gauld
ers of magnitude more difficult. The Lazarus open source project is based on Delphi's IDE. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos

Fwd: Friday finking: IDE 'macro expansions'

2023-03-17 Thread Alan Gauld
auto tricks but I don't always use them. In vim I use auto-indent and that's about it. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -

Re: Lambda returning tuple question, multi-expression

2023-03-09 Thread Alan Gauld
e3.config(state="normal") ) ) It's not a radical change from using a lamba as a callback but it does extend the use case to cover a common GUI scenario. I like it. I wish I'd thought of it years ago. Thanks for sharing. -- Alan G A

Re: RE: Which more Pythonic - self.__class__ or type(self)?

2023-03-04 Thread Alan Gauld
onic is still a much more loose term and the community less stressed about it than their C++ cousins where it has almost reached a religious fervour! -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr a

Re: Python list insert iterators

2023-03-03 Thread Alan Bawden
Guenther Sohler writes: Hi Python community, I have a got an example list like 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 T T and i eventually want to insert items in the given locations (A shall go between 2 and 3, B shall go between 6 and 7) Right now i just use ind

Re: Which more Pythonic - self.__class__ or type(self)?

2023-03-03 Thread Alan Gauld
ing for static types should rarely be necessary since Python uses duck typing and limiting things to a hard type seriously restricts your code. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: h

Re: Regular Expression bug?

2023-03-02 Thread Alan Bawden
compile(m0) s0 = r0.match(s) >>> print(s0) None Assuming that you were expecting to match "pn=2017", then you probably don't want the 'match' method. Read its documentation. Then read the documentation for the _other_ methods that a Pattern supports. T

Re: TypeError: can only concatenate str (not "int") to str

2023-02-26 Thread Alan Gauld
e (and standard library) as it exists. (We also cover beginner questions about programming in general.) So this thread is most definitely in the right place IMHO. -- Alan G Tutor list moderator -- https://mail.python.org/mailman/listinfo/python-list

Re: Usenet vs. Mailing-list (was: evaluation question)

2023-01-31 Thread Alan Gauld
) is a now more complicated than before. So I have to be very highly motivated to jump through the hoops. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauld

Re: RE: NoneType List

2023-01-02 Thread Alan Gauld
axed the ludicrously strict typing slightly. Turbo Pascal made Pascal a joy and I still use Delphi for Windows programming today. TP also introduced classes to Pascal (although Apple had already done so for the Mac and Borland basically ported the syntax to the PC). -- Alan G Author of the Lea

Re: NoneType List

2022-12-31 Thread Alan Gauld
uld chain them. But sadly it doesn't. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list

Re: String to Float, without introducing errors

2022-12-17 Thread Alan Gauld
ecimal accuracy is your primary goal, it might suit you better. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list

Re: Does one have to use curses to read single characters from keyboard?

2022-12-13 Thread Alan Gauld
On 12/12/2022 17:45, Alan Gauld wrote: Absolutely nothing apparently! But in practce I did pen some esponses to Davids post. However this list seems to strip out what I've written, its happened a few times now. Not every time but enough that I rarely post here. But I'll try once mor

Re: Does one have to use curses to read single characters from keyboard?

2022-12-12 Thread Alan Gauld
rd-python > > Disclaimer: have had it on my 'radar', but never actually employed. > (if you have considered, will be interested to hear conclusions...) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list

Re: an oop question

2022-11-03 Thread Alan Gauld
On 03/11/2022 18:29, Chris Angelico wrote: > On Fri, 4 Nov 2022 at 05:21, Julieta Shem wrote: >> >> Chris Angelico writes: >> >>> On Thu, 3 Nov 2022 at 21:44, Alan Gauld wrote: >>>> Also Python is not a purely OOP language, in that you can write >&g

Re: an oop question

2022-11-03 Thread Alan Gauld
ut you really have to fight the system to do so. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list

Re: [correction]an oop question

2022-11-02 Thread Alan Gauld
I'd implement the example hierarchy as > >>>> class Language: > ... def f(self): > ... print(self.greeting) And that would be perfectly valid too. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/aut

Re: an oop question

2022-11-02 Thread Alan Gauld
xactly as in cellular automata theory. .. Unfortunately, there is a huge gap between pure OOP theory and practical OOP languages! And just as big a gap between OOP language potential and real-world OOP usage. Very few purely OOP programs exist (maybe excepting in Smalltalk - see Stefan's posts

Re: an oop question

2022-10-31 Thread Alan Gauld
f __str__(self): > return "Empty()" > def __repr__(self): > return self.__str__() > def __new__(clss): > if not hasattr(clss, "saved"): > clss.saved = super().__new__(clss) > return clss.saved > > class Stack(Pair): > def pop(self): > return self.first > def push(self, x): > return Stack(x, self) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list

Re: random.SystemRandom().randint() inefficient

2022-07-27 Thread Alan Bawden
Cecil Westerhof writes: Alan Bawden writes: > Cecil Westerhof writes: > >Yes, I try to select a random element, but it has also to be removed, >because an element should not be used more as once. > > Instead of using pop to do that why

Re: random.SystemRandom().randint() inefficient

2022-07-27 Thread Alan Bawden
g to have it destroyed by this process: seq = list(seq) n = len(seq) while n: i = randrange(n) yield seq[i] n -= 1 if i < n: seq[i] = seq[n] -- Alan Bawden -- https://mail.python.org/mailman/listinfo/python-list

Re: on a statement followed by an expression

2022-06-04 Thread Alan Bawden
e _same_ dictionary every time. Your original code that used a `for' loop is actually much clearer. -- Alan Bawden -- https://mail.python.org/mailman/listinfo/python-list

Re: min, max with position

2022-06-04 Thread Alan Bawden
ng for is usually called "argmax" and "argmin" (see ). These don't exist in the standard Python library as far as I can tell, but numpy does have "argmax" and "argmin" routines. -- Alan Bawden -- https://mail.python.org/mailman/listinfo/python-list

Re: tail

2022-05-09 Thread Alan Bawden
Marco Sulla writes: On Mon, 9 May 2022 at 19:53, Chris Angelico wrote: ... Nevertheless, tail is a fundamental tool in *nix. It's fast and reliable. Also the tail command can't handle different encodings? It definitely can't. It works for UTF-8, and all the ASCII compatible single

Re: Python/New/Learn

2022-05-05 Thread Alan Gauld
of the discussions there will be closer to your level than the more advanced topics that get addressed here. Finally, I have a tutorial aimed at complete beginners, see the link below... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_

Re: Python app on a Mac

2022-04-15 Thread Alan Gauld
I displays but so does a Terminal in the background. The SO answer does mention you can get the Terminal to close when the script terminates whhich would be better than now. However, another answer mentions something called Automator, which I'll need to Google... Thanks for the pointer thou

Python app on a Mac

2022-04-15 Thread Alan Gauld
escript or somesuch? Alan G. -- https://mail.python.org/mailman/listinfo/python-list

Fwd: Re: Long running process - how to speed up?

2022-02-19 Thread Alan Gauld
somewhere. But it might be possible to divide and conquer and get better speed. It all depends on what you are doing. We can't tell. We cannot answer such a vague question with any specific solution. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon

Re: Best way to check if there is internet?

2022-02-08 Thread Alan Bawden
And I missed one that was just published last month: https://datatracker.ietf.org/doc/html/rfc9171 Unlike RFC 5050, this version of the protocol actually claims to be a "Proposed Standard". -- Alan Bawden -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to check if there is internet?

2022-02-08 Thread Alan Bawden
ps://en.wikipedia.org/wiki/Delay-tolerant_networking https://datatracker.ietf.org/doc/html/rfc4838 https://datatracker.ietf.org/doc/html/rfc5050 -- Alan Bawden -- https://mail.python.org/mailman/listinfo/python-list

Re: Advanced ways to get object information from within python

2021-12-23 Thread Alan Gauld
xv', 'exceptions', 'http', 'item', 'link', 'linkextractors', 'selector', 'signals', 'spiders', 'twisted_version', 'utils', 'version_info'] > I wish there was a convenient way for me

Re: Advantages of Default Factory in Dataclasses

2021-11-16 Thread Alan Bawden
David Lowry-Duda writes: ... For the same reason that the following code doesn't do what some people might expect it to: ```python def add_to(elem, inlist=[]): inlist.append(elem) return inlist list1 = add_to(1) list2 = add_to(2) print(list1) # prints [1

Re: New assignmens ...

2021-10-24 Thread Alan Bawden
w the target to be as general as possible! I'm guessing that about 70% of you will think that this is a horrible idea, 10% of you will find it compelling, and the remaining 20% will find themselves conflicted. You can count me in that last category... -- Alan Bawden -- https://mail.python.o

Fwd: Re: sum() vs. loop

2021-10-12 Thread Alan Gauld
in transit. Presumably, especially for large numbers, a single python loop is faster than 2 C loops? But that's purely my speculation. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr

Re: Question again

2021-09-16 Thread Alan Gauld via Python-list
uot; : > print("Wait hold on! are you really leaving??") > > #User answers > answer = input() > #If user says 'yes' again, reply 'fine! bye then!' > if answer == "yes" : > print("Fine! bye then!") Shouldn't those lines

Re: Friday Finking: Contorted loops

2021-09-12 Thread Alan Gauld via Python-list
dead code (possibly emitting a warning in the process?). A linter likewise might identify the redundant code. I don't use any python linters, does anyone know if they do detect such dead spots? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/au

Re: Friday Finking: Contorted loops

2021-09-12 Thread Alan Gauld via Python-list
ction of small C programs of mine I find: > > 35 regular for loops > 28 while loops > 2 infinite for loops > 1 "infinite" for loop (i.e. it exits somewhere in the middle) > 0 do/while loops. That wouldn't surprise me, I've only used do/while in C a handful o

Re: Friday Finking: Contorted loops

2021-09-11 Thread Alan Gauld via Python-list
On 10/09/2021 19:49, Stefan Ram wrote: > Alan Gauld writes: >> OK, That's a useful perspective that is at least consistent. >> Unfortunately it's not how beginners perceive it > ... > > Beginners perceive it the way it is explained to them by > their tea

Re: Friday Finking: Contorted loops

2021-09-10 Thread Alan Gauld via Python-list
cases, it executes the 'else' part if it didn't break out of the > loop. That's it. OK, That's a useful perspective that is at least consistent. Unfortunately it's not how beginners perceive it and it causes regular confusion about how/when they should use els

Re: Friday Finking: Contorted loops

2021-09-10 Thread Alan Gauld via Python-list
state that the use of for loops was rare? But I would hope that any empirical research would look at the wider function of the loop and its purpose rather than merely analyzing the syntax and keywords. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.c

Re: Friday Finking: Contorted loops

2021-09-10 Thread Alan Gauld via Python-list
ys gets executed at least once. But at the cost of duplicating the loop-body code, thus violating DRY. Just another thought... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://ww

Re: on writing a while loop for rolling two dice

2021-09-07 Thread Alan Gauld via Python-list
e { > #define ENDIF } > ... > > IIRC he copied them out of a magazine article. That was quite common in C before it became popular(early/mid 80s). I've seen Pascal, Algol and Coral macro sets in use. You could even download pre-written ones from various bulletin boards (remember them

Re: The sqlite3 timestamp conversion between unixepoch and localtime can't be done according to the timezone setting on the machine automatically.

2021-09-04 Thread Alan Gauld via Python-list
issue - except we'd be an hour out of sync with the EU. (Post Brexit that may not be seen as a problem!! :-) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list

Re: The sqlite3 timestamp conversion between unixepoch and localtime can't be done according to the timezone setting on the machine automatically.

2021-09-03 Thread Alan Gauld via Python-list
people. Most still see it as a benefit because they get longer working daylight. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list

Re: The sqlite3 timestamp conversion between unixepoch and localtime can't be done according to the timezone setting on the machine automatically.

2021-09-02 Thread Alan Gauld via Python-list
from DELL but the EU PCs had a slightly different BIOS). The differences you cite should have thrown up issues every year. I must see if I can find my old log books... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my

  1   2   3   4   5   6   7   8   9   10   >