Peter Hansen wrote:
Jeff Shannon wrote:
Unless I'm seriously mistaken, the only way that this will be possible
is if there's a Win32 API call that will give the correct information.
This might be possible to find in the MSDN documentation, if it
exists, but I suspect that it probab
trol-variable tuples are not so straightforward as is being
claimed.
There may be valid arguments in favor of enhancing tuple unpacking in
this way (indeed, I believe I recall a thread or two on this subject),
but it's important to consider the general consequences, not just the
single aspect of f
- the capture app would pass (almost) all input to the child
app and then retrieve the child app's output (and probably perform the
actual display on-screen). This won't let you capture the text of an
arbitrary window, though, and would probably be pretty fragile.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
Antoon Pardon wrote:
Op 2005-03-18, Jeff Shannon schreef <[EMAIL PROTECTED]>:
I find it odd that you start by saying you still find them very
consistent and here state there is a slight inconsistency.
I said that the way that binding a name on a class instance always
creates an instance att
Raymond Hettinger wrote:
def count(self, value, qty=1):
try:
self[key] += qty
except KeyError:
self[key] = qty
I presume that the argument list is a typo, and should actually be
def count(self, key, qty=1): ...
Correct?
Jeff
lopers working on OO.o), it's not too surprising
that OpenOffice hasn't changed that much.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
raise ValueError("...")
The for/else pattern may look a bit odd, but the key feature here is
that the else clause only runs if the for loop terminates normally --
if you break out of the loop, the else does *not* run.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
Antoon Pardon wrote:
Op 2005-03-16, Jeff Shannon schreef <[EMAIL PROTECTED]>:
Bruno Desthuilliers wrote:
- if x is a class attribute of class A and a is an instance of A,
a.x=anyvalue create a new instance attribute x instead of modifying A.x
This is very consistent with the way that bin
st would enable you to do this
for multiple local names with a single call, but getvinfo() doesn't
try to do that...
Don't forget, in Python, all names are references. You only have to
be careful when you start re-binding names...
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
As far as I'm concerned, if you're just going to
'import *' your helper modules, you might as well leave the whole mess
as one big file, because you're throwing away almost all of the
benefits of dividing it into modules.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
in
other cases it won't be, so it's important to keep in mind that the
cost exists.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
the automatic file closing
happens as part of the object deletion, files opened in this way won't
be closed until the garbage collector runs (and collects this file
object).
Most of the time, this won't be a problem, but it's good to be aware
that things are not necessar
icial things, and in many cases there's real evidence to support
the contention that Python's design choices will decrease the
frequency of bugs.
Perhaps Python *is* becoming less Lisp-like... but I've never been
convinced that Lisp is the best of all possible programming l
my guess being that it's towards the
hight end of that range.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
Martin v. Löwis wrote:
Jeff Shannon wrote:
I'd be in favor of that, unless someone can come up with a compelling
current use-case for octal literals.
Existing code. It may use octal numbers, and it would break if they
suddenly changed to decimal.
Right, which was my original point -- i
Tobiah wrote:
m = get_next_module()
some_nice_function_somehow_loads( m )
that'd be
mymodule = __import__('modulename')
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
m
constructing a single hash collision to make it worthwhile to invest a
*large* number of petaflops of processing power.) Sure it's not "100%
perfect", but... how perfect do you *really* need?
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
the system network code instead of the application code.)
If you need to care about when the network access happens, then you
should be using the lower-level protocols -- httplib and/or socket.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
that, then this idiom should be harmless even under Jython.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
Steven Bethard wrote:
Jeff Shannon wrote:
now that almost the entire industry has standardized on power-of-2
word sizes, octal is nearly useless but is still carried about for
backwards compatibility.
So do you think it's worth lobbying for its removal in Python 3.0 when
we can break
sizes, octal is nearly useless but is still carried
about for backwards compatibility.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
module-level reference "var". No variables are
actually created in the execution of "global var".
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
Christopher J. Bottaro wrote:
Jeff Shannon wrote:
Python's __del__() is not a C++/Java destructor.
Learn something new everyday... What is it then? Excuse my ignorance, but
what are you suppose to do if your object needs to clean up when its no
longer used (like close open file handles
rgs, **kwargs)
if s != 'OK':
raise NotOK((s,r))
return r
return wrapped
I believe that this will be semantically almost equivalent, but
conceptually slightly simpler.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
our
server changing status without your client taking direct action.
I really think that you *do* want to do fairly frequent status checks
with your server. The cost is small, and the gains in responsiveness
and robustness are potentially very significant.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
questionable.
There *are* similar-but-not-compatible libraries for DOS... or perhaps
I should say *were*, because I have no idea where one might find such
a thing now. (Though I presume that Google would be the best starting
place.) One would then need to find/create a Python wrapper for th
se a timer to do this; just have it fire periodically every
second or so, rather than only after several minutes.)
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
eep using that word. I do not think that it means
what you think it means."
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
e), then str() will throw an exception.
The Effbot mentioned a join() implementation that would be smart
enough to do the right thing in this case, but it's not as simple as
just implicitly calling str().
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
27;t
actually looked at it, but EasyGui (recently mentioned here; google
should help you find it) may meet your needs and be simpler to use.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
__() is not a C++/Java destructor. Trying to make it
into one is unlikely to give an overal benefit.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
do more command-line checking than
this...)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
se, one could ensure that unicode.join() used unicode() and
str.join() used str(), but I can conceive of the possibility of
wanting to use a plain-string separator to join a list that might
include unicode strings. Whether this is a realistic use-case is, of
course, a completely different quest
name to this
new function, it's simply calling itself.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
u insist on using an OS that's been obsolete for a decade or
more. ;)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
x27;t ever (normally) be cleaned up while they're still in use, but
during program shutdown refcounting necessarily ceases to apply.
The closest that would happen in C++, I believe, would manifest itself
as memory leaks and/or access of already-freed memory.
Jeff Shannon
Technician/Programmer
Credi
Bruno Desthuilliers wrote:
Jeff Shannon a écrit :
If running a console app from Explorer, the console will close as soon
as the app terminates. Using raw_input() at the end of the app means
that it won't close until the user hits Enter.
So why dont you just open the console before runnin
names do that nicely. What do you see as the harm of using it?)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
ot;Interpretation is irrelevant. Logic is irrelevant. You will be
assimilated."
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
eed -- it looks like this worked perfectly to me, so the issue is
in what's expected. :)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
act) matches to his
"requirements". Instead of saying "Hey, someone's done half my work
for me -- great!", he's saying "Hey, why haven't you done the rest of
my work!"
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
not* take that opportunity to
purge things like GOTO.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
Dennis Lee Bieber wrote:
On Thu, 10 Feb 2005 09:36:42 -0800, Jeff Shannon <[EMAIL PROTECTED]>
declaimed the following in comp.lang.python:
And as Peter Hansen points out, none of the Python versions leave n in
the same state that the C loop does, so that's one more way in whic
the interval [0...4)
(including 0 but not including 4).
Modulus is useful for all sorts of periodic behavior.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
--
def pr(self):
print self.var
---
(Though frankly I don't see the advantage of having this tiny function
in a separate file to begin with...)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
Dennis Lee Bieber wrote:
On Wed, 09 Feb 2005 18:10:40 -0800, Jeff Shannon <[EMAIL PROTECTED]>
declaimed the following in comp.lang.python:
for i in range(n)[::-1]:
func(n)
Shouldn't that be
func(i)
(the loop index?)
You're right, that's what I *
Courageous wrote:
*checks self to see if self is wearing rose colored glasses*
assert(self.glasses.color != 'rose')
;)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
may (as just one of many examples) be much
better off with something more like:
for i in range(n)[::-1]:
func(n)
The '[::-1]' iterates over the range in a reverse (decreasing)
direction; this may or may not be necessary depending on the
circumstances.
Jeff Shannon
Technician/
the exec'ed statement actually
sees, as well as what happens with the results. (But as I mentioned
before, there is no real security here if you're exec'ing arbitrary
code -- there's no sandboxing involved, and the exec'ed string *can*
use that __builtins__ reference (among other things) to do all sorts
of malicious stuff.)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
real security, because malicious
code can still get to __builtins__ from almost any object...)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
on a single installation medium would be a tricky
edge case. I suspect it *could* be done in a GPL-acceptable way, but
one would need to take care about it.)
Of course, this is only my own personal interpretation and opinion --
IANAL, TINLA, YMMV, etc, etc.
Jeff Shannon
Technician/Program
losed during program
shutdown if it hasn't happened before then.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
.
After it, on step (3) you can safely and peacefully add new PowerOfGenerator
variable.
You can also get all places where said variable exists by using grep,
or your editor's search feature. I don't see how a var declaration
gains you anything over 'grep PowerOfGenerator *.py
rpreter and
try fiddling with things. You've got a lot of subexpressions there;
pick some values and try each subexpression, one at a time, and take a
look at what you get.
I bet that it won't take you long to figure out why you're not getting
the result you expect.
J
ating dictionaries that'll be passed into functions, create class
instances.
class MyClass(object):
def __init__(self, **kwargs):
for key, val in kwargs:
setattr(self, key, val)
def fun(self):
self.z = self.y + self.x
a = MyClass(x=1, y=2)
a.fun()
print a.z
Je
Jeremy Bowers wrote:
On Fri, 04 Feb 2005 16:44:48 -0500, Daniel Bickett wrote:
[ False , False , True , None ]
False would be returned upon inspection of the first index, even
though True was in fact in the list. The same is true of the code of
Jeremy Bowers, Steve Juranich, and Jeff Shannon. As
for item in lst:
if item is True: return True
if item is False: answer = False
return answer
But yeah, the original, straightforward way is probably enough clearer
that I wouldn't bother with anything else unless lists might be long
enough for performance to matter.
Je
be an issue in the vast majority of cases, but I'm naturally
curious :)
Disk access should be buffered, possibly both at the C-runtime level
and at the file-iterator level (though I couldn't swear to that). I'm
sure that the C-level buffering happens, though.
Jeff Shannon
Technic
flamesrock wrote:
I should also mention that I'm using
version 2.0.1 (schools retro solaris machines :( )
At home (version 2.3.4) it prints out 'True' for the above code block.
That would explain it -- as /F mentioned previously, the special case
for None was added in 2.1
Christian Dieterich wrote:
On Déardaoin, Ean 27, 2005, at 14:05 America/Chicago, Jeff Shannon wrote:
the descriptor approach does. In either case, the calculation happens
as soon as someone requests D.size ...
Agreed. The calculation happens as soon as someone requests D.size. So
far so good
Christian Dieterich wrote:
On Dé Céadaoin, Ean 26, 2005, at 17:09 America/Chicago, Jeff Shannon wrote:
You could try making D a container for B instead of a subclass:
Thank you for the solution. I'll need to have a closer look at it.
However it seems like the decision whether to do
me size for your
test is a reflection of buffering. The next question is, which
provides the most *conceptual* simplicity? (The answer to that one, I
think, depends on how your brain happens to see things...)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
our GUI widgets directly
from the worker (i/o) thread -- very few GUI toolkits are threadsafe,
so you need to make all GUI calls from a single thread.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
just for this!
Normally it's a large round button, with perhaps a green backlight.
Press the button and hold it in for about 3 seconds, and the rest of
your code/writing will be ignored just as it should be.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.o
te, and you have the
very essence of object-oriented programming.
(What you describe here *is* object-oriented programming, you're just
trying to avoid the 'class' statement and use module-objects where
'traditional' OO would use class instances.)
Jeff Shannon
Techn
John Machin wrote:
Jeff Shannon wrote:
[...] For ~10 or fewer types whose spec
doesn't change, hand-coding the conversion would probably be quicker
and/or more straightforward than writing a spec-parser as you
suggest.
I didn't suggest writing a "spec-parser". No (mechanical)
), then you can give D's
__init__() a B parameter that defaults to None.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
Jeff Shannon wrote:
[...] If each record is CRLF terminated, then
you can get one record at a time simply by iterating over the file
("for line in open('myfile.dat'): ..."). You can have a dictionary
classes or factory functions, one for each record type
odes of expression, different
ways of approaching the same problem. That's *why* we have so many
different programming languages -- because no single approach is the
best one for all problems, and knowing multiple approaches helps you
to use your favored approach more effectively.
J
h requires complex inheritance trees. In Python, an
object is whatever type it acts like -- behavior is more important
than declared type, so there's no value to having a huge assortment of
potential types. Deep inheritance trees only happen when people are
migrating from Java. ;)
Jeff
#x27;t
be too horrible on resources/management, and that he shouldn't be so
afraid to try something new...
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
one of Python's RAD tools (Boa
Constructor, or maybe PythonCard, as examples) you'd be able to get
very nice results.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
n letting them script it in Python is a perfectly valid
(and probably quite desirable) approach.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
his purely abstract philosophy?
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
ng the identifiers made it so
that you felt the need to add a comment indicating what they were
identifying, I'd say that yes, the long words *are* helpful. ;)
Comments are good, but self-documenting code is even better.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail
e in a master dictionary keyed by id -- in other words,
simply replace the tuples in my previous example with a dict like what
you've got here. You could also create a simple class to hold each
item, rather than using small dicts. (You'd probably still want to
store class instances in a master dict keyed by id.)
Generally, any time your problem is to use one piece of information to
retrieve another piece (or set) of information, dictionaries are very
likely to be the best approach.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
cripts, you'll probably have the same security issues I mentioned for
Python. Unless you really need that level of features, you may be
better off designing your own limited language. Check into the docs
for pyparsing for a starter...
Jeff Shannon
Technician/Programmer
Credit Internatio
mory allocation, and for
a reasonable tuple the size of the memory required is not going to
significantly affect the allocation time.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
ot;a:b:c".split(':')
>>> o = LineObj(*l)
>>> o.__dict__
{'a': 'a', 'c': 'c', 'b': 'b', 'e': None, 'd': None}
>>>
This is a bit more likely to be meaningful, in that there's
ore robust (and
readable) fashion.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
uch closer to the "completely flat" side of things.
It's not "... as nested (or as flat) as you have to be and no
more", it's "... as nested as you have to be and no more, but if you
need significant nesting, you might want to re-examine your design". ;)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
ol over the circumstances in
which your Singleton will be created and/or retrieved, and it also
makes it trivial to replace the Singleton with some other pattern
(such as, e.g., a Flyweight or Borg object) should the need to
refactor arise.
Jeff Shannon
Technician/Programmer
Credit International
--
anageable level.
To rephrase this a bit more succinctly ;) there's a big difference
between having no practical way to prevent something, and actually
encouraging it.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
a more-detailed matching, you might look into finding an algorithm
to determine the "distance" between two strings and using that to
score possible matches.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
ings get too bad here, I'd
like to have somewhere pleasant to emigrate to. ;)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
for RNA sequences as well as DNA
sequences, you've got at least a fifth base to represent, which means
you need at least three bits per base, which means only two bases per
byte (or else base-encodings split across byte-boundaries) That
gets ugly real fast.)
Jeff Shannon
Tec
s
s = func(s)
This seems to be a way to go, but it becomes messy if i hand over
lots of parameters and expect some more return functions.
This has the advantage of being explicit about s being (potentially)
changed. References, in the way that you mean them, are even messier
in the case of nume
is simpler. (For a large
file, chunking it might be necessary, though...)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
B now.
And besides, for long-term archiving purposes, I'd expect that zip et
al on a character-stream would provide significantly better
compression than a 4:1 packed format, and that zipping the packed
format wouldn't be all that much more efficient than zipping the
character stream
dicts are unordered, the ordering of the literal
(or of a set of statements adding to the dict) doesn't matter.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
Antoon Pardon wrote:
Op 2005-01-12, Jeff Shannon schreef <[EMAIL PROTECTED]>:
It's also rather less necessary to use references in Python than it is
in C et. al.
You use nothing but references in Python, that is the reason why
if you assign a mutable to a new name and modify the obj
your nested function would have
access to the outer namespace via normal nested scopes, so I'm really
not seeing what the gain is...
(Then again, I haven't been following the whole using/where thread,
because I don't have that much free time and the initial postings
failed to c
acking) and use exceptions to
indicate error status. Changing the value of a parameter is a
side-effect that complicates reading and debugging code, so Python
provides (and encourages) more straightforward ways of doing things.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mai
nd) to map/lambda than it is to a list comprehension. In this case,
at least the code block is visually self-contained in a way that
lambdas are not, but I still have to do more mental work to visualize
the overall results than I need with list comps.
Jeff Shannon
Technician/Programmer
Credit Int
;cc"):
return extToMimeDict["cpp"]
If the intent of this is to catch .cc files, it's easy to add an extra
entry into the dict to map '.cc' to the same string as '.cpp'.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
Jon Perez wrote:
... or why 'Perl monkey' is an oft-heard term whereas 'Python
monkey' just doesn't seem to be appropriate?
That's just because pythons are more likely to *eat* a monkey than to
be one :)
Jeff Shannon
Technician/Programmer
Credit Internati
command shell open. Edit, save,
alt-tab to command shell, uparrow-enter to run program... not as
convenient as a toolbar button or hotkey, but it works.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
mutate it. Since it's the same object,
it doesn't matter where the mutation happened. But in rebind(), we're
moving the somedict label to a *new* dict object. Now d and somedict
no longer point to the same object, and when the function ends the
object pointed to by so
de of someone who wants to write Visual Basic as
filtered through Java and Perl... If I want mental gymnastics when
reading code, I'd use Lisp (or Forth). (These are both great
languages, and mental gymnastics would probably do me good, but I
wouldn't want it as part of my day-t
enough
that lambda would be undesireable if not impossible, or they're simple
and numerous (e.g. calling a function with different parameters) such
that it's easy to write a factory function that returns closures
rather than feed the parameter in with a lambda.
Jeff Sha
1 - 100 of 174 matches
Mail list logo