Robert Kern wrote:
On 7/26/10 5:16 PM, Michael Hoffman wrote:
I have been using Jason Orendorff's path.py module for a long time. It
is very
useful. The only problem is that Python 2.6 deprecates the md5 module it
imports, so I (and others using my software) now get this warning
whenever
all change. The question is what is the best way to do
that and ensure continuity with the previous versions. Can I (or someone
else) take over the PyPI entry in question? Other suggestions?
Many thanks,
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Sebastian Wiesner wrote:
I'm willing to consider TeX- and HTML-based approaches.
I can recommend latex with the beamer package. It doesn't directly support
formatting of code snippets, but the pygments syntax highlighter comes with
a Latex formatter.
This is what I have been doing so fa
alex23 wrote:
How do you feel about reStructuredText? If you're open to it, I highly
recommend Bruce: http://pypi.python.org/pypi/bruce
That looks like it would be perfect. Unfortunately it doesn't seem to
work on my Windows laptop:
C:\Documents and
Settings\Michael\Desktop\bruce-3.2.1>C:\
Thanks for the suggestions.
And if you do use Crunchy for a presentation, you might be interested
in the html style used for Crunchy's own talk at the latest Pycon:
http://us.pycon.org/media/2009/talkdata/PyCon2009/012/crunchy_.html
H, I have to click on the next link every time?
The best
Does anyone here have software they would suggest for making a
presentation that includes Python code? Other than that it would
probably be mainly bullet points. I'm willing to consider TeX- and
HTML-based approaches.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Unknown wrote:
On 2009-01-16, Michael Hoffman <9qobl2...@sneakemail.com> wrote:
Is there a portable way to find the full path of a filename that would
be called by os.execvp()?
Yes. Use os.path.abspath() on the name before you call it with
os.execvp()
That doesn't work:
Python
Is there a portable way to find the full path of a filename that would
be called by os.execvp()?
Thanks,
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Michael Hoffman wrote:
unlink = os.unlink
Actually, I need to use shutil.rmtree instead, but you get the idea.
--
http://mail.python.org/mailman/listinfo/python-list
Please accept my apologies if this message was posted several times. My
newsreader claimed that a timeout error kept the message from being
posted, but I think it got through.
--
http://mail.python.org/mailman/listinfo/python-list
I am writing a library that creates temporary files and calls a series
of external programs to process these files. Sometimes these external
programs create files in the same directory as the input files, so to
make sure they are all deleted, one must create them in a temporary
directory, then
ion is it referring to? Should these really be all
> caps?
There's a style convention that global constants at file scope are
defined in all caps.
Personally, I do all my optparsing in a special function rather than in
the __name__ == '__main__' block.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
ehensions are faster.
Why do you think that?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
want? A bool typecode for the stdlib array
module?
I can guess a number of things that you might mean, but it would be best
if you explained with an example of what current behavior is and what
you would like it to be.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
>> Oh yes ? So what's the compiler doing, and what are those .pyc files ?
>> (hint: read the doc)
>
> Sorry, I surely know that Python has a compile time, I wanted to say
> somthing like "compile time checks except from syntax".
Well, if you try to reassign
utes, only the modules that
> are imported.
I think you mean that CPython doesn't save the results of the
compilation of a script. The scripts are compiled every time they are
run, as you go on to say.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Gabriel Genellina wrote:
> "except" is hard to translate, and
> even in English I don't see what is the intended meaning (is it a noun?
> a verb? an adverb? all look wrong).
It's a preposition.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Haven't you thought about what is the right religion?!
Sure, why do you think I use Python?
> Here you will get the answer
Agreed.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
tive Windows Python.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
rt WMF (not EMF) to SVG or EPS.
http://wvware.sourceforge.net/libwmf.html
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
rn euclid(c,d)
>
> Unfortunately this doesnt work since a,a1,b,b1 arent declared in the
> function. Is there a way to make these variables accessible to the
> euclid function. Or is there a better way to design this function?
Well, it would be simpler to pass through all the variab
helpful
<http://www.catb.org/~esr/faqs/smart-questions.html>.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
d
>> the ShedSkin/Psyco restrictions seem to be enough to allow that.
>> Type annotations don't seem to solve any problem that really needs
>> to be solved.
>>
>> The main advantage of strongly typed systems is that more errors
>> are detected at co
project, I can't
> remember... but perhaps someone here can remind me what it was? If so,
> there may be yet another young python programmer in training :-)
BeautifulSoup?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
gt;>> that.
>>>
>>> I checked the latest copy out from sourceforge and that was 4.75 too.
>>>
>>> Can someone please tell me where to find the latest?
>>>
>> It's from Emacs 22.
>
> Note that's a different python-mode to the
MaHL wrote:
> Can I use python to copy something(like a string) to the clipboard, so
> that I can paste it somewhere else. Is there a way to do this?
If you're using Cygwin Python you can just open /dev/clipboard and work
on that.
--
Michael Hoffman
--
http://mail.python.org/mailm
description='Position reference'
)),
I'm using py-version "$Revision$." Oops! Anyway, try to install the
latest python-mode, whatever that is, if it isn't 4.78.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Python. It might be Perl, or OCaml, or Java, or C, or JCL. If you
want static type checking, Python definitely isn't the right tool for you.
If you asked Java programmers why you couldn't turn *off* Java's static
type checking if you wanted to, you'd probably get a similar respon
ted to needless name-calling as a result of your mistake,
which I don't think enhances the usefulness of this forum. What exactly
are you trying to achieve?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
peter wrote:
> Just a tad arrogant, don't you think, to put a notice of some local
> event on an international forum without saying where it is?
It says right in the subject line! DFW. If you don't know what DFW
means, then it's probably not your local area.
--
Mic
oad the
resulting data frames into R for analysis and graphics.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
th('//a//b//c')
> \\a\b\c
>
> Is it intentional or is it a bug?
Intentional.
http://en.wikipedia.org/wiki/Path_(computing)#Universal_Naming_Convention
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
he
>> script printed:
>> sh: wrong_command_test: command not found
>> well Done
>
> That's because it is not an exception, it is an error message coming
> from your shell, not from Python.
Of course if you use subprocess.check_call() instead of os.system(), it
wil
ve (which
> it will not if you use a custom variable).
Thanks, I didn't know that __debug__ was optimized like this. But that
was really just a specific example of the general case.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
for index in xrange(100):
print index
do_stuff(index)
else:
for index in xrange(100):
do_stuff(index)
It would be nice if this sort of thing could be done automatically,
either by the interpreter or a function decorator.
--
Mich
ECTED]' (Using password: YES)
This has nothing to do with Python. It is obvious from the error that
the user "papermen" doesn't have the privileges to load data into that
table. Ask your database administrator to give you the appropriate
privileges.
Followups set.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
bird to access various infrequently-used mailing lists via
NNTP and Gmane.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Neil Cerutti wrote:
> I find i and j preferable to overly generic terms like "item."
Well, I probably wouldn't use "item" in a real example, unless it were
for a truly generic function designed to act on all sequences.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
t;
> Or should the good python hacker do that differently? Hope not ;).
Well, yes, I would do:
for item in data:
do_stuff(item)
or, if using enumerate:
for item_index, item in enumerate(data):
do_stuff(item_index, item)
I agree with Bruno that i and j should be used only for indices, but I'm
usually less terse than that.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
sages and versions of
Pyrex/Python/GCC. Better yet, do this in the Pyrex mailing list rather
than here.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Michael Hoffman wrote:
> Thorsten Kampe wrote:
>
>> for validanswer in validanswers:
>> if myAnswers.myanswer in myAnswers.validAnswers[validanswer]:
>> MyOptions['style'] = validanswer
>
> I usually try to avoid using "my" because I
Thorsten Kampe wrote:
> for validanswer in validanswers:
> if myAnswers.myanswer in myAnswers.validAnswers[validanswer]:
> MyOptions['style'] = validanswer
I usually try to avoid using "my" because I find it obscures a better
understanding of what
uld have RTFA
A request to have the docs changed so that "Deprecated since release
2.0." in bold appears next to all three would not go amiss.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
.split()[0] for line in blankless_words]
> some_set = frozenset(first_words)
Re-writing code so that it is self-documenting is almost always a better
approach. Premature optimization is the root of all evil.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
t what I get:
Python 2.5 (r25:51908, Mar 13 2007, 08:13:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class A: pass
...
>>> class B: pass
...
>>> a = A()
>>> id(a)
2146651820
>>> b = B()
>>> id(b)
2146651948
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Arjun Narayanan wrote:
> That AND I didn't use the american spelling Py_Initiali >>> Z <<< e();
Like many words ending in -ize/-ise, initialize is listed with what you
call the "American" spelling in the Oxford English Dictionary.
--
Michael Hoffman
--
htt
al_attr(args)
>some_var = self.attr
In many cases (I would really have to see the context to be sure) would
prefer something like:
def get_attr(self, args):
# calculations here
return calculated_value
Don't have a self.attr, just return the results of get_attr().
--
Mich
John Machin wrote:
> On May 3, 10:21 am, Michael Hoffman <[EMAIL PROTECTED]> wrote:
>> Tobiah wrote:
>>
>>> >>> elegant_solution([1,2,3,4,5,6,7,8,9,10])
>>> [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
>> That's not an array, it's
Tobiah wrote:
>
> >>> elegant_solution([1,2,3,4,5,6,7,8,9,10])
> [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
That's not an array, it's a list. See the array module for arrays
(fixed-length, unlike variable-length lists).
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
or me but it's throwing an error
No, you have to create the folder first. Try os.makedirs()
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
ison
> function is called for EVERY comparison. The key= function is only called
> once per element.
Right. Using sort(key=keyfunc) is supposed to be faster than
decorate-sort-undecorate. And I think it is clearer too.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
27;))
>
> If you don't need a tuple, and a list will do:
>
> the_string.split('\n')
or the_string.splitlines()
> If you want to get rid of the white space after each chunk of text:
>
> [s.strip() for s in the_string.split('\n')]
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Alex Martelli wrote:
> Michael Hoffman <[EMAIL PROTECTED]> wrote:
>
>> Alex Martelli wrote:
>>> Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>>>...
>>>>>>> decorated.sort()
>>>...
>>>>> def i
d the .sort step above.
Well, counting the index() function that is called in both cases, the
original rank() had one sort, but my version has two sorts.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
__)
Hint: if you find yourself using a decorate-sort-undecorate pattern,
sorted(key=func) or sequence.sort(key=func) might be a better idea.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
for more information.
>>> 2 == True
False
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
> On 27/04/2007 11:19 PM, Michael Hoffman wrote:
>> stef wrote:
>>> hello,
>>>
>>> In the previous language I used,
>>> when reading a line by readline, the EOL character was removed.
>
> Very interesting; how did you disting
John Nagle wrote:
> (P.S. PEP 3117 is a joke, right?)
Note date of creation.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
t1.findall("xabcxaaaxabc")
['c', 'a', 'c']
Here it finds multiple matches, but only because the x occurs multiple
times as well. In your example there is only one match.
> i would expect either 'abc' or 'a', 'b', 'c' or at least just
> 'a' (because that would be the first match).
You are essentially doing this:
group1 = "a"
group1 = "b"
group1 = "c"
After those three statements, you wouldn't expect group1 to be "abc" or
"a". You'd expect it to be "c".
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
the 2 characters CR+LF are converted to 1 character ?
> Is there a more automatic way to remove the EOL from the string ?
line = line.rstrip("\r\n") should take care of it. If you leave out the
parameter, it will strip out all whitespace at the end of the line,
which is what I do in most cases.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
"opera"] is in your
path. Your Cygwin environment must be set so one of these is in your
path when it isn't normally.
You should also submit a bug.
> And, more to the point, how can I use webbrowser from scripts launched under
> cygwin?
If you're using native Windows
file:
for line in infile:
words = line.split()
print " ".join(word for word in words
if keyword.iskeyword(word))
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Michael Hoffman wrote:
> How about something like this:
>
> index = 0
> while res < maximum:
> yield minimum + (step * index)
> index += 1
Well it really would have to be something LIKE that since I never
defined res. Let's try that again:
index = 0
res = m
yield minimum + (step * index)
index += 1
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
compiles the human-readable code to a
bytecode which it then runs on a virtual machine.
--
Michael Hoffman (no relation)
--
http://mail.python.org/mailman/listinfo/python-list
they all begin with a-m? The answer would be that it would make the
language harder to use to cram concepts that should more naturally start
with n-z into spellings that start with a-m.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
alues of iMax, iMin and iStep. I suspect this requires a
> detailed understanding of the implementation of floating point
> arithmetic, and would appreciate hearing any thoughts you might have
> on gilding this lily.
In addition to the comments of Stargaming, most of which I agree with, I
th
7stud wrote:
> [EMAIL PROTECTED] wrote:
>> Annoyances:
>>
>
> Every language has annoyances. Python is no exception. Post away.
> Anyone that is offended can go drink a Guinness.
I find Guinness annoying.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
ange
> much easier.
>
> I suppose the above model could avoid this notational problem if
> you say that a[k] means the one element slice a[k:k+1]
> (technically true for strings, but false for lists), rather than
> ever thinking of item indexes as pointing directly at an item.
>
; gpxlist.txt
./myprog.py --gpx-file=gpxlist.txt *.jpg
Or to accept more than one file per argument:
./myprog.py -t "$(echo *.gpx)" *.jpg
Personally I would prefer the file list approach. If you start expanding
wildcards yourself, then if someone stupidly wants to use a wildcard
character, they'll have to triple-escape things, and it'll just be messy.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
t example is probably the transition from sets.Set to
__builtin__.set. The API changed but only slightly. So far sets.Set
retains the old implementation--it is not a wrapper for __builtin__.set.
Future modules may be implemented differently.
--
Michael Hoffman
--
http://mail.python.org/mailman/lis
> but l isn't then changed in place.
>
> Using
>
> sorted(l,operator.itemgetter(1))
>
> behaves as I'd expect, but I really want something like
> operator.itemgetter(1).itemgetter(1), which (understandably) causes a
> syntax error.
Unless you are do
e a ValueError exception."
>>> sys.maxint << 2
8589934588L
>>> 2**31
2147483648L
It looks like the limitation has been removed. This might be a nice
optimization as well, as 1 << n is faster than 2**n for large enough n.
Might be rare, although I have a friend who has been doing this all day.
In Python.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
eans "1 shift left by k"
Yes.
> which is the same as multiplying with k.
No.
Try starting the Python interpreter and entering 1 << 10.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
s compatibility. Don't know about `set` and `object`. I guess
> it's foolish consistency!?
Well originally there was sets.Set (uppercase). It became set when it
went to being a built-in.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Kay Schluehr wrote:
> My question is: does anyone actually follow guidelines here
Yes.
> and if yes
> which ones and are they resonable ( e.g. stable with regard to
> refactoring etc. )?
All of them that I know of. What does it mean to be "stable with regard
to refactoring e
ow
>
> Any suggestions on a different approach or fix?
What do you want to do? What do you think that is supposed to do? What
does this have to do with Python?
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
gt; permission to manipulate a file, os.access is a good function.
The try first approach is better for at least two reasons:
1) It saves you an extra stat() on the disk, which can be really
important for some filesystems I use :)
2) It is atomic. If os.path.isfile() returns True but the file is
deleted before you open it, you are still going to have to handle the
exception.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
how to define this RPMError. I looked at python
> docs but they were not useful.
http://docs.python.org/tut/node10.html#SECTION001050
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
[Michael Hoffman]
>> Personally, I do not think of slices in the way this tutorial suggests,
>> but I think taking it out without replacement would not help. If you
>> want to add a more accurate replacement, I think that would be better
>> received than just saying th
ying that the section should be removed. Even more
so if you provide it in the form of a patch.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Completing with a trailing ",", using the entire sequence instead of a
subset, and dealing with your hex constants are left as an exercise to
the reader.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
rnet.and earn 4000USD every month." So you'll have to do
better than that for an adequate incentive. ;)
Seems like a good idea, although I don't have any constructive
suggestions at this point.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> file_input = raw_input("Enter The ODX File Path:")
> odx_file_output = raw_input("Enter the output file path : ")
> log_file_output = raw_input("Enter the path for LogFile : ")
>
> saveout = sys.stdout
> try:
> f_open=open(odx_file_output, 'w')
> except:
> prin
r simply link to PEPs 8 and 257. What is
> the point of keeping old, out-of-date essays up on python.org? That
> beginning comment does not indicate that the essay is any different from
> the PEPs.
http://wiki.python.org/moin/PythonWebsiteCreatingNewTickets
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Steven W. Orr wrote:
> On Saturday, Apr 21st 2007 at 19:18 +0100, quoth Michael Hoffman:
>
> =>Chris Lasher wrote:
> =>> Should a Python module not intended to be executed have shebang/
> =>> hashbang (e.g., "#!/usr/bin/env python") or not? I'm used to
ted)(items)
A clever little hack, but please don't do this. Anyone else who will
read your code will thank you.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Python code intended to be
> executable (i.e., run from the command line).
Personally I include it in all of them, as part of boilerplate in a
template.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
y make such a difference?
It would if you were dealing with enormous blocks of text at once, say
from a database.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
Richard Brodie wrote:
> "Michael Hoffman" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
>>> Neither is particularly intuitive; it just depends whether you are more
>>> familiar with the Posix terminology or the Java one. I persona
ink setDaemon
>> should be renamed to setDetached or something similar.
>
> Neither is particularly intuitive; it just depends whether you are more
> familiar with the Posix terminology or the Java one. I personally prefer
> detached but there is little chance of a name change now.
loial wrote:
> How can I get more info what the cause of the OSError exception is?
For starters, post the traceback here.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
since I've worked with ipc.
I usually don't think of starting new processes as being IPC. I've only
ever seen it used to refer to communicating between processes after they
have started.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
little difficulty.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
LE. Here's what I did:
>
>>>> Script1.py
> Traceback (most recent call last):
> File "", line 1, in ?
> NameError: name Script1 is not defined
>
>>>> python Script1.py
You need to do this from a Windows command line, not from Python.
C:\Python25>
=True)
Another way is using the glob module (and optionally
os.path.expanduser() for tilde expansion and os.path.expandvars() for
variable expansion, other things that are normally taken care of by the
shell).
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
type( x ) == NoneType:
>> # true
>> < code >
>> else:
>> # false; do something else.
>> < more code >
>>
>> Steven Howe
>
> Is that any better than this?
>
> if x is None:
> # do something
> else:
> # d
ith national specification, but this could be done
> only in python 2.5. Any solution for 2.4?
I think you mean locale, for anyone else who was puzzled by this.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
[Michael Hoffman]
>> For x root use y**(1/x)
[Steve Holden]
> >>> 3.14159 ** (1/3)
> 1.0
> >>>
>
> So the cube root of pi is 1? I don't think so.
>
> For generic roots use y ** (1.0 / x)
Yes, good point. :)
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
[Michael Hoffman]
>> In floating point arithmetic, the naive way of calculating both roots
>> always using the formula (-b +/- sqrt(b**2 - 4*a*c))/2*a will give you
>> inaccurate results sometimes. See
>> <http://www.cse.uiuc.edu/eot/modules/floating_point/quadrati
1 - 100 of 449 matches
Mail list logo