On Tue, 15 Feb 2011 07:06:35 -, Steven D'Aprano
wrote:
On Sun, 13 Feb 2011 23:42:06 +, Rhodri James wrote:
On Fri, 11 Feb 2011 02:08:01 -, Steven D'Aprano
wrote:
On Thu, 10 Feb 2011 15:48:47 +, Cousin Stanley wrote:
Steven D'Aprano wrote:
I have a tkin
What causes the exception? Is it necessary to catch this exception
> and manually retry the Queue operation? Thanks.
Are you getting this when your application is shutdown ?
I'm pretty sure you can safely ignore this exception and
continue.
cheers
James
--
-- James Mills
--
-- "
to discourage overly long lines.
--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 21 Feb 2011 01:41:12 -, Richard D. Moores
wrote:
On Sun, Feb 20, 2011 at 16:31, Rhodri James
wrote:
On Sat, 19 Feb 2011 23:56:45 -, Richard D. Moores
wrote:
Vista
Python 3.1.3
I can't figure out how to get IDLE to wrap text pasted in from, say, a
newspaper ar
at). You'll
want to edit the current PATH setting (in the lower half of the
dialog) to add ";C:\python27" to the end. Obvious, isn't it :-/
--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list
quot;, 5000.0]
]
Note proper parsing of ints, floats, etc.
I've already wrote the evaluator for the parsed lists, so I'm not
interested in alternatives to S-expressions. Also, I'm really not
interested in json, yaml, etc., for the configuration format because I'm
quite fond
width : 2
length : 7
factor : 2
minor_axis : 48.290018647
It is not perfect but if it will help, I'll cheeseshop it.
James
--
http://mail.python.org/mailman/listinfo/python-list
e. For example:
"You are doing it wrong! Don't not do re.split('\s{2,}', s[2])."
Please answer this way in the future.
Thank you,
James
--
http://mail.python.org/mailman/listinfo/python-list
J_TREE.png')
>
> class D(B,C):
> def __init__(self):
> B.__init__(self) ; OBJ_TREE.add_node(B,D)
> C.__init__(self) ; OBJ_TREE.add_node(C,D)
> OBJ_TREE.plot('OBJ_TREE.png')
>
> This is not good -- a lot of dumb code with chance to make mistakes
Why not make things simple and just write a function
that computes the edges of a class tree ? Something like this:
http://codepad.org/xWKDlS52
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
ot;Return the highest index in S"
I haven't looked at python's source code for the
str object, but perhaps this is exactly what it's
algorithm does!
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
reading'
module (which is a wrapper atop this).
'threading' aside from everything else it does, really in the
end calls thread.start_new_thread(...)
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
ed way - I was hoping it was
possible to poll the Tk event system...).
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
umbers)[3:]
[5, 7, 8]
Now try returning the top two or four numbers.
sorted(numbers)[-2:]
[7, 8]
sorted(numbers)[-4:]
[4, 5, 7, 8]
or in general
sorted(numbers)[-k:]
That said, reverse sorting is probably clearer, and might be marginally
faster, though frankly I can't be bothe
ion and therefore does not exceed python's limited recursion
depth (configurable btw).
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
hat's be best way to implement the function
> get_the_var_name(ne) that returns the name
> of the variable that could not be found?
A NameError Exception does not store the name of the
variable. it has two attributes: .args and .message
both of which contain (usually) a string such
lly by calling 'start' and 'stop' on the
script respectively).
This can vary from across various distributions of Linux however and is normally
something a package maintainer might do.
I am not aware of any cross-platform way of performing what you're asking.
cheers
James
--
ment C headers for
gdbm. If you're using a Debian-based system
try something like:
$ apt-get install gdbm-dev
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
]
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
ck (most recent call last):
File "", line 1, in
AttributeError: 'A' object has no attribute 'bar'
>>> from types import MethodType
>>> setattr(a, "bar", MethodType(bar, a))
>>> a.bar()
'bar'
>>> a.foo
>
>>> a.bar
>
>>>
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
on't actively use Debian/ubuntu based systems.
Please consult your package manager and search for
the "right package" to install.
"You need to install the development packages"
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
a
tool called 'pysqlplus' that's much-like the mysql
command-line tool but will also work for sqlite
and oracle databases (if you have the python drivers
installed).
See:
http://bitbucket.org/prologic/pymills/src/tip/pymills/table.py
and
http://bitbucket.org/prologic/tools/s
ources
and whether or not the python build scripts can pick it up ? (./configure)
Also maybe check ./configure options (maybe you're system is different) ?
Without knowing more about your system I can't offer any further useful advise.
--james
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Apr 30, 2010 at 5:53 AM, gert wrote:
> How do you upload a plain text .py file as a source file?
http://lmgtfy.com/?q=python+distutils+tutorial
--
http://mail.python.org/mailman/listinfo/python-list
I've been trying to write a Python C extension module that uses NumPy
and has a subtype of numpy.ndarray written in C. However, I've run into
a snag: calling numpy.ndarray.__new__(mysubtype, ...) triggers an
exception in the bowels of Python (this is necessary for a handful of
NumPy features).
On 5/2/2010 4:34 AM, Carl Banks wrote:
Why don't you use mysubtype.__new__(mysubtype,...)?
If you wrote mysubtype in C, and defined a different tp_new than
ndarray, then this exception will trigger. And it ought to; you don't
want to use ndarray's tp_new to create an object of your subclass, if
On 5/2/2010 1:43 PM, Robert Kern wrote:
Perhaps things would be clearer if you could post the C code that you've
written that fails. So far, you've only alluded at what you are doing
using Python-syntax examples.
I'm not sure how much this will help, but here you go. The actual C code
probably
On 5/2/2010 3:58 PM, Robert Kern wrote:
Well, I think we can change zeros_like() and the rest to work around
this issue. Can you bring it up on the numpy mailing list?
def zeros_like(a):
if isinstance(a, ndarray):
res = numpy.empty(a.shape, a.dtype, order=a.flags.fnc)
res.fill(0)
res = res.view(
y (which is it's own repository)
and commit a bunch of .html
files.
cheers
James
1. http://bitbucket.org/
--
http://mail.python.org/mailman/listinfo/python-list
> tell me please: how can generate the same output (depending on A and B)
>> without control structure? i mean in a natural "pythonic" way...
>>> def quadratic(a, b):
... return a + b if a > b else a**b - b**2
...
>>> a, b = 2, 3
>>> print quadratic(a, b)
-1
>>> a, b = 3, 2
>>> print quadratic(a, b)
5
>>>
--james
--
http://mail.python.org/mailman/listinfo/python-list
uot;, "copyright", "credits" or "license" for more information.
>>> a, b = 2, 3
>>> print a + b if a > b else a**b - b**2
-1
>>> a, b = 3, 2
>>> print a + b if a > b else a**b - b**2
5
>>>
--James
--
http://mail.python.org/mailman/listinfo/python-list
ful resources.
--james
--
http://mail.python.org/mailman/listinfo/python-list
perience of non-indentation sensitive languages
such as C-class (curly braces) it's just as hard to keep track
of opening and closing braces.
--James
--
http://mail.python.org/mailman/listinfo/python-list
code would be responsible for explaining its licence
and will include other relevant documentation.
For my own code on codewiki I include installation instructions as
text, where necessary.
> I really just want anyone who might need a little networking/security
> tool like this to be ab
may be wrong, but I recall that Google Code Hosting's Wiki Engine
has a macro that will allow you to render raw HTML.
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
port
rendering text/html mime-type files in the repository (like Trac can).
On a side-note, not sure if you're interested in this at all...
I wrote (for the hell/fun of it) a "Sphinx Server", here's the code:
http://codepad.org/ywo8pscb
This uses the latest development version
On 5 May, 04:25, Scott wrote:
> James,
>
> Thanks for the comprehensive reply. I would like to post it to
> comp.lang.python but the main file is 169 lines long and the file for
> functions is 316 lines long. I'm thinking that is a little long for
> this format.
You'
Process(target=func, args=("1",)).start()
multiprocessing.Process(target=func, args=("2",)).start()
...
Surprise surprise it has almost the same API
as the threading module :)
--James
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, May 8, 2010 at 12:04 PM, Vincent Davis wrote:
> Is there a functional assert(x==y, 'error msg') ?
> I can only find the assert that is used like;
> assert x==y, 'error msg'
>
What about:
def assertfunc(expr, msg):
assert expr, msg
cheers
James
--
ered bad practise.
Consider instead using a class/object. You could for example
have a "config" object that is shared by other modules.
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
_of_strings if word[0] == 'a']
> ['awes', 'asdgas']
I would do this for completeness (just in case):
>>>> [word for word in list_of_strings if word and word[0] == 'a']
Just guards against empty strings which may or may not be in the list.
--James
--
http://mail.python.org/mailman/listinfo/python-list
"help", "copyright", "credits" or "license" for more information.
>>> class MyFloat(float):
... def __repr__(self):
... return "MyFloat(%f)" % self
...
>>> x = MyFloat(3.1415926535897931)
>>> x
MyFloat(3.141593)
>>>
--James
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, May 12, 2010 at 2:01 AM, wrote:
>> word[len(word)-1:]
This works just as well:
>>> word[-1:]
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
y),chunksize):
> h.send(body[i:i+chunksize])
> show_progressinfo()
>
>
> But how could I create body step by step?
> I wouldn't know the content-length up front?
>
> thanks in advance
My suggestion is to find some tools that can
send multiple chucks of data
On Fri, May 14, 2010 at 6:12 AM, albert kao wrote:
> My program plan to use only files but ignore directories on Windows.
> I google but do not find some functions like
> bool isFile(string)
> bool isDirectory(string)
> Please help.
Try looking up the os module.
cheers
s:
>
> a1 a2 b1 b2
> a3 a4 b3 b4
> a5 a6 b5 b6
> a7 a8 b7 b8
>
> how to do that?
This is completely untested, but this "should" (tm) work:
from itertools import chain
input1 = open("input1.txt", "r").readlines()
input2 = open("i
On Sat, May 15, 2010 at 4:46 AM, Tim Chase
wrote:
> I think you meant izip() instead of chain() ... the OP wanted to be able to
> join the two lines together, so I suspect it would look something like
You're quite right! My mistake :)
--James
--
http://mail.python.org/mailman/list
turning it into a sequence (list) unless the underlying data of
a set were exposed.
--James
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, May 14, 2010 at 6:19 PM, harry k wrote:
> Write a spell checking tool that will identify all misspelled word in a text
> file using a provided dictionary.
Is this an assignment ? Sure looks like it!
I don't see a question anywhere.
--james
--
http://mail.python.org/mailm
On Sun, May 16, 2010 at 3:12 PM, Aahz wrote:
> It's also at least partly due to problems with mail<->news gateways and
> the differing fields used to maintain threading.
Some blame goes on MUAs too :)
--
http://mail.python.org/mailman/listinfo/python-list
22 0 22 C
This had better not be yet another assignment
you're asking us to help you with ? *sigh*
Break your problem down!
Since you haven't really asked a specific question
I can't give you a specific answer.
--James
--
http://mail.python.org/mailman/listinfo/python-list
pplication.
If you have to use global variables in your application you are
designing it WRONG!
Python has powerful support for object orientated programming. Use it!
I highly recommend the Python tutorial - especially the section on classes.
--James
--
http://mail.python.org/mailman/listinfo/python-list
module shared as a static value.
Anything else should be an object that you share. Don't get into the
habit of using global variables!
--james
--
http://mail.python.org/mailman/listinfo/python-list
of "config.x", in main it would be
"mod.config.x".
--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list
)?
Yes it does unless you re-assign it.
--James
--
http://mail.python.org/mailman/listinfo/python-list
but
> it predated threading.
To be honest, classes work just fine for defining constants.
(Though in my own code I use ALL UPPER CASE variables as it the style).
--James
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, May 17, 2010 at 2:24 PM, Steven D'Aprano
wrote:
> In what way are they constant? Can you not modify them and rebind them?
It's just style/convention :)
Much like _ to denote private variables and methods!
--james
--
http://mail.python.org/mailman/listinfo/python-list
-site dining — all situated on 10
tropically landscaped acres. Here, guests can experience a full-
service resort with discount hotel pricing in Orlando.
We invite draft paper submissions. Please see the website
http://www.PromoteResearch.org for more details.
Sincerely
James Heralds
--
http
On Mon, 17 May 2010 05:29:20 +0100, Steven D'Aprano
wrote:
On Sun, 16 May 2010 18:57:15 -0700, John Nagle wrote:
James Mills wrote:
The only place global variables are considered somewhat "acceptable"
are as constants in a module shared as a static value.
Python reall
rking fine for me, using Opera on Window and Ubuntu, for the
last week or so.
--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list
his documented somewhere?
>
> I want to make sure that no part of the existing Python installation
> on Fedora Core is overwritten by an "altinstall" of 2.6.
Check the generated Makefile (created by ./configure)
--James
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, May 31, 2010 at 9:27 AM, est wrote:
> Except Google/youtube, what's next?
bitbucket (1) is mostly implemented in Python
cheers
James
1. http://bitbucket.org/
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
ace the union object with an integer zero? Do
you mean
FrameFormat.XUnion.subSample = 0
FrameFormat.XUnion.binning = 0
instead?
FrameFormat.flagsX = 0
FrameFormat.YUnion = 0
Ditto here?
--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list
your MySQL server version for the right syntax to
> use near ''127541158007'' at line 1")
>
> But when I print that statement out (exchanging the comma for a %) and
> manually enter it:
>
> mysql> drop table tmp127541158007;
> Query OK, 0 rows af
s execution time ?
I must be missing something!
--James
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Jun 7, 2010 at 1:40 AM, MRAB wrote:
> As has been explained already, SQL might not (and here it clearly does
> not) let you use placeholders for table or column names, only for
> values.
Yes I should have stated that '?' place-holders are used only for
"va
On Mon, Jun 7, 2010 at 9:20 AM, Steven D'Aprano
wrote:
>> Ruby has a very nice map
>
> I'm thrilled for them. Personally I think the syntax is horrible.
I concur!
--James
--
http://mail.python.org/mailman/listinfo/python-list
y of the string s with only its first character
capitalized.
"""
The behavior you've demonstrated is "exactly" what the documentation
says the .capitalize() method does.
--James
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Jun 9, 2010 at 6:36 AM, Mark Lawrence wrote:
> Yes alright bloody Aussies ** n * sodit * *wink*. Not sure if this is a
> syntax error, but too lazy too test at an interactive prompt.
I resent that remark :)
--James
--
http://mail.python.org/mailman/listinfo/python-list
in
> situations like this where you'd like to encapsulate lower level stuff
> for neophyte users but make it easily available to advanced users?
Use a container instead and pass this around. eg: an Environment class.
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
thers" were willing to put "their time"
and effort into doing the work.
Also I should point out that no-one is going to take you seriously
when you publically point out your 1.5 years experience in using
(what projects have you actively worked on and contributed to?) Python.
Have a nice day,
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
the input file line-by-line and give you a list of those lines.
If (however) there are no line endings in the file, you'll
get a list with only 1 item (the entire contents of the file).
Maybe this is what you're confused about ?
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Jun 14, 2010 at 5:02 PM, Robin wrote:
> What are some good python modules that can be downloaded for any
> purpose that is recomended?
That's a rather vauge question Robin.
There are tonnes of packages on PyPi (1).
cheers
James
1. http://pypi.python.org/
--
-- "Pro
fear to do something bad by myself..
> please help!
Just run the python-2.4 binary.
There will likely be a /usr/bin/python-2.4 or similar.
cheers
James
--
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
ing.
In addition to my good colleagues sound advise:
There are many many web frameworks available in the Python world
of all things wonderful. But first, "Learn Python". Then pick a web
framework that best suites your needs and "Learn" it.
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
s the beauty with vim is you just read the line no.
type it in and hit ^G
IDEs are over glorified IHMO and yes I've had my fair share of them
with things like Delphi, Visual Basic, Visual Studio, and others...
--James
--
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
he right direction? The only solution I could come
up with was to compile python itself from scratch which, even on a high
end desktop, takes hours and hours and hours... (etc) on an Msys setup.
Thanks,
James Ravenscroft
Funky Monkey Software
james (at) funkymonkeysoftware (dot) com
--
http://mail.python.org/mailman/listinfo/python-list
d. Are you sure you meant that ?
What in particular do you _not_ enjoy about using
map/reduce (and possibly other functional features of
the Python programing language) ?
--James
Quantification of "experience" is meaningless.
--
--
-- "Problems are solved by method"
--
Further: What is "Pythonic" ? This is probably more of a style and
personal taste that might vary from one programmer to another.
I don't recall anywhere in the Python documentation or a Python
document that says map/reduce is or isn't "pythonic" (whatev
On Thu, Jun 17, 2010 at 2:23 PM, Stephen Hansen
wrote:
> It could certainly do with a little less 'taking oneself too seriously' :)
You do realize my question was completely rhetorical :)
--James
/me withdraws from this discussion :)
--
--
-- "Problems are solved b
On Thu, Jun 17, 2010 at 2:43 PM, James Mills
wrote:
> /me withdraws from this discussion :)
Of course - thank you for that enlightening description of "Pythonic" :)
Hopefully it helps others to understand!
:)
--
--
-- "Problems are solved by method"
--
http://mail.pyth
On Thu, Jun 17, 2010 at 2:53 PM, Stephen Hansen
wrote:
> My entire response was largely tongue-in-cheek :)
I know :)
Don't you wish there was a "Close Thread" button :)
--
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
e_object.other_attr.attr or your solution which is however
> longer to type :)
It would actually help to see some code.
--James
--
http://mail.python.org/mailman/listinfo/python-list
h hardware, and
if you are doing that, Python wasn't the best place to start from.
--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Jun 22, 2010 at 12:27 AM, Alexander Eisenhuth
wrote:
> Hello out there,
>
> - what is the reason, that __slots__ are introduced in python?
>
> - I want to use slots to define a class where no attributes are added at
> runtime. Is that a good idea to use slots for that?
Here is the relevan
On Mon, 21 Jun 2010 04:34:40 +0100, Steven D'Aprano
wrote:
On Sun, 20 Jun 2010 22:45:14 +0100, Rhodri James wrote:
No. Modern C compilers often produce very good machine code, but the
best hand-written assembly code will be better. I can usually write
*very* marginally better code
() against it and find out what's going on.
I'm not familiar with this library (either), however you
would be better off digging through it's documentation
and/or it's sources and find out how to change where it logs
errors to.
--James
--
--
-- "Problems are solved by
th reading.
So there you go...
Sorry I can't offer you a real objective response!
cheers
James
--
http://mail.python.org/mailman/listinfo/python-list
ly - and again sorry if there are any
Python/Rub* dualists!) -- When I came across Rub* I found it to
be just a rip-off of Python (in some respects) and couldn't understand
how it became popular so quickly :)
It's not that great really!
--James
--
--
-- "Problems are solved by metho
perhaps a more specific question
and describe your problem a little more concisely perhaps
I (and we) might have a bit more to offer you.
cheers
James
--
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
vailable on PyPi (1).
cheers
James
1. http://pypi.python.org/
--
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
in some fashion.
You could also subclass (you'll learn about this) the dict class
creating your own customized dict (if you will).
The former approach may be better suited however instead of
diving into things you may not yet come to fully understand
until you really learn the inner workings o
g a mapping of user -> user record.
You select a user record by key.
>>> users["Bob Jane"]
Your example of a user record if perfectly fine to me.
If you wanted to iterate over all user records:
>>> for k, v in users.items():
... # some code here
cheers
James
--
--
I iterate through and access an individual user record!
>
> Thanks in advance,
I'm not sure what's wrong with your email client but I already
answered this for you.
To access an individual record given that you have a dict
called "users" that holds a mapping of us
ly
going to even need a pretty book now are you ? :)
(No phun intended!
--james
--
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
of sorts ?
If so, do you have the actual problem description ?
It's often better to come up with a different (perhaps better)
solution without looking at someone else's :)
--james
--
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
ies I mentioned above) would
> make everyone's life easier.
Like I said, no "phun" intended :) I don't know any off hand
and reading printed material is not something I enjoy!
:)
--James
--
http://mail.python.org/mailman/listinfo/python-list
gt; def foo(): pass
...
>>> type(foo)
>>> isbuiltin(foo), isclass(foo), isfunction(foo)
(False, False, True)
>>> type(open)
>>> isbuiltin(open), isclass(open), isfunction(open)
(True, False, False)
>>>
Notice anything ?
--James
PS: The Python REPL is your friend :)
--
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
e source code cannot be retrieved.
"""
This "does not" include an object / instance (whichever you prefer).
$ python main.py
class A:
pass
$ cat main.py
import inspect
class A:
pass
a=A()
print inspect.getsource(a.__class__)
cheers
James
--
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
on has MySQL drivers.
--James
--
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Jun 23, 2010 at 6:10 AM, John Bokma wrote:
> My guess is that this is just spam for a blog. Please don't copy
> spamvertized URLs.
My bad :/
--
--
-- "Problems are solved by method"
--
http://mail.python.org/mailman/listinfo/python-list
3001 - 3100 of 3508 matches
Mail list logo