Re: on writing a while loop for rolling two dice

2021-08-28 Thread Alan Gauld via Python-list
me[ 0 ] Now its all inside the loop. But remember readable code is better than cute code every time. And personally I'd just declare the x,y up front. Easier to understand and debug IMHO. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.c

Python UI (was Re: urgent)

2021-08-30 Thread Alan Gauld via Python-list
things you want we can tell you where to find them (if they exist!) But the basic Python interpreter is primarily there to run your programs, it's hard to see how you can make that less boring without also making it very inefficient. And professional users would hate that! -- Alan G Au

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

2021-08-31 Thread Alan Gauld via Python-list
g to DST for an extra week because it would make the snow melt faster and spoil the skiing! This was decided by the council on the Friday before it was due to happen and announced on the local radio... I got more grey hairs on that project than any other. -- Alan G Author of the Learn to Pro

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
y change their time settings on a whim. To be complete you need the ability to manually override too. -- 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/alangaul

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
was for the farmers!) because it meant that farm labourers would start work at first light, effectively extending the working day. -- 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

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
e reporting and some updates showing as having happened in the future! -- 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
that manual control becomes important. Also the problems we had were about 15 years ago, things may be better ordered nowadays. (I've been retired for 7 years so can't speak of more recent events) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.c

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

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-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: 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: 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: 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
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-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-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-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: 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: Handle foreign character web input

2019-06-29 Thread Alan Meyer via Python-list
hat to choose depends on your needs and resources. And of course all bets are off if some of your data is Chinese, Japanese, Hebrew, or maybe even Russian or Greek. Sometimes I think, Why don't we all just learn Esperanto? But we all know that that isn't going to happen. Alan -- https://mail.python.org/mailman/listinfo/python-list

Re: Do I need a parser?

2019-06-29 Thread Alan Meyer via Python-list
iera hablar español tan bien como usted habla inglés, estaría muy feliz. (You should have seen what that looked like before I applied Google Translate :) Alan -- https://mail.python.org/mailman/listinfo/python-list

Re: Pyqt5 help

2020-02-02 Thread Alan Gauld via Python-list
ke (pseudo code!): for a in self.n: newLabel = QtWidgets.QLabel(self) NewLabel.setText(self.friends[a].friend_name + "has birthday on " + self.friends[a]._date) NewLabel.setGeometry(QtCore.QRect(self.calculateGeometry(a)) self.friendLabels.append(newLabel) # i

Re: Pyqt5 help

2020-02-02 Thread Alan Gauld via Python-list
ect(30, 250, 100, 100)) The labels all have the name of the most recent friend? And they all have the same geometry, so presumably sit on top of each other? -- 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

Missing python curses functions?

2020-05-19 Thread Alan Gauld via Python-list
() case? Is anyone other than me still even using Python curses? :-) -- 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: Strings: double versus single quotes

2020-05-19 Thread Alan Gauld via Python-list
and a big movement of my left hand from home. So I use single quotes most of the time (ie unless it contains a single quote) -- 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.c

Re: Missing python curses functions?

2020-05-20 Thread Alan Gauld via Python-list
I can create an attr_get(win)->int function in Python... -- 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

Solved: Re: Missing python curses functions?

2020-05-20 Thread Alan Gauld via Python-list
On 19/05/2020 20:53, Alan Gauld via Python-list wrote: > One of the functions discussed that does not appear to have > a Python equivalent is attr_get() which gets the current > attributes. OK, Using inch() I've written the following function: def attr_get(win): ""

Python Curses Programming HowTo -reviewers?

2020-06-16 Thread Alan Gauld via Python-list
y. Eventually I'm aiming to put the finished document on my website. It's amazing what a pandemic can produce... -- 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.

Re: Python Curses Programming HowTo -reviewers?

2020-06-17 Thread Alan Gauld via Python-list
On 16/06/2020 16:38, Alan Gauld via Python-list wrote: > This is now available as a PDF and I'd be interested in review comments. Just to add that I can send a zip of the code files too. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.co

Re: Aw: Python Curses Programming HowTo -reviewers?

2020-06-17 Thread Alan Gauld via Python-list
comments. > > I'd be interested in having a look, generally. > > Will this be available somewhere ? Eventually, on my web site. After the next round of corrections. I'll send the PDF and zip via direct mail. BTW I have enough reviewers now, Thanks everyone! -- Alan G Aut

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-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: >>> %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: 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: 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: 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

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: 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_

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: 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: 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-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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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

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: please, help with python 3.1

2010-08-03 Thread Alan Wilter Sousa da Silva
### It prints essentially the same thing with a *very* *big* difference it takes 22 seconds and actually the alarm only works when the whole task ('find /') is finished. I hope it's better now. Thanks, Alan On Tue, Aug 3, 2010 a

how to use xdrlib

2010-08-22 Thread Alan Wilter Sousa da Silva
ther times, '\x00\x00\x00\x04Bond\x00\x00\x00\x05Angle\x00\x00\x00\x00\x00\x00\x0bProper Dih.\x00' if not a error. Well, as you see, I am a bit lost here and any hint would be very appreciated. Thanks in advance, Alan -- Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate Departme

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 ?

Re: TkInter Scrolled Listbox class?

2024-11-04 Thread Alan Gauld via Python-list
the fact that IDLE has had a tone of work done in recent years using ttk) -- 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.or

Re: Printing UTF-8 mail to terminal

2024-10-31 Thread Alan Gauld via Python-list
gt; module: https://docs.python.org/3/library/quopri.html One of the things I love about this list are these little features that I didn't know existed. Despite having used Python for over 25 years, I've never noticed that module before! :-) -- Alan G Author of the Learn to Program web site ht

Re: bool type have big problem. finally program returned "True".Is this the TRUE spec?

2025-01-20 Thread Alan Bawden via Python-list
あうぇくろ writes: tpr=composite(type,print) print(tpr('a')==tpr(1)) Why does tpr('a')==tpr(1) return True? Because tpr always returns the value None. -- https://mail.python.org/mailman/listinfo/python-list

RE: Tools to help with text mode (i.e. non-GUI) input

2025-01-13 Thread Alan Gauld via Python-list
s around, hide/show areas, position the cursor anywhere on screen. You can even create huge virtual screens and use the visible screen as a viewport into that(think like a big spreadsheet) There are a couple of Howto type documents online Shameless Plug: - I wrote a short kindle book on curs

Re: Tools to help with text mode (i.e. non-GUI) input

2025-01-14 Thread Alan Gauld via Python-list
On 14/01/2025 00:20, Grant Edwards via Python-list wrote: > On 2025-01-13, Alan Gauld via Python-list wrote: > >> All of that is possible in curses, you just have to code it. > > All of that is easy with curses in C. Unfortunately, the high level > "panel" and &q

Re: Tools to help with text mode (i.e. non-GUI) input

2025-01-15 Thread Alan Gauld via Python-list
structuring a non-GUI-like text UI. It doesn't support mouse or screen mapping or colours etc. But if all you want/need is a pdb type interface it works well. -- 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: Tools to help with text mode (i.e. non-GUI) input

2025-01-17 Thread Alan Gauld via Python-list
On 15/01/2025 00:41, Keith Thompson via Python-list wrote: > Alan Gauld writes: >> On 11/01/2025 14:28, Chris Green via Python-list wrote: >>> I'm looking for Python packages that can help with text mode input, >> >> The standard package for this is curses whi

Re: Python tutor mailing list?

2025-05-27 Thread Alan Gauld via Python-list
On 28/05/2025 00:32, Alan Gauld via Python-list wrote: > The archives are still there and the sign-up page seems to > work, but it doesn't recognise me. I tried signing up as > a new member with a different address and that seems to work(ie no > errors) but I still don;t see any

Python tutor mailing list?

2025-05-27 Thread Alan Gauld via Python-list
ddress and that seems to work(ie no errors) but I still don;t see any list activity. So, is it just the case that the admins have unsubscribed everyone on the list (again, this happened a few years ago)? Puzzled, -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http:/

debugging xmlrpc servers

2005-01-22 Thread alan dot ezust at gmail dot com
Problems with XMLRPC I have an xmlrpc server with a method called results() which returns an XML message. I've been able to use this function without problems when I had only one client talking to one server. I have recently introduced a P2P aspect to this process and now I have servers calling e

Re: debugging xmlrpc servers

2005-01-23 Thread alan dot ezust at gmail dot com
ctual method which was being called by xmlrpc, and setting the breakpoint to be the statement following that line (rather than the function itself). cheers --alan -- http://mail.python.org/mailman/listinfo/python-list

<    8   9   10   11   12   13