A new release of markup.py is available at http://markup.sourceforge.net/
This new release is compatible with both python 2 and 3.
What is markup.py?
Markup.py is an intuitive, light weight, easy-to-use, customizable and
pythonic HTML/XML generator. The only goal is quickly writing HTML/XML
It might be slightly off topic here but couldn't find a more suitable
place for this question:
I'm trying to build the python binding for ming -- http://ming.sf.net
-- but for some reason the python macro for autoconf -- python.m4 --
doesn't seem to detect my python installation correctly. The
A very simple question: I currently use a cumbersome-looking way of
getting the first, second, etc. line of a text file:
for i, line in enumerate( open( textfile ) ):
if i == 0:
print 'First line is: ' + line
elif i == 1:
print 'Second line is: ' + line
On 7/26/07, Alan [EMAIL PROTECTED] wrote:
Hi List!
I have I Macbook Pro Intel running OSX 10.4.10.
I downloaded Python 2.5 and tried
TclTkAquaBI-8.4.10.0.dmg, but I got:
Traceback (most recent call last):
File stdin, line 1, in module
File
Thanks all! I think I will stick to my original method because the
files can be quite large and without reading the whole file into
memory probably enumerate( open( textfile ) ) is the only way to
access an arbitrary Nth line.
--
http://mail.python.org/mailman/listinfo/python-list
A very simple question: I currently use a cumbersome-looking way of
getting the first, second, etc. line of a text file:
for i, line in enumerate( open( textfile ) ):
if i == 0:
print 'First line is: ' + line
elif i == 1:
print 'Second line is: ' + line
...
I want to create a standalone program ( an exe file ) from my python files
which works on Windows and Linux.
Could you please tell me how to do that?
The same executable should work on both linux and windows? Not
possible. But see:
There seems to be some problem. For the tar version, initial steps
execute OK, but after typing:
[EMAIL PROTECTED] pygame-1.7.1release]# ./configure
bash: ./configure: No such file or directory
So i don't hav a configure file? What should i do now?
Sorry, instead of ./configure do this:
how to import bluebit matrik calculator that result of singular value
decomposition (SVD) in python programming..
I'm not really sure I understand you but you might want to check out scipy:
http://scipy.org/
HTH,
Daniel
--
http://mail.python.org/mailman/listinfo/python-list
Im working in red hat linux 9.0. I've downloaded the pygame package
but i dont know how to install it. If anybody has the time to detail
the steps sequentially... thanx!
P.S. I've downloaded both the tar and the rpm packages...
First you can try the rpm package:
su
(give the root password)
I have an issue I think Python could handle. But I do not have the
knowledge
to do it.
Suppose I have a class 'myClass' and instance 'var'. There is function
'myFunc(..)'. I have to add (or bind) somehow the function to the
class, or
the instance. Any help, info or point of
I need a reference to get all the programs which used to package Python
programs into standalone executables files.
Would you help me?
windows: http://www.py2exe.org/
mac: http://cheeseshop.python.org/pypi/py2app/
linux: http://wiki.python.org/moin/Freeze
linux/windows:
I have an issue I think Python could handle. But I do not have the knowledge
to do it.
Suppose I have a class 'myClass' and instance 'var'. There is function
'myFunc(..)'. I have to add (or bind) somehow the function to the class, or
the instance. Any help, info or point of reference is
Write a program that takes as its first argument one of the words
'sum,' 'product,' 'mean,' or 'sqrt' and for further arguments a
series of numbers. The program applies the appropriate function to
the series.
My solution so far is this:
http://dpaste.com/13469/
I would
Hi
I'm considering learning Python...but with the python 3000 comming
very soon, is it worth waiting for?? I know that the old style of
coding python will run parallel with the new, but I mean, its going to
come to an end eventually.
What do you think??
Chris
99% of what you would learn
Python 2.5.1
Boost.Python
Qt 4.2.2
SIP 4.6
PyQt 4.2
WinXp
I've a memory leak in a PyQt application and no idea how to find it. What
happens in the application ?
From QWindow a QDialog is called on a button pressed() signal, that
instantiate a QThread and waits for it. If the thread
Hi list,
Well, the short question is: what are they? I've read Guido's python
3000 status report on
http://www.artima.com/weblogs/viewpost.jsp?thread=208549 where he
mentions ABC's but don't quite understand what the whole story is
about.
Anyone has good use cases?
Daniel
--
Well, the short question is: what are they? I've read Guido's python
3000 status report on
http://www.artima.com/weblogs/viewpost.jsp?thread=208549 where he
mentions ABC's but don't quite understand what the whole story is
about.
The story is at PEP 3119:
I was wondering if there was a python-live-environment available on a
public web-site similar to the ruby-live-tutorial on
http://tryruby.hobix.com/
I would prefer something which allows to paste small scripts into a
text-field, to run them on the server, and to be able to read the
class UserDict:
def __init__(self, dict=None):
self.data = {}
if dict is not None: self.update(dict)
I just don't understant this code, as it is not also mention in the
book. the update is a method of a dict right? in my understanding the
last statement should be
How does one effect a goto in python? I only want to use it for debug.
I dasn't slap an if clause around the portion to dummy out, the
indentation police will nab me.
http://entrian.com/goto/
--
http://mail.python.org/mailman/listinfo/python-list
I see that the weapon of choice for google maps is javascript... Is
there anything for python?
I wrote the following for finding the latitude/longitude of a
location. You need to set the variable 'key' to the actual key you got
from google.
(Indentation might get mixed up on the way.)
I have created an image hosting site and when a user uploads an image,
I want a service to run on the server to create a few thumbnails while
the user does other things.
My stupid host (pair.com) doesn't have PIL installed and I'm too much
of a stupid newbie to figure out how to get it to
Are there other options I overlooked?
Daniel
There is a CRUD template for TG:
http://docs.turbogears.org/1.0/CRUDTemplate
Might be what you're looking for.
I was looking for something that is not based on a framework such as
django or tg (and not on sqlalchemy either, but on
Hi list,
I'm looking for an sqlobject based model browser with a web interface
(is this the thing called CRUD these days?). Searching all over the
place turned up of course django's automatic admin interface and
turbogears' catwalk but I wouldn't want to buy into any of these two
frameworks
And before you ask, yes, I did read
http://mail.python.org/pipermail/python-list/2007-May/440337.html but
there was nothing beyond django/tg :)
--
http://mail.python.org/mailman/listinfo/python-list
For example, it HAS been published elsewhere that YouTube uses lighttpd,
not Apache: http://trac.lighttpd.net/trac/wiki/PoweredByLighttpd.
How do you explain these, then:
http://www.youtube.com/results.xxx
http://www.youtube.com/results.php
http://www.youtube.com/results.py
Just wondering,
For example, it HAS been published elsewhere that YouTube uses lighttpd,
not Apache: http://trac.lighttpd.net/trac/wiki/PoweredByLighttpd.
How do you explain these, then:
http://www.youtube.com/results.xxx
http://www.youtube.com/results.php
http://www.youtube.com/results.py
For example, it HAS been published elsewhere that YouTube uses lighttpd,
not Apache: http://trac.lighttpd.net/trac/wiki/PoweredByLighttpd.
How do you explain these, then:
http://www.youtube.com/results.xxx
http://www.youtube.com/results.php
http://www.youtube.com/results.py
Just wondering if there is any way of sending a JavaScript array to a
Python cgi script? A quick Google search didn't turn up anything
useful.
Simplejson is what you want: http://cheeseshop.python.org/pypi/simplejson
HTH,
Daniel
--
http://mail.python.org/mailman/listinfo/python-list
A new release is available for markup.py, a module for generating
HTML/XML output painlessly and practically without any learning curve.
The goal of markup.py is to be able to quickly put together documents
in an ad hoc basis so if you need anything for production look for
something else, e.g.
I don't know exactly what the first non-space character is. I know the
first non-space character will be * or an alphanumeric character.
How about:
mystring = 'ksjfkfjkfjds '
print len( mystring ) - len( mystring.lstrip( ) )
4
HTH,
Daniel
--
I've found the following strange behavior of cPickle. Do you think
it's a bug, or is it by design?
Best regards,
Victor.
from pickle import dumps
from cPickle import dumps as cdumps
print dumps('1001799')==dumps(str(1001799))
print cdumps('1001799')==cdumps(str(1001799))
I've found the following strange behavior of cPickle. Do you think
it's a bug, or is it by design?
Best regards,
Victor.
from pickle import dumps
from cPickle import dumps as cdumps
print dumps('1001799')==dumps(str(1001799))
print
I am working on the networking code for a small Multiplayer RPG I'm
working on. I currently have some basic code using threads, but it
seems like asyncore would be far better suited for my needs. However,
I have trouble finding a solid example for what I need. Python.org and
other sites
Hi list,
How does one prevent elementtree converting to amp; (and similarly
for other entities)?
from xml.etree import ElementTree as et
x = et.Element( 'test' )
x.text = ''
et.tostring( x )
'testamp;/test'
Sometimes I would like to have the output 'test/test'
Daniel
--
How does one prevent elementtree converting to amp; (and similarly
for other entities)?
from xml.etree import ElementTree as et
x = et.Element( 'test' )
x.text = ''
et.tostring( x )
'testamp;/test'
Sometimes I would like to have the output 'test/test'
elementtree is for
I've got an instance of a class, ex :
b=gtk.Button()
I'd like to add methods and attributes to my instance b.
I know it's possible by hacking b with setattr() methods. But i'd
like to do it with inheritance, a kind of dynamic subclassing,
without subclassing the class, only this instance b
I've got an instance of a class, ex :
b=gtk.Button()
I'd like to add methods and attributes to my instance b.
I know it's possible by hacking b with setattr() methods. But i'd
like to do it with inheritance, a kind of dynamic subclassing,
without subclassing the class, only
Suppose I have class ShoppingCart which has one method called buy(),
and class Buyer who has one reference to ShoppingCart... Can I also
have method buy() in class Buyer, which will then called
ShoppingCard.buy(), and also do some other stuff? Is this legal
design pattern, have methods with
After reading a file is it possible to write to it without first
closing it? I tried opening with 'rw' access and re-winding. This does
not seem to work unless comments are removed.
Also, does close force a flush?
Thanks,
jh
#~~
f =
I am very new to Python and Mod_Python and I am running into what
looks like a caching problem.
I have the following code:
---
from mod_python import apache
from folder import Messenger
def handler(req):
msg = Messenger(req):
# using req.write
i find it difficult to understand the difference between the magic methods
__getattr__ and __getattribute__
and so donot know when to use former or later.
From the docs:
__getattr__(self, name) Called when an attribute lookup has not found
the attribute in the usual places (i.e. it is not an
Does sqlite come in a mac version?
The interface (pysqlite) is part of the python 2.5 standard library
but you need to install sqlite itself separately (as far as I
remember) fromwww.sqlite.org
http://developer.apple.com/documentation/MacOSX/Conceptual/OSX_Techno...
I
Lots of code, calls to, calls by, inheritance, multiple tasks, etc.
What do people use to figure out what's happening?
This is a pretty cool project just for that:
http://codeinvestigator.googlepages.com/codeinvestigator
HTH,
Daniel
--
http://mail.python.org/mailman/listinfo/python-list
Does sqlite come in a mac version?
The interface (pysqlite) is part of the python 2.5 standard library
but you need to install sqlite itself separately (as far as I
remember) from www.sqlite.org
Daniel
--
http://mail.python.org/mailman/listinfo/python-list
The built in zipfile.write doesn't seem to like taking a directory instead
of a filename.
for example:
for each in listofdir:
archive.write(each)
blows up when one of the items listed in listofdir is a subdirectory.
File /usr/local/lib/python2.4/zipfile.py, line 405,
I'm using python 2.4.4 because the download said there were more mac
modules available for 2.4.4. than 2.5, and I can't seem to locate a
place to download sqlite for mac.
I it comes on OS X Tiger, and possibly earlier versions as well (it's
used as an index for Mail.app).. You just
Does sqlite come in a mac version?
The interface (pysqlite) is part of the python 2.5 standard library
but you need to install sqlite itself separately (as far as I
remember) fromwww.sqlite.org
Daniel
I'm using python 2.4.4 because the download said there were more mac
modules
I am parsing an XML file and sending the output to two files.The
code asks the user to enter the input file,something like:
file_input = raw_input(Enter The ODX File Path:)
input_xml = open(file_input,'r')
Now suppose the user enters the path as :
C:\Projects\ODX Import\Sample
I am parsing an XML file and sending the output to two files.The
code asks the user to enter the input file,something like:
file_input = raw_input(Enter The ODX File Path:)
input_xml = open(file_input,'r')
Now suppose the user enters the path as :
C:\Projects\ODX
I made a C/S network program, the client receive the zip file from the
server, and read the data into a variable. how could I process the
zipfile directly without saving it into file.
In the document of the zipfile module, I note that it mentions the
file-like object? what does it mean?
I made a C/S network program, the client receive the zip file from the
server, and read the data into a variable. how could I process the
zipfile directly without saving it into file.
In the document of the zipfile module, I note that it mentions the
file-like object? what does it
The lines
if __name__ == 'main':
someClass().fn()
appear at the end of many examples I see. Is this to cause a .class
file to be generated?
Python doesn't generate .class files, and the example you mean is
probably more like
if __name__ == '__main__':
.whatever
A bit more of a complex one this time, and I thought I'd get your opinions
on the best way to achieve this. Basically I'm looking for a way to describe
a re-occurring event, like a calendar event or appointment I guess. I'm
likely to use an XML file for the definition of the events, but
Looking to build a quick if/else statement that checks a dictionary for a
key like follows.
If myDict contains ThisKey:
Do this...
Else
Do that...
Thats the best way of doing this?
if key in myDict:
Do this.
else:
Do that
HTH,
I'm using the following function 'str (now)' to place a date time stamp into
a log file, which works fine, however it writes the stamp like this.
2007-04-25 11:06:53.873029
But I need to expel those extra decimal places as they're causing problems
with the application that parses the log
[Alex]
When cash is involved, it's important to avoid even the
slightest hint of a suggestion of a suspicion of a conflict of interest
I propose the non-PSF sponsored Grand Prize For Successfully Squeezing
4 Of's In A Single Sentence should be received by Alex Martelli this
month :)
--
2. File D:\Python24\lib\socket.py, line 295, in read
data = self._sock.recv(recv_size)
error: (10054, 'Connection reset by peer')
That looks like M$ Windows version of UNIX/Linux error number 54
(pretty much all Windows socket errors are UNIX number+1)
Errors coming
This may be pretty obvious for most of you:
When I have an object (an instance of a class Foo) I can access
attributes via dot notation:
aFoo.bar
however when I have a dictionary
aDict = {bar:something}
I have to write
aDict[bar]
What if I
This may be pretty obvious for most of you:
When I have an object (an instance of a class Foo) I can access
attributes via dot notation:
aFoo.bar
however when I have a dictionary
aDict = {bar:something}
I have to write
aDict[bar]
What if I
Is it possible to convert an object into a string that identifies the
object in a way, so it can later be looked up by this string.
Technically this should be possible, because things like
__main__.Foo instance at 0xb7cfb6ac
say everything about an object. But how can I look up the real
I'm running a program of mine from Linux bash script and it currently
outputs status messages to the command prompt, but they all look a little
boring to say the least, it'll be like this.
[snip]
And perhaps have the word 'success' in green, or red for 'failed' and things
like that, just to
I'm running a program of mine from Linux bash script and it currently
outputs status messages to the command prompt, but they all look a little
boring to say the least, it'll be like this.
[snip]
And perhaps have the word 'success' in green, or red for 'failed' and
things
like that,
Can you please suggest a technique in Python where we can spawn few number
of worker threads and later map them to a function/s to execute individual
Jobs.
Have a look at the threading module:
http://docs.python.org/lib/module-threading.html
HTH,
Daniel
--
Hi All,
I was thinking about the feasbility of adjusting Python as a
compiled language. Being said that I feel these are the following advantages
of doing so --
1) Using the powerful easy-to -use feature of Python programming language
constructs.
2) Making the program to run at
I have a function that returns a array{uint32}, is there any way to output
that to screen in a more user friendly format? At the moment when I print it
by itself it appears as [65541L], which isn't much used to anyone.
I'm not sure I understand your question precisely but this might help:
I'm looking to clear those log files we were discussing earlier chaps,
What the best method to do this? Delete the file completely? Or just empty
its content?
If you just want to delete the content of a file but keep it with 0
length you can do:
f = open( 'myfile', 'w' )# or open(
I am probably misunderstanding some basic issue here but this
behaviour is not what I would expect:
Python 2.4 (#1, Mar 22 2005, 21:42:42)
[GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2
Type help, copyright, credits or license for more information.
class mystr( str ):
... pass
Why is the strip( ) method returning something that is not a mystr
instance? I would expect all methods operating on a string instance
and returning another string instance to correctly operate on a mystr
instance and return a mystr instance.
Why would you expect that?
Would you expect
And the last example brings up another question. What's the deal with a
tupple that has a list in it such as:
my_tupple = (1, 2, 3, 4, 5, [6, 7, 8, 9])
Now I read somewhere that you could change the list inside that tupple. But
I can't find any documentation that describes HOW to do it.
Is there an easy way to take binary data and build it into a file? Generally
this will be BLOB data drawn from a database, the data will be for jpg
images, I want to take the blob data and build it into a physical .jpg file.
Is there a simple function for doing this in python? Like
I have just started learning python.I need to parse an XML file
and present the contents in a particular format.The format is called
as ini file.I have written some code.A section of the format needs
the data to be present in format as given below:
[Services]
I'm looking for a collection of useful programming projects, at
the hobbyist level.
My online search did turn up a few collections (isolated projects
are less useful to me at the moment), but these projects are either
more difficult than what I'm looking for (e.g. code a C compiler)
or not
Thought this might amuse some of you:
http://youtube.com/results?search_query=korect+my+speling
I'd heard that YouTube uses Python, but it's fun to see proof of that,
even if it comes in the form of a minor bug.
But their web frontend is (probably) in php:
Can an instance of a class in a module, in any simple way find out which
other classes that exists in said module ?
# module x ##
class c1:
pass
class c2:
pass
###
Python 2.5 (r25:51908, Nov 1 2006, 11:42:37)
[GCC 3.4.2 20041017 (Red Hat
I'm in a process of rewriting a bash/awk/sed script -- that grew to
big -- in python. I can rewrite it in a simple line-by-line way but
that results in ugly python code and I'm sure there is a simple
pythonic way.
The bash script processed text files of the form:
I was told in this NG that string is obsolet. I should use
str methods.
So, how do I join a list of strings delimited by a given
char, let's say ','?
Old way:
l=['a','b','c']
jl=string.join(l,',')
New way?
Dunno if it's the new way, but you can do: ''.join(l)
The OP
Hi list,
I'm in a process of rewriting a bash/awk/sed script -- that grew to
big -- in python. I can rewrite it in a simple line-by-line way but
that results in ugly python code and I'm sure there is a simple
pythonic way.
The bash script processed text files of the form:
This is my first try:
ddata = {}
inside_matrix = False
for row in file(data.txt):
if row.strip():
fields = row.split()
if len(fields) == 2:
inside_matrix = False
ddata[fields[0]] = [fields[1]]
lastkey = fields[0]
else:
The Python documentation for str says
str([object]) :
Return a string containing a nicely printable representation of an
object.
However, there's no mention of the fact that str of a Unicode string
with non-ASCII characters will raise a conversion exception. The
documentation (and
I'm just getting started with numpy/scipy and first would like to get
a view of what it can do and what it can't. The main idea is to move
from maple to python and the first thing that poped up is the fact
that maple is very convenient for both formal manipulations and exact
integer calculations.
I need to process a really huge text file (4GB) and this is what i
need to do. It takes for ever to complete this. I read some where that
list comprehension can fast up things. Can you point out how to do
it in this case?
thanks a lot!
f = open('file.txt','r')
for line in f:
I need to process a really huge text file (4GB) and this is what i
list comprehension can fast up things. Can you point out how to do
f = open('file.txt','r')
for line in f:
db[line.split(' ')[0]] = line.split(' ')[-1]
db.sync()
What is db here? Looks like a
The etree.Element (or ElementTree.Element) supports a number of
list-like methods: append, insert, remove. Any special reason why it
doesn't support pop and extend (and maybe count)?
Those methods would not be hard to add. Perhaps, submit a feature
request to Fredrik Lundh on
Sorry jumped the gun a little there. Is this what you are looking for?
http://codespeak.net/download/py/py-0.9.0.zip
Probably not, the OP is looking for a python distribution, what you
are posting is a third party package *for* python and is actually a
part of the pypy project.
--
The etree.Element (or ElementTree.Element) supports a number of
list-like methods: append, insert, remove. Any special reason why it
doesn't support pop and extend (and maybe count)?
--
http://mail.python.org/mailman/listinfo/python-list
I am new to python and working on a project that involves designing a
new language. The grammar of the language is very much inspired from
python as in is supports nearly all the statements and expressions
that are supported by python. Since my project is in initial stage, so
I think it would
Could you please tell me, on that 64-bit build, what happens with:
importgmpy, sys, operator
sys.maxint
???
gmpy.mpz(sys.maxint)
???
operator.index(gmpy.mpz(sys.maxint))
???
sys.maxint+1
???
gmpy.mpz(sys.maxint+1)
???
operator.index(gmpy.mpz(sys.maxint)+1)
???
I'm probably fundamentally misunderstanding the way the interpreter
works with regard to scope, but is this the intended behavior...
[]
SOMEGLOBAL:
Traceback (most recent call last):
File unboundlocal.py, line 15, in ?
foo()
File unboundlocal.py, line 11, in foo
print
Could you please tell me, on that 64-bit build, what happens with:
import gmpy, sys, operator
sys.maxint
???
gmpy.mpz(sys.maxint)
???
operator.index(gmpy.mpz(sys.maxint))
???
sys.maxint+1
???
gmpy.mpz(sys.maxint+1)
???
operator.index(gmpy.mpz(sys.maxint)+1)
???
i.e., what
Hi Alex,
I did another test, this time with python 2.4 on suse and things are
worse than in the previous case (which was python 2.5 on fedora 3),
ouput of 'python gmp_test.py' follows:
Unit tests for gmpy 1.02 release candidate
on Python 2.4 (#1, Mar 22 2005, 21:42:42)
[GCC 3.3.5 20050117
Hi Alex,
I did another test, this time with python 2.4 on suse and things are
worse than in the previous case (which was python 2.5 on fedora 3),
ouput of 'python gmp_test.py' follows:
Interesting! gmpy interacts with decimal.Decimal by monkey-
patching that class on the fly; clearly
Something funny:
The new programming model of NVIDIA GPU's is called CUDA and I've
noticed that they use the same __special__ notation for certain things
as does python. For instance their modified C language has identifiers
such as __device__, __global__, __shared__, etc. Is it a coincidence?
Something funny:
The new programming model of NVIDIA GPU's is called CUDA and I've
noticed that they use the same __special__ notation for certain things
as does python. For instance their modified C language has identifiers
such as __device__, __global__, __shared__, etc. Is it a
Thus far, everything works fine unless I'm trying the Deposit or Withdrawal
functions. (I know they're different, but both give roughly the same error.)
Whenever I attempt one of these functions I get the following error message:
Exception in Tkinter callback
Traceback (most recent call
If you're interested in gmpy (the Python wrapper of GMP, for
unlimited-precision arithmetic, rationals, random number generation,
number-theoretical functions, etc), please DO check out
http://code.google.com/p/gmpy/ -- gmpy 1.02 is there (as far as I can
tell) in a workable state. Source on
Can any body tell how Dict is implemented in python... plz tell what
datastructure that uses
Please see
http://svn.python.org/view/python/trunk/Objects/dictnotes.txt?rev=53782view=markup
for general notes and
Or is any progress going on now?
The JIT in MATLAB or Java seems to be very effective.
This document describes the JIT situation in pypy:
http://codespeak.net/pypy/dist/pypy/doc/jit.txt
--
http://mail.python.org/mailman/listinfo/python-list
I want to convert string to dictionary .what is the best solution for this?
for example string is like this:
'{SalutationID:[primarykey,8388607,0,None],CompanyID:[0,8388607,0,index],
SalutationName:[,255,0,None],isDefault:[tinyint,1,1,None]}'
and I want to convert this string to
1 - 100 of 227 matches
Mail list logo