of the file it tried to get
to in an attribute filename, so just catch it outside this code (as
others have already suggested).
-Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
a parameter,
for i in f(v)
is it defined that the variable is evaluated for every loop?
Nope. Take the tutorial.
for i in f(v):
suite
is the same as:
iterator = iter(f(v))
for i in iterator:
suite
-Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org
]) != bag([1,2,3,4])
bag([1,2,2,3]) - bag([1,2]) == bag([2,3])
bag([1,2,3]) - bag([3,4]) == bag([1])
Excellent. By symmetry, I see that list casts the set back into a list.
Some will say 'sorted' is a better conversion of a set to list, since
the result is well-defined.
--Scott David Daniels
[EMAIL
in self.ported_pages():
if page.port in missing:
missing.pop(page.port)
if not missing:
break
sampleList = missing.values()
...
-Scott David Daniels
--
http://mail.python.org/mailman/listinfo/python-list
yagyala wrote:
Hi. I would like to be able to tell, at run time, how many parameters
a function requires. Ideally I would like to be able to tell which are
optional as well. I've tried looking at the functions attributes, but
haven't found one that helps in this. How can I do this?
Thanks
CC wrote:
... But am still a long way from seeing how I can use this OOP stuff.
... I wrote:
from string import hexdigits
def ishex(word):
for d in word:
if d not in hexdigits: return(False)
else return(True)
Then I can do this to check if a string is safe
Laurent Pointal wrote:
Thomas Jollans a écrit :
On Friday 17 August 2007, Beema shafreen wrote:
hi everybody,
i have a file with data separated by tab
mydata:
fhl1fkh2
zip
shows these two are separated by tab represented as columns
i have to check the common data between these two
is hidden while Small is being
defined.
-Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
dealt with this.
Thanks for your help,
-Pat
My guess (without seeing your code or error messages; shame on you) is
that you are running A/B/anothermodule.py; not -m A.B.anothermodule
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
shabda raaj wrote:
... Oh, I wasn't aware that I could see the source of all python modules
Well, actually not _all_ (or is that __all__), but that is exactly why
so many of us love Python -- no magic (or at least as little as needed).
--Scott David Daniels
[EMAIL PROTECTED]
--
http
way to know if a stamp is leap-second aware or not;
you'll just have to know for a whole group.
Once you have done a naive difference, there is no way to correct it.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
unnecessary for the Python compiler.
Your post led a newbie to presume the extra use of global was good
style, while I think you'll find there is no such consensus.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
higher order functions to build functions,
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
files:
files.pop().close()
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
be using methods
on the named object to alter the referenced object). You only need
global when you need to write (re-bind) the global name-to-object
mapping.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
print x, y
foolish(2.4)
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
can decide
among various ways to interpolate (the term for what you want to do).
I personally like the cubic B-spline because it is so easy to
understand it visually.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
accompany identical priority values?
Thanks,
Chris
Make the priority value for element: (intended_value, id(element))
always a total order that obeys the partial order implied by
intended_value.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
.' %
modname, class_, name)
if __name__ == '__main__':
import sys
for modname in sys.argv[1: ]:
investigate(modname, sometest)
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
to see you all there,
Mike
You might mention Toronto, Ontario, Canada in an announcement to a
global mailing list.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
,
'KeyError', False, 'KeyError', False, 'KeyError']
And here are the results under Python 2.4.3:
tester(10)
[works]
Looks like a bug to me.
No problem with 2.5.1c1 here.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
= result.setdefault(b, {}).setdefault(c, [])
if a not in inner:
inner.insert(0, a) # I had used append, but ...
print result == wanted
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
'
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
')
gal = Person(age=31, name='Martha')
kid = Person(age=1, name='Ellen', dad=guy, mom=gal)
print '%s of %s and %s.' % (kid, kid.dad, kid.mom)
print %s's kids: %s. % (guy, guy.children())
print %s's kids: %s. % (gal, gal.children())
--Scott David Daniels
[EMAIL PROTECTED]
--
http
really want to see what is going wrong, replace that last by:
print 'Please answer yes or no (not %r):' % hint
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
zero from zero that way. Not saying I know how
in portable C, but
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Ben Finney wrote:
I prefer to use the term title case to refer unambiguously to
NameWithSeveralWords, leaving the term camel case to describe the
case with the humps only in the middle :-)
The names TitleCase and camelCase might suffice here.
--
--Scott David Daniels
[EMAIL PROTECTED
()
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
data as it changes, you could Create a Block and fill it. If you need
Python 2.4 or 2.5, you'll need to figure out how to build from sources
on Windows (I assume building from sources is otherwise easy).
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python
:
#yield os.path.join(root, r)
def findallfiles(base):
return list(produce_all_files(base))
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
]
Or, if you want to simultaneously assert there is only one list,
use unpacking like:
[l] = l
Although I'd prefer to use a better name than l; something like:
lst = [[3.5, 4.5, 5.5, 6.5, 7.5]]
[inner] = lst
print inner, lst
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http
:] or ['.']:
for name in non_ascii(glob.glob(os.path.join(dirname, '*.py')) +
glob.glob(os.path.join(dirname, '*.pyw'))):
print name
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
compression -- that is, I was seeing less than
a single bit required per byte in the original.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
= __le__ = __ge__ = __lt__
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Scott David Daniels wrote:
Sorry, I blew the __ne__:
def __ne__(self, other):
return not isinstance(other, Heap) or self.h != other.h
return not isinstance(other, self.__class__) and sorted(
self.h) != sorted(other.h)
Should
Tim Peters wrote:
... Alas, most people wouldn't read that either 0.5 wink.
Oh the loss, you missed the chance for a 0.47684987 wink.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
entries of mat are = 0.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
with:
maxlength, maxlist = max((len(lst), lst) for lst in list_of_lists)
or (for those pre-2.5 people):
maxlength, maxlist = max([(len(lst), lst) for lst in list_of_lists])
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
MRAB wrote:
Scott David Daniels wrote:
[EMAIL PROTECTED] wrote:
In Windows the null device is, strictly speaking, nul or nul:, not
nul.txt, but the latter appears to work too.
Although I find the windows design and reasoning to be a mistake, I
believe the use of file names NUL, PRN, and CON
:
numShells += aGun.shells
return numShells
theBizmark = Battleship()
print theBizmark.getShellsLeft()
In the above code, I guess I'm just asking for the *correct* way to do
these simple kinds of things...
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman
])
...
For Python 2.4 or later: # allows generator expressions
...
def getShellsLeft(self):
return sum(aGun.shells for aGun in self.guns)
...
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
that, unless you intend to get the newsgroup to
write your code for you. Come back with your efforts and any problems
you have with them.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
' and 'NoneType' objects
What's the data and program that does that?
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
), line[9:].rstrip()
or:
for line in AP_file:
print decoded_File, '%.4f' % (int(line[:8], 16) * .0001
), line[9:].rstrip()
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
the
raw open (which should get the available channel), and the C stdout
stuff is successfully redirected. Once done w/ your function,
close your new stdout and copy the channel back.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
that got us here.
...
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
):
def __new__(class_):
instance = object.__new__(class_)
instance.a = 1
return instance
You might have figured more of this out with:
t = T()
print repr(t)
newt = NewT()
print repr(newt)
T.a
t.a
--Scott David Daniels
[EMAIL PROTECTED]
--
http
,
and I'll put it up). If you look it over and have questions, let me
know.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
-
functions, you should change your wishes.
If, however, you are talking solely about the interactive prompt and
ease of typing, you might want to check out ipython (find via your
favorite search tool). Its flexibility may well be to your taste.
--Scott David Daniels
[EMAIL PROTECTED]
--
http
Hacked(Pending, SomeTrickyClass):
_pending = sample_value_generator()
TempHold, SomeTrickyClass = SomeTrickyClass, Hacked
try:
do the test
finally:
SomeTrickyClass = TempHold
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman
):
print size, list(chunky('abcdefghijklmnopqrstuvwxyz', size))
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
that
are written in C in CPython. Not only is PyPy trying to get the
_entire_ Python system into Python, it is trying to do so in a
friendly-to-translation-in-a-statically-typed-language way.
Besides, if you can freely use eval and exec, how hard is a pure
python language interpreter?
--Scott David
to the class here? Why can't I assign to
attributes of an instance of object?
object itself doesn't have a __dict__ slot, so that very small objects
(such as points) can be built without that overhead.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
, 60)
Or, depending on your leading zero requirements:
totalsecs = int(whatever)
print '%2d:%02d' % divmod(totalsecs, 60)
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
, b.east, c.east = A, B, C
A.west, B.west, C.west = a, b, c
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
to convert values to associated names for debugging and such.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
can be skipped as well:
return excinfo_str
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
.
import sys
sys.getrefcount(42 * 7)
2
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
that uses something like:
def action():
sleep(50)
if not canceled:
callback(foo)
as its action.
The callback ill be in another thread, but Look up threading for
more details.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman
.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Bruno Desthuilliers wrote:
... idempotent - no side effects.
Nope. idempotent: f(f(x)) = f(x)
That is, after doing it once, repeating it won't hurt.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Try:
def leaders(sorted_list):
held = None
for phrase in held:
if held is None or not phrase.startswith(held):
held = row
yield held
print list(leaders(sorted(data)))
--Scott David Daniels
[EMAIL PROTECTED]
--
http
Tim Chase wrote:
def leaders(sorted_list):
held = None
for phrase in held:
... I suspect you mean
for phrase in sorted_list:
no?
Ooops -- renaming code before posting should get its own test.
You are absolutely correct.
--Scott David Daniels
[EMAIL PROTECTED
works to give you Idle, the problem is in creating
a separate process linked via a socket to localhost port 8833.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Ron Adam wrote:
Scott David Daniels wrote:
Ron Adam wrote:
... Is there a way to have the display show a wire frame image instead of
shaded shapes?
You can draw the edges as lines.
Is there a setting for this?, or are you suggesting reading the
coordinates and creating curve objects
Ron Adam wrote:
Scott David Daniels wrote:
James Stroud wrote:
I'm looking for a program to do line-drawings in 3d, with output to
postscript or svg or pdf, etc. I would like to describe a scene with
certain 1-3d elements oriented in 3d space with dashed or colored
lines and filled
).
Take a look at VPython -- easy to start, 3-D display (wall-eye /
cross-eye) easy to run on.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
, Ch) for Ch in Str]
return \ + .join(mapped) + \
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
('is') or nm.startswith('has'))
['hasattr', 'hash', 'isinstance', 'issubclass']
[hasattr(type,'mro'), hash(123), isinstance(type, type),
issubclass(type, type)]
[True, 123, True, True]
:-)
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python
a
separator, sometimes there is a mix, and sometimes you do need a regular
expression. Save re for when you need to do pattern matching.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
customers pay as if they are using
the full library.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
, some_param1, some_param2)
...
Or another for readability:
4. some_string = ' '.join([cd, working_dir, ;,
ssh_cmd, str(some_count), some_param1, some_param2])
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
before in this newsgroup, Xerox Parc had that
ability (the ability to finish an exception by returning to its source)
in their system implementation language, and finally removed the
capability when they saw how many bugs were related to its use.
--Scott David Daniels
[EMAIL PROTECTED]
--
http
[EMAIL PROTECTED] wrote:
Are there any visualization tool which would depict the random graph
generated by the libraries.
Google for DOT (.DOT format w/ renders to a variety of output formats).
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python
to some strings as raw when what you really
mean is that the notation you are using is a raw notation for a
perfectly normal string.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
of us playing along at home, there is a typo there:
The preceding line should read:
value. You will notice that 3072 == 12 * 256.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
an inductir.
--Scott David Daniels (who couldn't resist)
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
of
real useful code containing, sorted(xrange(a, b, c)) are pretty slim.
If you don't have to build the list in memory, returning a list can make
a program that could be very memory efficient suddenly _much_ less so.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman
the language will be
jarring to the user, as well as expensive to implement.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
be
more substantial even to a viewer with full color vision.
--
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
learn an assembly language. You can still execute it (plenty of
simulators are available for free), and you can get an idea of kinds of
efficiency without having to learn five or six architectures.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
File
...
code that uses File
...
or (actually my current style):
from sdd import goodidea
...
code that uses goodidea.File
...
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
AttributeError(%r object has no attribute %r
% (self.__class__.__name__, name))
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Scott David Daniels wrote:
class Forwards(object):
to_forward = set(['flush', 'read', 'write', 'close'])
def __init__(self, backends):
self.backends = backends
def forwarder(self, methodname):
def method(*args, **kwargs):
for b
this is to modify the
the interpreter. We could call the new language Python?!, or
actually use an interobang if Unicode has such a character.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
python books they own?
Sounds great! Send me $1.50 and I'll send you my six answers.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
and
too general.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
= self.held
if __name__ == '__main__':
unittest.main()
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
not include that part of the program, so you wound up
crippling those who were willing to try to help you, because you
thought you kinda-sorta knew what was going on (but not enough to
fix it). Find smart questions and read it a couple of times.
--
--Scott David Daniels
[EMAIL PROTECTED
tiny theories and _test_ them.
and the theories wander farther and farther off into the weeds
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
module documentation as well.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
of reference counts doesn't do the
mad useless-copy stuff.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
at PyGame if you want to paint screens.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
:
old_output, sys.stdout = sys.stdout, old_output
old_output.close()
print 'Output safely written to:', old_output.name
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
= super(class_, Limited).__new__(
class_, *args, **kwargs)
class_._held_instances[id(instance)] = instance
return instance
return random.choice(class_._held_instances.values())
--Scott David Daniels
[EMAIL
(to which the best reply is, See, we told you so.).
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
701 - 800 of 1437 matches
Mail list logo