Since this topic is not focused on efficiency, why exactly does it matter if
your function should check if a file exists and then avoid a collision?
What you are describing sounds a bit like a hash function. In many cases,
when you perform the computations you may find the slot you hash to is
Alan,
Many people have machines with a single login that is shared with nobody.
I install lots of software on multiple machines that only I use and have
often wondered what the purpose for me was to install for everyone. On some
machines you then need to log in as whatever variant of superuser
I am not totally up on the exact purposes of this group but have noted how
many of the questions asked have been frustrating.
I wonder if it would make any sense to provide a template people might fill
out to suit their needs.
An example might be people who want you to pretty much do their
There are many ways to do some things. I present a fairly straightforward
method for consideration.
Synopsis. Use two dictionaries to keep track of how many times a letter can
be found in the source word and the target word.
Loop over the target letters and as soon as you find a letter
; % fs"*, Now I dont see the error "SyntaxError: can't assign to
literal"
This is not returning exactly "*vfat*" instead of this, it is returning as
"*
/dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"* "
Could you please hel
What Alan wrote makes sense if you just want to put out one mark per second
till you stop.
But if you want a percentage of progress, you need some way to estimate what
percent of the way you are to being done. You need to determine how many
marks represent 100% such as 50 periods. You need to
I have been reading the replies and wonder sometimes if we understand the
real question as intended.
Classes in Python can be changed in all kinds of ways even after they have
been defined and the changes take effect on any new instances created
afterward. So can instances in multiple ways. If
As I see others have replied, the question is not easy to understand and seems
so broad as to be overwhelming to actually do without further info.
It would be easier if someone asked if we could direct him to resources that
either explain the algorithms needed or to full-blown packages/modules
WARNING to any that care:
As the following letter is a repeat request without any hint they read the
earlier comments here, I did a little searching and see very much the same
request on another forum asking how to do this in MATLAB:
After my earlier message (snipped out for space savings) focused on choosing
among various methods to retain a buffer of recent lines from a file, I
realized that for many, the best method is simply to import a solution others
have created, often in the form of an object. Many of the methods I
g
or debugging overhead. It is even flexible enough, if you choose, to store
or display the lines backwards as in showing the last line that showed the
error, followed by successively earlier lines.
Why use a limited solution when you can play with a full deck?
-Original Message
Asad,
Like many projects, there may be many ways to do things BUT some rules do
apply.
You can only read an open file ONCE unless you seek back to the beginning or
reopen it.
string = f3.read()
string1 = f3.readlines()
The first line reads the entire file into a single buffer.
The second
I may be missing something but it looks like the embedded double quotes may be
a problem in this:
cmd = "blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % ...
if you use single quotes as in:
cut -d"="
becomes
cut -d'='
or escape the double quotes with \" and so on ...
The above seems to
Dev,
There are many ways to learn a programming language but a list of all
commands is not necessarily a good way. I suspect your real question is how
do you learn Python as either a beginner at this language or with little
knowledge of computers in general.
There are tons of books and classes
An interesting discussion that is outside the scope of a group like this is
HOW malicious things can be done and perhaps how to avoid them.
Obviously some contexts are totally uncontrolled. If you write a
"calculator" that asks the user to type in an arbitrary string like
"2*(3+5)" or "sin(30)"
In replying to what "Stealth Fleet" asked, I have too many comments,
starting with a suggestion to put a SUBECT on the Subject: line.
Your first error was not converting the text input to an integer or floating
point number.
tokenAmount = input( "How many tokens would you like to buy or
Alan and others have answered the questions posed and what I am asking now
is to look at the function he proposed to keep track of the last five lines.
There is nothing wrong with it but I wonder what alternatives people would
prefer. His code is made for exactly 5 lines to be buffered and is
I have been thinking about the thread we have had where the job seemed to be
to read in a log file and if some string was found, process the line before
it and generate some report. Is that generally correct?
The questioner suggested they needed both the entire file as one string but
also as a
BREAK fast ,
You certainly haven't been idle!
Until you get IDLE working ideally, you can still use one of many text editors
and programming environments and perhaps run python on the files manually.
Have you verified that the rest of your installation worked?
Sent from AOL Mobile Mail
On
a problem
On Fri, Dec 28, 2018 at 10:39:53PM -0500, Avi Gross wrote:
> I will answer this question then head off on vacation.
You wrote about 140 or more lines, but didn't come close to answering the
question: how to randomly split data from a dictionary into training data
and reserved data.
--
St
percentages to
partition by or other ways.
Sent from AOL Mobile Mail
On Saturday, December 29, 2018 Avi Gross wrote:
Steven,
As I head out the door, I will sketch it.
Given a data.frame populated with N rows and columns you want to break it
into training and test data sets.
In a data.frame, you
Re: [Tutor] decomposing a problem
On Wed, Dec 26, 2018 at 11:02:07AM -0500, Avi Gross wrote:
> I often find that I try to make a main point ad people then focus on
> something else, like an example.
I can't speak for others, but for me, that could be because of a number of
reasons:
- I agree w
My apologies. This reply went to the wrong forum.
Hopefully it contains little to be debated. An even shorter version would
be:
If at first you don't succeed ...
-Original Message-
From: Tutor On Behalf Of Avi
Gross
Sent: Thursday, December 27, 2018 9:48 PM
To: tutor@python.org
Subject
This is a serious question. I have tried things and searched and remain
stumped. It is about python and perhaps just the interpreter.
Copying and pasting multiple lines into the interpreter fails in mysterious
ways, unless they are a logical single entity.
Is there a way to change this
Asad,
After reading replies to you by Alan and Steven I want to ask you if you can
first tell us in normal words what the exact outline of the program does. If
you only want help on one small part, tell us about that.
I was first fooled into thinking you wanted to show us how you solve the
the problem does not
really need to be solved by me and I move on.
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent: Thursday, December 27, 2018 5:11 PM
To: Python
Subject: Re: dangerous class neighborhood
On Fri, Dec 28, 2018 at 8:47 AM Avi Gross wrote:
> Quest
I have my usual off the wall answer.
OK, seriously. Not exactly an answer but perhaps an experiment.
The question was how to have a non-named first argument to a function with
some form of default.
As was pointed out, this does not fit well with being able to have python
gather all positional
Mary,
Mary,
It is often best to develop and test small parts of the project where you
can easily play with it, then move it into more complex configurations like
a function body
Here is your code:
def read_words(words_file):
return [word.upper() for line in open(words_file, 'r') for word
al Message-
From: Mike Mossey
Sent: Tuesday, December 25, 2018 9:49 PM
To: Avi Gross
Subject: Re: [Tutor] decomposing a problem
> On Dec 25, 2018, at 4:00 PM, Avi Gross wrote:
>
> [Long enough that some should neither read nor comment on.]
>
> Mats raised an issue that
e might see:
lines.sort(show=True).reverse(show=True).pop()
Or some other similar stratagem. Then we could write a fairly complex
sequence in a pipelined mode.
-Original Message-
From: Tutor On Behalf Of
Mats Wichmann
Sent: Tuesday, December 25, 2018 11:04 AM
To: tutor@python.or
method like pop() to suddenly return the list with a member dropped but it
would be nice to fix some like this one:
>>> testink.remove('7')
>>> testink
['1', '3', '15']
Meanwhile, I hear Beethoven is decomp..., well never mind! It was probably
Liszt!
-Orig
-0500, Avi Gross wrote:
> class chainable_list(list):
> """Same as list but sort() can now be chained"""
> def chainsort(this, *args, **kwargs):
> this.sort(*args, **kwargs)
> return this
In Python, it is traditional to use "
Asad,
I wonder if an import from __future__ happened, perhaps in the version of
collections you used. Later versions of 2.x allow optional use of the 3.x
style of print.
When you redefine print, the old statement style is hidden or worse.
-Original Message-
From: Tutor On Behalf Of
ould allow tricks like this in a pre-processor.
From: Bob Gailer
Sent: Thursday, December 13, 2018 2:33 PM
To: Avi Gross
Cc: tutor@python.org
Subject: Re: [Tutor] Long Lines techniques
On Dec 13, 2018 1:51 PM, "Avi Gross" mailto:avigr...@verizon.net> > wrote:
>
> S
anded to much more.
-Original Message-
From: Tutor On Behalf Of
Steven D'Aprano
Sent: Thursday, December 13, 2018 7:27 PM
To: tutor@python.org
Subject: Re: [Tutor] Long Lines techniques
On Thu, Dec 13, 2018 at 12:36:27PM -0500, Avi Gross wrote:
> Simple question:
>
> When line
If you know what a CommaSeparatedValues file looks like, then reading ONE
LINE gives you enough info to answer the question about how many columns of
data it describes.
-Original Message-
From: Tutor On Behalf Of
Alan Gauld via Tutor
Sent: Thursday, December 13, 2018 7:47 PM
To:
To: tutor@python.org
Subject: [Tutor] Obfuscated Python [was Long Lines techniques]
On Thu, Dec 13, 2018 at 11:07:59PM -0500, Avi Gross wrote:
> Python may claim to be straightforward but I can easily see ways to
> fool people in python too with dunder methods or function closures
:59PM -0500, Avi Gross wrote:
[...]
> There are cases where it may make sense to have a long like connected
> by AND or OR given how python does short-circuiting while returning
> the last thing or two it touched instead of an actual True/False. For
> example, you may want to ta
There is linear thinking and then there is more linear thinking.
As Alan, Mats and others said, there are often choices we can make and many
approaches.
If your goal is to solve a problem NOW and right where you are, any method
you can find is great.
If your goal is to solve it repeatedly or in
Simple question:
When lines get long, what points does splitting them make sense and what
methods are preferred?
Details.
I am used to many languages where you can continue a statement across
multiple lines. What they share in common is the fact they do not use
indenting for the use
Ivo,
One thing you could have done is explore with simpler code to see if you can
deduce what is happening.
If you opened your Python interpreter and tried to see what happens with a
simplified variant like this, what do you get?
if (match = 5) is not None: pass
That might answer your
ences but then you might have said I was too broad and showed no
reasons or examples. As I said, life is short.
-Original Message-
From: Tutor On Behalf Of Steven
D'Aprano
Sent: Wednesday, November 28, 2018 6:15 PM
To: tutor@python.org
Subject: Re: [Tutor] user overloaded
On Wed,
Mats,
This may not be a direct answer to your question but I have used more
generic tools in a way that might make some sense.
You can use a videoconference tool such as SKYPE to connect and have one of
you share your screen with the otgher so you can see whatever is open such
as an editor they
d be asked to limit their code to the
standard distribution.
-Original Message-
From: Tutor On Behalf Of Alan
Gauld via Tutor
Sent: Tuesday, December 4, 2018 6:43 PM
To: tutor@python.org
Subject: Re: [Tutor] Borrowing free code
On 04/12/2018 19:31, Avi Gross wrote:
> But some packag
[[ Real SUBJECT: emulating decorators ]]
Steven,
I am not suggesting that a particular way of reusing a name is a good idea.
I am asking if some ways are encouraged and others are discouraged in the
python community.
Just to clarify one point you asked about:
# > I have often seen something
I left the "subject" above to be the same, as requested.
The actual subject might have been "Pythonic variable name use"
Alan says he had a challenge evaluating code (below) because the same
variable names were reused and it made me wonder if the python community has
general ideas about name
David,
What does it mean when someone says they cannot install a module? I can see how
a school assignment might require using only some limited set of functionality.
I note some installations add more than others or let you designate optional
components to include.
Some companies may have
I don't want to start (and continue) another sideways discussion. Alan and
Steven (not Stephen) both made very good points and helped clarify my
understanding.
I am NOT advocating copying code. Not even "free" code.
I am saying there may be times you want to package the code for special
Alan,
Yes, I meant that many things are effectively free these days. Some things are
required to be distributed free by CopyLeft. But you can pay a nominal fee for
say a CD of the software. You can pay for a bundle like you describe, perhaps
including some consulting or warranties to keep you
Just to be different, and perhaps return to the purpose of this group, I have a
question.
Is there some functionality available in Python that you could put in the
beginning of a program so it aborts with a message if the version of R being
run is not acceptable?
Let me elaborate. There
)
import os
os.system("python -m pip install " + modulosity)
exec(f"import {modulosity}")
I am sure something is doable and can be made into a proper function. Yes, I
cheated by using exec. But it is now after Spanksgiving.
-Original Message-
From: Tutor
Python
Subject: Re: [Tutor] A required question
> On Nov 23, 2018, at 09:35, Alan Gauld via Tutor wrote:
>
> On 23/11/2018 05:34, Avi Gross wrote:
>> What I was thinking was the ability to do something like this:
>>
>> import ReChoir as require
>>
>>
This is not a question or reply. Nor is it short. If not interested, feel free
to delete.
It is an observation based on recent experiences.
We have had quite a few messages that pointed out how some people approach
solving a problem using subconscious paradigms inherited from their
at least three times on that line, no matter what the
word is. You may need to tell it whether a match should be greedy and many
other considerations such as ignoring case.
Have fun.
Avi
-Original Message-
From: Tutor On Behalf Of
Asad
Sent: Monday, November 19, 2018 10:15 PM
Asad,
As others have already pointed out, your request is far from clear.
Ignoring the strange use of words, and trying to get the gist of the
request, would this be close to what you wanted to say?
You have a file you want to open and process a line at a time. You want to
select just lines
sage-
From: Tutor On Behalf Of Mark
Lawrence
Sent: Tuesday, November 20, 2018 3:45 PM
To: tutor@python.org
Subject: Re: [Tutor] Pythonic way
On 20/11/2018 18:08, Avi Gross wrote:
>
> We have two completely separate ways to format strings that end up
> with fairly similar func
Steve,
You may be right. It often happens that someone has a (small) idea, perhaps
very focused, and others chime in and try to apply it more widely, perhaps by
making it more general, and it grows. Over the years, the earlier adopters may
be seen almost as co-creators or even become the lead
.
Avi
-Original Message-
From: Tutor On Behalf Of
Steven D'Aprano
Sent: Tuesday, November 27, 2018 5:40 AM
To: tutor@python.org
Subject: Re: [Tutor] Writing the right code rite
On Mon, Nov 26, 2018 at 07:18:46PM -0500, Avi Gross wrote:
> What kind of answers have people provi
Alan has been involved with Python for a long time so he has more to offer
historically.
I don't see some things as either/or. You can start with one major
motivation and it morphs from a one-celled creature like an Amoeba to a
complex vertebrate like a Python which needs modules added so it can
: Tutor On Behalf Of Steven
D'Aprano
Sent: Thursday, November 22, 2018 1:06 AM
To: tutor@python.org
Subject: Re: [Tutor] origins bootstrapped.
On Wed, Nov 21, 2018 at 11:31:59AM -0500, Avi Gross wrote:
> Alan has been involved with Python for a long time so he has more to
> offer historically.
.org
Subject: Re: [Tutor] origins bootstrapped.
On Wed, Nov 21, 2018 at 11:31:59AM -0500, Avi Gross wrote:
...
> Can I ask a question that I really want an opinion on? As a preface, I see
> some think python as a formal language is being pushed by industry in
> directions that may not
-
From: Tutor On Behalf Of
Mats Wichmann
Sent: Monday, November 26, 2018 10:23 AM
To: paso...@gmail.com
Cc: tutor@python.org
Subject: Re: [Tutor] A required question
On 11/25/18 8:54 PM, Asokan Pichai wrote:
> On Sat, Nov 24, 2018, 14:33 Avi Gross
>> David,
>>
>> As I suspe
I am here to learn but also to help out when I already know something that
is asked.
What has been of some concern to me is how to reply when the asked has not
shared with us lots of info.
If I see them using "print" without parentheses, I can assume they are not
using 3.x and perhaps
inding this colon in a wrong context?
I conclude by saying life is complicated and then you die. I mean there are
many places where similar but not identical things happen in languages as
well as life.
-Original Message-
From: Tutor On Behalf Of
Steven D'Aprano
Sent: Wednesday, November 28, 201
I suggest starting at the beginning when asking a question to people who
have no way of knowing what you have not told them.
Your sentence is completely in middle or even near the end of something that
has to be larger:
" If the user selected a sandwich, french fries, and a beverage, reduce the
I was wondering if I was the only one who felt the urge to apply a tad of humor
and suppressed most of the thoughts about idol/IDLE worship and other puns so I
am glad to see Steve do just a little of the same.
It seems that despite how portable Python is touted to be, quite a few people
Harry,
Your code may not have come through as intended as the formatting often
combined lines.
It may help to think about the question before giving deeper answers.
You have two places and two sets of goods with prices. You want the
intersection of those two to focus on what goods are in both.
not handle any form. Can you save a value of Inf that is
meaningful even to read back in? I don't mean from using something like
pickle, but from some storage formal like CSV or EXCEL.
I see Steve wrote a bit more and will just say I agree. God programming
style tries to avoid surprises when it can
on
On Fri, Dec 28, 2018 at 12:58:00AM -0500, Avi Gross wrote:
[...]
> Copying and pasting multiple lines into the interpreter fails in
> mysterious ways, unless they are a logical single entity.
>
> Is there a way to change this behavior, or perhaps an
> editor/environ
nction in python
On Sun, Dec 30, 2018 at 12:07:20AM -0500, Avi Gross wrote:
[...]
> Or on a more practical level, say a function wants an input from 1 to 10.
> The if statement above can be something like:
>
> >>> def hello(a, *n, **m) :
> if not (1 <= a <=
python consistently
enough has everything being object-oriented. R started off without and has
grafted on at least a dozen variations which can be a tad annoying.
-Original Message-
From: Tutor On Behalf Of
Steven D'Aprano
Sent: Friday, December 28, 2018 8:04 PM
To: tutor@python.org
Subj
Steve,
I am going to just respond to one part of your message and will snip the
rest. I am not is disagreement with most of what you say and may simply
stress different aspects. I will say that unless I have reason to, I don't
feel a need to test speeds for an academic discussion. Had this been a
variable arguments in a function in python
On 30/12/2018 17:26, Avi Gross wrote:
> Replying to Steve's points. Again, it was not a serious design and
> said so but was an ACADEMIC exploration of what could be done. I fully
> agree with Steve that it is probably not a great i
Brief(er) message on topic:
Someone was having a problem that was traced to their use of a pipe to
communicate between tasks that normally passes data in binary mode.
They were offered solutions on how to convert the data that should work
fine. I am offering a different solution from the
74 matches
Mail list logo