Re: Still Loving Python

2005-12-13 Thread DH
Ivan Voras wrote:
> Maybe the OP really wants a GUI builder.
> 
> More than 5 years ago, i programmed in Visual Basic and Delphi and I 
> still miss the wonderful ease of graphically creating the user interface 
> in WYSIWYG mode. If you haven't tried it, you don't know what you're 
> missing :)
> 
> I only know about Glade and similar GUI builders (Boa) and they are not 
> even close to the robustness & ease of use. Are there any easy GUI 
> builders for any Python-supported toolkits?

Search for QT Designer.  It's the best designer you're going to find by far.
http://www.riverbankcomputing.co.uk/pyqt/
http://www.opendocs.org/pyqt/
http://www.pragmaticprogrammer.com/titles/ctrubyqt/

It's a shame though because pygtk and wxpython are probably better gui 
apis for python, but their gui builders are no where near as nice.
QT Designer lets you drop in controls as you are designing, and THEN
apply layout constraints, instead of the reverse like in other gui
builders.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which Python web framework is most like Ruby on Rails?

2005-12-14 Thread DH
Alex Martelli wrote:
> Alternatively, counting Google hits:
> 
> rails python django 112,000
> rails python subway  81,600
> rails python turbogears  32,000
> 
> This isn't exactly "buzz", of course, but it's SOME measure of "critical
> mass" -- and with django about equal to subway+turbogears, it does not
> appear to show any emerging dominance.  A significant measure of "buzz"
> might be obtained by redoing the same search in, say, two weeks, and
> noticing the deltas...

Actually the turbogears mailing list has ~850 subscribers while
the django one has ~650.  I don't think that should be interpreted
as anything, but it does show the opposite of what you found with
the google search.  They both have "buzz".
Also others are working on another rails-like framework
called pylons: http://pylons.groovie.org/project
Because of course if other languages have 1 or two frameworks, python
needs a dozen.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Visual Python : finished ?

2005-12-16 Thread DH
Do Re Mi chel La Si Do wrote:
> Hi!
> 
> See :
>  http://www.activeperl.com/Products/Visual_Perl/?mp=1

Yes, they have discontinued it but there is Komodo,
or numerous other alternative IDES for python:
http://wiki.python.org/moin/IntegratedDevelopmentEnvironments
One good one not listed on that page is pydev:
http://pydev.sourceforge.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Optional typecheck

2006-01-07 Thread DH
Gregory Petrosyan wrote:
> Hello all! Please enlighten me about optional typecheck:
> 
> 1) Will it be available in Python 2.5?
> 2) Will it support things like
> 
> def f(a: int | float)
> 
> 3) Will it support interface checking like
> 
> def g(a: BookInterface)
> 
> or even mix like
> 
> def k(a: file | BookInterface)
> 
> 4) Will it support things like
> 
> def t(*args: T1 | T2, **kwds: T1 | T3)
> 

No, not til python 3.0, which is years off.
For now you can use:
http://www.ilowe.net/software/typecheck/
Or if you want static type checking with it speed boost instead of
typechecking at runtime, there are lots of other options too.
shedskin, pyrex, scipy.weave, boo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: urllib2 and proxies support ?

2006-01-07 Thread DH
tomazi75-nospam(at)gmail.com wrote:
> Hello all,
> 
> I've a problem using urllib2 with a proxy which need authentication.
> 

I don't have a way to test this myself but you can try the
suggestion at the bottom of this page:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52199
Move your name/password to an HTTPBasicAuthHandler.
-- 
http://mail.python.org/mailman/listinfo/python-list


Taking data from a text file to parse html page

2006-08-23 Thread DH
Hi,

I'm trying to strip the html and other useless junk from a html page..
Id like to create something like an automated text editor, where it
takes the keywords from a txt file and removes them from the html page
(replace the words in the html page with blank space) I'm new to python
and could use a little push in the right direction, any ideas on how to
implement this?

Thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython GUI designer

2006-06-18 Thread DH
[EMAIL PROTECTED] wrote:
> I am newbie learning wxPython. I tried using GUI designer called
> wxGlade. When it generated code I couldnt get the same level of
> flexibility as writing the code by oneself.
> 
> Any view on what you think about using GUI designer tools.
> 
> Every help is appreciated.
> 

In my opinion none of the wx* or gtk* related designer tools are
any good.  QT Designer (which can be used with pyqt) is excellent,
however, you probably would only want to use that if you are
developing non-commercial software or else can afford a commercial
license from Trolltech.  For wx and gtk projects, I usually just write 
the gui by hand like you have already been doing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: array of array of float

2006-07-09 Thread DH
[EMAIL PROTECTED] wrote:
> i used C too much and haven't used Python for a while...
> 
> like in C, if we want an array of array of float, we use
> 
> float a[200][500];
> 
> now in Python, seems like we have to do something like
> 
> a = [ [ ] ] * 200
> 
> and then just use
> 
> a[1].append(12.34)   etc
> 
> but it turns out that all 200 elements points to the same list...
> and i have to use
> 
> a = [ ]
> for i in range (0, 200):
> a.append([ ])
> 
> is there a simpler way... i wonder...
> 

Right, try the numpy module, and you can do:

from numpy import *
a = zeros((200,500), Float)

documentation:
http://numeric.scipy.org/numpydoc/numpy-6.html#pgfId-60291
download:
http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103
main page:
http://numeric.scipy.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Taking data from a text file to parse html page

2006-08-24 Thread DH
Frederic,
Good points...

I have a plain text file containing the html and words that I want
removed(keywords) from the html file, after processing the html file it
would save it as a plain text file.

So the program would import the keywords, remove them from the html
file and save the html  file as something.txt.

I would post the data but it's secret. I can post an example:

index.html (html page)

"
"Python has been an important part of Google since the
beginning, and remains so as the system grows and evolves.
"
-- Peter Norvig, 

"

"

-- Peter Norvig,  DH,
>   Could you be more specific describing what you have and what you want? 
> You are addressing people, many of whom are good at
> stripping useless junk once you tell them what 'useless junk' is.
>   Also it helps to post some of you data that you need to process and a 
> sample of the same data as it should look once it is
> processed.
>
> Frederic
>
> - Original Message -
> From: "DH" <[EMAIL PROTECTED]>
> Newsgroups: comp.lang.python
> To: 
> Sent: Thursday, August 24, 2006 2:11 AM
> Subject: Taking data from a text file to parse html page
>
>
> > Hi,
> >
> > I'm trying to strip the html and other useless junk from a html page..
> > Id like to create something like an automated text editor, where it
> > takes the keywords from a txt file and removes them from the html page
> > (replace the words in the html page with blank space) I'm new to python
> > and could use a little push in the right direction, any ideas on how to
> > implement this?
> >
> > Thanks!
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Taking data from a text file to parse html page

2006-08-24 Thread DH
 I found this
http://groups.google.com/group/comp.lang.python/browse_thread/thread/d1bda6ebcfb060f9/ad0ac6b1ac8cff51?lnk=gst&q=replace+text+file&rnum=8#ad0ac6b1ac8cff51

Credit Jeremy Moles
---

finds = ("{", "}", "(", ")")
lines = file("foo.txt", "r").readlines()

for line in lines:
for find in finds:
if find in line:
line.replace(find, "")

print lines

---

I want something like
---

finds = file("replace.txt")
lines = file("foo.txt", "r").readlines()

for line in lines:
for find in finds:
if find in line:
line.replace(find, "")

print lines

---



Fredrik Lundh wrote:
> DH wrote:
>
> > I have a plain text file containing the html and words that I want
> > removed(keywords) from the html file, after processing the html file it
> > would save it as a plain text file.
> >
> > So the program would import the keywords, remove them from the html
> > file and save the html  file as something.txt.
> >
> > I would post the data but it's secret. I can post an example:
> >
> > index.html (html page)
> >
> > "
> > "Python has been an important part of Google since the
> > beginning, and remains so as the system grows and evolves.
> > "
> > -- Peter Norvig,  > "
> >
> > replace.txt (keywords)
> > "
> > 
> >
> > "
> >
> > "
> >
> > -- Peter Norvig,  >
> > "
> >
> > something.txt(file after editing)
> >
> > "
> >
> > Python has been an important part of Google since the beginning, and
> > remains so as the system grows and evolves.
> > "
>
> reading and writing files is described in the tutorial; see
>
>  http://pytut.infogami.com/node9.html
>
> (scroll down to "Reading and Writing Files")
>
> to do the replacement, you can use repeated calls to the "replace" method
>
>  http://pyref.infogami.com/str.replace
>
> but that may cause problems if the replacement text contains things that
> should be replaced.  for an efficient way to do a "parallel" replace, see:
>
>  http://effbot.org/zone/python-replace.htm#multiple
> 
> 
> 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Taking data from a text file to parse html page

2006-08-24 Thread DH
SE looks very helpful... I'm having a hell of a time installing it
though:

-

[EMAIL PROTECTED]:~/Desktop/SE-2.2$ sudo python SETUP.PY install
running install
running build
running build_py
file SEL.py (for module SEL) not found
file SE.py (for module SE) not found
file SEL.py (for module SEL) not found
file SE.py (for module SE) not found

--
Anthra Norell wrote:
> You may also want to look at this stream editor:
>
> http://cheeseshop.python.org/pypi/SE/2.2%20beta
>
> It allows multiple replacements in a definition format of utmost simplicity:
>
> >>> your_example = '''
> "Python has been an important part of Google since the
> beginning, and remains so as the system grows and evolves.
> "
> -- Peter Norvig,  '''
> >>> import SE
> >>> Tag_Stripper = SE.SE ('''
>  "~<(.|\n)*?>~="   # This pattern finds all tags and deletes them 
> (replaces with nothing)
>  "~~="   # This pattern deletes comments entirely even 
> if they nest tags
>  ''')
> >>> print Tag_Stripper (your_example)
>
> "Python has been an important part of Google since the
> beginning, and remains so as the system grows and evolves.
> "
> -- Peter Norvig, 
> Now you see a tag fragment. So you add another deletion to the Tag_Stripper 
> (***):
>
> Tag_Stripper = SE.SE ('''
>  "~<(.|\n)*?>~="   # This pattern finds all tags and deletes them 
> (replaces with nothing)
>  "~~="   # This pattern deletes commentsentirely even 
> if they nest tags
>  "  # "-- Peter Norvig,  Norvig has to go too
>''')
> >>> print Tag_Stripper (your_example)
>
> "Python has been an important part of Google since the
> beginning, and remains so as the system grows and evolves.
> "
> -- Peter Norvig,
>
> " you can either translate or delete:
>
> Tag_Stripper = SE.SE ('''
>  "~<(.|\n)*?>~="   # This pattern finds all tags and deletes them 
> (replaces with nothing)
>  "~~="   # This pattern deletes commentsentirely even 
> if they nest tags
>  "  # "-- Peter Norvig,  Peter Norvig has to go too
>  htm2iso.se # This is a file (contained in the SE package that 
> translates all ampersand codes.
>   # Naming the file is all you need to do to 
> include the replacements which it defines.
>''')
>
> >>> print Tag_Stripper (your_example)
>
> 'Python has been an important part of Google since the
> beginning, and remains so as the system grows and evolves.
> '
> -- Peter Norvig,
>
> If instead of "htm2iso.se" you write ""=" you delete it and your output 
> will be:
>
> Python has been an important part of Google since the
> beginning, and remains so as the system grows and evolves.
>
> -- Peter Norvig,
>
> Your Tag_Stripper also does files:
>
> >>> print Tag_Stripper ('my_file.htm', 'my_file_without_tags')
> 'my_file_without_tags'
>
>
> A stream editor is not a substitute for a parser. It does handle more 
> economically simple translation jobs like this one where a
> parser does a lot of work which you don't need.
>
> Regards
>
> Frederic
>
>
> - Original Message -
> From: "DH" <[EMAIL PROTECTED]>
> Newsgroups: comp.lang.python
> To: 
> Sent: Thursday, August 24, 2006 7:41 PM
> Subject: Re: Taking data from a text file to parse html page
>
>
> > I found this
> >
> http://groups.google.com/group/comp.lang.python/browse_thread/thread/d1bda6ebcfb060f9/ad0ac6b1ac8cff51?lnk=gst&q=replace+text+file&r
> num=8#ad0ac6b1ac8cff51
> >
> > Credit Jeremy Moles
> > ---
> >
> > finds = ("{", "}", "(", ")")
> > lines = file("foo.txt", "r").readlines()
> >
> > for line in lines:
> > for find in finds:
> > if find in line:
> > line.replace(find, "")
> >
> > print lines
> >
> > ---
> >
> > I want something like
> > ---
> &g

Re: Taking data from a text file to parse html page

2006-08-25 Thread DH
Yes I know how to import modules... I think I found the problem, Linux
handles upper and lower case differently, so for some reason you can't
import SE but if you rename it to se it gives you the error that it
can't find SEL which if you rename it will complain that that SEL isn't
defined... Are you running Linux? Have you tested it with Linux?

> Surely you write your own programs. (program_name.py). You import and run 
> them. You may put SE.PY and SEL.PY into the same
> directory. That's all.
>   Or if you prefer to keep other people's stuff in a different directory, 
> just make sure that directory is in "sys.path",
> because that is where import looks. Check for that directory's presence in 
> the sys.path list:
>
> >>> sys.path
> ['C:\\Python24\\Lib\\idlelib', 'C:\\', 'C:\\PYTHON24\\DLLs', 
> 'C:\\PYTHON24\\lib', 'C:\\PYTHON24\\lib\\plat-win',
> 'C:\\PYTHON24\\lib\\lib-tk' (... etc)]
>
> Supposing it isn't there, add it:
>
> >>> sys.path.append ('/python/code/other_peoples_stuff')
> >>> import SE
>
> That should do it. Let me know if it works. Else just keep asking.
>
> Frederic
>
>
> - Original Message -
> From: "DH" <[EMAIL PROTECTED]>
> Newsgroups: comp.lang.python
> To: 
> Sent: Friday, August 25, 2006 4:40 AM
> Subject: Re: Taking data from a text file to parse html page
>
>
> > SE looks very helpful... I'm having a hell of a time installing it
> > though:
> >
> > -
> >
> > [EMAIL PROTECTED]:~/Desktop/SE-2.2$ sudo python SETUP.PY install
> > running install
> > running build
> > running build_py
> > file SEL.py (for module SEL) not found
> > file SE.py (for module SE) not found
> > file SEL.py (for module SEL) not found
> > file SE.py (for module SE) not found
> >
> > --
> > Anthra Norell wrote:
> > > You may also want to look at this stream editor:
> > >
> > > http://cheeseshop.python.org/pypi/SE/2.2%20beta
> > >
> > > It allows multiple replacements in a definition format of utmost 
> > > simplicity:
> > >
> > > >>> your_example = '''
> > > "Python has been an important part of Google since the
> > > beginning, and remains so as the system grows and evolves.
> > > "
> > > -- Peter Norvig,  > > '''
> > > >>> import SE
> > > >>> Tag_Stripper = SE.SE ('''
> > >  "~<(.|\n)*?>~="   # This pattern finds all tags and deletes them 
> > > (replaces with nothing)
> > >  "~~="   # This pattern deletes comments entirely 
> > > even if they nest tags
> > >  ''')
> > > >>> print Tag_Stripper (your_example)
> > >
> > > "Python has been an important part of Google since the
> > > beginning, and remains so as the system grows and evolves.
> > > "
> > > -- Peter Norvig,  > >
> > > Now you see a tag fragment. So you add another deletion to the 
> > > Tag_Stripper (***):
> > >
> > > Tag_Stripper = SE.SE ('''
> > >  "~<(.|\n)*?>~="   # This pattern finds all tags and deletes them 
> > > (replaces with nothing)
> > >  "~~="   # This pattern deletes commentsentirely 
> > > even if they nest tags
> > >  " > >  # "-- Peter Norvig,  > > Peter Norvig has to go too
> > >''')
> > > >>> print Tag_Stripper (your_example)
> > >
> > > "Python has been an important part of Google since the
> > > beginning, and remains so as the system grows and evolves.
> > > "
> > > -- Peter Norvig,
> > >
> > > " you can either translate or delete:
> > >
> > > Tag_Stripper = SE.SE ('''
> > >  "~<(.|\n)*?>~="   # This pattern finds all tags and deletes them 
> > > (replaces with nothing)
> > >  "~~="   # This pattern deletes commentsentirely 
> > > even if they nest tags
> > >  " > >  # "-- Peter Norvig,  > > if Peter Norvig has to go too
> > >

Re: M$ windows python libs installed in arbitrary directories forcustomized python distributions

2006-08-29 Thread DH
Fredrik Lundh wrote:
> alf wrote:
> 
>> ok, let me clarify, by M$ I meant Micro$oft.
> 
> http://www.catb.org/~esr/faqs/smart-questions.html#writewell
> 
> 
> 

And by /F, you mean fuck off?

http://www.libervis.com/blogs/15/Jastiv/eric_raymond_and_the_rtfm_jerks
http://www.codinghorror.com/blog/archives/000603.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: attribute decorators

2006-12-22 Thread DH

Fredrik Lundh wrote:
> Gert Cuykens wrote:
>
> > would it not be nice if you could assign decorators to attributes too ?
> > for example
> >
> > class C:
> > @staticattribute
> > data='hello'
> >
> > or
> >
> > class C:
> > @privateattribute
> > data='hello'
>
> and that would do what?
>
> 

Don't mind Fredrik's trolling.  Your examples are perfectly clear,
however, a similar call for extending the use of decorators to other
structures besides functions was rejected:
http://lambda-the-ultimate.org/node/1389

I'm not sure if that decision still stands with Python 3000, however,
Guido has changed his mind before:
http://www.artima.com/weblogs/viewpost.jsp?thread=87182

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: VB to Python migration

2006-01-28 Thread DH
see vb2py to help the conversion
http://vb2py.sourceforge.net/
or if you want to convert vb6 to vb.net instead, there are tools from 
microsoft and others to help with that, such as:
http://www.microsoft.com/downloads/details.aspx?FamilyId=10C491A2-FC67-4509-BC10-60C5C039A272&displaylang=en

or if you want to start over from scratch, the other recommendations are 
good, like pyqt and qt designer, or else do it as a web app instead of 
desktop app if it just involves basic form controls.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Another try at Python's selfishness

2006-02-02 Thread DH
[EMAIL PROTECTED] wrote:
> Having read previous discussions on python-dev I think I'm not the only
> Python programmer who doesn't particularly like python's "self"
> parameter:
> 
> class Foo:
> def bar(self, a,b):
> return a+b
> Foo().bar(1,2) => 3
> 
> The main reason (at least for me) is that there's simply too much
> "magic" in it. Why does the expression left of the '.' get promoted to
> the first parameter? It even goes further:
> 
> Foo.bar(Foo(), 1,2)
> 
> works, but:
> 
> Foo.bar(1,2,3)
> 
> doesn't, just because of the "magical first parameter" in a member
> function. But:
> 
> Foo.__dict["bar"]__(1,2,3)
> 
> Does work.
> 
> The point is, I _do_ think it's a good idea to explicitly write
> "self.SomeMember" for member-access, so I thought: why can't we be
> equally explicit about member function declaration? Wouldn't it be nice
> if I could write (say, in Python 3k, or maybe later):
> 
> class Foo:
> def self.bar(a,b):
> return a+b
> Foo().bar(1,2) => 3

That's similar to ruby.  Really this isn't going to change in python,
at least not anytime soon.  If it really bothers you, then ruby is 
something to look into.
But I think most people who don't like the extraneous 'self' in python 
just consider it a minor inconvenience and don't even notice it after 
using python for a while.  It is only when you switch between python and 
other languages that you notice it again.

If python extends decorators to allow them to be applied to classes as 
well as functions (which is more likely to happen perhaps), then you'll 
see a bunch of useful hacks pop up to eliminate the need for 'self' in 
method declarations.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Another try at Python's selfishness

2006-02-08 Thread DH
Frithiof Andreas Jensen wrote:
> <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Having read previous discussions on python-dev I think I'm not the only
>> Python programmer who doesn't particularly like python's "self"
>> parameter:
> 
> Ok, there might be five programmers and one imam. The imam does not like
> anything more recent than 700 A.D ...
> 


You Danes and your Muslim jokes :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jedit

2006-02-13 Thread DH
ziggy wrote:
> Just wondering if there is something out there like Jedit, but written 
> in python ( not just supporting, but actually written in it.. )
> 
> Nothing large like Stanzi's or Boa.. Just something quick and simple, 
> with code completion, and a debugger..

No.  The only editors with features like JEdit are vim and emacs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic gui format?

2006-02-13 Thread DH
Bruno Desthuilliers wrote:
>> I am currently seeking for pythonic alternative for XML. 
> 
> A pretty obvious one is dicts and lists. What about (Q&D):


That's like JSON: http://www.json.org/example.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: PyGUI 1.6

2006-02-13 Thread DH
Wolfgang Keller wrote:
> Hello,
> 
> On Sun, 12 Feb 2006 07:50:56 +0100, greg wrote
> (in article <[EMAIL PROTECTED]>):
>> PyGUI is an experimental highly-Pythonic cross-platform
>> GUI API.
> 
> How "experimental" (or useable for productivity applications) would you 
> consider it compared to e.g. wxwidgets?
> 
> And, btw; I couldn't immediately figure out from the documentation which 
> widgets it supports. Does it support the Cocoa outline view, for example?

It sounds like you probably should stick with either wxpython or cocoa.

PyGUI is sort of a wrapper for other gui toolkits (only gtk & cocoa 
right now), to simplify the development of basic gui apps.
See the 'visual classes' part of the docs page for the controls it
supports.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic gui format?

2006-02-14 Thread DH
bruno at modulix wrote:
> DH wrote:
>> Bruno Desthuilliers wrote:
>>
>>>> I am currently seeking for pythonic alternative for XML. 
>>>
>>> A pretty obvious one is dicts and lists. What about (Q&D):
>>
>> That's like JSON: http://www.json.org/example.html
> 
> No, it's pure Python. It happens that JSON looks pretty close to Python,
> but that's another point.

Python dict and lists ARE JSON.  The only difference that python can't
handle is multiline comments.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic gui format?

2006-02-14 Thread DH
Gregory Petrosyan wrote:
> Thanks for JSON. It's more clean&simple than XML, but my main idea is
> to remove any extra layer between Python and GUI. I want all GUI
> elements/data to be directly accessible from Python (without extra
> libraries).

Since JSON is just python dicts and lists, you don't need an extra 
library to use it, essentially.


> Your dicts example is nice, but this  approach (and some others) lacks
> one important feature: ordering of GUI elements. In XML, the order of
> all elements is specified, and with dicts (or with very clean Georg's
> model) it is not. (BTW remember topics about ordered dicts...)

That's a good point.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic gui format?

2006-02-14 Thread DH
bruno at modulix wrote:
> DH wrote:
>> bruno at modulix wrote:
>>
>>> DH wrote:
>>>
>>>> Bruno Desthuilliers wrote:
>>>>
>>>>>> I am currently seeking for pythonic alternative for XML. 
>>>>>
>>>>> A pretty obvious one is dicts and lists. What about (Q&D):
>>>>
>>>> That's like JSON: http://www.json.org/example.html
>>>
>>> No, it's pure Python. It happens that JSON looks pretty close to Python,
>>> but that's another point.
>>
>> Python dict and lists ARE JSON.  The only difference that python can't
>> handle is multiline comments.
> 
> And what about true vs True and false vs False ?-)

The syntax is the same, except for, as I said, JSON's multiline comments.
The semantics do differ, but that has nothing to do with the user's
question, about an alternative to XML for data representation.  You
can use "true" or True or "null" or None or whatever semantic values
you want.

You can use the JSON library if you want.  But there really is no
need in this case.  Just import the file containing the dicts and lists.

> No, Python's dicts and lists are not JSON. 

Which are syntactically identical to JSON's.

 > They are Python's dicts and
> lists. JSON stands for JavaScript Object Notation, and AFAIK, Python and
> javascript are two different languages

No shit.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Embedding an Application in a Web browser

2006-02-14 Thread DH
bruno at modulix wrote:
> rodmc wrote:
>> Is it possible to embed a Python application within Internet explorer?
> 
> No. Nor in any other browser (except from Grail, but I think this
> doesn't count).

You can if you use IronPython.  Of course it will only work with
Internet Explorer on windows.
Java and JVM languages are of course much better for applets: jython, 
groovy, jruby, etc.  I don't know if jython or jruby applets are 
actually possible however since it is interpreted.


>> However if someone clicks
>> on a shape it should open up another application, such as Word.
> 
> Lol. This would be a really big bad security issue.

Look up Microsoft's smart client api.  It is their answer to java web start.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python vs. Lisp -- please explain

2006-02-18 Thread DH
[EMAIL PROTECTED] wrote:
> A few years ago I
> had an AI class where we had to use Lisp, and I absolutely hated it,
> having learned C++ a few years prior.  They didn't teach Lisp at all
> and instead expected us to learn on our own.

CS classes haven't changed, I see.

> In learning Python I've read more about Lisp than when I was actually
> trying to learn it, and it seems that the two languages have lots of
> similarities:
> 
> http://www.norvig.com/python-lisp.html
> 
> I'm wondering if someone can explain to me please what it is about
> Python that is so different from Lisp that it can't be compiled into
> something as fast as compiled Lisp?  From this above website and
> others, I've learned that compiled Lisp can be nearly as fast as C/C++,
> so I don't understand why Python can't also eventually be as efficient?
>  Is there some *specific* basic reason it's tough?  Or is it that this
> type of problem in general is tough, and Lisp has 40+ years vs Python's
> ~15 years?

It is by design. Python is dynamically typed.  It is essentially an 
interpreted scripting language like javascript or ruby or perl, although 
python fans will be quick to tell you python is compiled to byte code. 
They'll also be quick to tell you:
-python has true closures (although nothing like ruby's blocks)
-is beginner friendly (despite being case sensitive and 3/4==0, for example)
-is not, in fact, slow at all (despite benchmarks as you noted showing 
otherwise).
Judge for yourself.

There are projects that combine static typing + the python syntax, which
result in dramatically faster code, but perhaps only 80% of python's
functionality and less flexibility you get from dynamic typing. 
Projects like shedskin.  But some python fans don't think 80% cuts it, 
even if you do get a 100 fold speed increase.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-line lambda proposal.

2006-05-09 Thread DH
Kaz Kylheku wrote:
> I've been reading the recent cross-posted flamewar, and read Guido's
> article where he posits that embedding multi-line lambdas in
> expressions is an unsolvable puzzle.

To say that multi-line lambda is an unsolvable problem is completely
absurd.  Furthermore it has already been solved.
http://wiki.python.org/moin/AlternateLambdaSyntax#head-c81743c0b461ab6812564785c7bc7ba581dec6fa
So I agree with you, but I doubt you'll have any luck getting your
proposal or any other multiline lambda proposal accepted into python
anytime soon.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The whitespaceless frontend

2006-04-15 Thread DH
Stelios Xanthakis wrote:
> It had to happen :)
> 
> http://pyvm32.infogami.com/EPL
> 
> Seriously, this is not so much about the whitespace as for the
> new features, which might interest people who are thinking about
> new features. More specifically, "methods" and the "$" operator
> are really great and seem to solve the problem with having to
> type "self." all the time.  The new syntax has been tested in
> core libraries of pyvm.
> 
> Feedback is welcome, but preferably not in c.l.py because indentation
> can be a dangerous topic :)

Very nice work.  Lotta good ideas (of course that will never show up in
in standard python, but who cares).  I would mention though if you had 
used "end" for block delimiters (like ruby) instead of curly braces, 
there would be no conflict with dictionary literals.  I made such a
parser for another project.  Just my opinion but "end" looks a bit
cleaner too than curly braces.  Now if only you could make python
100 times faster, too.
-- 
http://mail.python.org/mailman/listinfo/python-list


access read / write violation with ctypes

2009-08-05 Thread DH
Hi all,

I'm quite new to cytpes and am having some troubles I was hoping I
could get a little help with. Before I get into the details this is
what I'm trying to accomplish - I would like to read a dng with python
pass it through either libraw.dll or dcraw.dll (notes on dcraw.dll
version at the end) for initial processing then to MagickWand for some
light enhancement and final jpeg output. After I get these working I
will see how I can add LittleCMS into the fray. I'm not doing
something correctly but don't know what. I've read a lot of documents
over the past couple days and though I've learned quite a lot I just
can't get past this access violation error.

I very grateful for anything that can be offered.

dh

...

I am currently working out MagickWand and dcraw separately but am
having similar troubles with both resulting in either 'Windows Error:
exception: access violation reading 0x' or alternatively
'Windows Error: ... writing'

1 - MagickWand (read violation):

I'm using popen to capture dcraw stdout and want to pass it to
magickwand. If I instead write the dcraw output to a file then read it
with magickwand I get the same error. But if I comment out the dcraw
protion and read the dcraw output file from the previous attempt,
MagickWand opens the file fine and I can manipulate it to my hearts
content. The basics:

proc = subprocess.Popen("dcraw -c -4 -T image.dng", shell=True,
close_fds=False, stdout=subprocess.PIPE).communicate()[0]

magickWandLib = 'C:\\Program Files (x86)\\ImageMagick-6.5.3-Q16\
\CORE_RL_wand_.dll'
Magick = cdll.LoadLibrary(magickWandLib)

Magick.MagickWandGenesis()
wand = Magick.NewMagickWand()

Magick.MagickReadImageFile(proc)
-> access violation reading

2 - DCRaw (write violation):

I've been bouncing between libraw.dll and dcraw.dll. The dcraw version
I'm using is found at
http://translate.google.com/translate?hl=en&sl=es&tl=en&u=http://www.ojodigital.com/foro/perfectraw-perfectblend/206898-perfectraw-0-5-a.html
. Libraw is limited in the sence that it is mainly suited to loading
and unpacking raw images. Actual processing is done only in emulation
mode which I have not yet been able to access throught the library.
PerfectRaw uses a tweaked and librarised version of dcraw with thier
GUI + some enhanced functions. I'm only interesed in the dll though

2.1 - libraw.dll

I won't go into great detail as I can get it to work but only open,
unpack and write out a tiff or ppm. No process settings

2.2 - dcraw.dll

I can load the library but cannot initialise an instance. Each attempt
in a variety or methods always returns an 'access violation writing
0x'. The parameters I use to initialise are taken from a test
program provided by the authors.

test app:
int w,h;
printf("Resultado de leer el RAW: %i\n",DCRAW_Init("c:\\test\
\IMG_4118.CR2",&w,&h)

python:
dcraw_lib = 'C:\\programs\\PerfectRaw\\dcraw.dll'
dcraw = ctypes.cdll.LoadLibrary(dcraw_lib)

img = 'C:\\programs\\PerfectRaw\\image.dng'
dcraw.DCRAW_Init(img,4000,3000) # canon G9 converted to dng
-> access violation writing

-- 
http://mail.python.org/mailman/listinfo/python-list