It has been nearly three decades since I have had to write in C, Stefan, but
what I suggested jokingly is quite mild compared to what the winners of the
obfuscated C Contest do:
https://www.ioccc.org/
Time for me to drop out of this thread. Personally I fully agree uses of
"while' as described
To: python-list@python.org
Subject: Re: on writing a while loop for rolling two dice
On 2021-09-06 at 20:11:41 -0400,
Avi Gross via Python-list wrote:
> And in the python version, has anyone made a generator that returned
> NULL or the like so you can say uselessly:
>
> for ( _ in forever(
Let me add something, Stefan. Some people just want to get a job done. For
this person, he had a very specific need for a one-time project where the
rest of it was understood but one small step was confusing. Frankly, he
could have done it faster by opening a text editor on something like a CSV
I actually like it if a language lets you spell out your intention, although
adding many keywords is not a plus.
So, yes something like:
loop
...
end loop;
Is appealing as it makes clear the decision on when to exit the loop must be
within the loop (or till
For some people the "while true" method seems reasonable but it has a
problem if the internal body does not have some guarantee of an exit. And
that exit can be subtle. Many have mentioned ways an end condition can fail
due to rounding errors not being exactly equal to what you are looking for,
or
This is a bit sillier then some other discussions here!
There are many programs (especially back when more command-line programs were
used) that presented default prompts like "$" and many or most of them let you
over-ride it.
Can someone tell this person that if >>> is not pleasing, they can
And there is the ever popular recursive version you call with no while loop
in sight. And, oddly, no variable declared in your main body:
# CODE START ---
import random
def roll2():
return random.randint(1,6), random.randint(1,6)
def roll_equal(counter):
first, second = roll2()
This conversation has, of course, veered away from the original question so
I am starting afresh.
My memory of the original question is about how one sets up a test for
material covered in class or associated materials for what sounds like a
beginner class. I am not sure whether this would be the
In addition to the other requests for more info on a very ambiguous
question, let me add one. Did the message suggest something worked on an
earlier version and broke with a new version, or did they mean they just
started USING the current version and hoped the version number was
meaningful for
Chris,
Just a bit off topic, but google does have some advanced features such as using
the word AND or putting something in quotes to make it search for the
combination written the same way.
Some of the tricks work for other search engines too. Google does have an
advanced search feature
thon-list@python.org
Subject: Re: Optimizing Small Python Code
On 24 Jun 2021, at 16:58, Avi Gross via Python-list mailto:python-list@python.org> > wrote:
Now a has a length of 53!
It now looks like this:
b'x\x9c3\xe4R\x00\x03\x03.#8\x0bB\x1br\x19c\x88(\x18q\x99p!q\xc1\x00\xa6\x
utput, that makes the output
time also O(n^2) here too.
So I guess this only looks like it's reduced to linear because the output here
is very small. For large n it would become obvious.
jan
On 24/06/2021, Avi Gross via Python-list wrote:
> Yes, I agree that if you do not need to s
Yes, I agree that if you do not need to show your work to a human, then the
problem specified could be solved beforeand and a simple print statement
would suffice.
Ideally you want to make a problem harder such as by specifying an N that
varies then testing it with an arbitrary N.
But I suggest
I had a similar question, Greg. Optimized for what, indeed.
Some might suggest removing a VISIBLE loop is an optimization and some might
not.
First you need to look at what your code does. It is fairly primitive.
Here is a two-line version but is it simpler:
for n in range(1, 7):
print
Greg,
My point was not to ASK what python does as much as to ask why it matters to
anyone which way it does it. Using less space at absolutely no real expense
is generally a plus. Having a compiler work too hard, or even ask the code
to work too hard, is often a minus.
If I initialized the
May I ask if there are any PRACTICAL differences if multiple immutable
tuples share the same address or not?
I mean if I use a tuple in a set or as the key in a dictionary and a second
one comes along, will it result in two entries one time and only one the
other time?
Some languages I use often
You guys are all very knowledgeable but he is asking what to say to an
EDITOR who clearly may know little or nothing about computers and thinks
python is a snake and not a language and may need to be spoken to in his own
language which understands other forms of abstraction better.
So, just for
ubject: Re: learning python ...
When the idea is to learn something, it's not exactly helpful to abandon that
idea when encountering the first obstacle or when someone tells you you don't
like it as much as they do ...
On 5/25/21 7:56 AM, Avi Gross via Python-list wrote:
> I have studied man
I have studied many programming languages and am amused when people attack
python as if every other language is somehow more optimal.
Cameron and others have provided examples but look at positives AND negatives.
Yes code like: num = int(num)
does look a tad off as it reuses the same name for
Actually, Joe, putting in any serious program using toggle switches without
anything like a BACKSPACE was very hard as I often had to abort and start
again. Doing it twice the same way, Argh
Luckily, I only had to do it a few times to learn just like I had to write
assembler programs
Benjamin,
The topic is being changed by me because I get amused by statistics.
We can all agree that any form of energy use uses energy, duh! But that does
not make it good or bad in isolation.
If I had a job that had me wake up every day in the dark, drive for an hour to
an airport, hop
Chris,
I got the fastest python yesterday as it was so fast that it beat the one
coming tomorrow.
The trick is adding back the legs that evolution allowed to lapse.
Without bated breath,
Regardless,
Avi
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent:
Chris,
Given some notice, what stops anyone from joining the mailing list before
there is a divorce between the forums?
Everybody has trivial access to an email account these days and many mailers
allow incoming messages that fit a pattern to be placed in some names folder
to be read as a group
Yes, Python is a moving target, as are quite a few such things these days.
The changes when release 3 came along mean that what you find by a search
may not apply to your situation. And as new features get added, some advice
might shift. The presence of so many add-on modules also means that the
Sidestepping the wording of "options" is the very real fact that providing
names for even required parts can be helpful in many cases.
There re programs that may not require anything on the command line to be
done but many need something to provide some flexibility.
So, I tend to agree that in
https://translate.google.com/?sl=is=en=translate
Or, you could do it the hard way.
Kidding aside, there may be a python module you can hand a file name or
contents to and have it do much of the job using some API that may tap into
the above Google resource.
Dan specifically suggested importing
Terry: ... '__missing__' is new since I learned Python ...
With so many new dunder variables added, I am wondering when some dunderhead
comes up with:
__mifflin__
The documented use paper is:
https://theoffice.fandom.com/wiki/Dunder_Mifflin_Paper_Company
-Original
Chris,
Now that it is April 2, I have to ask which of the methods for dealing with
chocolate is more pythonic and is there a module for that?
Next April, can we switch beans and discuss different grades of coffee and
which ones are best to shave at home with a potato peeler?
I think that would
Bill,
I went afterward to the US Amazon Site and the prices are in dollars and
ordered the paperback for $5.99, no shipping cost with PRIME but I ordered,
paradoxically, an assortment of mice alongside so it would have been free
anyway. The Kindle version is $1.49
Congratulations, Alan, on the book.
I continue to wonder if people will buy the book for the wrong reason or ban
it thinking you created an AI snake that creates and spews new CURSES never
heard before.
The good news is that for those interested you can click on the book image
and see the
What are the odds, Chris, that rewriting an existing project written in an
older version of a language like python FROM SCRATCH into any other existing
language, would be easier than updating it to the same language which made
fairly specific changes and has some guidelines how to update?
True,
plit!
∀vi ∃. Grθß
-Original Message-
From: Python-list On
Behalf Of 2qdxy4rzwzuui...@potatochowder.com
Sent: Friday, March 26, 2021 9:43 PM
To: python-list@python.org
Subject: Re: convert script awk in python
On 2021-03-26 at 21:06:19 -0400,
Avi Gross via Python-list wrote:
> A generat
Michael,
A generator that opens one file at a time (or STDIN) in a consistent manner,
would be a reasonable thing to have as part of emulating AWK.
As I see it, you may want a bit more that includes having it know how to
parse each line it reads into some version of names that in Python might
Just to be clear, Cameron, I retired very early and thus have had no reason
to use AWK in a work situation and for a while was not using UNIX-based
machines. I have no doubt I would have continued using WK as one part of my
toolkit for years albeit less often as I found other tools better for some
ython-list On
Behalf Of Alan Gauld via Python-list
Sent: Wednesday, March 24, 2021 5:28 AM
To: python-list@python.org
Subject: Re: convert script awk in python
On 23/03/2021 14:40, Avi Gross via Python-list wrote:
> $1 == 113 {
> if (x || y || z)
> print "More than one ty
anslator by just saving some JSON descriptions?
-Original Message-
From: Python-list On
Behalf Of Cameron Simpson
Sent: Tuesday, March 23, 2021 6:38 PM
To: Tomasz Rola
Cc: Avi Gross via Python-list
Subject: Re: convert script awk in python
On 23Mar2021 16:37, Tomasz Rola wrote:
>On Tue, M
Alberto,
To convert any algorithm to python (or anything else) you have to understand
it. Do you know what AWK is doing? And does the darn thing work already in
awk? Why do you need to convert it? My suspicion is that it has errors and
if so, it is NOT about converting at all.
I will not solve
Speaking for myself, I am beyond tired of this topic, however informative
parts have been.
I will say it is irrational to try to impose rationally across all possible
languages, let alone people like me who often combine 3 or more language in
a single sentence when talking to others like myself
Speaking for myself, that is a very significant piece of homework to do and
unless you do quite a bit and get stuck and ask for help in some aspect,
this is not the place to ask if anyone wishes to do all the work.
The assignment seems to want you to write your own code to implement the
The precedence example used below made a strange assumption that the
imaginary program would not be told up-front what computer language it was
being asked to convert from. That is not the scenario being discussed as we
have described. In any particular language, there usually is a well-known
I apologize for my earlier snide remark as I was not then aware there was an
algorithm called apriori based on the Latin term and wondered if someone was
pulling someone's leg, in advance.
Someone has posted a pointer to Python code that is supposed to do that. If
that is suitable, then the
"I want to make apriori algorithm from start. Anybody have any
reference file?"
Excellent question. Based on everything you shared, I think all I can offer
is that whatever you do, do not make the aposteriori version.
Or, you could consider asking a real question with enough detail that
Just to be clear, and luckily the person who posed such boasts is luckily
gone and I AM NOT interested in having the discussion again here, I have a
point to make.
He did not suggest a magical compiler that could translate any language. Not
exactly.
I think he suggested that if all languages
As a guess, Rob, precedence rules for not may not bind as strongly as you think.
1 + (not 1)
With parentheses, "not 1" is a subexpression that should be performed first and
might return the value "False"
1 + False
treats False in a numeric context as a zero so evaluates to 1.
But
1 + not 1
a category that could be doable.
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent: Thursday, February 25, 2021 1:14 AM
To: Python
Subject: Re: name for a mutually inclusive relationship
On Thu, Feb 25, 2021 at 4:06 PM Avi Gross via Python-list
wrote:
>
> Is ther
Is there a more general idea here? How about asking for a control that
internally manages N items and requires exactly M of them before the entry
is accepted when you click? The case being discussed sort of wants N out of
N, or nothing.
Example, you order a family dinner from a Restaurant and are
ilable in Python.
I hope that clears up some confusion.
Cheer!
On Sun, Feb 21, 2021 at 9:44 AM Chris Angelico wrote:
> On Mon, Feb 22, 2021 at 1:39 AM Avi Gross via Python-list
> wrote:
> > But you just moved the goalpost by talking about using a data.frame
> > as
> that
&g
22, 2021 at 1:39 AM Avi Gross via Python-list
wrote:
> But you just moved the goalpost by talking about using a data.frame as
> that (and I assume numpy and pandas) are not very basic Python.
Given that the original post mentioned a pd.Series, I don't know how far the
goalposts actually
Mike,
You moved the goalpost.
Some of us here have been speculating you were asking what we call a
homework question here. The problem seemed to be the kind asked for that can
be done using fairly simple commands in python combined together.
Of course, some of the answers posted used ideas
Wouldn't it be nice, Grant, if Homework was assigned with statements like:
"Using only the features of the language covered up to chapter 3, meaning
individual variables and lists of them and simple loops and only using the
arithmetic built-in variable of +, -, % ... Solve this problem "
But
Benjamin,
I wonder if you understood my intended meaning not about the plusses and
minuses of using a language like LISP but that it is fundamentally build on
using the CONS concept to make lists in a poetic way but has no PROSE.
Not only does every language have what I meant by the usual
Some of us here go way back and have stories to tell of what we did even
before Python existed. I won't rehash my history here now except to say I
did use PASCAL in graduate school and my first job before switching to C
which was less annoying to use.
What I am interested in, in this forum, is
Dennis made the interesting comment "... Python has too much built in ..."
I understand his point. At the same time, I wonder what most people using
computers today, or in the future, need. Given serious amounts of computer
power, what many people may want is higher-level ways to get things done
I wonder if someone has come up with a sort of Python environment that lets
kids play with more fundamental parts of the language that lets them get
educated without the confusion. I mean a limited subset and with some
additions/modifications.
Someone mentioned how something like range(1,10)
Christian,
Thanks for sharing. I took a look and he does have a few schemas for Ada and
C from TWO YEARS ago. Nothing about the infinite number of other languages
he plans on supporting, let alone Python. And what he has is likely not
enough to do what he claims he can do easily and rapidly.
Grant,
Haven't thought about Prolog in a LOOONG time but it had some wild twists on
how to specify a problem that might not be trivial to integrate with other
languages as our now seemingly censored person with much delusion of
grandeur suggests. It is a language that does not specify what to do
I think we have discussed this a few times. There are tradeoffs in computer
science and obviously a compiled language with some optimization using
low-level data structures does much better at solving simple problems.
Interpreted languages often have serious overhead to start with and allow all
It is likely that people would understand better if spoken to properly so I
have been listening and hopefully gaining a picture that I can share, and be
corrected helpfully when wrong.
My personal guess is that the project at hand is to do something very vaguely
like what was done to the
I agree both with the idea that it is not good to mutate things during
iteration and that some things we want to do may seemingly require
effectively something like a mutation.
I want to consider what data structure might capture a normal activity like
having a to-do-list for TODAY and another
I may be the only one who does not deal well with a condescending attitude.
I have to wonder what international standards body ever completes a task in
finite time, only to find the real world has moved on. Having standards can be
a great idea. When the standard does not properly describe any
I am wondering how hard it would be to let some generators be resettable?
I mean if you have a generator with initial conditions that change as it
progresses, could it cache away those initial conditions and upon some
signal, simply reset them? Objects of many kinds can be set up with say a
Ethan, if it is not obvious, then should we add the following functions just
in case?
cube_root()
fourth_root()
nth(root)
two_thirds_root()
e_th_root()
pi_th_root()
.
Dropping out, ...
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent: Monday, December 28, 2020 8:02 PM
To: Python
Subject: Re: Which method to check if string index is queal to character.
On Tue, Dec 29, 2020 at 10:08 AM Avi Gross via Python-list
wrote:
>
> Th
This may be a nit, but can we agree all valid email addresses as used today
have more than an @ symbol?
I see it as requiring at least one character before the @ that come from a
list of allowed characters (perhaps not ASCII) but does not include the
symbol @ again. It is normally followed by
I agree Chris, that your original question is quite to the point. But is it
always?
If you do something that tries to read a file (such as opening a database to
send queries) on a remote server, how many different things might time out for
various reasons? Some may resolve if you keep trying
The original question sounded like someone was asking what errors might be
thrown for a routine they wrote that used other components that might
directly throw exceptions or called yet others, ad nauseum.
Some have questioned the purpose.
I can well imagine that if such info was available, you
As always, it may be useful to know WHY the questioner wants to skip
intermediate functions already in progress and jump back to some unspecified
earlier level.
There is a reason why functions are "stacked" and there are data structures
that really may need to be unwound. But if the question is
My comments at end:
-Original Message-
From: Python-list On
Behalf Of duncan smith
Sent: Wednesday, November 4, 2020 1:09 PM
To: python-list@python.org
Subject: Re: Find word by given characters
On 04/11/2020 04:21, Avi Gross wrote:
> Duncan, my comments below yours at end.
>
>
Duncan, my comments below yours at end.
---YOURS---
The Counter approach only requires iterating over the letters once to
construct the letters bag, then each word once to create the relevant word
bag. After that it's (at worst) a couple of lookups and a comparison for
each unique character in
I, too, have wondered what exactly the point was of the required
functionality for SCRABBLE but note you can extend a current word so
additional letters may be available in a game but only if they are an exact
fit to put before, after, or in middle of your word.
But this seems to be a fairly
People have a tendency to go too far in their religious zeal, Peter.
We could go back to writing on chalkboards to do calculations then re-use
the chalk dust when erasing to write again.
Many computers do almost nothing 90+ percent of the time. Want to outlaw
those or force them to accept random
These discussions can be bit frustrating. People talk past each other.
Languages seem almost like religions, as do paradigms.
I try to stay above it and absorb each paradigm as an alternative choice
made and then try to think of what problems I can solve better with one or
another and so on.
st',)
I understand the design choice and can imagine there may be another function
that initializes a tuple more directly in some module.
Returning to lurking mode ...
-Original Message-
From: Python-list On
Behalf Of MRAB
Sent: Sunday, September 20, 2020 7:35 PM
To: python-list@python.org
Su
There is a simple and obvious way to make sure you have a tuple by invoking the
keyword/function in making it:
>>> a=('first')
>>> type(a)
>>> a=("first",)
>>> type(a)
>>> a=tuple("first")
>>> type(a)
That seems more explicit than adding a trailing comma. It also is a simple way
to make
I have to wonder if this is a bit like what happens when something like
Windows offers you an upgrade if you pay for it. Some people have noticed
how after such things come out, a series of rapid bug fixes come along. So,
they wait. Some wait long enough until another entire version has come along
Cameron,
I am not at all against the feature. I like it as my programming style is
like you describe. One entry per line indented at the same level, in
multiple languages. I often do graphics where I generate an image then
fine-tune additional parameters to get the effect I want. Some functions
nd Missing Commas
On Tue, 24 Dec 2019 at 19:05, Avi Gross via Python-list
wrote:
> There are some lint programs that check your code and supply warnings
> and I see some languages have the option to generate warnings when the
> two strings are on the same line. I wonder if a
As a purist, it makes people uncomfortable if all 'objects' are not treated
alike.
But I look at the question from a definition and parsing mechanism view.
When an interpreter (or compiler) reads a program, it often does it in
phases and tries to tokenize parts.
So, the definition of something
What others have answered is tangential. Nobody doubts there are places
where you want to repeat something N times. Just to add an example, if you
are parsing something nested by parentheses or perhaps HTML, and you reach a
point where you have seen N opening symbols and start seeing a closing
I would like some examples of how one does what is requested in some other
programming languages. I doubt there is much need of a shorter way to do
anything N times and throw away any return values.
Python has many ways to do just about anything. It has some features which
suggest a particular
Bob,
As others have noted, you have not made it clear how what you are doing is
running "in parallel."
I have a similar need where I have thousands of folders and need to do an
analysis based on the contents of one at a time and have 8 cores available
but the process may run for months if run
TOPIC: how to save, retain and retrieve files as they change.
There seem to be several approaches and one proposal here involved using
altered file names with a numeric suffix.
Can we compare two different concepts? A typographical approach with little
or no built-in support like searching for a
201 - 282 of 282 matches
Mail list logo