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 studi
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 hu
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
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 tuple
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 (n,
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 t
rtional to the length of the output, 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
[email protected]
Subject: Re: Optimizing Small Python Code
On 24 Jun 2021, at 16:58, Avi Gross via Python-list mailto:[email protected]> > 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\
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 here
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 the
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
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()
e
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 d
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
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 some
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
fil
[email protected]
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(
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 ar
Although I sort of agree with Alister, I also note that many languages
deliberately provide you with the means to customize in ways that make your
personal life more amenable while making it perhaps harder for others.
Consider the humble import statement frequently used as:
import numpy as np
imp
Greg,
Yes, a smart person may come up with such tricks but a really smart person,
in my view, adjusts. With some exceptions, such as when trying to port
existing code to a new language quickly, someone who is not too obsessive
will try to pick up the goals and spirit of a new language and use them
another object means you over-rode the meaning of
+= for instance.
-Original Message-
From: Python-list On
Behalf Of Richard Damon
Sent: Tuesday, September 7, 2021 10:09 PM
To: [email protected]
Subject: Re: on writing a while loop for rolling two dice
On 9/7/21 3:51 PM, Avi Gross via
Charles,
This forum is for python discussions so I will clarify that there is nothing
wrong with making up a new language, including by bootstrapping an old
language. But why not call it new and do not try to confuse people using the
old.
Python has grown and added much over the years and even ha
So why use the word "else" when it really does not mean what users consider
else?
Again, we have words like "finally" used in some places to mean it should be
done no matter what, like closing a file that may be open.
What phrase used either in one or all contexts might have been better, if
longe
In this discussion, I shudder to mention that people often simply use all kinds
of additional logic to get a result. How much code have you seen that has some
variable like "completed = False" that can be set to True in multiple places
and many areas inside the loop are enclosed in an IF stateme
Alan and others,
I think human languages used to make computer languages will often cause
confusion.
Some languages have an IF .. ELSE construct but also an EITHER ... OR and a
NEITHER ... NOR and other twists and turns like words that sometimes come
apart and you end up having to dangle a part
Peter, in your own personal finite sample, I am wondering what you might do
TODAY if you looked at your loops again and considered redoing them for an
assortment of reasons ranging from using the code for teaching to efficiency
to just fitting your mood better?
I have seen seasoned authors go back
: Sunday, September 12, 2021 5:44 AM
To: [email protected]
Subject: Re: Friday Finking: Contorted loops
On 2021-09-11 21:38:02 -0400, Avi Gross via Python-list wrote:
> Peter, in your own personal finite sample, I am wondering what you
> might do TODAY if you looked at your loops aga
Stefan,
Agreed that writing code to handle all possible eventualities is usually
overkill and results in bloated software delivered very late or not at all.
My point is that often OTHERS start adding requests afterward that seem
trivial to THEM as they have no idea what it takes. I have often don
Some of what I read makes me chuckle.
Yes, large units of code, and even smaller ones, may be a chore to figure
out. Arguably harder when you use indentation and the next/last parts are
not even on the same screen as the rest. Sometimes you want to use a
split-screen in some editor to line up the
on.org
Subject: Re: Friday Finking: Contorted loops
On 2021-09-12 17:11:58 -0400, Avi Gross via Python-list wrote:
> Yes, large units of code, and even smaller ones, may be a chore to
> figure out. Arguably harder when you use indentation and the next/last
> parts are not even on the same scr
Some questions make no sense to me.
Can a kind of snake solve Sudoku? Do you mean a specific puzzle, or any puzzle
or even a puzzle with no solution?
Can a programming language do it? Well, in my experience, programming languages
are tools to be used by humans, or sometimes by other programming
Alan,
I wonder if this is yet another case when a pop-up window closes rapidly
when done and any last text written is just not perceived.
Good design in such cases makes a final pause till the user acknowledges in
some way that they are done and then no more messages!
Avi
-Original Message-
Can we agree that there are way more general ways to store data than
anything currently in common use and that in some ways, CSV and cousins like
TSV are a subset of the others in a sense? There are trees and arbitrary
graphs and many complex data structures often encountered while a program is
run
What you are describing Stephen, is what I meant by emulating a relational
database with tables.
And, FYI, There is no guarantee that two authors with the same name will not be
assumed to be the same person.
Besides the lack of any one official CSV format, there are oodles of features I
have s
Michael,
I don't care what you choose. Whatever works is fine for an internal use.
But is the data scheme you share representative of your actual application?
>From what I see below, unless the number of "point" variables is not always
exactly four, the application might be handled well by any f
Michael,
Given your further explanation, indeed reading varying numbers of points in
using a CSV is not valid, albeit someone might just make N columns (maybe a
few more than 7) to handle a hopefully worst case. Definitely it makes more
sense to read in a list or other data structure.
You keep ta
I replied to Michael privately but am intrigued by his words here:
"The thing that creates realistic test cases is my brain."
I consider extensions to my brain to include using a language like Python on
my computer and in particular, to take a model I think of and instantiate
it. Lots of people h
400, Avi Gross via Python-list wrote:
>> You keep talking about generators, though. If the generators are
>> outside of your program, then yes, you need to read in whatever they
produce.
>
> As I understood it, the "generators" don't generate the data, they are
>
Not lucky at all, Michael. The problem is he published a number of things
with Paul Erdős a few years after I got my degrees and went to Bell
laboratories. I never met Erdős but he was prolific and had 507 people
publish with him as co-authors. I would have loved to as I also speak
languages he spo
I think that to make electricity comprehend, you need a room temperature
superconductor. The Cooper Pairs took a while to comprehend but now ...
I think, seriously, we have established the problems with guessing that
others are using the language in a way we assume.
So how many comprehensions do
Sounds like an excellent homework question.
But your method of using an object is not what first comes to mind based on
your cursory description.
There is a python idiom using functional programming that looks like this:
def doit(a, b, fun): return(fun(a,b))
So make up your own function
Dave,
Just one point.
many things are allowed by a language even if normal people would NOT have
any reason to do it NOR should use it.
Although when used in one context + and - can be considered unary operators,
the evaluation may result in successive unary operations being done one
after anoth
Alan,
I am also wondering about that zip() function call to bind the two lists
into a sort of iterator object. Presumably that calls the iterator N times.
I did a test where I made two list called A and B and used zip to make an
object holding the two and then removed A and B. I was able to print
Yes, Stefan, I realized that and did not test more thoroughly. Chris pointed
it out too. I indeed deleted the names but a second reference remained so I
may be wrong and the function may just keep track of the position and return
one tuple at a time. That would be a good design, unless there was a
No, many things need not be as general as possible once you consider how
much work it may take to develop code and how many bugs and oddities might
be introduced and even how much it may slow the interpreter.
I could make an argument that everywhere you can put in a character string
should also al
paste operation for the more complex scenarios
even if they remember the fancy version exists and is bound to some
forgotten series of keys clicked together like control-X control-alt-t or
something.
-Original Message-
From: Python-list On
Behalf Of Antoon Pardon
Sent: Monday, October 2
We have had discussions debating if Python is a good language for teaching.
The short answer is NO unless you only teach a small subset and the students
know there is more they can learn as needed. The language is too rich and
has too many ways to do seemingly anything and that is before you add mo
Chris,
I was just about to suggest:
1+3+5+7+9
and
50*101
but that would mean helping with what does seem like fairly simple homework
with no effort to show us what they already tried and got stuck with!
So, ignore my attempts at trivial humor as I suspect some form of loop was
anticipated.
Stefan,
Yes, I often pass even fairly trivial functions like "add" or "+" or
whatever the language makes me say, to other functions in various forms of
functional programing. My point is that my example may seem trivial and not
necessary as an EXAMPLE of the greater point that may be easier to
und
Chris,
I think it is time someone set up a business where they do the homework for
people for a mere $1,000 or so per hour. Anonymously, of course. And we can
refer requests for free homework advice there.
Maybe the answer to this request is to suggest they use FACEBOOK which
seemingly keeps you
I think anyone who suggests we should separate costs from benefits belongs
securely within the academic world and should remain there.
Practical things need to be built considering costs. Theoretical things,
sure, cost is not an issue.
Python is not only a real-world set of applications but an ev
normally have enough local help.
-Original Message-
From: Python-list On
Behalf Of dn via Python-list
Sent: Wednesday, October 27, 2021 12:15 AM
To: [email protected]
Subject: Re: Create a contact book
On 27/10/2021 04.16, Avi Gross via Python-list wrote:
> Chris,
>
> I thin
Dave,
You make me wonder about unintended side effects. Are we allowing the ++ and
--- operations into Python through a side door?
any context that allows you to insert the walrus operator like:
index := index + 1
index := index - 1
Is now similar to notations in C/C++ and other
I realized that the person seeking completeness in Python may next ask why
the Walrus operator, :=, is not properly extended to include a whole
assortment of allowed assignment operators
I mean in normal python programs you are allowed to abbreviate
x = x + 5
with
x += 5
Similar
I just realized I left out **= so my apologies. Are there other such
abbreviations and does anyone use them?
-Original Message-
From: Python-list On
Behalf Of Avi Gross via Python-list
Sent: Wednesday, October 27, 2021 8:57 PM
To: [email protected]
Subject: walrus with a twist
Wednesday, October 27, 2021 9:11 PM
To: Python
Subject: Re: walrus with a twist :+= or ...
On Thu, Oct 28, 2021 at 11:58 AM Avi Gross via Python-list
wrote:
> On a serious note, if it was ever considered a good idea, what would
> be an acceptable sequence of symbols that might not b
we got along fine before a walrus came along, ...
or did we?
-Original Message-
From: Python-list On
Behalf Of MRAB
Sent: Wednesday, October 27, 2021 9:21 PM
To: [email protected]
Subject: Re: walrus with a twist :+= or ...
On 2021-10-28 02:06, Avi Gross via Python-list wrote:
>
Names can be taken too far as the same variable may have different
connotations in one place than another.
Say I am counting how many of something and incrementing variable HowMany as
I go along and initialized to zero. Then I want to test if I have any and
instead of:
if (HowMany > 0)
I
Antoon,
You keep beating a dead horse. NOBODY denies there are benefits to suggestions
like the one we are describing. It is a logical fallacy to keep arguing this
way.
And nobody (meaning me) suggests costs are a dominant factor in decisions no
matter the benefits. The realistic suggest
ything like I am describing (or something much better)
is being looked at?
-Original Message-
From: Python-list On
Behalf Of Peter J. Holzer
Sent: Thursday, October 28, 2021 5:08 AM
To: [email protected]
Subject: Re: walrus with a twist :+= or ...
On 2021-10-27 22:15:09 -0400, Avi
Stefan,
I choose not to get involved in a discussion about arbitrary naming rules as
many languages and programmers have their own ideas and preferences and rules.
My examples were EXAMPLES and the actual names are irrelevant. Feel free not to
use them and I assure you I have no plans to either
, that should do even on standard keyboards.
∴
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent: Thursday, October 28, 2021 3:24 PM
To: Python
Subject: Re: walrus with a twist :+= or ...
On Fri, Oct 29, 2021 at 5:53 AM Avi Gross via Python-list
wrote:
> Is ther
29, 2021 10:04 AM
To: [email protected]
Subject: Re: New assignmens ...
Op 28/10/2021 om 19:36 schreef Avi Gross via Python-list:
> Now for a dumb question. Many languages allow a form of setting a variable to
> a value like:
>
>
>
> assign(var, 5+sin(x))
When people post multiple comments and partial answers and the reply every time
is to ask for more; there may be a disconnect.
Some assume that the person is just stuck but generally can go forward with a
little hint. But when you keep being asked for more, maybe it means they want
you to do it
This discussion gets tiresome for some.
Mathematics is a pristine world that is NOT the real world. It handles
near-infinities fairly gracefully but many things in the real world break
down because our reality is not infinitely divisible and some parts are
neither contiguous nor fixed but in some
n
floats but on the design not accommodating the precision needed or perhaps
on the algorithm used not necessarily being expected to reach a certain
level.
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent: Saturday, November 20, 2021 5:17 PM
To: [email protected]
Can I suggest a way to look at it, Grant?
In base 10, we represent all numbers as the (possibly infinite) sum of ten
raised to some integral power.
123 is 3 times 1 (ten to the zero power) plus
2 times 10 (ten to the one power) plus
1 times 100 (ten to the two power)
123.456 just extends this wi
not expected
to apply for a non-abelian case.
-Original Message-
From: Python-list On
Behalf Of Rob Cliffe via Python-list
Sent: Saturday, November 20, 2021 6:19 PM
To:
Subject: Re: Unexpected behaviour of math.floor, round and int functions
(rounding)
On 20/11/2021 22:59, Avi Gross
om: Python-list On
Behalf Of Chris Angelico
Sent: Saturday, November 20, 2021 6:23 PM
To: [email protected]
Subject: Re: Unexpected behaviour of math.floor, round and int functions
(rounding)
On Sun, Nov 21, 2021 at 10:01 AM Avi Gross via Python-list
wrote:
> Computers generally
-
From: Python-list On
Behalf Of Chris Angelico
Sent: Saturday, November 20, 2021 8:03 PM
To: [email protected]
Subject: Re: Unexpected behaviour of math.floor, round and int functions
(rounding)
On Sun, Nov 21, 2021 at 11:39 AM Avi Gross via Python-list
wrote:
>
> Can I suggest a
I am not sure what your real problem is, Ulli, but many antivirus programs
can be TEMPORARILY shut off. Not highly recommended, of course, but if you
properly disable it on a newly rebooted system running little, and it still
happens, then something else may be going on.
If one recognizes your cod
I am not an expert on the topic but my first reaction is it depends on how
the data is corrupted and we do not know that. So I am addressing a more
general concept here.
Some algorithms break if a single byte or even bit changes and nothing
beyond that point makes sense. Many encryption techniques
Beauty of Recursion?
Well, there is what I call Mathematical Beauty, and then there is reality.
It is fantastic to prove neat theorems that something is possible by methods
like mathematical induction that in some sense use recursion as in if
something is true for some base value and it can be sh
I am sure some people have a sense of humor, but anyone on this forum who
actually does not have some idea of what various "tree" data structures are
in computer science, probably won't get any replies from me when asking such
questions.
But indeed there are things closer to classical trees that a
This entire thread seems a bit IFFY to me.
It does seme like HW to me but also a bit peripheral.
The fact that the data is in EXCEL is a detail. And unless a spreadheet is
complex, it may be trivial to save the file as a .CSV and from then on read
from there into Python (or anything) and when don
I have to wonder if when something looks like HOMEWORK, if it should be
answered in detail, let alone using methods beyond what is expected in class.
The goal of this particular project seems to be to find one (or perhaps more)
columns in some data structure like a dataframe that match two condi
Is this thread even close to being on track?
It is not really relevant to argue yet on whether to use EXCEL directly or a
data.base. Many ways can be used to solve a problem and if the EXCEL sheet will
never be updated manually or by some other program, it is sort of moot as you
can ONE TIME tra
I am not replying to anything below so I have removed it.
So I need to remind people of the topic and how it has wandered.
Someone has data in a not particularly great format in an EXCEL spreadsheet.
They want to somehow use an external language like Python to manipulate the
contents from outsid
To: [email protected]
Sent: Sat, Jan 15, 2022 3:05 pm
Subject: Re: What to write or search on github to get the code for what is
written below:
On 1/13/22 16:08, Avi Gross via Python-list wrote:
>
> I am not replying to anything below so I have removed it.
> Instead, someone sug
Mahmood,
Ask yourself WHY you want to do what you are doing. Are you using the power and
features of the language or trying to do it step by step in the way that
earlier languages often made you do it?
Yes, there are ways to include commas in fields of a CSV file and they can lead
to complicatio
I can appreciate people under time pressure wanting the job DONE first and
maybe learning more after. So, yes, it makes perfect sense to delegate the task
to others with expertise or ask for advice.
This forum may mean many things to many people but for me, it is a place to
offer guidance and s
I do not manage any python lists or have any say in how they run so I have no
idea why I am being asked by name below, as Dennis pointed out.
So I won't reply on whatever I am being asked, but want to point out that many
forums may be asked questions and some people on the forum will not respond
I keep wondering about the questions asked by NArshad here. His message can be
read below mine, for context.
This is a place focused on using the Python language. The web page being in
HTML is beyond irrelevant and in particular, web pages generally are in HTML
even if only as a way to call oth
Definitely it sounds like you may use both. Quite a bit of what people do using
DataFrame objects includes working on copies of individual columns, which often
are numpy Series or the like and in the other direction, can be used to create
or amend a pandas DataFrame. Plus, many operations used t
I applaud trying to find the right solution but wonder if a more trivial
solution is even being considered. It ignores big and little endians and just
converts your data into another form and back.
If all you want to do is send an integer that fit in 32 bits or 64 bits, why
not convert it to a
Jen,
I would not be shocked at incompatibilities in the system described making it
hard to exchange anything, including text, but am not clear if there is a
limitation of four bytes in what can be shared. For me, a character string can
use any number of contiguous bytes in memory that some kind
time_after_time
But to be more pythonic, throw some double underscores before and after.
-Original Message-
From: Igor Berger
To: [email protected]
Sent: Fri, Feb 4, 2022 12:40 pm
Subject: Re: Waht do you think about my repeated_timer class
On Friday, February 4, 2022 at 12:28:53 PM
Is there any way to get this mesage to stop showing up in my mailbox in what
seems to be a shotgun approach asking everybody everywhere they can think of to
participate in something very amorphous and at the same time having NOTHING
particular to do with Python?
I consider things like this SPAM
Actually, you may want a dynamic page. Pages may sometimes be delivered from
some cache along the way perhaps within your own company firewall if someone
else recently accessed them.
Consider a page that returns the current time or like the following asks for an
arithmetical calculation to add 5
Anyone think someone keeps asking homework questions? This seems absolutely
unrelated to earlier discussions from this person. Jobs often tend to remain
focused.
I opt out after frustration with earlier exchanges with NArshad about library
books and EXCEL ...
-Original Message-
From: N
Indeed not a clear request. Timing is everything but there are times ...
For many purposes, people may read in the entire CSV at a gulp into some data
structure like a pandas DataFrame. The file is then closed and any processing
done later does whatever you want.
Of course you can easily read on
Not really. Anonymous functions are anonymous in name only, so to speak.
When you call a function and pass it an argument that is an anonymous function
definition, it is bound to a variable within the function and used mostly in a
non-anonymous way. You did not bother giving it a name but it is r
dAVId,
I would like to assume that the processing needed is quite a bit more than
calculating the square of each X.
But as we are getting negligible information on anything useful, why continue
interacting.
I am trying to imagin a scenario with a million rows of sorts in a CSV
(typically not us
Amusingly, Greg, if you had a system where the un-named anonymous function was
to be named the unique value of the empty string, then a second such anonymous
function definition would over-write it, as with any named function. The kind
of anonymous function we are more used to might be something
Eric,
You bring up a related topic which I agree with. You need to be careful to make
aspects of a language as consistent as possible and thus allowing no receiver
of a function definition (somewhat different than no name) might result in
anomalies in other parts of the language. Errors that cou
Frank,
Given this kind of data: d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']}
You seem focused on a one-liner, however ridiculous or inefficient. Does this
count as a somewhat weird one liner?
comb = []; _ = [comb.append(v) for v in d.values()]
If you run the code and ignore the returned
As usual, his discussion is wandering a bit.
Yes, some things are not reliable but sometimes a heuristic answer is better
than none.
Internet connections are beyond flaky and worse the connection you want may be
blocked for many reasons even if other connections you try are working. Any
number
I had to think about it too, David.
Renaming it lets it make a bit more sense:
[item for sublist in d.values() for item in sublist]
This spells it out for me that you are taking one list within the main list at
a time and then taking one item at a time from the list. Since the nesting is
consi
I agree with Richard.
Some people may be confused and think c is the speed of light and
relativistically speaking, nothing can be faster. (OK, just joking. The uses of
the same letter of the alphabet are not at all related. One is named for the
language that came after the one named B, while th
Is that fair, Grant?
I go back far enough that in my earliest years I was submitting FORTRAN
programs written on punched cards and often getting them back the next day. The
compiling was not the major factor in how long it took.
For many cases, a compiled language only needs to be compiled once
101 - 200 of 312 matches
Mail list logo