Re: do design patterns still apply with Python?

2006-03-02 Thread Thomas G. Willis
On 3/2/06, Terry Hancock <[EMAIL PROTECTED]> wrote:
On Thu, 02 Mar 2006 16:38:44 -0500Roy Smith <[EMAIL PROTECTED]> wrote:> In article <[EMAIL PROTECTED]
>,>  John Salerno <[EMAIL PROTECTED]> wrote:> > Since Python does so many things different, especially> > compared to  compiled and statically typed languages, do
> > most of the basic design  patterns still apply when> > writing Python code? If I were to read a  design pattern> > book (such as Head First Design Patterns), could I apply> > their Java examples to Python easily enough, or does
> > Python require a  different perspective when applying> > patterns?> [...]> The basic concepts in the pattern books are worth knowing.>  You just have> to be able to tease apart the concepts from the
> language-specific cruft  that so often obfuscates the> descriptions.This sounds like an article crying out to be written,"(Learning) Design Patterns with Python".Has it been written already?
Cheers,TerryBruce Eckel began writing "Thinking In Python" it was last updated in 2001.He's a busy dude with a lot on his plate, so finishing it or updating it isn't known.
I emailed him once about it and actually got a cordial reply which amounted to,..."I have no time but I'd love to finish it" But, the draft does have some interesting tidbits in it and it's worth a look I think. You def. get the message that patterns apply a lot differently in python as compared to the {...;} languages.
Details here.http://mindview.net/Books/Python/ThinkingInPython.html-- Thomas G. Willis---
http://i-see-sound.comhttp://tomwillis.sonicdiscord.comAmerica, still more rights than North Korea
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: dict is really slow for big truck

2009-05-01 Thread Thomas G. Willis
On Apr 28, 8:54 am, forrest yang  wrote:
> i try to load a big file into a dict, which is about 9,000,000 lines,
> something like
> 1 2 3 4
> 2 2 3 4
> 3 4 5 6
>
> code
> for line in open(file)
>    arr=line.strip().split('\t')
>    dict[arr[0]]=arr
>
> but, the dict is really slow as i load more data into the memory, by
> the way the mac i use have 16G memory.
> is this cased by the low performace for dict to extend memory or
> something other reason.
> is there any one can provide a better solution

I think you need to upgrade the l2 cache on your cpu.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Not fully OO ?

2008-09-20 Thread Thomas G. Willis
On Sep 20, 5:23 am, candide <[EMAIL PROTECTED]> wrote:
> Excerpt quoted fromhttp://www.astro.ufl.edu/~warner/prog/python.html:
>
> "About Python: Python is a high level scripting language with object
> oriented features.
> (...)
> Python supports OOP and classes to an extent, but is not a full OOP
> language."
>
> Thanks for any comment.

My comment is "Who cares?"

I was always under the impression that if any language truly was "OO"
it would be smalltalk. And I don't derive any benefit from smalltalk
at all. I do however derive substantial benefit from other languages
that "OO zealots" would likely poo poo on including python.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Linq to Python

2008-09-23 Thread Thomas G. Willis

> But surely the idea behind it will eventually spread.  It's really
> just comprehensions generalized over XML and relational datasets, a
> noble goal.  Besides, it's main purpose for .NET was to bring
> functional programming to it.  Python already has that, somewhat...

it's really any object out of the box, i think the sql linq stuff is
more of a query compiler, IMO sqlalchemy does that.


query = select(user_cols,

and_(table_relationship.c.accept_user_id==user.id,

table_relationship.c.start_date==None

),

from_obj=join(

table_relationship,table_user,

onclause=table_user.c.id==table_relationship.c.init_user_id

).outerjoin(table_profile)

)

session.execute(query).fetchall()






XML? meh hopefully I would never need it. :)


C# is my day job, and when I got my hands on LINQ back in January my
initial thought was "Finally I have list comprehensions day job is
fun again"

For the most part, I think C# is catching up.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Linq to Python

2008-09-24 Thread Thomas G. Willis
On Wed, Sep 24, 2008 at 11:25 AM, hrishy <[EMAIL PROTECTED]> wrote:

> Hi Tom
>
> This is what i like and feel of the Python programmers smarter then every
> other langauge i know of.
>
> But i am not comfortable with your second statement XML i never need it
> one day everybody would need it.
>
>
> regards
> Hrishy
>
>
Well you may be right which is why I said "hopefully" one thing I do know
is  that in my work in both .net and java, XML plays a more significant
role. Everyone can probably speculate differently as to why this is. My
personal feeling is that it is because XML is less of a hassle than
building/passing around class hierarchies for application state in various
scenarios.But in python, it is far easier for me to pass around a dict or
some similar structure to get roughly the same effect. So in my mind, XML
solves a problem that is present in both .net and java, but not necessarily
python. In the same way, linq to xml solves the problem of handling xml in a
more convenient way.  In order for it to be useful in python, the problem
that xml solves would have to be present IMO.

That's not to say it's not possible. Someone who needs something like LINQ
to XML but in python could write something probably similar to what
sqlalchemy does and it would require no changes to the python language or
runtime. If it was written then maybe people would invent ways to use XML in
python that are better than what other things do. Hooray for the free market
of ideas. :)


This is all my opinion , I have no idea what the conventional wisdom of the
python community is on XML, but in my experience in other languages, it
seems to be the answer to a question that no one asked, or the wrong answer,
more often than it is the appropriate answer. Maybe it's only that way on
OHIO. :)




-- 
Thomas G. Willis
--
http://mail.python.org/mailman/listinfo/python-list

Re: Linq to Python

2008-09-24 Thread Thomas G. Willis
On Sep 24, 4:59 pm, Duncan Booth <[EMAIL PROTECTED]> wrote:
...
> I haven't yet had occasion to use LINQ in anger yet, so I have no idea
> whether its an idea to love or to hate. I do think it is good that C# has
> effectively sprouted list comprehensions (not to mention anonymous types
> and type inferencing) and I expect there may be some aspects worth looking
> at for Python but I think they are more likely to lead to itertools
> functions than extensions to syntax.

My thoughts exactly when I first looked at it. "Hey C# NOW has list
comprehensions!!! SWEET!!!"

As I understand it LINQ is libraries(System.Data.Linq.dll,
System.XML.Linq.dll) + syntactic sugar, i wouldn't call that a change
to the language. The addition of lambdas and functions as first class
objects however, that was indeed a language change, and it was a
change for the better that makes LINQ possible, (also makes writing
delegates less cumbersome). To someone other than a C# person, these
features are not new or revolutionary, it's just C# catching up. Kudos
to them for getting there before java.

After some more thought on what might conceivably be missing from
python that LINQ has, that someone might want is the equivalent of
System.XML.Linq.dll, and I can't see any reason why someone couldn't
write it with the exception that there doesn't seem to be a definitive
XML lib for python, meaning generally regarded as the best. That in my
mind would be a prerequisite. But if someone wrote both the XML lib
with the LINQ-ish syntax, maybe it would become the definitive XML
lib.

Again, I personally don't see myself using XML and thus needing that
unless my hand was forced by some business requirement that dictated I
use XML, I would not use it if I had a choice. The SQL LiNQ-ish
though, I think every python ORM has that covered to a degree, and I
use that quite a bit.



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


Re: New python.org website

2006-03-08 Thread Thomas G. Willis
I don't necessarily like it, but I think the true test is whether a pointy haired manager type can be convinced that python can be taken seriously as a welcome addition to the programming arsenal. I think the site re-design will aid in that area more so  than  the previous one.
I'm not feeling the new logo though. But it's better than what I can produce in an svg editor/ -- Thomas G. Willis---
http://i-see-sound.comhttp://tomwillis.sonicdiscord.comAmerica, still more rights than North Korea
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: New python.org website

2006-03-08 Thread Thomas G. Willis
On 3/8/06, Robert Boyd <[EMAIL PROTECTED]> wrote:
On 8 Mar 2006 07:47:15 -0800, Michael Tobis <[EMAIL PROTECTED]> wrote:> > No one> > of the complainers and negativists do claim that they could do it much
> > better.>> Indeed, I do not have to be able to write a particular program to> notice it has bugs.>> On the other hand, (since I think the design, while not brilliant, is> good) fixing the logo is something that can be achieved without too
> much fuss.> [snip]While I don't dislike the logo, there has been a lot of grumblingabout it. Dislike has been due to aesthetic reasons, or theresemblance to a cross, or general "it's not as good as x".
So I gave it another close look, and I wondered if this would improve it:Retain the stylized blue snake. Remove the yellow snake, but keep itsbody that's in line horizontally with the blue snake's, and color it
blue. Result: one snake with a horizontal tail that curls up slightlyat the right edge.When I first saw it I thought "twisted" than I thought "is that a cross?"  then I thought maybe it's a messed up yin/yang.
I thought the yin/yang idea might be interesting, and maybe would work but the overall shape needs to be more circular to convey that idea better.But I'm no graphic designer
-- Thomas G. Willis---http://i-see-sound.comhttp://tomwillis.sonicdiscord.com
America, still more rights than North Korea
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: python debugging question

2006-03-08 Thread Thomas G. Willis
On 8 Mar 2006 13:23:44 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
I am a python newbie. I have writen some 500 lines of code. There are 4classes and in all 5 files.
Now, I am trying to run the program. I am getting wrong values for thesimulation results.Is there any debugging facilities in python which would let me go stepby step and check the values of the variables at every step. I have
done something like this in MS Visual Stdio 6.0 sometime back.For python, I am using SPE.what is a good way of debugging such large and iterative programs ? Anytips.Every help is appreciated.
Thanks--http://mail.python.org/mailman/listinfo/python-listThis might help.
http://www.onlamp.com/pub/a/python/2005/09/01/debugger.html-- Thomas G. Willis---http://i-see-sound.com
http://tomwillis.sonicdiscord.comAmerica, still more rights than North Korea
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python Evangelism

2006-03-09 Thread Thomas G. Willis
I used to get all fired up about the language I love. And I'd
evangelize a bit. But I'm getting too old for that. Energy could be
better spent utilizing the tools you like. Sort of a "If you build it,
they will come..." kind of thing.


I get particulalry annoyed now with linux when I start up synaptic and
my choices are cluttered with several programs who might help me in
some way, but the only difference described in the description is that
they were implemented in language XXX.  I don't really consider
that a choice, it's more noise than anything.

On the other hand, programs that really do seem to be valuable don't
seem to be screaming about what language they are written in.  I
had no idea the original BitTorrent was written in python, or scons
when I installed it. Bittorrent helps me get files faster, scons helps
me build ardour. They could be written in lisp for all I care, it
benefits me nonetheless. 

My opinion is that providing programs that benefit people in some way
could go a lot farther in promoting the language than propoganda about
what you can do with the language. Shouting about the potential of the tools will only get you so far. 


Rails is the killer framework of the moment. So what? Where's the
killer app that helps me do something new? All i hear about is people
writing frameworks on top of rails to do things that can already be
done. CMS's for example, there are some written in rails. To my
knowledge none of them are mature yet, and thus the only "selling"
point I hear about "written in rails".  Benefit to me as a user
still = 0%.

How about this? someone write an interface to the quake3 engine, and make it damn easy for kids to write games and game mods.

or...

Make it possible to write ladspa plugins so that I can write crazy effects for ardour.

or...

an itunes like music manager that doesn't lock all my music away and
handles m3u files properly out of the box. With a plug in system so
people can extend it.


don't even mention it was done in python, if it's done right, the true
value will be apparent and your users will do the evangelizing for you.

OK, I will now return to my happy place. :)

-- Thomas G. Willis---http://i-see-sound.comhttp://tomwillis.sonicdiscord.com
America, still more rights than North Korea
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python Evangelism

2006-03-10 Thread Thomas G. Willis
...In any case, I'm sure Django was a great musician, but theproduct needs a better name to have any chance of displacing Rails.
|>oug

Yes he was an amazing guitarist. If you ever listen to his stuff, keep
in mind he had 2 working fingers on his fret hand, and ripping on a
guitar that would be considered impossible to play by todays standards.

When I saw Django as a python based web framework, I got a positive vibe from the name of it. But then I'm also a guitarist.
 -- Thomas G. Willis---http://i-see-sound.comhttp://tomwillis.sonicdiscord.com
America, still more rights than North Korea
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Pycrypto - active ??

2006-03-20 Thread Thomas G. Willis
On 19 Mar 2006 13:39:58 -0800, dirvine <[EMAIL PROTECTED]> wrote:
Does anyone know if pycrypto is active at allThis was one of the packages that was updated today on my gentoo box. so, I would say yes.-- Thomas G. Willis---
http://i-see-sound.comhttp://tomwillis.sonicdiscord.comAmerica, still more rights than North Korea
-- 
http://mail.python.org/mailman/listinfo/python-list