Lawrence D'Oliveiro wrote:
> In message , Thomas Bellman wrote:
>> Speaking as a sysadmin, running applications for production,
>> programs not using SO_REUSEADDR should be taken out and shot.
>> Not using SO_REUSEADDR means forcing a service interruption of
>>
nclosed, no matter
what you do.
Not using SO_REUSEADDR means forcing a service interruption of
half an hour (IIRC) if for some reason the service must be
restarted, or having to reboot the entire machine. No thanks.
I have been in that situation.
--
Thomas Bellman, Lysator Academic Computer
message with an octet sequence that cannot occur
within a message. For example, a linefeed without a backslash
before it (and you would probably want a way to escape the
backslash, in case you want to end a message with a backslash).
- Have small header of a fixed size at the start of eac
Steven D'Aprano wrote:
> You can hash numbers no matter how big they are.
> >>> hash(float('inf'))
> 314159
Cute. And hash(float('-inf')) is -271828...
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"God is
erface
for running external commands. For example, you can avoid having
to deal with quoting shell metacharacters, and interpreting the
return values are easier.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Life IS pain, highness. Anyone who tells
s one thing to let the user overwrite a
file named "foo; rm -rf $HOME", quite another to pass that string
unquoted to /bin/sh when the user thought he was just typing a
filename.)
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"I don't think [tha
ython-coded function at all. The operator
module is your friend: key=operator.attrgetter('real', 'imag')
will create the required tuples for sorting.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"God is real, but Jesus is
(not all!) shells. It should not be
trusted outside those shells, and hardly inside them either.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Adde parvum parvo magnus acervus erit" ! bellman @ lysator.liu.se
(From The Mythic
find the Makefile at /tmp/p if the current
> directory were another one... (?)
The problem is, he is not printing the name of the current working
directory; he is printing the value of the variable $PWD. That is
likely set from the environment by the shell he started the Python
program from,
t an illogical stance to take. It's just
a totally different issue from encountering a non-numeric element
in the sequence. In some cases it might actually make sense to
treat the empty sequence as an error, but just ignore non-numeric
elements (i.e, treat them as if they were zero).
ad) does return NULL for a sum over the empty sequence, so you
could argue that that would be the correct behaviour for the
Python sum() function as well, but you can't argue that because a
sum *involving* a NULL value returns NULL.
--
Thomas Bellman, Lysator Computer Club, Linköping U
symlinks from the chroot jail that try to
point to things outside the chroot, you are at least guaranteed
that you won't give the chroot:ed process to much information.
Unfortunately, you won't be giving it the tools it needs to do
its designed job, either, since symlinks can't esca
cess can do even when
chroot:ed, like creating device files or setuid binaries.
All this is of course assuming that the chroot is done for
security reasons. There are other reasons one might want to
run in chroot.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
27;], 0)
>>> d.default_factory = list
>>> d
defaultdict(, {'y': 0, 'x': 0})
>>> d['z']
[]
>>> d
defaultdict(, {'y': 0, 'x': 0, 'z': []})
The keys you give to the fromkeys() method
his, then I believe the warning I gave about performance
does not apply; my understanding is that calling built-in functions
(like the int constructor) is fast.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Beware of bugs in the above code; I have! be
ntain the list. Unlikely,
but not entirely impossible, and just a small change of the
problem size can change the balance again.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"What sane person could live in this world ! bellman @ lysator.liu.se
and not be crazy?" -- Ursula K LeGuin ! Make Love -- Nicht Wahr!
--
http://mail.python.org/mailman/listinfo/python-list
en to defaultdict will be called the
first time a key is mentioned, and if the keys are mostly unique,
that will be the majority of the times, and calling a pure Python
function is fairly slow in CPython. (It probably won't matter
unless you have many thousands of unique keys, though.)
--
Thom
t you *also* create
a 17 long list with all elements set to None, that is immediately
thrown away.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"I refuse to have a battle of wits with an ! bellman @ lysator.liu.se
unarmed person."! Make Love -- Nicht Wahr!
--
http://mail.python.org/mailman/listinfo/python-list
Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
>(Ctrl+Z which sends SIGSTOP and _cannot_ be masked
> or otherwise ignored)
Bzzt! Ctrl-Z causes a SIGTSTP to be sent, not SIGSTOP, and
SIGTSTP can be both caught, ignored and masked.
--
Thomas Bellman, Lysator C
e
using. And RHEL/CentOS 4 is still quite common, so if you want
to reach a large "customer base", make sure that your Python
programs work with Python 2.3.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Don't tell me I'm burning the candle
be more or less random, but it will make
sure that the four-tuple identifying the TCP connection will be
unique.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"There are many causes worth dying for, but ! bellman @ lysator.liu.se
none worth killing for.&
Scheme? If so, then no, in Scheme
only #f is false, and the empty list () is considered true.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"When C++ is your hammer, everything ! bellman @ lysator.liu.se
looks like a thumb."
Ivo <[EMAIL PROTECTED]> wrote:
> Thomas Bellman wrote:
>> However, the os.read() function will only read what is currently
>> available. Note, though, that os.read() does not do line-based
>> I/O, so depending on the timing you can get incomplete lines, or
&g
Christian Heimes <[EMAIL PROTECTED]> writes:
> Thomas Bellman wrote:
>> The readlines() method will read until it reaches end of file (or
>> an error occurs), not just what is available at the moment. You
>> can see that for your self by running:
> Bad idea ;)
W
hink, Ctrl-Z if you are using MS-Windows).
However, the os.read() function will only read what is currently
available. Note, though, that os.read() does not do line-based
I/O, so depending on the timing you can get incomplete lines, or
multiple lines in one read.
--
Thomas Bellman, Lysat
> Yes but my python threading is worse than rudimentary. I will look
> into the `trheading` module suggested by the other poster.
I think you would be better off looking into the correctly spelled
'threading' module rather than the misspelled 'trheading' module. :-)
--
Th
there is a space instead of a dash after the "250" code in
the last line above, the SMTP client knows that there won't be
any more lines in response to its command.
If you can't get the program you are calling to follow some
protocol like this, then you can only make guesses.
of "cat"
as a test program, I suppose that isn't a problem for you.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"God is real, but Jesus is an integer." ! bellman @ lysator.liu.se
! Make Love -- Nicht Wahr!
--
http://mail.python.org/mailman/listinfo/python-list
files, but on pipes, sockets or
terminals, you would have major problems, since suddenly calling
the eof() method would block the process. Probably not what you
were expecting.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Life IS pain, highness. Anyone who te
x27; is the expression
List comprehensions:
>>> c
Traceback (most recent call last):
File "", line 1, in
NameError: name 'c' is not defined
>>> eval('[ord(c) for c in "parrot"]')
[112, 97, 114, 114, 111, 116]
>&g
erently
that for example a Japanese person will not be able to recognize
a character rendered in the Taiwanese or mainland Chinese way.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Adde parvum parvo magnus acervus erit" ! bellman @ lysator.liu
but that
will only apply to your terminal, not to anyone else's.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Don't tell me I'm burning the candle at both ! bellman @ lysator.liu.se
ends -- tell me where to get more wax!!" ! Make Lo
(Don't feel too bad about it. I have made similar
mistakes myself, but after many years working with computer
security I have managed to learn not to do *that* particular
error again; I hope...)
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Life IS pai
for the same #! line.
I seem to remember having used some Unix flavor that allowed
multiple words as arguments, and thus passed the four words
"foo", "bar", "gazonk" and "del" as arguments for the above #!
line, but I don't remember what Uni
printf("Pointer cast: %d %10.6f\n", *(int*)&f, *(float*)&i);
to the program. It should output the same numbers as the
"Bitcopy" printf(). But what is cast here is the *address* of
the variables, not the actual contents of them. It is the
*dereferencing* of thos
gs, **kwargs):
kwargs.setdefault('allow_none', 1)
return self.__dumps[0](*args, **kwargs)
xmlrpclib.dumps = _xmldumps(xmlrpclib.dumps)
import SimpleXMLRPCServer
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"
Alex Martelli <[EMAIL PROTECTED]> wrote:
> C has no stand on complex numbers.
If by that you mean that C does not have complex numbers, then
you are wrong. C99 defines the three types float _Complex,
double _Complex, and long double _Complex, and also the header
.
--
Thoma
Lawrence D'Oliveiro <[EMAIL PROTECTED]> writes:
> "const" is in C89/C90.
Although with slightly different semantics from in C++... For
instance:
static const int n = 5;
double a[n];
is valid C++, but not valid C.
--
Thomas Bellman, Lysator Computer Club
subprocess without deadlocking, you may be helped
by using my asyncproc module, which you can download from
http://www.lysator.liu.se/~bellman/download/asyncproc.py
I suspect that it only works on Unix, though.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
&q
zeros
65M zeros
(You can infer from the above that my file system has a block
size of 4 Kbyte.)
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"There are many causes worth dying for, but ! bellman @ lysator.liu.se
none worth killing for."
to read, you will terminate prematurely in many cases. Even
'dd if=/dev/zero | myprogram.py' will stop at some random point,
when the OS happens to decide that myprogram.py should be scheduled
twice without dd getting the chance to fill the pipe buffer
inbetween.
--
Thomas Bellman, Ly
ee it is much more work than to do it the right
way. It's also much more fragile; think for example about what
happens if your SQL statement (I assume that's what sqlsth is)
yields zero rows, and you then try to look at pkcolumns after
that loop.
--
Thomas Bellman, Lysator Computer Club,
e child process was started using subprocess.Popen, you
should usually use the poll() methods on the Popen object to
check if the process has terminated.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"You are in a twisty little passage of ! bellman @ lysator
s.makedirs("/tmp/trh/spam/norwegian/blue/parrot/cheese")
except os.error, e:
if ( e.errno != errno.EEXIST or
not os.path.isdir("/tmp/trh/spam/norwegian/blue/parrot/cheese")):
raise
--
Thomas Bellman, Lysator Computer Club, Linköping Uni
o the function.
Thus, this gives you the behaviour you want:
try:
os.makedirs("/tmp/trh/spam/norwegian/blue/parrot/cheese")
except os.error, e:
if e.errno != errno.EEXIST:
raise
--
Thomas Bellman, Lysator Computer Club, Linköping University,
7;t use
that OS, and thus can't test it.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Beware of bugs in the above code; I have! bellman @ lysator.liu.se
only proved it correct, not tried it." ! Make Love -- Nicht Wahr!
--
http://mail.python.org/mailman/listinfo/python-list
s"), but i wish to know if there's non-hack way to
> determine when a system process is done.
Have you tried reading the manual for the subprocess module? You
just *might* find the answer to your question if you look at what
you can do with Popen objects. Actually, just learning about
ble in comparison, and would likely fit within the
slots when 'md5sum' is waiting for I/O even on a single-CPU
system.
And I'm fairly certain that 'sort' won't start spending CPU time
until it has collected all its input, so you won't gain much
there either.
--
T
=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= <[EMAIL PROTECTED]> wrote:
>Thomas Bellman wrote:
>> Fixed-with characters *do* have advantages, even in the external
>> representation. With fixed-with characters you don't have to
>> parse the entire file or stream in
o an octet position that can be
calculated directly from N.
In-place editing of single characters in large files becomes more
efficient.
The codec for UTF-32 is extremely simple. There are no illegal
sequences to care about, like there are in UTF-8 and UTF-16, just
illegal single 32-bit values (those
compatible
with ASCII (the way UTF-8 is), nor uses fixed-with characters (like
UTF-32 does)?
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"You are in a twisty little passage of ! bellman @ lysator.liu.se
standards, all conflicting."!
lass. It doesn't do exactly what you
want, but maybe you can use it as inspiration for doing it yourself.
It requires the subprocess module, but I have successfully used
it under Python 2.3.2 with subprocess installed locally.
--
Thomas Bellman, Lysator Computer Club, Linköping Univer
t it's not really fair to say "ignore it
> and it won't affect you" -- there's still a cost associated with such
> features that can't be ignored away.
There is a "local" cost with it, for learning Python, but I'm not
sure there really is
r using the package.
If some authors write bad books, do you blame the English
language for allowing them to write such books, or do you
blame the writers for using English in a bad way?
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"We don't understand
parrot() with a one-element tuple either. However,
'parrot(1)' and 'parrot(1,)' means exactly the same thing, while
'print 1' and 'print 1,' does not.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Adde parvum parvo magnus
55 matches
Mail list logo