Hello,
What are some good & recommended number theory libs for Python (or
accessible interfaces to C libs), for things like primes,
factorization, etc. Naturally, speed is of utmost importance here.
In other words, which Python libraries and tools to you use to help
you solve Project Euler proble
Hello,
The Python interpreter uses ASDL (http://www.cs.princeton.edu/~danwang/
Papers/dsl97/dsl97.html) to describe the AST resulting from parsing.
In previous versions, there was another AST being used by the compiler
module - ast.txt and astgen.py in tools/compiler in the Python 2.5
source. Howe
andrew cooke wrote:
> Hi,
>
> I have a new project, that I just released in beta (http://
> www.acooke.org/lepl - a recursive decent parser with full
> backtracking). At the moment I am using pypi and setuptools for
> distribution (it's a pure python package) and I am happy with hosting
> static
I'm having a problem with 2.6's new os.path.relpath function.
This is correct:
relpath(r'd:\abc\jho', r'd:\abc')
=> 'jho'
But this isn't:
relpath(r'd:\jho', r'd:\\')
=> '..\jho'
Neither is this:
relpath(r'd:\jho', r'd:')
=> '..\..\..\jho'
What am I missing?
--
http://mail.python.org/mailman
On Jan 14, 2:57 pm, sturlamolden wrote:
> According to a Norwegian publication, Nokia will release Qt under LGPL
> as of version 4.5.
>
> If I had stocks in Riverbank Computing ltd., I would sell them now...
>
Unlikely...
The switch of Qt to LGPL will almost certainly vastly increase the Qt
user
On Dec 16, 1:48 am, Torsten Mohr wrote:
> Hi,
>
> i found some examples when googling for the subject but nothing really
> matched.
>
> Is there a standard module available that lets me parse a syntax like "C"
> with numbers, operators, braces, variables and function calls?
>
> I'd like to use thi
> > My system is Gentoo, which installs python from source. Maybe gentoo
> > applies patches that the binary releases don't have.
>
> I can't reproduce the problem. I got exactly the same results (0.999...)
> with all the releases I have at hand, ranging from 3.0 back to 2.1.3, all
> on Window
On Dec 10, 4:12 am, [EMAIL PROTECTED] wrote:
> On Mon, 8 Dec 2008 at 23:46, eliben wrote:
> > This is about Python 2.5.2 - I don't know if there were fixes to this
> > module in 2.6/3.0
>
> > I think I ran into a bug with difflib.SequenceMatcherclass.
> > Sp
Hello,
This is about Python 2.5.2 - I don't know if there were fixes to this
module in 2.6/3.0
I think I ran into a bug with difflib.SequenceMatcher class.
Specifically, its ratio() method. The following:
SequenceMatcher(None, [4] + [10] * 500 + [5], [10] * 500 + [5]).ratio
()
returns 0.0
Whil
On Oct 14, 1:18 pm, sert <[EMAIL PROTECTED]> wrote:
> I'm developing a circuit simulation application and will need to
> plot the output of my program. The output will not be functions,
> just a collection of numerical values of the dependent and
> independent variables.
One good option is matpl
On Oct 8, 4:04 pm, pepitovadecurt <[EMAIL PROTECTED]> wrote:
> Hi I need to access to the Google Calendar under python.
> Is posible?
Yes:
http://code.google.com/p/gdata-python-client/
Eli
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 18, 6:01 pm, Tim Golden <[EMAIL PROTECTED]> wrote:
> Joe G (Home) wrote:
> > Hi All,
>
> > Background
> > ===
> > I have installed Python for windows today from the python web site .I also
> > installed pySerial using the Windows installer from the sourceforge web
> > site..
> Biggest issue I have with Python is screen input and output. I am trying
> to master wxPython (and Tkinter) but find this aspect harder than it
> ought to be.
>
This is hardly an issue with Python. You'll run into it with all
languages. You think wxPython is hard to master ? You should try
writi
On Aug 19, 7:34 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On Tue, Aug 19, 2008 at 12:19 PM, eliben <[EMAIL PROTECTED]> wrote:
> > Python provides a quite good and feature-complete exception handling
> > mechanism for its programmers. This is good.
> Here is an example from a Django web app: when there is a bug, a
> generic Exception is thrown and Django catches it and reports a
> beautifully formatted stack trace. When something must be reported to
> the user, a MyAppException is thrown (not the real name). The HTTP
> request handler for the
On Aug 21, 12:40 pm, Bruno Desthuilliers wrote:
> eliben a écrit :> On Aug 19, 7:19 pm, eliben <[EMAIL PROTECTED]> wrote:
> >> Python provides a quite good and feature-complete exception handling
> >
>
> > Thanks for the interesting discussion. Armed by th
> >http://eli.thegreenplace.net/2008/08/21/robust-exception-handling/
>
> Just a few random points. You say:
>
> "Exceptions are better than returning error status codes. Some languages
> (like Python) leave you with no choice as the whole language core and
> standard libraries throw exceptions."
>
On Aug 19, 7:19 pm, eliben <[EMAIL PROTECTED]> wrote:
> Python provides a quite good and feature-complete exception handling
Thanks for the interesting discussion. Armed by the new information
and few online sources, I blogged a summary for myself on the topic of
robust exception ha
On Aug 21, 4:51 am, Dave Benjamin <[EMAIL PROTECTED]> wrote:
> Christian Heimes wrote:
> > eliben wrote:
> >> Ruby's 'Scruct' class (http://ruby-doc.org/core/classes/Struct.html)
> >> does this. I suppose it can be done with 'exec', but is
On Aug 21, 1:30 am, Ethan Furman <[EMAIL PROTECTED]> wrote:
> nntpman68 wrote:
> > johnewing wrote:
>
> >> I am trying to figure out how to test if two numbers are of the same
> >> sign (both positive or both negative). I have tried
>
> >> abs(x) / x == abs(y) / y
>
> >> but that fails when one of
On Aug 20, 9:22 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I see on this link "# Python is
> Stupid"http://schlake.livejournal.com/809567.html
> Code is
>
> #!/usr/bin/env python
> for flour in range( 50, 1000 + 1, 5): # Python is Stupid
> print '%.2f %.2f %.2f' % ( (flour), (flour * 0
""" between file()
and open() in Python 2 and 3, a NameError is thrown with open() in
Python 3 and an IOError is thrown in the other three cases .
"""
This is *exactly* my concern with Python exceptions. You just never
know what can be thrown at you.
> You want to look up Easier to Ask Forgivness
Python provides a quite good and feature-complete exception handling
mechanism for its programmers. This is good. But exceptions, like any
complex construct, are difficult to use correctly, especially as
programs get large.
Most of the issues of exceptions are not specific to Python, but I
sometim
On Aug 18, 11:16 am, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> On 13 ago, 14:46, eliben <[EMAIL PROTECTED]> wrote:
>
> > On Aug 13, 7:30 pm, Christian Heimes <[EMAIL PROTECTED]> wrote:
>
> > > eliben wrote:
> > > > Ruby's &
On Aug 15, 4:21 pm, "Paul Wilson" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'd like to be able to do the following to a python source file
> programmatically:
> * Read in a source file
> * Add/Remove/Edit Classes, methods, functions
> * Add/Remove/Edit Decorators
> * List the Classes
> * List
Hello,
At the moment, I place all the code of my project in a src/ directory,
and all the tests in a sibling tests/ directory, so for instance a
sample project can look like this:
doc/
...
src/
play.py
write.py
tests/
test_play.py
test_write.py
While this works fine, I have a couple of
On Aug 13, 7:30 pm, Christian Heimes <[EMAIL PROTECTED]> wrote:
> eliben wrote:
> > Ruby's 'Scruct' class (http://ruby-doc.org/core/classes/Struct.html)
> > does this. I suppose it can be done with 'exec', but is there a more
> > Pythonic
Hello,
I want to be able to do something like this:
Employee = Struct(name, salary)
And then:
john = Employee('john doe', 34000)
print john.salary
Basically, Employee = Struct(name, salary) should be equivalent to:
class Employee(object):
def __init__(self, name, salary):
self.name = na
On Aug 1, 5:31 pm, [EMAIL PROTECTED] wrote:
> I'm writing Python as if it were strongly typed, never recycling a
> name to hold a type other than the original type.
>
> Is this good software engineering practice, or am I missing something
> Pythonic?
I'm not sure you've got the terminology 100% ri
> > 2) What is the meaning of the comment in astgen.py ? Are the Python
> > maintainers unhappy with the design of the AST ?3
>
> Node, I think, is talking about a node in the parse tree. (AST is
> generated from another parse tree.) See PEP 339 for details.
>
Thanks, PEP 339 clarified a lot to
Hello,
I'm building a parser in Python, and while pondering on the design of
my ASTs had the idea to see what Python uses. I quickly got to the
compiler.ast module, and understood it's automatically generated. So I
went to the source, ast.txt and tools/compiler/astgen.py, where I was
this unexpect
On Jun 28, 8:20 am, John Machin <[EMAIL PROTECTED]> wrote:
> On Jun 28, 3:41 pm, eliben <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jun 27, 3:10 pm, eliben <[EMAIL PROTECTED]> wrote:
>
> > > Hello,
> > > I'm trying to compi
On Jun 27, 3:10 pm, eliben <[EMAIL PROTECTED]> wrote:
> Hello,
> I'm trying to compile the minimal example
> fromhttp://en.wikibooks.org/wiki/Python_Programming/Extending_with_Cwith
> MinGW (latest version) and Python 2.5 (latest ActiveState binary
> install). When r
Hello,
I'm trying to compile the minimal example from
http://en.wikibooks.org/wiki/Python_Programming/Extending_with_C with
MinGW (latest version) and Python 2.5 (latest ActiveState binary
install). When running the setup file, the following happens:
running build
running build_ext
building 'hello
On Jun 23, 6:44 am, eliben <[EMAIL PROTECTED]> wrote:
> Thanks for all the replies in this post. Just to conclude, I want to
> post a piece of code I wrote to encapsulate function creation in this
> way:
>
> def create_function(code):
> """ Create
Hello,
I'm interested in converting integers to a binary representation,
string. I.e. a desired function would produce:
dec2bin(13) => "1101"
The other way is easily done in Python with the int() function.
Perl has a very efficient way to do dec2bin, because its pack/unpack
have a B format for
> If code generation is not the best, and I fail to see any performance issue
> that could explain such a choice, except a misunderstanding of
> what "compilation" means in python, just don't use it, use closures or
> callable instances, there are many way to achieve this.
And while we're on the t
Thanks for all the replies in this post. Just to conclude, I want to
post a piece of code I wrote to encapsulate function creation in this
way:
def create_function(code):
""" Create and return the function defined in code.
"""
m = re.match('\s*def\s+([a-zA-Z_]\w*)\s*\(', code)
if m
> Fair enough. To help you understand the method I used, I'll give you
> this hint. It's true that regex on works on strings. However, is there
> any way to convert arbitrarily complex data structures to string
> representations? You don't need to be an experienced Python user to
> answer to this ;
On Jun 21, 3:36 pm, [EMAIL PROTECTED] wrote:
> Which tools would you use? I want the interface design to be as easy
> and fast as possible, all ideology aside. I'm considering either
> IronPython+Visual Studio or Python+Qt -- but I'm open for other
> suggestions.
>
> Visual Studio seems to offer th
> > I see. In my case I only evaluate function definitions with 'exec', so
> > I only need to de-indent the first line, and the others can be
> > indented because they're in a new scope anyway. What you suggest works
> > for arbitrary code and not only function definitions. It's a nice
> > trick wi
On Jun 21, 8:52 am, Peter Otten <[EMAIL PROTECTED]> wrote:
> eliben wrote:
> > On Jun 20, 2:44 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> >> eliben wrote:
> >> > Additionally, I've found indentation to be a problem in such
> >> > co
On Jun 20, 2:44 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> eliben wrote:
> > Additionally, I've found indentation to be a problem in such
> > constructs. Is there a workable way to indent the code at the level of
> > build_func, and not on column 0 ?
>
>
>d = {}
> execcode in globals(), d
> return d['foo']
>
> My way:
>
> return function(compile(code, '', 'exec'), globals())
>
With some help from the guys at IRC I came to realize your way doesn't
do the same. It creates a function that, when called, creates 'foo' on
globals(). This is not
> So you are saying that for example "if do_reverse: data.reverse()" is
> *much* slower than "data.reverse()" ? I would expect that checking the
> truthness of a boolean would be negligible compared to the reverse
> itself. Did you try converting all checks to identity comparisons with
> None ? I m
On Jun 20, 3:19 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
> On Jun 20, 8:03 am, eliben <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jun 20, 9:17 am, Bruno Desthuilliers
> > [EMAIL PROTECTED]> wrote:
> > > eliben a écrit :> Hello,
>
> &g
> [1] except using compile to build a code object with the function's
> body, then instanciate a function object using this code, but I'm not
> sure whether it will buy you much more performance-wise. I'd personnaly
> prefer this because I find it more explicit and readable, but YMMV.
>
How is com
> FWIW, when I had a similar challenge for dynamic coding, I just
> generated a py file and then imported it. This technique was nice
> because can also work with Pyrex or Psyco.
>
I guess this is not much different than using exec, at the conceptual
level. exec is perhaps more suitable when you
On Jun 20, 9:17 am, Bruno Desthuilliers wrote:
> eliben a écrit :> Hello,
>
> > In a Python program I'm writing I need to dynamically generate
> > functions[*]
>
> (snip)
>
> > [*] I know that each time a code generation question comes up people
> &g
Hello,
In a Python program I'm writing I need to dynamically generate
functions[*] and store them in a dict. eval() can't work for me
because a function definition is a statement and not an expression, so
I'm using exec. At the moment I came up with the following to make it
work:
def build_func(a
On Jun 9, 8:57 am, Thin Myrna <[EMAIL PROTECTED]> wrote:
> I'd like to access some drive hardware via CAN bus from Python under Linux
> (sending rec'ing PDOs). Googling around I couldn't find a Python package,
> but people who said that they are doing this, though. I guess they are
> using their ho
On May 17, 11:42 am, eliben <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm getting into Python now after years of Perl, and as part of my
> research I must understand how to do some common tasks I need.
>
> I have a bunch of Windows PCs at work to which I want to dis
On Jun 7, 10:15 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Fri, 06 Jun 2008 23:57:03 -0700, s0suk3 wrote:
> > You can just split the path on `os.sep', which contains the path
> > separator of the platform on which Python is running:
>
> > components = pathString.split(os.sep)
>
>
Hello,
os.path.split returns the head and tail of a path, but what if I want
to have all the components ? I could not find a portable way to do
this in the standard library, so I've concocted the following
function. It uses os.path.split to be portable, at the expense of
efficiency.
-
On May 29, 3:08 am, Matimus <[EMAIL PROTECTED]> wrote:
> > I have a game class, and the game has a state. Seeing that Python has
> > no enumeration type, at first I used strings to represent states:
> > "paused", "running", etc. But such a representation has many
> > negatives, so I decided to look
Hello,
I have a game class, and the game has a state. Seeing that Python has
no enumeration type, at first I used strings to represent states:
"paused", "running", etc. But such a representation has many
negatives, so I decided to look at the Enum implementation given here:
http://aspn.activestate
Hello,
I have a small wxPython application. Today I was trying to add some
RPC capability to it, so I implemented an instance of
SimpleXMLRPCServer that runs in a separate thread when invoked and
answers requests.
All went fine until I realized that I have to sometimes stop the
server - which is
On May 17, 8:54 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote:
> "eliben" <[EMAIL PROTECTED]> wrote in message
>
> news:[EMAIL PROTECTED]
> | Is there a simple way to find out which packages are used by my
> | script ?
>
> Ggrep for import stateme
On May 17, 3:23 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote:
> On May 17, 4:42 am, eliben <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello,
>
> > I'm getting into Python now after years of Perl, and as part of my
> > research I must understand how to do
Hello,
I'm getting into Python now after years of Perl, and as part of my
research I must understand how to do some common tasks I need.
I have a bunch of Windows PCs at work to which I want to distribute an
application I've developed on my PC. All these PCs have Python 2.5
installed.
If my appl
60 matches
Mail list logo