nt function, but that's
probably worse than swapping sys.stdout.
(I agree that print should be a function, simply because
there's no strong reason for it *not* to be. But I
don't think it makes a difference to this particular
problem.)
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
eing
closed could be referenced from somewhere else.
If that's so, the __del__ method may be performing
a useful service by closing it more promptly than
it would otherwise be.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
nd logs
stuff written to it.
> What do you find wrong with this sort of "monkeypatching"?
At least sys.stdout was designed somewhat with the
possibility of replacing it in mind. It's not an
entirely unexpected thing to do. Replacing something
in the builtin namespace seems like a more
willing to put in a huge amount of time,
effort and ingenuity, it's possible to overcome a
problem that only existed in the first place because
you chose an inappropriate technique for implementing
a user interface...
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
read from a
stream, and it won't be read otherwise. In that case,
the code *still* won't ever see a None.
So I think the PEP has it right.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Marc 'BlackJack' Rintsch wrote:
> File descriptors are integers. It's a low level C thing. Either use the
> low level functions in `os` or open the file with the `filename`.
In particular, os.fdopen(fd) will give you a
file object.
--
Greg
--
http://mail.python.org/ma
e same file twice before a worker
has gotten around to working on it, and there is no
need for a custom queue class.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
xcept clause will only catch
exceptions in , whereas in the
second it may catch exceptions in
as well.
It probably doesn't make a difference in this example, but
there are situations where it can.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Robert Coe wrote:
> It's hard to imagine anything more OT in this newsgroup
It's on topic as long as the air conditioner
can be programmed in Python. With the amount
of electronics being used in cars these days,
that's not entirely beyond the realms of
possibility...
yadin wrote:
> hi am doing a polar plot of the radiation pattern of an antenna.
> the polar plots represents the value of the power in dB's and the dB
> go from -40dB to 0dB
Add 40 so that the range goes from 0 to 40, then
plot that to an appropriate scale.
--
Greg
--
http://m
Hi All,
Could anyone tell me how I could syslog to a specific log (e.g. /var/
log/daemon.log, /var/log/syslog.log...)?
Thanks very much in advance!
-Greg
--
http://mail.python.org/mailman/listinfo/python-list
can
actually be played in a deliberate way now instead
of just trial and error like the first one.
Currently available here:
http://www.cosc.canterbury.ac.nz/greg.ewing/python/PyWeek4/Probe-1.0.zip
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ace operators
to the language was held up for a long time until
the present compromise was devised. You might not
like it, but it's here to stay.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin wrote:
> Maybe we can concoct a cross between Python and Haskell, and call it
> "Paskell" after the philosopher Blaise ;-).
No, we name it after Pascall's confectionery:
http://www.homesick-kiwi.com/productpage.php?id=51
Lots of syntactic sugar.
"a new kind of integer" that
is not compatible with other integers.
Pascal and Modula just had a fixed set of numeric
types with various predefined compatibility
rules, not much different from C.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
list of N non-random
numbers that sum to M, and then adjust them up or down
by random amounts. By performing up/down adjustments in
pairs, you can maintain the sum invariant at each step.
So then it's just a matter of how long you want to go
on fiddling with them.
--
Greg
--
http://mail
splay* it rounded
to the number of digits you want using formatting,
e.g.
>>> "%.2f" % x
'0.15'
Alternatively, use the Decimal module, which stores
numbers as decimal and does arithmetic in ways that
will match your calculator. It's slower, though.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
to be *random* at all... or,
equivalently, they can have a very skewed
distribution. :-)
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Gabriel Genellina wrote:
> The 5th number is not "random".
More precisely, the fifth number is not *independent*
of the others. You can't have five independent random
numbers that sum to 50; only four independent numbers
plus a dependent one.
--
Greg
--
http://mail.python.or
rent use cases.
It's usually not appropriate for __init__ calls,
because an __init__ method generally doesn't have
the same signature as that of its base class(es).
You're better off calling the base __init__
directly, then you know exactly which method
you're calling and what s
John Nagle wrote:
> and when we get to
> Unicode-only strings, "str" will never raise a conversion exception.
On *strings*, maybe, but objects can implement __str__ in
arbitrary ways, so you can't say anything in general about
what str() will do.
--
Greg
--
http://ma
ince one object is being
shared between all instances.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
way, such as semantic analysis and/or code generation.
That stuff has to be done anyway, and validation sort of comes
out of that for free. So inserting an extra validation step
might not be of any advantage.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ll as just a single type.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Steve Holden wrote:
> >>> basestring
>
You're right, I'm not sure what made me think it
was a tuple. Maybe because people used to write
isinstance(x, (str, unicode)) before basestring
existed.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ks like a bug in gcc to me -- what do people
think?
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
I have released a small update to Plex to fix the
problem of assignment to None causing syntax warnings
or errors in Python 2.3 and later.
What is Plex?
Plex is a Python module for lexical analysis that
provides similar functionality to Lex and Flex.
--
Greg
--
http://mail.python.org/mailman
Pyrex 0.9.5 is now available:
http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
Warning Elimination
Extensive changes have been made in this version in an
effort to eliminate most of the C compiler warnings that
used to occur when compiling with distutils.
There are also numerous other
for lexical analysis that
provides similar functionality to Lex and Flex.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
wds):
...
Without that, your Python subclass would have to define
its own __new__ method which accepts the extra args
and strips them out, e.g.
class MySpam(Spam):
def __new__(cls, name1=None, name2=None):
return Spam.__new__(cls)
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Pyrex 0.9.5.1 is now available:
http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
This is a minor release to fix a few bugs introduced
in 0.9.5. See the CHANGES for details.
What is Pyrex?
--
Pyrex is a language for writing Python extension modules.
It lets you freely mix
ickens *wink*
Or Mr. Luxury-Yacht, which as we all know is
pronounced Throatwarbler-Mangrove. With a
silent hyphen.
--
Greg Psmith (pronounced You-ing)
--
http://mail.python.org/mailman/listinfo/python-list
Pyrex 0.9.5.1a is now available:
http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
This is a glitch-fix nanorelease to correct a problem
with the setup.py file. The list of packages to install
is now calculate dynamically, so that it will work with
or without the testing files.
What is
James Stroud wrote:
> You haven't addressed why the limitation isn't arbitrary.
It's not arbitrary because there is a built-in meaning
for infix minus, but not for infix tilde.
Python doesn't go out of its way to provide operators
which aren't used by at least
Jonathan Curran wrote:
> Greg,
> You have managed to peak my interest.
I think the word you're after here is "pique"
(although I suppose "peak" kind of makes sense
as well:-).
--
Greg (a different one)
--
http://mail.python.org/mailman/listinfo/python-list
gonzlobo wrote:
> 2. Decimate an Excel file & write... say every other line (user
> selectable)... to a new file.
Every other line would be bicimating or something,
wouldn't it?
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ble to find out
what you need to know from those.
> would it be possible to include some optional positioning
> parameters, something like left,center,right,top,middle,bottom to
> show_text()).
Yes, I'm considering something like that.
> All in all thanks a lot for PyGUI,
Glad yo
"duplicating" is
actually from the wrong root? And also we have
"bifurcation", which means splitting in two rather
than multiplication by two -- or does that come
down to the same thing?
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
s, but with Python you wouldn't have to spend a
couple of weeks sitting and thinking before starting
to type that line...
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> class Point(object):
> def _init_(self, x, y):
The name of the __init__ method needs *two* underscores
at each end, i.e.
def __init__(self, x, y):
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
main class as inheriting from all of them. That
avoids the monkeypatching-like behaviour of what
you're doing -- the main class definition makes it
clear what parts it's made up of -- and it uses
only standard Python techniques, so it doesn't
harbour any surprises.
--
Greg
--
http://
st about any sequence of
non-letters as an infix operator, but it has no notion
of precedence, even for the built-in operators.
I think SNOBOL may have had something for defining new
operators, but I can't remember the details.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
.
>
> A generic function helps on using it on objects of any kind - like
> len()
> Perhaps it was more important with old style classes.
It also avoids intruding on the method namespace of the
object. That's important -- I like the way that the
namespace of a brand-new cla
+ i][x] = buffer[y + i][x + i] = "*"
for i in range(4):
buffer[y + 3][x + i] = "*"
print_sierpinski(2)
###
By making the recursion explicit, I think this brings out the
self-similarity better than any of the other solution
#x27;t help feeling that this JIT business is over-hyped.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
table objects.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ou need it. Whether that's better or
not will depend on how frequently you need the value.
--
Greg
>
> totalgia keeps incrementing when this code is used under mod_python.
>
> We most certainly are in 'murky waters of accidental concurrent access'.
> A life vest would
at way.
There's a description of the NFA-to-DFA algorithm
here:
http://www.gamedev.net/reference/articles/article2170.asp
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ecause it will do the right thing
for the platform, which might not be so simple
in all cases.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
How does one get access to the class that imported a module. For example:
foo imports bar -- how does bar access foo?
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
r, but if you can find a formula, you should be
able to use similar techniques to "vectorize" it
using Numeric.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
(self)
self.c = 42 # <--- Not allowed!
You could get around this by temporarily de-initializing
it, i.e.
def __init__(self):
NothingNew.__init__(self)
del self.__dict__['initialized']
self.c = 42
self.initialized = True
but that'
it makes a lot of sense to consider whether Python itself
could be used.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
mething
in the code.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
#x27;s perhaps a little
misnamed in that regard).
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
():
from tokenize import STRING, NUMBER
def atom(next, token):
...
return atom
atom = make_atom()
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ability to set arbitrary attributes on an object, which
is almost never wanted for built-in types, so it's not
provided by default.
You can easily get it if you want it by defining a Python
subclass of the type concerned.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ccurs right here after the last line
>
No, if the line you just read ends in "\n", you don't know whether
eof has been reached until the for-loop tries to read another line.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ambda, nested functions or partial().
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
it was get(f) to read the next record
into the buffer. Read(f, x) was a higher-level procedure
equivalent to something like
x = f^;
get(f)
Plus for text files read() and write() did various other
fancy things.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
r.
Do you get any traceback?
> try:
> cidnum = sys.argv[1]
> except:
> print "Format: netcid.py cidnum cidname"
> sys.exit(1)
You realise that having directed stdout into /dev/null,
you're not going to see these messages?
What happen
nly is it easier to read, it's also more efficient,
because it avoids looking up instance variables more than
once.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
else()
Doesn't even need any new syntax. :-)
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
t;, var3 = stuff))
if you really wanted to. (Don't be surprised if
everyone else refuses to maintain your code, though!)
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
t way later.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
a much more consistent and less error-prone way. If
you mistakenly try to use encoded data as though it were
decoded data or vice versa, you'll get a type error.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
27;s the safest assumption. Python is refusing the temptation
to guess the encoding of anything outside the range 0-127 if you
don't tell it.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
rs. That should
give them the right mental model to build on.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
xes and arrows. It's much easier to explain all these
things unambiguously with diagrams than with words
that may not mean the same thing to the listener that
they mean to you.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
; culture.
Not necessarily. A python is a sleek and powerful
creature, which are good associations for a programming
language. The word also hints at a bit of danger and
excitement. On the whole, I think it's a good name.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
the value of
the expression C++ is actually C. So when using C++ you
only get to take away the old language, and you have to
leave the new one behind in its place...
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ate name for a programming
language, I'd suggest Babbage. (not for Python, though!)
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
level parts (or at least doesn't expose them unless
you explicitly ask it to).
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
as utf8-encoded unicode. I just tried
an experiment and managed to get Greek letters displayed
this way.
I had to turn off the "Wide Glyphs for Japanese/Chinese etc."
option under File/Get Info to get the spacing to come out
right.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
u can get to it from Terminal using
"Special Characters..." on the Edit menu. There's a search
box down the bottom where you can enter part of the unicode
name of a character, e.g. "GREEK" will get you into the greek
alphabet area.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
farsheed wrote:
> It is some kind of in house tool and I want to copy protect it. this
> is very complicated tool and not useful for
> many people.
So there will be very few people with any incentive to
steal it, and even less if it's not distributed to the
public.
--
Carl Banks wrote:
> From the OP's post, it seemed likely to me that the OP was asked by a
> misguided management to make sure it was "reverse-engineer-proof".
In that case, just package it with py2exe and tell him
it's done. The misguided management won't kno
Tim Chase wrote:
> -Write Lovecraftian code ("import goto" comes to mind) designed
> to make reverse-engineers go insane trying to figure out what you
> were thinking
The problem with that is it makes it hard for *you* to
figure out what you were thinking...
--
Greg
--
htt
ive you the range of expression you need.
Sounds like AK is talking about Python here and doesn't know it...
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ll the elements of 'arrays' are
actual lists.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
used behind the scenes when people didn't
realise it.
So while rationals might be useful to have available for
some things, you should have to explicitly ask for them.
Returning rationals from '/' applied to integers would
be a bad idea, for example.
--
Greg
--
http://mail.pyt
Pyrex 0.9.4.1 is now available:
http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
This is a very minor update to correct a tab/space
problem in the distutils extension.
What is Pyrex?
--
Pyrex is a language for writing Python extension modules.
It lets you freely mix
PyGUI 1.7.1 is now available:
http://www.cosc.canterbury.ac.nz/~greg/python_gui/
New features:
- Slider control.
- run() convenience function, equivalent to application().run().
- Geometry.rects_intersect() function.
Enhancements:
- Files given on the command
o work your way backwards along the __mro__ until
one of them succeeds, but there's probably a more
direct way.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
ned.
There are ways of fixing that, but for various
reasons it's usually a bad idea for subsidiary
modules to try to import things from the main
module of a program. It would be better to move
globalvar into a third module.
Even better again would probably be not to use
a global at all, bu
dits or vice versa.
If you really want to generate code, find a way of
separating out the generated code into another .py
file that never needs to be edited by hand.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
nding
out how long it takes them to notice they're being fed a load
of bull.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
of view, a *low* hit rate on the Python
web site could be seen as a good sign. :-)
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
hing.
So to get back to the original topic, it doesn't really matter
whether you talk about light travelling or propagating. Take
your pick.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
division
traps turned on, and when one occurs, consult the state to
determine whether to raise an exception or re-try that
operation with trapping turned off.
That would only incur the overhead of changing the hardware
setting when a zero division occurs, which presumably is a
relatively rare occurre
real division
// --> mathematical integer division
/// --> IEEE floating point division (where supported)
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
rs in the code it's trying to compile!
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
, if one process is forked from the other, the parent
can mmap an anonymous block and the child will inherit that
mapping.
(I suppose if both processes had sufficient privileges they
could map physical memory out of /dev/mem, but that would be
*really* dangerous!)
--
Greg
--
http://mail.python.o
#x27;s correct. E.g. they will likely expect a 2kg hammer
to fall to the floor twice as fast as a 1kg hammer, which
isn't anywhere near to being true.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
you'd think that
rocket engineers, of all people, would be acutely
aware of the need to avoid confusing force and
mass!
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
pletely
different. E.g. in C, if you can describe the table
entirely with static data, it'll be very fast to
load and incur no overhead for code to create it at
all. Also, with demand-paging out of the executable
file, and infrequent lookups, only parts of the
table will actually get loaded
block
of memory, that can be moved when its size changes.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
pes such as tuples also don't need to
be on it, even though they contain references, because it's
impossible to create a cycle consisting entirely of such
objects. There has to be at least one mutable object in the
cycle, and the GC will be able to find the cycle via that
object.
--
ed to the argument list rather than passed as a
single object?
ie. class T:
def __init__(self, foo, bar):
self.foo = foo
self.bar = bar
argspec = inspect.argspec(T.__init__)
args = (1, 2)
??? how do you call T(args)?
Thanks.
Greg
--
http://mail.pytho
pped') # The secret -- run out.
Another way is to make your object iterable -- read
up about the "iterator protocol".
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
101 - 200 of 1198 matches
Mail list logo