Collin Winter wrote:
> If possible, I'd like to see this go in before 3.0.
+1
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
baseclass.__init__(arg)
This is an example of polymorphism generally, not overloading.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
oad_source() compiles the script first, making a file
called "polysubc" which I do not want. Is there a better solution?
And even if there is a better solution, can you please tell me of a way to load
the script as a module without generating the "polysubc" file? No points for
tellin
[Michael Hoffman]
>>Hi. I am trying to use unittest to run a test suite on some
>>scripts that do not have a .py extension.
[Sybren Stuvel]
> I'd move the functionality of the script into a separate file that
> does end in .py, and only put the invocation into the .py-less
look up who Rasmus Lerdorf was...
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
on of code?
What version of Python are you using? Is it the standard Windows
distribution?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Xah Lee wrote:
# here's a while statement in python.
> [...]
>
# here's the same code in perl
[...]
So?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
ions are installed in different directories.
What problems are you having?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
except herror:
hostname = "NONE"
print hostname, ip_address
break
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Steve Holden wrote:
I suspect rather that the OP is looking for os.environ, as in:
He was using the examples of PYTHONHOME and PYTHONPATH which have
specific meanings. Using sys.prefix is better than
os.environ["PYTHONHOME"], which is unlikely to be set.
--
Michael Hoffm
Denis S. Otkidach wrote:
Certainly, it can be done more efficient:
Yes, of course. I should have thought about the logic of my code before
posting. But I didn't want to spend any more time on it than I had to. ;-)
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
RE_FAST 1 (i)
72 JUMP_ABSOLUTE9
With the other methods, when you find a false result, all you have to
do is the JUMP_ABSOLUTE. That saves you some time over several
million repetitions.
Well, that was longer than I thought it would be. HTH.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
ast):
File "", line 1, in ?
TypeError: list objects are unhashable
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
defline_old = self._defline
else:
lines.append(line.rstrip())
return defline_old, ''.join(lines)
blastdb.py:
#!/usr/bin/env python
from __future__ import division
__version__ = "$Revision: 1.3 $"
"""
blastdb.py
access blastdb f
Uwe Mayer wrote:
is it possible to delete a file from a tar-archive using the tarfile module?
The tarlib.py in pyNMS claims to be able to do it. It doesn't use the
tarfile module, though.
http://cvs.sourceforge.net/viewcvs.py/pynms/pyNMS/lib/tarlib.py?rev=1.1.1.1&view=auto
--
Michae
k yourself and it will be in exactly
the format you want. Give me a break.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
bined edification. I would have been considerably less annoyed if you
had done that and explained why it is better rather than nitpicking my
version.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Lucas Raab wrote:
Please see both the Python and C code at
http://home.earthlink.net/~lvraab. The two files are ENIGMA.C and engima.py
If you post a small testcase here you are much more likely to get helped.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Paul McGuire wrote:
So "A" == 'a' is true in Python, not true in C.
>>> "A" == 'a'
False
I think you meant:
>>> "A" == "A"
True
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
ur web site and make some
suggestions. If you had written a better question I guarantee you would
have had more people answering your question sooner.
Oh yeah, and:
http://www.catb.org/~esr/faqs/smart-questions.html#not_losing
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Michael Hoffman wrote:
Paul McGuire wrote:
So "A" == 'a' is true in Python, not true in C.
I think you meant:
>>> "A" == "A"
True
Er, "A" == 'A'
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
hould do most of the work for you.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
entation. You could probably get a slight speedup by using
"from time import clock" and then just clock().
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
once in the
entire run of your program, not every time you call the debug() function
(which is presumably many times).
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Peter Hansen wrote:
> Michael, tai64nlocal is a program that converts a special "packed"
> timestamp to human-readable form.
Thanks Peter. I was asking somewhat rhetorically but I have a love of
UNIX arcana and now I know. :)
--
Michael Hoffman
--
http://mail.python.org/
John Roth wrote:
> you need _both_ isinstance and the types module to do a correct
> check for any string type: isinstance(fubar, types.StringTypes).
> That's because both string and unicode are subtypes of one base.
But basestring, their base class is a built-in.
--
Michael Ho
Paul Watson wrote:
> While printf() does tightly control formatting in C, it does not in
> Python.
There is no printf() in Python. You should not think of print as being a
Python version of printf.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
ackspace character.
> If you feed this output to another program, chances are it will
> not treat as no space at all.
>
> I prefer building up a list and doing ' '.join(thelist) in these situations.
A much better approach. Or you can use sys.stdout.write() as others have
ggs.
You apparently don't know how to do it without getting egg on your face.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
__init__(self, x, y)
> self.z = z
> #--
Well for the example you used, multiple constructors are not needed.
This will get you the same result as what I imagine you wanted the
first example to do:
class myPointClass:
def __init__(self, x=0, y=0, z=0):
self.x = x
Peter Hansen wrote:
> Using Jason Orendorff's "path" module, all this code basically collapses
> down to this beauty (with your variable "path" renamed to myPath to
> avoid a name collision):
This has to be the non-stdlib library I use the most. It
understand why this isn't in 2.4
Because it would break existing code.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
o True or False, mainly as a
compatibility measure for the days before they were built-ins. If you
try assigning None, CPython will refuse to compile the module, even if
the code where None is assigned is unreachable.
If there was ever a good reason to assign to None, I don't know it.
--
M
Antoon Pardon wrote:
> Op 2005-06-22, Michael Hoffman schreef <[EMAIL PROTECTED]>:
>
>>Remi Villatel wrote:
>>
>>>Fredrik Lundh wrote:
>>>
>>>>checking if a logical expression is true by comparing it to True is bad
>>>>style, an
.html#how-do-i-check-for-a-keypress-without-blocking
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
avior using a dummy class. If you try to create a
self-contained testcase, you will have an easier time figuring where the
problem is.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
ing featurism. Is this actually useful in real code?
Personally, I use it all the time. It's a much more convenient literal
for a dictionary. And before it was introduced I used this utility function:
def mkdict(**kwargs):
return kwargs
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Robert Kern wrote:
> I would like to see the setuptools/PythonEggs/EasyInstall trifecta get
> more attention and eyeballs. Once it is mature, I think that it will
> obviate the desire for stdlibification of most of the packages being
> requested here.
Looks pretty cool!
--
Mic
> I think he means something like this:
> e = 'i_am_an_attribute'
> o.(e) = 10
> o.i_am_an_attribute == 10
I always use the getattr() and setattr() built-ins which could be
considered syntactic sugar when compared to the alternatives above.
But that's all the syntactic sugar you need--any more will give you
cancer of the semicolon.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
nsophisticated and dumb?
>
> Be blunt. We Americans need to know.
To be blunt, I have no idea what this has to do with Python. Surely
selecting the right forum to use indicates more sophistication and high
intelligence than the way one speaks. ;-)
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
muldoon wrote:
> Michael Hoffman wrote:
>>muldoon wrote:
>>
>>>Americans consider having a "British accent" a sign of sophistication
>>>and high intelligence. Many companies hire salespersons from Britain to
>>>represent their products,etc. Qu
The
original function a(x) will still be stored as a closure in what is
returned from b().
If this is of purely academic interest then the answer is I don't know. :)
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
may help, but I wonder if there is a ready-to-use function in python
> libs?
That's a good start. Why doesn't dircmp work for you?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
n't understand the original question either until Robert Kern
guessed what the OP was talking about.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
trangely enough there are Brits who pronounce "hotel" without an H at
the beginning. And even those who pronounce it with an H sometimes say
"an hotel" rather than "a hotel" because it used to be pronounced
starting with the vowel!
Similarly, the Brits should
could ildg wrote:
> I found dircmp compare only the direct dirs and files,
> and it will not do anything to the sub-directories.
The documentation for dircmp.report_full_closure() disagrees with you.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
;
>
> where is the problem?
The problem is that you are using IDLE (and an old version at that),
which doesn't use sys.ps2.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
shisa wrote:
> What should I do to correct the errors accordingly?
What error? IDLE appears to be behaving as designed.
Also, please don't top-post--it makes responding to your message in a
way that others can understand more difficult.
http://en.wikipedia.org/wiki/Top-posting
--
with PyScripter, not Python. You'd be
better off asking the PyScripter people than asking here.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
in data:
> whatever
> finally:
> data.close()
>
> Guido has made a pronouncement on open vs. file. I think he prefers
> open for opening files, and file for type testing, but may well be
> wrong. I don't think it's critical.
He has said tha
h a simpler testcase. Strangely, the exception occurs in
the statement *following* the os.utime() call:
>>> import os, sys
>>> os.utime("foo_test_file", (0, float(sys.maxint+1)))
>>> print "hi"
OverflowError: long int too large to convert to int
Loo
might just be added for bash.
That said, this would be very useful. You should submit an RFE on the
Sourceforge tracker.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Greg Lindstrom wrote:
> I hear that Perl 6 is
> going to have a rewrite of regular expressions; it will be interesting
> to see what their hard work produces.
From what I saw a while ago, it didn't look like it would be any
simpler or more elegant. But that was a while ag
l the
advice applies to you, feel free to ignore it, but you clearly haven't
been getting the results from this forum that you expected.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Jeff Epler wrote:
> Here's the bug. You're using Windows.
QOTW (speaking as someone who is using Windows right now).
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
e you don't seem
to have anything callable named ctor. As for the constructor, just call
it __init__, it will avoid confusion with __new__.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Throne Software wrote:
> Throne Software has opened up a Python Forum at:
>
> http://www.thronesoftware.com/forum/
>
> Join us!
Why shouldn't I just stay here?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
gs *x and **y instead,
but they will still act just like *args and **kwargs.
The stars are magic, not the names.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
to get this deprecated but Guido disagreed.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
D H wrote:
> See the mechanize module: http://wwwsearch.sourceforge.net/mechanize/
I second this, a very useful module. I've unfortunately had to change it
a little to deal with inevitably bad HTML supplied by web sites.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinf
our existing a and b "a0" and "b0", and the next a and b
"a1" and "b1". When you do a, b = b, a+b you are assigning:
a1 = b0
b1 = a0 + b0
But when you use separate statements, you are assigning:
a1 = b0
b1 = a1 + b0 = b0 + b0 = 2*b0
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
is.
>
> Well, that part's easy at least:
>
> live[::-1]
>
> :-) And so the circle is complete ...
What about reversed(live)? Or if you want a list instead of an iterator,
list(reversed(live))?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
in more of my modules and scripts than any other third-party
module, and I know it will be very helpful when I no longer have to
worry about deploying it.
Thanks in advance,
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
what the function signature for enumerate() was
when that is easy to Google, then I would think they were wasting
everyone's time.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> I've Read-TFM, but I only see good info on how to create my own class
> of exception; I don't see anything on how to override an existing
> exception handler.
You need to read the tutorial on handling exceptions:
http://docs.python.org/tut/node
just notified Jason about this. I presume a solution like mine
> will be used, and look forward to seeing Jason's module in stdlib.
This sounds like a bug in "freeze" rather than something that should be
worked around in the standard library. Although there have already been
people opposed to naming it path because the duplication with os.path
might confuse humans.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
> [EMAIL PROTECTED] wrote:
>
>> Can someone tell me the difference between single quote and double
>> quote?
>
> >>> ord("'") - ord('"')
> 5
Very zen.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Reinhold Birkenfeld wrote:
> Michael Hoffman wrote:
>
>>Having path descend from str/unicode is extremely useful since I can
>>then pass a path object to any function someone else wrote without
>>having to worry about whether they were checking for basestring. I think
Java hackers here want to tell us of the wonders of the Java Path
class? I would be interested in seeing how other OO languages deal with
paths.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
> Michael Hoffman wrote:
>
>> John Machin wrote:
>>
>>> [EMAIL PROTECTED] wrote:
>>>
>>>> Can someone tell me the difference between single quote and double
>>>> quote?
>>>
>>> >&g
Stefan Rank wrote:
> on 22.07.2005 00:21 Michael Hoffman said the following:
>> Any Java hackers here want to tell us of the wonders of the Java Path
>> class?
>
> no such thing exists.
>
> there is only the `File` class that incorporates a little bit of the
> `p
whether they were checking for basestring. I think
there is a widely used pattern of accepting either a basestring[1] or a
file-like object as a function argument, and using isinstance() to
figure out which it is.
What do you gain from removing these methods? A smaller dir()?
[1] Probabl
that does this, but I cant remember
> where I read about it. Can anyone enlighten me?
You want a Least Recently Used, or LRU, cache. Here's one:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252524
Google for to find others.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
s a histogram):
>
> i.e.:
>
> L2 = [(1,3),(2,2),(3,1)]
>>> import itertools
>>> L1 = [1,1,1,2,2,3]
>>> L2 = [(key, len(list(group))) for key, group in itertools.groupby(L1)]
>>> L2
[(1, 3), (2, 2), (3, 1)]
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Tzanko Tzanev wrote:
> #but there is an error in
> playlist_txt += mp3id + mp3_title + mp3_artist
It'd be a lot easier to help if you'd say what the error was.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
make people's lives easier.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
hich one it is you want.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
nder intense CPU load.
How negative are we talking about? What platforms are you using?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
#x27;, 'fp',
> 'geturl', 'headers', 'info', 'read', 'readline', 'url']
> Traceback (most recent call last):
> File "CSVParser.py", line 144, in ?
> print parseQHost(circuits[cktname], cktname)
> File "CSVParser.py", line 126, in parseQHost
> r = csv.DictReader(ifs, fieldlist)
> File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
> python2.3/csv.py", line 100, in __init__
> self.reader = reader(f, dialect, *args)
> TypeError: argument 1 must be an iterator
>
> Whoa! Where did the __iter__, readlines, and next attributes go? Ideas?
Works for me on Python 2.4.1.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
h the current path implementation, this Just Works. If I were using
something that parsed and understood paths, the scp/rcp convention of
host:filename would either cause an error or have to be programmed in
separately. The current implementation is much more flexible.
What are the practical
tring. Mainly, that you can use it anywhere a basestring
would be used today and it Just Works.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
tion()
What do you want to be in a, if not None?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
ile systems have something to do with the
> encoding? So D: (a FAT drive) might naturally be str, while C:
> (an NTFS drive) might naturally be unicode.
The current path module handles these situations at least as well as the
libraries that come with Python do. ;-)
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Peter Hansen wrote:
> When files are opened through a "path" object -- e.g.
> path('name').open() -- then file.name returns the path object that was
> used to open it.
Also works if you use file(path('name')) or open(path('name')).
--
M
new users will not try to use a Path instance where a string is
> needed, just as you wouldn't try to pass a list where a string is wanted.
But many functions were written expecting lists as arguments but also
work for strings, and do not require an explicit list(mystring) before
calling the function.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
hen I informed
him of it. I'd love to hear what he had to say about the design.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
that a class implements special method names,
but doesn't make it very clear that an object can't always override them.
If you redirect to a second method you can overwrite on the instance, I
think you will get the results you want.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
line, which is convenient, but strange.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
se methods to start with.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
nce
slicing has little to do with the newsgroup. A more general Python FAQ
will be more helpful.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
7;s a string method
with that name. Instead it's path.joinpath(). This is a nuisance, but
changing the semantics of base class methods is worse. (I know, I tried
it.) The same goes for split().
"""
It ain't broke. Please stop breaking it.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Keith P. Boruff wrote:
> Michael Hoffman wrote:
>> Keith P. Boruff wrote:
>>> Is there an FAQ available specific to this NG as I'm sure some of the
>>> list slicing questions I have have been asked before.
>>
>> Try Google for .
>
> I tried and
al message instead of making a new post.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
or design principles and discussion here:
http://wiki.python.org/moin/PathClass
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Reinhold Birkenfeld wrote:
> * Add base() method for converting to str/unicode.
+1
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
y and always use joinpath().
Personally, I'm -0 on __div__, but I suppose if anyone here claimed to
have used in the past, rather than it just being some novelty that might
be a good idea, that would be good enough for keeping it.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Currently it returns Path('None'). This means I have to do a check on
input before pathifying it to make sure it is not None.
Perhaps it should throw ValueError?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Does anyone have any Emacs skeletons they find useful for Python? I
Googled a little but didn't find anything enticing. I already have a
script that sets up script/module templates, so those aren't all that
useful.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Michael> Does anyone have any Emacs skeletons they find useful for
> Michael> Python?
>
> What's an "Emacs skeleton"?
Somewhat of an elaborate mini-language for inserting boilerplate.
http://www.emacswiki.org/cgi-bin/emacs-en
use pdb from the commandline instead
these days, with 'alias pdb="python -m pdb"' in my .bashrc.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 449 matches
Mail list logo