, y = symbols('x y')
print( solve([x*y - 1, x - 2], x, y) )
which prints the result:
[(2, 1/2)]
Perhaps if you explain what you are trying to do, we can help better.
But please, cut down your code to only code that is being used!
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
un()
except IOError:
pass
time.sleep(0.05)
# -- b.py --
filename = 'data'
import os, time
while True:
try:
os.remove(filename)
except OSError:
pass
time.sleep(0.05)
The time.sleep() calls are just to slow them down slightly. You can leave
an do
everything that concurrency can do, and more, and both of which are
significantly easier to understand too.
So why do we need asyncio? What is it actually good for?
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
indows, but on Linux it behaves as you describe (and
as Linux users will expect):
[steve@ando ~]$ python program.py column1=2174 and column2='R'
argv: ['program.py', 'column1=2174', 'and', 'column2=R']
column1=2174 and column2=R
This is *absolutely n
demand
powerful tools, and they expect that wildcards like * should be expanded.
Windows treats the command line as an afterthought, and until a few years
ago you were limited to a DOS shell. Today, your options are not as
limited: there's Powershell, and bash for Windows.
--
Steve
“Chee
n argument *.*, what do you do with it?
You probably expand it yourself. How does the application know when not to
expand the wild cards? You need to support some sort of command-line switch
to turn it off, but that will effect the entire command line. So you need
some sort of escaping mechanism so that you can pass
myprogram *.* *.*
and have the first *.* expanded but not the second. (For example.)
Congratulations, you've just re-invented your own mini-shell.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
ity risk, if you're getting the arguments from an untrusted
source, so don't pass shell=True unless you know what you're doing.)
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
you like, by writing some code:
display_string = '::'.join(str(value).upper() for value in obj)
print('[[' + display_string + ']]')
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
On Tue, 6 Dec 2016 10:09 am, eryk sun wrote:
> On Mon, Dec 5, 2016 at 4:49 PM, Steve D'Aprano
> wrote:
>>
>> You've never used cmd.com or command.exe? "The DOS prompt"?
>
> The default Windows shell is "cmd.exe", and it's informally ca
just "systemd can't do that", but "you shouldn't do that".
Why not? We used to do it, and it is necessary for our application.
"Because its wrong."
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
are system dependent limits on globbing expansion and the number of
arguments you can pass to a program:
http://stackoverflow.com/questions/4185017/maximum-number-of-bash-arguments-max-num-cp-arguments
http://www.in-ulm.de/~mascheck/various/argmax/
--
Steve
“Cheer up,” they said, “things c
en entries, screwing everything up.
>>
> Now you're suggesting the _shell_ is going to read and process a CVS
> file???
Be fair: he's giving an analogy.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
t.com/news/fact-checker/wp/2015/06/29/has-there-been-one-school-shooting-per-week-since-sandy-hook/
In other words, if you ignore 90% of school shootings, you can dismiss
concerns of school shootings as a lie.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sur
s Fool", the majority of comments I saw were from dual Windows/Linux
system administrators saying "At last I can use bash on Windows!".
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
command @files
*Requiring* this would be completely unacceptable. Forcing the user to write
two lines (one to create a variable, then to use it) every time they needed
a glob expansion would go down among sys admins like a lead balloon.
But for those times when you really need to repeat a comple
On Thu, 8 Dec 2016 02:19 am, BartC wrote:
> On 07/12/2016 14:34, Steve D'Aprano wrote:
[...]
>> I don't know why you are so hung up over the number of characters here,
>> or this bogeyman of "one million files" in a directory.
>
> Because /you/ brought it
e expansion,
arithmetic expansion, parameter expansion, variable expansion, and I dare
say I've forgotten some others.
[steve@ando ~]$ echo ~
/home/steve
[steve@ando ~]$ echo $((1+7*5))
36
[steve@ando ~]$ echo $http_proxy
http://ando:3128
The echo command doesn't have to understand anythi
signed the shell to work the way they
want are wrong.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
s expected to behave, *as if* it were following the
LEGB rule, not necessarily a statement of the implementation of any
specific Python implementation.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
ances)
Sounds similar to classic Mac OS, where you had:
volume:path
where the path uses : as directory separators. Removable media (floppies,
removable hard drives) could be unplugged and re-inserted into any physical
drive, and the OS would track where the media was and whether it was
phys
her, and iİ go together. But other
languages want iI to go together, meaning that the standard case
conversions are lossy:
py> 'ıIiİ'.lower()
'ıiii'
py> 'ıIiİ'.upper()
'IIIİ'
Maybe it would have been better if the standard had kept ıİ together, and
iI, so at least the case conversion was lossless. Alas, too late now.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
So is "".
That's one way of looking at things... I'm not sure that the empty string
counts as a file name. Its more of the LACK of a file name.
Besides, that would be ambiguous. Would "/home/steve/" mean my home
directory, or the file "" inside my home directory?
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
On Fri, 9 Dec 2016 09:34 pm, Marko Rauhamaa wrote:
> Steve D'Aprano :
>
>> On Fri, 9 Dec 2016 04:52 pm, Marko Rauhamaa wrote:
>>> In Linux, "." and ".." are taboo.
>>
>> No that's incorrect. It isn't that . and .. are forb
web archive as it
contains defamatory material.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
ty libraries, including your script-runner.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
On Sat, 10 Dec 2016 03:15 pm, DFS wrote:
> On 12/09/2016 08:39 PM, Steve D'Aprano wrote:
>> On Sat, 10 Dec 2016 08:07 am, DFS wrote:
>>
>>>
>>> As of 04:04PM December 09, 2016
>>>
>>> Posts 85 Posters
>> [...]
>>
>>
&g
ng of length 1
%d %i %u => int(obj), which ends up calling __int__
%x %X => int(obj), then convert to hexadecimal
%o => int(obj), then convert to octal
%e %E %f %g %G => float(obj), which ends up calling __float__
%% => a literal % sign
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
.
Indeed. But although c.l.p is a mirror of the mailing list, it is not a
*perfect* mirror. The two do diverge: some things go to the mailing list
but apparently never make it to the newsgroup, and some things get to the
newsgroup but don't make it to the mailing list.
The stats generated by
rmal inheritance
rules are get the instance attribute if it exists, otherwise a
class or superclass attribute;
- use `type(self).attribute` when you want to skip the instance
and always return the class or superclass attribute.
--
Steve
“Cheer up,” they said, “things could be worse.” So I
fortunately vars() doesn't understand
__slots__, which I think is an oversight.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
ive constructor, MyClass.make_instance(...).
Naming things is hard.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
s)) # Python 3
Personally, this would be my preferred technique, as I (nearly) always end
up doing a strip() on data I read from text files, so the extra call to
filter is no big deal.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got wor
run
a script *or* in interactive mode, there is an associated tty. Am I wrong?
>> python < script.py
>>
>> The behavior the OP is looking for of course is a way of demarcating the
>> end of the script and the beginning of data to feed the script.
>
> It's more
x27;ps1') or hasattr(sys, 'ps2') will tell you if you are running
in the REPL (interactive interpreter). The ps1 and ps2 variables aren't
defined in non-interactive mode.
Does that help?
> You can get similar behavior with python -c "import
> sys;exec(sys.stdin.read())&quo
.update will fail.
I don't know if Raymond has an objective reason for preferring one over the
other, or if it is just a matter of personal taste. If you have a Twitter
account, perhaps you could ask him to comment?
https://twitter.com/raymondh
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, 15 Dec 2016 01:28 am, Random832 wrote:
> On Tue, Dec 13, 2016, at 19:10, Steve D'Aprano wrote:
>> Can you show a simple demonstration of what you are doing?
>>
>> I'm having difficulty following this thread because I don't know
>> what "s
"ξ" belongs to the script "GREEK".
Is this information available from Python?
More about Unicode scripts:
http://www.unicode.org/reports/tr24/
http://www.unicode.org/Public/UCD/latest/ucd/Scripts.txt
http://www.unicode.org/Public/UCD/latest/ucd/ScriptExtensions.txt
--
ry from 1 to perhaps a hundred or so.
Has anyone dealt with data like this and could give a recommendation of the
right data structure to use?
The obvious way is to explicitly list each key, in a regular dict. But I
wonder whether there are alternatives which may be better (faster, more
mem
them "class methods" and "static methods", but in other
languages they may not exist at all or have other names.
(In Java, the closest equivalent to "class method" is called a "static
method".)
Adding to the complexity, the __name__ of MethodType is just &q
s, num_symbols)
entropies[c] = H
total = display_results(frequencies, entropies, num_symbols)
if __name__ == "__main__":
# Only run when module is being used as a script.
main()
# --- cut ---
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
On Fri, 16 Dec 2016 04:06 am, Steve D'Aprano wrote:
> I have some key:value data where the keys often are found in contiguous
> ranges with identical values.
[...]
Thank you to everyone who gave suggestions!
I have experimented with two solutions, and hope somebody might be able
t that *in practice* set/dict lookups require only a
single hash + equality, in principle (and sometimes in practice too)
collisions can be significant.
Nevertheless, I mention this only for completeness. In practice, you almost
never need to care about hash collisions except for the most patho
On Sat, 17 Dec 2016 08:31 pm, Peter Otten wrote:
> Steve D'Aprano wrote:
>
>> I have experimented with two solutions, and hope somebody might be able
>> to suggest some improvements. Attached is the test code I ran,
>> suggestions for improving the performance will
from!) and now it is obvious that the start index is included
and the stop index is excluded/
+---+---+---+---+---+---+
| P | y | t | h | o | n |
+---+---+---+---+---+---+
^...^
cut hereand here
There's no mental model that makes slicing with non-zero step sizes easy,
*especially* if the step size is a non-unit negative number (say, -3). For
those you really have to simulate the process of actually iterating over
the indexes one by one.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, 22 Dec 2016 09:10 pm, Frank Millman wrote:
> If this is the standard of security out there, it is no wonder we hear of
> so many attacks (and how many don't we hear of?)
Everything is broken:
https://medium.com/message/everything-is-broken-81e5f33a24e1
--
Steve
“Chee
tion."
Why are using Blake2 when the docs explicitly say not to use them in this
way? Have you read the FAQ to see what it says?
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
On Fri, 23 Dec 2016 10:08 pm, Frank Millman wrote:
> "Steve D'Aprano" wrote in message
> news:585d009f$0$1599$c3e8da3$54964...@news.astraweb.com...
>>
>> On Fri, 23 Dec 2016 09:19 pm, Frank Millman wrote:
>>
>> >
>> > 3. Generate the pass
quot;what was your
mother's maiden name?").
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
n my lights off. What. A. Time. To. Be. Alive."
https://twitter.com/TweetsByTSD/status/655297659381661696
[1] If any country is foolish enough to put control of the electricity grid
on the Internet. Of course nobody would do that. Right?
--
Steve
--
https://mail.python.org/mailman/listinfo/python-list
the input file is intended to be UTF-8? How was it
created?
- Is the second byte 0xFE? If so, that suggests that you actually have
UTF-16 with a byte-order mark.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
calling xml.etree.ElementTree.parse I
> included an XMLParser object:
>
> parser = xml.etree.ElementTree.XMLParser(encoding="utf8")
> root = xml.etree.ElementTree.parse(f, parser=parser).getroot()
That's the default, so there's no functional change here. Hence, the same
error.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
rsion of Python are you using?
(3) Code is better than English. Can you supply a *minimal* (as small and
simple as possible) example that shows this bug?
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
make it (e.g. since this issue has nothing
to do with sending email, your code should not send email -- a simple print
should be enough for output);
- complete (no missing dependencies, all necessary modules are imported, no
uninitialised variables, functions called with all necessary arguments
specified);
-
f-8 --" at
the begining of each document. This is way much easier and works as
charm
I have no words for how wrong that is. And this comment:
ty, this worked for my problem with python throwing UnicodeDecodeError
on var = u"""vary large string"""
efficiently, or at least not too inefficiently, do the
calculations in Python?
Signed arithmetic also has some gotchas. For example, -x is not necessarily
defined, nor is abs(x).
Thanks,
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
On Sat, 31 Dec 2016 02:14 am, Serhiy Storchaka wrote:
> On 30.12.16 16:47, Steve D'Aprano wrote:
>> Again, assume both operands are in range for an N-bit signed integer.
>> What's a good way to efficiently, or at least not too inefficiently, do
>> the calculations
[(1, 2), (3, 4)]
py> [a for a in data]
[(1, 2), (3, 4)]
py> [(x, y) for a in data]
Traceback (most recent call last):
File "", line 1, in
File "", line 1, in
NameError: name 'x' is not defined
Okay, let's create global variables x and y:
py> x
002py> \001\x1b[0m\002'
sys.ps2 = '\001\x1b[1m\002... \001\x1b[0m\002'
else:
sys.ps1 = 'py> '
That gives me a "py>" prompt, bolded in Python 3 and plain in Python 2.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
On Sat, 31 Dec 2016 10:26 am, einstein1...@gmail.com wrote:
> That's not the answer.
> If you don't have answer, please don't answer like this, because that will
> confuse others also.
What's not the answer? What's the question?
--
Steve
“Cheer up,” they s
se many different styles of prompts:
Python: >>>
iPython:In [1]:
Ruby (irb): irb(main):001:0>
bash: [steve@ando ~]$
bash (root):[steve@ando ~]#
DOS:>
rhino: js>
lua:>
julia: julia>
xion: >
mutt:
t] = l1[st]
The comments are, of course, redundant, and I probably wouldn't bother
putting them in my own code.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
r. Don't just hit send for every trivial thought that
enters your mind.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
ay "I'm wondering
about..." rather than "I have a question".
This is an international forum, and we should make allowances for variant
forms of English and those whose grasp of the Queen's English is not
perfect.
--
Steve
“Cheer up,” they said, “things could b
nt, we don't have many examples
of text written on the road surface myself. But when I do see them, I find
them more distracting than helpful.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
ue
(2) Step Two: add a temporary variable to avoid repeating the assignment
if condition:
temp = l1
else:
temp = l2
temp[v] = new_value
(3) Step Three: change the if...else statement to an expression
temp = l1 if condition else l2
temp[v] = new_value
(4) Step Four: no need for the temporary
loated and slow it
couldn't even keep up with my typing. I'm not even a touch typist! I'd
start to type a line like:
except ValueError as err:
and by the time my fingers were hitting the colon, Spyder was displaying
`excep` in red flagged with an icon indicating a syntax er
ything whatsoever should be coerced to int". If you have something
like:
left_margin = int_or_else(ftp_server)
that's surely a programming error that needs fixing, rather than something
that should just return a default value.
--
Steve
“Cheer up,” they said, “things could be wors
REPL for an interpreter, where you
want the REPL to keep going no matter what exceptions take place. But I
don't think this is the right way to do that, and it's not how the Python
REPL works either.
Other than that, I'm not seeing any use-case where this sort of thing is
anything but a
e of simple formats and see
which, if any, your console understands:
# HTML
http://www.example.com";>Example.
# URL in angle brackets
Example <http://www.example.com>
# URL alone
http://www.example.com
# I can't remember what these are called
http://www.example.com>
# M
x = 23 + )
^
SyntaxError: invalid syntax
You should copy and paste *all* of the error message, as much as you can
see.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
eed.
Another thought: if he is receiving human generated input, there is an
argument to be made for accepting "look alikes" -- e.g. maybe the data was
entered by Aunt Tilly, who was a typist in the 1960s and can't break the
habit of using l or I interchangeably for 1, and O for 0.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
ou get a random number. What you want
is:
computer_number = random.randint(1, 100)
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
nt.
> for file_name in name_set:
> directory = "output"
> with open(os.path.join(directory, filename, 'w', newline='') as
> csvf:
> for file in rootobs:
> # create and write csv
Your indentation is
at
you do. But when you hit "Reply" to a message, you inherit the "Reference"
and "In-Reply-To" headers from the previous message, so at least some
people will see it threaded in an existing thread rather than starting a
brand new one.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
re, but if you are working in a console or
terminal, just printing the URL is likely to be interpreted by the console
as a clickable link:
print("http://www.example.com";)
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
m sorry that I can't give you a one-sentence answer "just use
such-and-such a function, that does exactly what you want in a
platform-independent manner" :-(
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
ot;Anything whatsoever should be coerced to int". If you have something
like:
left_margin = int_or_else(ftp_server)
that's surely a programming error that needs fixing, rather than something that
should just return a default value.
--
Steve
â £Cheer up,â Ø they said, â £things cou
ase might be the REPL for an interpreter, where you want
the REPL to keep going no matter what exceptions take place. But I don't think
this is the right way to do that, and it's not how the Python REPL works
either.
Other than that, I'm not seeing any use-case where this sort of thi
a couple of simple formats and see
which, if any, your console understands:
# HTML
http://www.example.com";>Example.
# URL in angle brackets
Example <http://www.example.com>
# URL alone
http://www.example.com
# I can't remember what these are called
http://www.example.com>
#
ou get a random number. What you want
is:
computer_number = random.randint(1, 100)
--
Steve
â £Cheer up,â Ø they said, â £things could be worse.â Ø So I cheered up, and
sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
x = 23 + )
^
SyntaxError: invalid syntax
You should copy and paste *all* of the error message, as much as you can see.
--
Steve
â £Cheer up,â Ø they said, â £things could be worse.â Ø So I cheered up, and
sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
eive.
Indeed.
Another thought: if he is receiving human generated input, there is an argument
to be made for accepting "look alikes" -- e.g. maybe the data was entered by
Aunt Tilly, who was a typist in the 1960s and can't break the habit of using l
or I interchangeably for 1, a
want.
> for file_name in name_set:
> directory = "output"
> with open(os.path.join(directory, filename, 'w', newline='') as
> csvf:
> for file in rootobs:
> # create and write csv
Your indentati
k.
I'm sorry that I can't give you a one-sentence answer "just use such-and-such a
function, that does exactly what you want in a platform-independent manner" :-(
--
Steve
â £Cheer up,â Ø they said, â £things could be worse.â Ø So I cheered up, and
sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
y ever sort by thread, so it is no skin off my nose what you do. But when
you hit "Reply" to a message, you inherit the "Reference" and "In-Reply-To"
headers from the previous message, so at least some people will see it threaded
in an existing thread rather than startin
rywhere, but if you are working in a console or
terminal, just printing the URL is likely to be interpreted by the console as a
clickable link:
print("http://www.example.com";)
--
Steve
â £Cheer up,â Ø they said, â £things could be worse.â Ø So I cheered up, and
sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
tee corner")
default_YYY = XXX("│ ", "├─ ", "└─ ")
bold_YYY = XXX("┃ ", "┣━ ", "┗━ ")
ascii_YYY = XXX("| ", "|- ", "+- ")
def draw_tree(tree, YYY=default_YYY):
...
but what do I call XXX and Y
On Sat, 7 Jan 2017 12:03 am, Steve D'Aprano wrote:
> The second hardest problem in computer science is cache invalidation.
>
> The *hardest* problem is naming things.
Thanks everyone who answered, but I think some of you misunderstood my
question. I know that the individ
in iterable:
yield x
if predicate(x):
break
min(takeuntil(lambda x: x == 0, iterable), key=abs)
py> from itertools import count, chain
py> iterable = chain(reversed(range(10)), count())
py> min(takeuntil(lambda x: x == 0, iterable), key=abs)
0
py> iterable = cha
yield e
> if key(e) <= stop:
> break
> return min(take_until(), key=key)
Heh, great minds think alike :-)
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
's no longer a snapshot), or "list()" is sprinkled around every
> iterator access.
Not *every* view access. Only the ones where you insert/delete elements.
> In other words, what used to be a completely safe operation now is not.
>
> Thoughts?
The old Python 2 keys/values
it *looks like* 'match'.
Hint:
s = 'match '
print 'match', s # they look the same
print 'match' == s # but they aren't the same
Start by printing repr(candidate_text) and see what you really have.
--
Steve
“Cheer up,” they said, “things could be
way to do that is by editing the CSV file in LibreOffice or Excel
or another spreadsheet application.
If you have a list of records, call .sort() on the list, not the individual
records.
But if I am wrong, and you absolutely must sort the fields of each record,
call the sorted() function, which
http://aosabook.org/en/500L/a-python-interpreter-written-in-python.html
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
:
"What's the shortest piece of string to tie two things together?"
Um, it depends on which two things, it depends on how secure you need the
tie to be... we need more detail.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
working file.
An excellent way to manage this process is by using a revision control
system like Mercurial (hg) or equivalent. But at the very least, whenever
you change a working program, you should confirm it is still working before
making the next change.
--
Steve
“Cheer up,” they said,
Notice that the context manager simply raises an exception on failure, which
I can catch or not as I so choose, rather than returning None.
I really think that the problem here is the design of psql_cursor().
> Of course, that
> might not work, given that I may need to do something d
at you - why not
> just add it to your documentation?
A very good question :-)
Why am I doing this? Part of the answer is simply because I can. I want to
see how far I can go to lock down the class in pure Python code.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheer
; cls._instance = inst = super().__new__(cls)
>> return inst
>> return cls._instance
>> def __repr__(self):
>> return ''
>
> And this has to do with single instances, which is not what you asked
> about.
>
> This can be used as a decorator at class creation time, or at any later
> date to lock down a class. The downside is it's less obvious that the
> class is final... meaning there are no clues in the MRO.
Ah nice! I didn't know about __init__subclass__.
--
Steve
“Cheer up,” t
1001 - 1100 of 7146 matches
Mail list logo