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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
() 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
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
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
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):
""
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.
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
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
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
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://
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
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
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
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
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
)
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_
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
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)+&
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
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
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
.
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
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
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
"".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
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
"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://
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/
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
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
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
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
### 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
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
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 ?
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
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
あうぇくろ 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
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
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
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
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
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
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:/
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
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
1201 - 1267 of 1267 matches
Mail list logo