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 attribute
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
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 for-loop usage.
Jeff Shannon
--
http
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 probably doesn't
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 binding a name
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
not too surprising
that OpenOffice hasn't changed that much.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
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
() 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 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 necessarily as cut-and-dried as they might seem.
Jeff Shannon
--
http
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
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
towards the
hight end of that range.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
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 languages,
so maybe being less Lisp-like and more Python-like is a good thing.
Jeff Shannon
--
http
about for backwards compatibility.
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 some
.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
in the execution of global var.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
that it means
what you think it means.
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
periodically every
second or so, rather than only after several minutes.)
Jeff Shannon
--
http://mail.python.org/mailman/listinfo/python-list
.
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 that
library...
Jeff Shannon
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
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, etc
(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
Credit International
obsolete for a decade or
more. ;)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
to this
new function, it's simply calling itself.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
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 question...
Jeff Shannon
-line checking than
this...)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
to give an overal benefit.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
(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
() 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
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
is irrelevant. Logic is irrelevant. You will be
assimilated.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
as the harm of using it?)
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
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 running
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
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 which
an exact
like GOTO.
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 *meant* to say. (What
(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
for all sorts of periodic behavior.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
-- 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
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/Programmer
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
.
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' ...
Jeff Shannon
during program
shutdown if it hasn't happened before then.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
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/Programmer
Credit International
--
http
memory and is untested.)
The net effect is that exec uses the subsequent dictionaries as its
globals and locals, reading from and writing to them as necessary.
(Note that this doesn't get you any real security, because malicious
code can still get to __builtins__ from almost any object...)
Jeff
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
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
Jeff Shannon
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.
Jeff Shannon
Technician/Programmer
Credit
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
Technician/Programmer
Credit International
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
Technician/Programmer
Credit International
--
http
on the computer
case 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
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
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
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 some
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
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.
Jeff Shannon
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, keyed off
of the 2
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:
[...] 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) parsing is
involved
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.python.org
?
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
(and probably quite desirable) approach.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
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
...
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
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 Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo
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.
Jeff Shannon
Technician/Programmer
Credit
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 International
--
http://mail.python.org/mailman
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
(and
readable) fashion.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
almost
certainly some logical connection between the fields of the line
you're splitting and keeping them as a class demonstrates that
connection, but it still seems a bit smelly to me.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
--
http://mail.python.org/mailman/listinfo
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 convince me that there was any real point...)
Jeff Shannon
Technician/Programmer
Credit International
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 object through
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
.
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.
Jeff Shannon
parameters because *any* of those parameters
might change. By simply returning (new) objects for all changes, the
function makes it very clear what's affected and what isn't.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
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
Technician/Programmer
Credit
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 International
--
http://mail.python.org
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
/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 International
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://mail.python.org/mailman/listinfo
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 Shannon
Technician/Programmer
Credit International
--
http
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-to-day requirements...)
Jeff Shannon
to by somedict is garbage-collected, while the object
pointed to by d has never changed.
So, to do what you want to do, you simply need to arrange things so
that your parameter is an object that can be mutated in-place.
Jeff Shannon
Technician/Programmer
Credit International
--
http
, 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
and difficult to sort out. But when list comps
were introduced, after reading just a sentence or two on how they
worked, they were completely clear and understandable -- much more so
than map/lambda after many months of exposure.
Jeff Shannon
Technician/Programmer
Credit International
--
http
Paul Rubin wrote:
Jeff Shannon [EMAIL PROTECTED] writes:
Note that the so-called 'viral' nature of GPL code only applies to
*modifications you make* to the GPL software.
Well, only under an unusually broad notion of modification.
True enough. It can be difficult, in software development
does *not* require that your code also be (L)GPL'ed. Changes to
the core library must still be released under (L)GPL, but application
code which merely *uses* the library does not. (I've forgotten, now,
exactly how LGPL defines this distinction...)
Jeff Shannon
Technician/Programmer
Credit
Alex Martelli wrote:
Jeff Shannon [EMAIL PROTECTED] wrote:
Note that the so-called 'viral' nature of GPL code only applies to
*modifications you make* to the GPL software. The *only* way in which
your code can be 'infected' by the GPL is if you copy GPL source.
...
(Problems may come
or
not. Better to have that done by a developer tool (pychecker) than
through runtime checks every time the program is used.
Jeff Shannon
Technician/Programmer
Credit International
--
http://mail.python.org/mailman/listinfo/python-list
Nick Coghlan wrote:
Jeff Shannon wrote:
I suppose that your version has the virtue that, if the sortkey value
is equal, items retain the order that they were in the original list,
whereas my version will sort them into an essentially arbitrary order.
Is there anything else that I'm missing
due respect to Richard Feynman, I'd have thought that
counting numbers would be non-negative integers, rather than the
full set of integers... which, I suppose, just goes to show how
perilous it can be to make up new, more natural terms for things. ;)
Jeff Shannon
Technician/Programmer
Credit
1 - 100 of 153 matches
Mail list logo