Re: Apache2 + Python WITHOUT mod_pytho

2008-06-25 Thread Jorge Godoy
pistacchio wrote:

 Hi to all!
 How can i configure apache2 so that it processes all .py files with
 python _without_ using mod_python?
 I'm on Ubuntu 8.4.

I have no idea about how to do that in Ubuntu.

Use fcgi or wsgi for your Python scripts.  There should be recipes around for 
your distribution.

-- 
Jorge Godoy  [EMAIL PROTECTED]

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


Re: IDE on the level of Eclipse or DEVc++?

2008-06-25 Thread Jorge Godoy
Ben Finney wrote:

 Bruno Desthuilliers [EMAIL PROTECTED] writes:
 
 If you're into clickodroms, you may want to have a look at Eric too.
 As far as i'm concerned, I still wait for something that would be
 worth dropping emacs + python-mode + ecb.
 
 I'm having the most success with this combination, yes. Though ecb is
 rather non-Emacs-like in its configuration, and seems to strongly
 expect to be run in graphical mode, it is still very powerful.

Heh...  I'm another one that keeps trying new things but comes back to Emacs 
all the time.

Eclipse is too heavy, NetBeans has a poor support, Eric is too mousy...



-- 
Jorge Godoy  [EMAIL PROTECTED]

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


Re: IDE on the level of Eclipse or DEVc++?

2008-06-25 Thread Jorge Godoy
[EMAIL PROTECTED] wrote:

 How is emacs on a windows platform?

Except for Windows using _emacs instead of .emacs, it was the same I had on 
Linux, last time I tried it... :-)

There are packages for Windows that have a lot of things pre-packaged to make 
it feel more like a Windows application, including keyboard shortcuts.

-- 
Jorge Godoy  [EMAIL PROTECTED]

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


Re: Organizing a Python project

2008-05-19 Thread Jorge Godoy
A.T.Hofkamp wrote:

 Also, why do you make a distinction between shared and non-shared code?
 You could simply eliminate 'shared' directory, and put its contents
 directly under myproject.

I would go further and make them individual projects, with their own version
control, code repository and then install them as eggs using setuptools.

This has been working fine for me in some projects and has the advantage of
being reusable in different big projects.

Also, using setuptools on each big project I don't have to worry with
dependencies because it downloads and installs everything to me when I
install the main project.

 Is there a way to set this up that is a bit more self contained? For
 example, at first I was somewhat hopeful that Python could ascend
 parent directories until it reached a directory that did not include
 an __init__.py file, and it could use this as a root for referring to
 packages and modules from any file contained within. (e.g. in the
 example project above, any file could refer to myproject.shared.mylib1
 so long as 'myproject' and all subdirectories contained an
 __init__.py, and the parent of 'myproject' didn't contain such a
 file). Evidently this is not the case, but it seems like it could be a
 useful feature in these situations.

Eggs would solve that as well.  They would behave like any other
installed library on your system.

-- 
Jorge Godoy  [EMAIL PROTECTED]

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


Re: about bsddb module

2008-05-04 Thread Jorge Godoy
cocobear wrote:

 On 5月3日, 下午7时17分, cocobear [EMAIL PROTECTED] wrote:
 How to deal with multiple databases in an file. I want to get the
 content of several databases.

(...)
 
 Anybody can help me?

I believe you can only have one database per file with the Python
abstraction...  But you can try this (straight from Google for sleepycat
multiple databases and sleepycat came from the docs for bsddb):

http://www.nextgen6.net/docs/db4.1.25/api_java/db_open.html

and pay attention to the details here:

http://forums.oracle.com/forums/thread.jspa?threadID=581528tstart=15



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

Re: design choice: multi-threaded / asynchronous wxpython client?

2008-04-27 Thread Jorge Godoy
bullockbefriending bard wrote:

 A further complication is that at a later point, I will want to do
 real-time time series prediction on all this data (viz. predicting
 actual starting prices at post time x minutes in the future). Assuming
 I can quickly (enough) retrieve the relevant last n tote data samples
 from the database in order to do this, then it will indeed be much
 simpler to make things much more DB-centric... as opposed to
 maintaining all this state/history in program data structures and
 updating it in real time.

If instead of storing XML and YAML you store the data points, you can do
everything from inside the database.

PostgreSQL supports Python stored procedures / functions and also support
using R in the same way, for manipulating data.  Then you can work with
everything and just retrieve the resulting information.

You might try storing the raw data and the XML / YAML, but I believe that
keeping those sync'ed might cause you some extra work.


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


Re: design choice: multi-threaded / asynchronous wxpython client?

2008-04-27 Thread Jorge Godoy
bullockbefriending bard wrote:

 3) I need to dump this data (for all races, not just current about to
 start race) to text files, store it as BLOBs in a DB *and* update real
 time display in a wxpython windowed client.

Why in a BLOB?  Why not into specific data types and normalized tables?  You
can also save the BLOB for backup or auditing, but this won't allow you to
use your DB to the best of its capabilities...  It will just act as a data
container, the same as a network share (which would not penalize you too
much to have connections open/closed).
--
http://mail.python.org/mailman/listinfo/python-list


Re: design choice: multi-threaded / asynchronous wxpython client?

2008-04-27 Thread Jorge Godoy
bullockbefriending bard wrote:

 Tempting thought, but one of the problems with this kind of horse
 racing tote data is that a lot of it is for combinations of runners
 rather than single runners. Whilst there might be (say) 14 horses in a
 race, there are 91 quinella price combinations (1-2 through 13-14,
 i.e. the 2-subsets of range(1, 15)) and 364 trio price combinations.
 It is not really practical (I suspect) to have database tables with
 columns for that many combinations?
 
 I certainly DO have a horror of having my XML / whatever else formats
 getting out of sync. I also have to worry about the tote company later
 changing their XML format. From that viewpoint, there is indeed a lot
 to be said for storing the tote data as numbers in tables.

I don't understand anything about horse races...  But it should be possible
to normalize such information into some tables (not necessarily one).  But
then, there is nothing that prevents you from having dozens of columns on
one table if it is needed (it might not be the most efficient solution
performance and disk space-wise depending on what you have, but it works).

Using things like that you can even enhance your system and provide more
information about each horse, its race history, price history, etc.

I love working with data and statistics, so even though I don't know the
rules and workings of horse racings, I can think of several things I'd like
to track or extract from the information you seem to have :-)

How does that price thing work?  Are these the ratio of payings for bets? 
What is a quinella or a trio?  Two or three horses in a defined order
winning the race?

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


Re: Problem with the strip string method

2008-03-02 Thread Jorge Godoy
Colin J. Williams wrote:

 Return a copy of the string with the
 leading and trailing characters removed.
  

 Only the last two examples below behave
 as expected.

They all looks OK to me.

 [Dbg] 'ab$%\n\rcd'.strip('%')
 'ab$%\n\rcd'

No % at the beginning or end of string.  Nothing changed.

 [Dbg] 'ab$%cd'.strip('$')
 'ab$%\n\rcd'

No $ at the beginning or end of string.  Nothing changed.  I believe that
you didn't copy this from the standard input due to the presence of \r\n
on the answer...

 [Dbg] 'ab$%cd'.strip('$')
 'ab$%cd'

No $ at the beginning or end of string.  Nothing changed.

 [Dbg] '  ab$%cd  '.strip('$')
 '  ab$%cd  '

No $ at the beginning or end of string.  Nothing changed.

 [Dbg] '  ab$%cd  '.strip('%')
 '  ab$%cd  '

No % at the beginning or end of string.  Nothing changed.

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


Re: How about adding rational fraction to Python?

2008-02-25 Thread Jorge Godoy
Paul Rubin wrote:

 Carl Banks [EMAIL PROTECTED] writes:
 Try doing numerical integration sometime with rationals, and tell me
 how that works out.  Try calculating compound interest and storing
 results for 1000 customers every month, and compare the size of your
 database before and after.
 
 Usually you would round to the nearest penny before storing in the
 database.

There are cases where the law requires a higher precision or where the
rounding has to be a floor or...

Some things make no sense and when dealing with money things make even less
sense to either protect the customer or to grant the State getting its
share of the transaction.

Here in Brasil, for example, gas stations have to display the price with 3
decimal digits and round the end result down (IIRC).  A truck filling 117
liters at 1.239 reais per liter starts making a mess...  If the owner wants
to track losses due to rounding or if he wants to make his inventory of
fuel accurately, he won't be able to save just what he billed the customer
otherwise things won't match by the end of the month.

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


Re: float / rounding question

2008-02-25 Thread Jorge Godoy
sabatier wrote:

 On Feb 25, 10:44 am, [EMAIL PROTECTED] wrote:
 Hi I'm very much a beginner with Python.
 I want to write a function to convert celcius to fahrenheit like this
 one:

 def celciusToFahrenheit(tc):
 tf = (9/5)*tc+32
 return tf

 I want the answer correct to one decimal place, so
 celciusToFahrenheit(12) would return 53.6.

 Of course the function above returns 53.601.

 How do I format it correctly?
 
 By the way, I tried this:
 
 return '%2.1f' % tf but that returns a string instead of a number.
 
 Any other suggestions?

But you are asking for a string on your format string above.

And also formatting make no sense in other context since a number is a
number and 53.60 and 53.6 are the same number (besides precision). 

You are concerned with how numbers are represented in binary.  When
displaying the value use the format string you shown above and all will
work. 

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


Re: Double underscores -- ugly?

2008-02-20 Thread Jorge Godoy
Ivan Illarionov wrote:

 I would like to see something like %init or init to be converted to
 __init__ behind the scenes. And $something to be converted to
 self.something. But, unfortunately, most Python people would consider
 this ugly just because Perl uses too much syntactic sugar and anything
 Perl-like is considered ugly in Python community. So, unless Perl die,
 I believe that Python will remain sugar-free.

A good text editor allows you to replace text.  Some of them can even do
that for you with macros when you save a document or open it for editing
(making it possible to go from $ to self and vice-versa).

Maybe using another tool would solve your problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Why not a Python compiler?

2008-02-06 Thread Jorge Godoy
Reedick, Andrew wrote:

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:python-
 [EMAIL PROTECTED] On Behalf Of Grant Edwards
 
 Nothing can travel faster than the speed of light
 _in_a_vacuum_.  There are situtaitons where things can (and
 regularly do) travel faster than light:
 http://en.wikipedia.org/wiki/Cherenkov_radiation
 
 
 Nope.  It propagates, not travels, faster than light.  Go ask a physicist
 to explain it.  It's odd...

So let me see if I understood this correctly: C travels, C++ propagates? :-)


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


Re: Is it explicitly specified?

2008-02-03 Thread Jorge Godoy
mario ruggier wrote:

 Is there any way to tell between whether a keyword arg has been explicitly
 specified (to the same value as the default for it) or not... For example:
 
 def func(key=None):
 do something with key
 
 But the following two usages give same results:
 
 func()
 func(key=None)
 
 It may sometimes be useful to make use of the conceptual difference
 between these two cases, that is that in one case the user did not specify
 any key and in the other the user explicitly specified the key to be None.
 
 Is there any way to tell this difference from within the called function?
 And if so, would there be any strong reasons to not rely on this
 difference? Would it be maybe a little abusive of what a keyword arg
 actually is?

If you change the idiom you use to:

 def myfunc(**kwargs):
... something = kwargs.get('something', None)
... print something
... 
 myfunc()
None
 myfunc(something='Something')
Something


Then you can test if 'something' is in kwargs dict or not.  If it isn't,
then you used the default value.  If it is, then the user
supplied 'something' to you, no matter what its value is.


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


Re: Python GUI toolkit

2008-02-03 Thread Jorge Godoy
Grant Edwards wrote:

 On 2008-02-03, Dotan Cohen [EMAIL PROTECTED] wrote:
 
 I would recommend Qt, as it is cross-platform and can look native on
 all systems.
 
 Qt doesn't look native on my system. I run XFCE, and native
 is GTK.
 
 Opera, KDE, GoogleEarth, Acrobat, and lots of other software
 are written in Qt.
 
 And they don't look native on systems that don't use Qt as the
 native widget set.

But then,  there's no toolkit that does.

GTK based toolkits don't look native on Qt based systems.  Same for a lot of
others.

What you can define is a platform as in operating system and then go with
what the mainstream providers use for that.  For Windows and Mac that is
easy, for *nix this is harder.


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


Re: Python GUI toolkit

2008-02-03 Thread Jorge Godoy
[EMAIL PROTECTED] wrote:

 what i meant was, i tried gtk, didnt like it, the main reason was that it
 had a very bad gui appeal for me, i did try my hand at wx , and i would
 have stuck with it, but then i saw the qt4 screenshot and couple of
 examples of its code and i liked it, so i was wondering, if anyone would
 tell me that i should stick to wx or go forward with qt4.
 
 also, is qt4 apps better looking in both win/linux than wx apps, coz the
 main thing i m looking for is visual appeal of the gui.

Qt is a the best choice, IMHO.  Nice support, free if you write free
software, very nice API, nice tools to develop with and the best looking
widget system for *nix and mobile phones.

I also don't like GTK that much but unfortunately we have to live with some
apps written with it. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI definition for web and desktop

2008-02-03 Thread Jorge Godoy
Daniel Fetchinson wrote:

 It's clear to me that the logic behind a web interface and a desktop
 interface are two totally different things. I don't want a magic
 method to convert an html/javascript based web app to a desktop app as
 this is clearly impossible.

But it is not impossible to embed a server on your desktop and make it
render HTML on some windows.  Then you'd have to code just the web app and
the desktop would also use it...

If Internet is a requirement, you can even render the HTML from a remote
server. 

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


Re: Will Python on day replace MATLAB?????????????????????????????????????????????????????

2008-01-31 Thread Jorge Godoy
Danyelle Gragsone wrote:

 Could you please use less question marks.

This is not part of his Masters... :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python docs in contrib?

2007-12-16 Thread Jorge Godoy
Tshepang Lekhonkhobe wrote:

 Hi,
 I was surprised to find python2.{4,5}-doc in contrib and wondered why?

What contrib? 

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


Re: python docs in contrib?

2007-12-16 Thread Jorge Godoy
Tshepang Lekhonkhobe wrote:

 On Dec 16, 2007 4:33 PM, Jorge Godoy [EMAIL PROTECTED] wrote:
 Tshepang Lekhonkhobe wrote:

  Hi,
  I was surprised to find python2.{4,5}-doc in contrib and wondered why?

 What contrib?
 
 contrib section of the archive, as opposed to main

doc is right on the root of the tarball for Python 2.5.1.  

Are you sure you are not talking about any distribution package or something
like that?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is a real C-Python possible?

2007-12-09 Thread Jorge Godoy
Jack wrote:

 I wonder if it's possible to have a Python that's completely (or at
 least for the most part) implemented in C, just like PHP - I think
 this is where PHP gets its performance advantage. Or maybe I'm wrong

PHP is slower than Python.

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


Re: Arrays

2007-11-13 Thread Jorge Godoy
Steven D'Aprano wrote:

 The only intuitive interface is the nipple. After that, it's all
 learned.  --  Bruce Ediger on user interfaces.

And after we learn its other uses, not even the nipple is so easy...  Who
haven't heard (or said, if you're a woman) Don't bite it like that, it
hurts!? :-)

Anyway, back to nippling, I mean, programming... :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to know if folder contents have changed

2007-11-12 Thread Jorge Godoy
[EMAIL PROTECTED] wrote:

 can someone suggest a better way? i know it is a general programming
 problem..but i wish to know if a python solution exists

Use pyfam.  I believe all docs are in fam but it integrates with that. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Putting a line from a text file into a variable, then moving to next line

2007-10-07 Thread Jorge Godoy
Vernon Wenberg III wrote:

 I'm not really sure how readline() works. Is there a way to iterate
 through a file with multiple lines and then putting each line in a
 variable in a loop?

To know how something works you can always check the docs about this
specific functionality:

 a = open('a')
 help(a.readline)
Help on built-in function readline:

readline(...)
readline([size]) - next line from the file, as a string.

Retain newline.  A non-negative size argument limits the maximum
number of bytes to return (an incomplete line may be returned then).
Return an empty string at EOF.

 help(a.readlines)
Help on built-in function readlines:

readlines(...)
readlines([size]) - list of strings, each a line from the file.

Call readline() repeatedly and return a list of the lines so read.
The optional size argument, if given, is an approximate bound on the
total number of bytes in the lines returned.

 


If you are creating new variables on every loop iteration you might be
interested in two things:

- you can loop directly through the file, on a line by line basis
- you can assign the read line to a an array


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


Re: Segmentation fault..

2007-10-06 Thread Jorge Godoy
Abandoned wrote:

 Hi..
 I run a my script and 3-4 minutes later give me an error segmentation
 fault.
 What is the reason of this error ?
 
 I use in my script:
 Threading
 Psycopg2
 open  write to txt
 urlopen
 
 My platform is ubuntu linux.
 
 I'm sorry my bad english.
 King regards..

Without seeing any code, it is hard to say anything.  But the answer to the
ultimate question is 42.

Show the group some code and I'm sure people will help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another comparison of Python Web Frameworks

2007-10-06 Thread Jorge Godoy
Tim Chase wrote:
 
 Any respectable comparison of Python web frameworks should
 include evaluation of at least Django and TG.  Or at least give
 good reason why the comparison excludes them.

When he said that he didn't want anything complex neither anything that used
a templating system, I thought this had already excluded a lot of
frameworks, including TG and Django.

 Zope is also missing, but I'm not sure Zope qualifies so much as
 a framework, but as an answer to the question If Emacs were a
 Python web environment, what would it look like?

He already had dislikings with Plone that weren't clear, maybe a lot of
those are Zope related...


I agree, though, that more time could be spent explaining why things were
discarded / ignored.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another comparison of Python Web Frameworks

2007-10-06 Thread Jorge Godoy
Lawrence Oluyede wrote:

 Thomas Wittek [EMAIL PROTECTED] wrote:
 At least, you missed Turbo Gears :)
 http://turbogears.org/
 For me, it feels more integrated than Pylons.
 
 Yeah, so integrated that the next version will be based upon Pylons ;-) ?

What is good, since a lot of good things from Pylons will work with TG and a
lot of good TG things will remain (and possibly be compatible with Pylons). 
If you take a better look at the next version, you'll also see that the
major concern was with WSGI support and reinventing / rewriting the wheel
(what TG developers don't want to do all the time).

As an example of this fusion, take a look at ToscaWidgets.  Works, *today*,
with both frameworks.  You don't have to wait for the next version.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Segmentation fault..

2007-10-06 Thread Jorge Godoy
Bruno Desthuilliers wrote:

 Jorge Godoy a écrit :
 Without seeing any code, it is hard to say anything.  But the answer to
 the ultimate question is 42.
 
 Indeed. Err, what was the question, exactly ?-)

As soon as calculations are finished, you'll know. :-)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: status of Programming by Contract (PEP 316)?

2007-09-01 Thread Jorge Godoy
Carl Banks wrote:

 This is starting to sound silly, people.  Critical is a relative term,
 and one project's critical may be anothers mundane.  Sure a flaw in your
 flagship product is a critical problem *for your company*, but are you
 really trying to say that the criticalness of a bad web search is even
 comparable to the most important systems on airplanes, nuclear reactors,
 dams, and so on?  Come on.

Who said they were the same?  I said that just because it doesn't take lives
it doesn't mean it isn't important.  I wasn't going to reply to not extend
this, but this misunderstanding of your was bugging me.

I use Python on systems that deal with human health and wrong calculations
may have severe impact on a good sized population.  Using Python.

As with nuclear reactors, dams, airplanes and so on we have a lot of
redundancy and a lot of checkpoints.  No one is crazy to take them out or
even to remove some kind of dispositive to allow manual intervention at
critical points.


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


Re: status of Programming by Contract (PEP 316)?

2007-08-31 Thread Jorge Godoy
Russ wrote:

 Alex, I think you are missing the point. Yes, I'm sure that web
 searches are critical to
 Google's mission and commercial success. But the point is that a few
 subtle bugs cannot
 destroy Google. If your search engines and associated systems have
 bugs, you fix them
 (or simply tolerate them) and continue on. And if a user does not get
 the results he wants,
 he isn't likely to die over it -- or even care much.

But if this pattern of not getting wanted results is common, then the user
will migrate to alternative search engines and this will *kill* the
business.  Wrong results won't impact ONE search, but many will impact the
company business and will be part of the recipe to take it out of business. 

 Online financial transactions are another matter altogether, of
 course. User won't die, but
 they will get very irate if they lose money. But I don't think that's
 what you are talking about
 here.

Lets make someone loose his job and have all his money commitments
compromised because of this money lost and we might be talking about people
taking their lives.

Again, this isn't 100% sure to happen, but it *can* happen.  

As it happens with a peacemaker: the user won't die if his heart skips one
beat, but start skipping a series of them and you're incurring in serious
problems.

Just because the result isn't immediate it doesn't mean it isn't critical.


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


Re: Web based Reporting tool for Python

2007-08-12 Thread Jorge Godoy
Jon Rosebaugh wrote:
 Sure, but again, these aren't reporting engines; they're just template
 engines. And I don't think any of the web template engines have PDF
 output.

I generate my PDFs with Genshi / Kid and ReportLab.  For the markup
processing I use z3c.rml.

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


Re: Advice on sending images to clients over network

2007-07-22 Thread Jorge Godoy
Paul McNett wrote:

 Paul Rubin wrote:
 Frank Millman [EMAIL PROTECTED] writes:
 Any suggestions will be much appreciated.
 
 Why on earth don't you write the whole thing as a web app instead of
 a special protocol?  Then just use normal html tags to put images
 into the relevant pages.
 
 I believe he has a full desktop client app, not a web app. Believe it or
 not, there's still a solid place for desktop applications even in this
 ever-increasing webified world.

He's using wxPython and already has network connectivity to access the
database server.

 Use the right tool for the job...

Yep...  I also believe that a HTTP server is the right tool. :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: custom plugin architecture: how to see parent namespace?

2007-07-22 Thread Jorge Godoy
escalation746 wrote:

 I have updated documentation for this on my blog, diagrammes modernes.
 Surf:
 http://diagrammes-modernes.blogspot.com/

Your motivation looks a lot like what is solved by setuptools, eggs and
entry points.

http://peak.telecommunity.com/DevCenter/PkgResources
http://docs.pythonweb.org/display/pylonscookbook/Using+Entry+Points+to+Write+Plugins

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


Re: Python Web Programming - looking for examples of solid high-traffic sites

2007-05-18 Thread Jorge Godoy
John Nagle [EMAIL PROTECTED] writes:

As a direct result of this, neither the Linux distro builders like
 Red Hat nor major hosting providers provide Python environments that
 just work.  That's reality.

Try SuSE, OpenSUSE, Ubuntu...  They just work.  I've never had any
problem installing any library or module for Python.  Even the ones that
require huge libraries or compiling something.

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: No module named urllib

2007-05-07 Thread Jorge Godoy
HMS Surprise [EMAIL PROTECTED] writes:

 I edited environment varialbes and have added C:\Python25\Lib to
 PYTHONPATH but get the no module message when the statement

 import urllib

 is executed.

 Even tried copying the urllib file to my working directory.

 Any suggestions?

No messages is good! :-)

If you got any error messages then you'd have a problem.



-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: No module named urllib

2007-05-07 Thread Jorge Godoy
HMS Surprise [EMAIL PROTECTED] writes:

 Perhaps I should have put qoutes in my sentence.

Or I should have read it slowly. ;-)

 I get the no module message named urllib.

Can you please

import sys
print sys.path

and put the answer here on the newsgroup?

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: No module named urllib

2007-05-07 Thread Jorge Godoy
HMS Surprise [EMAIL PROTECTED] writes:

 Since sys.path = ['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython'] I
 copied urllib to c:\maxq\lib\Lib.

 Now I get the error -

 Traceback (innermost last):
   File string, line 5, in ?
   File C:\maxq\lib\Lib\urllib.py, line 1148
   _hextochr = dict(('%02x' % i, chr(i)) for i in range(256))
 ^
 SyntaxError: invalid syntax

 dict(1, 1)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: dict expected at most 1 arguments, got 2
 dict(a=1)
{'a': 1}
 


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLObject 0.8.3

2007-05-03 Thread Jorge Godoy
Oleg Broytmann [EMAIL PROTECTED] writes:

 * Fixed sqlbuilder - .startswith(), .endswith() and .contains() assumed
   their parameter must be a string; now you can pass an SQLExpression:
   Table.q.name.contains(func.upper('a')), for example.

Oleg,


this made me think: is it possible to call a function in a schema other
than public in PostgreSQL?  For example if I had myschema.myfunction and
wanted to use it I can't do func.myschema.myfunction...  Is there
something like a dbName for func? :-)


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decorating class member functions

2007-05-03 Thread Jorge Godoy
Andy Terrel [EMAIL PROTECTED] writes:

 I just need to keep the state around. I make a call to some function
 that is pretty expensive so I want to save it as a member during the
 __init__ of the decorator.

 Yeah I'm afraid it can't be done either, that's why I asked the group.

Have you looked at memoize decorators?  They seem to do what you want.
There are examples at the Python website (some link in there, I'm
sorry...).

This will give you lots of resources, including full recipes and
comments from the Python cookbook:
http://www.google.com.br/search?q=python+decorator+memoize


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Suggestion: str.itersplit()

2007-04-21 Thread Jorge Godoy
Dustan [EMAIL PROTECTED] writes:

 If anybody could inform me on how to get my hands on the python source
 code, I might even be able to come up with an example of how it could
 be implemented. I have no idea how to unzip that tgz or tar.bz2 file
 on a windows machine, though (and that's not from lack of trying).

You can try WinZip.  Last time I had to use a Windows machine it was
able to untar + gunzip some files perfectly fine (as we are able to
unzip and unrar on *nix...). 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do other Python GUI toolkits require this?

2007-04-20 Thread Jorge Godoy
Dennis Lee Bieber [EMAIL PROTECTED] writes:

   But is it a wrong idea if 999 people interpret the phrase one way,
 and just 1 insists upon an interpretation that, while correct in a small
 technical area, results in misunderstanding when speaking with the other
 999?

You remind me of my grandpa: if all soldiers but one are marching with
the wrong foot ahead, who's wrong?

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python editor/IDE on Linux?

2007-04-14 Thread Jorge Godoy
[EMAIL PROTECTED] (Aahz) writes:

 In article [EMAIL PROTECTED],
 Michael Bentley  [EMAIL PROTECTED] wrote:


 Everybody uses vim.

 Except for real programmers...

Who instead use emacs ;-)

 Emacs makes a good OS, but a lousy editor.

Yep.  Emacs comes with a lot of those funny phrases.  It is so good that
it even helps people using other editors to have some fun. ;-)

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: About Trolltech QT OpenSource license.

2007-04-11 Thread Jorge Godoy
Robert Kern [EMAIL PROTECTED] writes:

 I don't recommend it. You are talking to their salesman, not your lawyer. You
 are being given a sales pitch, not legal advice.

On the other hand, he's stating Trolltech's policies and agreeing /
disagreeing on your understanding of their license.  He's selling you his
product and stating how you can / can't use it.

I believe that this has some value in case they say you can't do one thing
that they told you could when you were acquiring their services.

I'd save those emails exchanged very carefully.

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using remote source code

2007-03-25 Thread Jorge Godoy
[EMAIL PROTECTED] writes:

 Is there any possible way that I can place a .py file on the internet,
 and use that source code in an .py file on my computer?

Besides Alex suggestion, you can also check Pyro. 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: organizing collections of small modules

2007-03-25 Thread Jorge Godoy
Eric S. Johansson [EMAIL PROTECTED] writes:

 I have a bunch of small modules that I use within my application.  Most of
 these modules are single file modules.  Currently, I have them set up as
 stand-alone modules but because it's a royal pain to fetch five or 10 of these
 modules for each application and tracking whether or not they are all up to
 date, I'm considering putting them all into one collection (rcsoc
 a.k.a. random cross-section of code[1]) so it's easier to load, install, and
 manage.

 Are there better techniques for managing collections of modules in 2.4 or
 later?

 ---eric


 [1]  derives from the expression that hamburger is random cross-section of
 cow

I'm using setuptools for that.  If they're somehow connected --
e.g. mathematics, database, finance, etc. -- then I create one single package
for them.  If they aren't, then creating several packages isn't hard.

If they are useful enough you can publish them on PyPI and then it is just a
matter of easy_install them.  If they aren't then you'll have to collect
them somewhere to use easy_install ;-)

It also supplies means to determine the minimum / maximum / exact version that
is required, so this also helps with how up-to-date your library has to be to
be used with some application.


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to find tag to /tag HTML strings and 'save' them?

2007-03-25 Thread Jorge Godoy
[EMAIL PROTECTED] writes:

 Hi All,

 Apologies for the newbie question but I've searched and tried all
 sorts for a few days and I'm pulling my hair out ;[

 I have a 'reference' HTML file and a 'test' HTML file from which I
 need to pull 10 strings, all of which are contained within h2 tags,
 e.g.:
 h2 class=ra href=http://www.someplace.com/;Go Someplace/a/h2

 Once I've found the 10 I'd like to write them to another 'results'
 html file. Perhaps a 'reference results' and a 'test results' file.
From where I would then like to 'diff' the results to see if they
 match.

 Here's the rub: I cannot find a way to pull those 10 strings so I can
 save them to the results pages.
 Can anyone please suggest how this can be done?

 I've tried allsorts but I've been learning Python for 1 week and just
 don't know enough to mod example scripts it seems. don't even get me
 started on python docs.. ayaa ;] Please feel free to teach me to suck
 eggs because it's all new to me :)

 Thanks in advance,

 Mark.


Take a look at BeautifulSoup.  It is easy to use and works well with some
malformed HTML that you might find ahead.

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLObject 0.8.1

2007-03-19 Thread Jorge Godoy
Larry Bates [EMAIL PROTECTED] writes:

 WOW!  Went from 0.7.4 to 0.8.1 in the span of only 23 minutes!

There are two branches: 0.7 and 0.8.  So, there were two releases. 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: To count number of quadruplets with sum = 0

2007-03-18 Thread Jorge Godoy
n00m [EMAIL PROTECTED] writes:

 my dial-up line's too slow for downloading 4mb of shedskin-0.0.20.exe

joke
Don't worry!  We can email it to you. :-D
/joke

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Automagically log changes in table

2007-03-18 Thread Jorge Godoy
aspineux [EMAIL PROTECTED] writes:

 On 18 mar, 04:20, George Sakkis [EMAIL PROTECTED] wrote:

 I'd rather avoid triggers since I may have to deal with Mysql 4. Apart
 from that, how can a trigger know the current user ?

 Because each user opening an web session will login to the SQL database
 using it's own login. That way you will be able to manage security at DB
 too. And the trigger will use the userid of the SQL session.

That's not common in web applications (he mentions TurboGears later).  What is
common is having a connection pool and just asking for one of the available
connections, when your app gets it, it just uses it.  After each request this
connection returns to the pool to be reused.


I dunno about SQL Alchemy (also mentioned later), but SQL Object 0.8x has some
events that can be bound so they can act is triggers on your database, but
client side.  Of course they don't have all the context as a real trigger
does, but those might be enough to avoid duplicating lots of code through the
app to set some variable.



-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: encoding - arabic(IBM 864) to UNICODE

2007-03-18 Thread Jorge Godoy
Madhu Alagu [EMAIL PROTECTED] writes:

 Hello,

 How to convert IBM 864,IBM 420  Nafitha(Arabic)  to UNICODE.

Your OS should have some tools for that.  On Linux I use 'iconv' to convert
from several encodings to several other encodings.

Another option is checking if Python has those encodings available (are they
standard or platform specific?) and using its own conversion method, as
explained in the docs. 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cheese shop: tagging and dating

2007-03-18 Thread Jorge Godoy
[EMAIL PROTECTED] [EMAIL PROTECTED] writes:

 The first thing I look at when examining a module is how often it is
 updated. Unfortunately, the entries there dont show this. Eg:

   http://www.python.org/pypi/PySimpleXML/1.0

 Second, it seems that tagging is more popular than the hierarchical
 browsing method currently offered by Cheese Shop. Are there efforts
 underway to support a tagging interface for the cheeseshop?

I believe hierarchies are easier when there's a lot of information.  You go
browsing by topic.

If there are only tags available, you'd have to look for hundreds of tags to
see if none of the possible names for the thing has been used (database,
db, relational, orm, mapper, etc.). 

Ammending the current hierarchic structure with an alternate tag interface
would be interesting, though.  But not making it the main interface or the
only one.

Tags are cool when they are few.  They are a nightmare when there are hundreds
or thousands of them to search for something.

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MIME Magic

2007-03-17 Thread Jorge Godoy
Samuel [EMAIL PROTECTED] writes:

 Hi,

 How can I determine the type of a file from magic bytes, similar to
 what the file command on unix does? I found

 http://docs.python.org/lib/module-mimetypes.html

 but this only seems to use the filename (extension) for finding the
 type. Any hints?

I'd start by taking a look at file's code. :-)

The thing is being able to identify the signatures of several different types
of files.  Here's some help for you:
http://www.garykessler.net/library/file_sigs.html

And here's an example of an authoritative source for that table:
http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html 



-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: string formatting: engineering notation

2007-03-14 Thread Jorge Godoy
Steve Holden [EMAIL PROTECTED] writes:

 Darren Dale wrote:
 Does anyone know if it is possible to represent a number as a string with
 engineering notation (like scientific notation, but with 10 raised to
 multiples of 3: 120e3, 12e-6, etc.). I know this is possible with the
 decimal.Decimal class, but repeatedly instantiating Decimals is inefficient
 for my application (matplotlib plotting library). If it is not currently
 possible, do you think the python devs would be receptive to including
 support for engineering notation in future releases?

 How close is this:

   %.3e % 3.14159
 '3.142e+00'

 %.3e % 314159
'3.142e+05'
 

Not close when you have the exponent.  



-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: merits of Lisp vs Python

2007-03-14 Thread Jorge Godoy
[EMAIL PROTECTED] (John J. Lee) writes:

 John Nagle [EMAIL PROTECTED] writes:

 John J. Lee wrote:
  Graham Dumpleton [EMAIL PROTECTED] writes:
 
 On Mar 11, 12:31 pm, [EMAIL PROTECTED] (John J. Lee) wrote:
 
  Is it possible to ask mod_python to start separate processes to serve
  requests, rather than separate interpreters?  We couldn't see a way.
 
 That's what CGI does.

 I meant long running processes, as I hoped was obvious from context...

Maybe FastCGI should help, then.  It can run forever after a request has
finished so it is suitable for long running processes. 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: setuptools and code.google.com

2007-03-12 Thread Jorge Godoy
[EMAIL PROTECTED] (Alex Martelli) writes:

 Hey, I'd just love to make it as easy as possible to get gmpy -- that's
 why I (shudder!-) even build and upload Windows installers...

Brave man! :-)

 OK, the .zip file IS there -- I don't know how to build .egg ones but of
 course I could study up on it -- can you suggest a URL?

The .egg is nice because it can be an already built binary.  

http://peak.telecommunity.com/DevCenter/setuptools

The URL above contains examples and instructions on how to use setuptools. 

 To be usable on Windows w/o effort, the packaged format must contain a
 .pyd (and, on Mac, a .so, etc).  Can a .egg deal w/that?

Yes.  I have a .egg that has a .so here, for rpy (http://rpy.sf.net/). 

 I need to find out w/certainty, because once I've uploaded a file w/a
 certain name I can't change the name, nor the contents -- the URLs on
 code.google.com are meant to be permanent...

Hmmm...  I'd suggest you to build only locally then...  I don't like this kind
of permanent things.  They could have a flag publish this to make it
permanent and make the standard unpublished.  Here's a suggestion for you to
forward there inside Google... ;-)

 OK, but since most Windows users don't have a suitable C compiler, and
 many Mac ones never bother installing the C compiler that comes with
 their OS DVDs, if I'm to make things easy I definitely need to pack up
 binaries.  How do I pack binaries (for dynamic link libraries) that need
 to be very different on Win, Mac, various Linux distros...?

One build per platform would be my choice.  Packing everything together would
make the package too big (specially if you start supporting other OSs). 

 Me neither, knowing near to nothing about setuptools (I'm not even a
 user of it...). Let's hope some expert does speak up -- I can't just
 freely experiment with uploads and the like...

Lets wait. ;-)



Thanks again,
-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to modify the source of a python file inside a python egg file?

2007-03-12 Thread Jorge Godoy
[EMAIL PROTECTED] [EMAIL PROTECTED] writes:

 How to modify the source of a python file inside a python egg file?
 I can see the file by unzipping it, but how can I package it back as a
 python egg file after my modification.

The correct way is to download the source, make your changes and rebuild the
egg.

Unzipping, changing and zipping it back also works.

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Signed zeros: is this a bug?

2007-03-11 Thread Jorge Godoy
[EMAIL PROTECTED] (Alex Martelli) writes:

 Incidentally (and I know you know that, Paul, but others interested in
 this thread might not) fast exact rational arithmetic (based on the LGPL
 library named GMP) is supplied, among other functionality, by module
 gmpy, currently found at http://code.google.com/p/gmpy/ (this version is
 more recent than the older one at sourceforce, which for some reason
 doesn't let me update things right any more).

For some reason setuptools isn't finding it:

jupiter:~ # easy_install gmpy
Searching for gmpy
Reading http://cheeseshop.python.org/pypi/gmpy/
Reading http://code.google.com/p/gmpy/
Reading http://cheeseshop.python.org/pypi/gmpy/1.02
No local packages or download links found for gmpy
error: Could not find suitable distribution for Requirement.parse('gmpy')


I believe that setuptools isn't ready to find packages on code.google.com
yet... ;-)

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


setuptools and code.google.com (was Re: Signed zeros: is this a bug?)

2007-03-11 Thread Jorge Godoy
[EMAIL PROTECTED] (Alex Martelli) writes:

 I'm not familiar with setuptools, what exactly is it looking for?

 If it's looking for stuff to download it should start at

 http://code.google.com/p/gmpy/downloads/list

 (but what does it want -- the sources' zipfile, or some binary, and in
 what format and with what naming convention?) -- I'll be glad to edit
 the URL for gmpy at cheeseshop if some setuptools expert can explain
 these subtleties... thanks for pointing out that there's a problem
 btw!-)

Thanks for caring ;-)


It looks for several things: eggs (for the Python version it is being used),
zipfiles and tarballs (I dunno if it looks for more things). 

If it finds, for example, gmpy-1.0.2-py2.4.egg it won't install here 'cause I
use Python 2.5 and then it will continue searching for gmpy-1.0.2-py2.5.egg or
an alternative format that can be used.  The last resort is the tarball / zip
with the sources so that the package can be rebuilt. 

Probably other people that are more experienced with it can help more.  I'm
more an end user of it and I know the essential for my needs. 

I just pointed out because setuptools helps a lot on obtaining a package and
installing it (even if there's some building needed before installing). 


Sorry for not being able to help more.


With regards to the hyperlink, I believe that if the link on Pypi was to the
URL above it would be easier.  Another alternative is a link at the first
page.  And, of course, the last alternative is teaching setuptools how to work
with code.google.com -- if it doesn't already know -- as it learnt how to work
with SourceForge and its random mirrors.  I don't know how to write that
code, though.


Be seeing you,
-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Database module multithreading

2007-03-10 Thread Jorge Godoy
jupiter [EMAIL PROTECTED] writes:

 Hi guys!!!


 Just one quick question... Which database module should I use when I
 want to use multi threading as my application requires lots of data
 from internet  I also want this database module to be fast, simple
 n efficient, in any case multi threading capabilities are # 1
 requirement.

For which database server?

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Database module multithreading

2007-03-10 Thread Jorge Godoy
jupiter [EMAIL PROTECTED] writes:

 conn = psycopg2.connect(dbname=test user=test)

 Traceback (most recent call last):
   File pyshell#8, line 1, in module
 conn = psycopg2.connect(dbname=test user=test)
 OperationalError: could not connect to server: Connection refused
 (0x274D/10061)
   Is the server running on host ??? and accepting
   TCP/IP connections on port 5432?

 this is the error I am getting with psycopg2 I want to access a local
 file

PostgreSQL is a server, it access the files.  You talk to the RDBMS server.
Is it running?  Is it accepting connections from your host?

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Project organization and import

2007-03-06 Thread Jorge Godoy
[EMAIL PROTECTED] (Alex Martelli) writes:

 Bruno Desthuilliers [EMAIL PROTECTED] wrote:

 I don't reload...  When my investigative tests gets bigger I write a script
 and run it with the interpreter.  It is easy since my text editor can call
 Python on a buffer (I use Emacs).
   
  That's interesting, is this workflow pretty universal in the Python
  world?
 
 I don't know, but that's also mostly how I do work.

 My favorite way of working: add a test (or a limited set of tests) for
 the new or changed feature, run it, check that it fails, change the
 code, rerun the test, check that the test now runs, rerun all tests to
 see that nothing broke, add and run more tests to make sure the new code
 is excellently covered, rinse, repeat.  Occasionally, to ensure the code
 stays clean, stop to refactor, rerunning tests as I go.

I believe this is a distinct case.  When we write tests we're worried with the
system itself.  When using the interactive interpreter we're worried with how
to best use the language.  There might be some feature of the system related
to that investigation, but there might be not.  For example: what are the
methods provided by this object? or which approach is faster for this loop?

I won't write a test case to test loop speed.  But I'd poke with the
interpreter and if the environment gets a bit big to setup then I'd go to the
text editor as I said. 


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Project organization and import

2007-03-06 Thread Jorge Godoy
Martin Unsal [EMAIL PROTECTED] writes:

 On Mar 5, 11:06 am, Chris Mellon [EMAIL PROTECTED] wrote:
 I never advocated big files with many functional units - just files
 that are just big enough.

 Then we're in total agreement. I'm not sure why you thought my
 opinions were the result of baggage from other languages when you
 don't seem to actually disagree with me.

I believe the reason was that you were advocating one class per file.  big
enough might be more classes.  Or fewer... :-)

 I agree that there is some subtlety there, and I appreciate your
 example. However the fact that Python's module system essentially
 forces you to use from foo import * and that reload is almost
 entirely imcompatible with from foo import *, I would say that
 reload is essentially useless.

The don't force you to that...  There are many modules that do, but they are
generally glueing your Python code to some other language (usually C) written
code.  This is common for GUI development, for example.

In fact, it is rare to me -- mathematics, statistics, database, web
development, testing -- to use this construction.  There are no modules that
demand that.

And you can also write:

from foo import Bar, Baz

or even

from foo import Bar as B1, Baz as B2  # OUCH! ;-)

 Well from foo import Foo is just a special case of from foo import
 *. :) It still breaks reload. It still means you're restarting your
 interpreter even to do the most trivial development cycle.

That's what you get when you're working with instances of Foo...  I believe
that for classmethods this would work right.  So, again, it depends on your
code, how it is structured (and how it can be structured), etc. 

 Here's an analogy. In C, you can do an incremental build and run your
 modified application without having to first reboot your computer. In
 Python, where reload() is essentially the incremental build process,
 and the interpreter is essentially a virtual machine, you guys are
 saying that my best option is to just reboot the virtual machine to
 make sure I have a clean slate. It may be the path of least
 resistance, but to say that it is necessary or inevitable is 1960s
 mainframe thinking.

How can you reload C code that would affect already running code --
ie. existing data, pointers, etc. -- without reloading the full program?  Even
changing and reloading a dynamic library wouldn't do that to already existing
code, so you'd have to reboot your application as well.



-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Project organization and import

2007-03-06 Thread Jorge Godoy
Martin Unsal [EMAIL PROTECTED] writes:

 On Mar 6, 9:19 am, Chris Mellon [EMAIL PROTECTED] wrote:
 You do? Or do you only have trouble because you don't like using from
 foo import Foo because you need to do more work to reload such an
 import?

 More work, like rewriting __import__ and reload??? :)

 There's a point where you should blame the language, not the
 programmer. Are you saying I'm lazy just because I don't want to mess
 with __import__?

I *never* messed with __import__.  And one of my systems has more than 15
packages, with an average of 7 more subpackages plus __init__.py...

Why do you need messing with __import__?

 I was clearly talking about files and you assumed I was talking about
 namespace. That's Pythonic thinking... and I don't mean that in a good
 way!

Hmmm...  Why not?  How are you going to track down where is something, on
which file?  I can make sucessive imports and I can subclass things, so I
might be importing a subclass of a subclass of the class that provides the
method that I want to change.  Having a direct correlation helps me a lot with
big projects.  For small ones I don't care since they are very simple and a
grep usually takes me directly to where I want (just to avoid tools that map
classes to files that are specific to one IDE or editor). 

 Because I have written a project with 50,000 lines of Python and I'm trying
 to organize it in such a way that it'll scale up cleanly by another order of
 magnitude. Because I've worked on projects with millions of lines of code
 and I know about how such things are organized. It's funny, I'm a newbie to
 Python but it seems like I'm one of the only people here thinking about it
 as a large scale development language rather than a scripting language.

I don't se a problem scaling my biggest project with, now, 65K lines of code.
What are the problems you're seeing for yours?  In fact, the Python part of
this code is the easiest to deal with.  And there's ctypes involved here,
which messes things up a bit since I need to keep C + Python in sync.

And if I once imagined I'd write that many LOC and would reach the millions of
LOC of *Python* code then it would certainly make me feel comfortable knowing
that this approach *do* scale.  At least to me and to the ones that work with
me and use the system...  Implementing new features is fast and extremely
modular.  There are modules specific to one client, modules specific to
another, modules shared between all clients, etc.  It isn't a monolithic take
all or nothing.  And even like that it works.

There are customizations on some features that only exists at one client's
branch, there are customizations that might be selected on the fly by
choosing something on a preferences screen, etc.

It is a normal (but rather complex) application on any aspect that we see
around.  And it scales.  I don't fear changing code.  I don't fear adding new
features.  It simply works.


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Project organization and import

2007-03-06 Thread Jorge Godoy
[EMAIL PROTECTED] (Alex Martelli) writes:

 Not sure I get what you mean; when I write tests, just as when I write
 production code, I'm focused (not worried:-) about the application

semantics... ;-)  Thanks for the correction. 

 functionality I'm supposed to deliver.  The language mostly gets out of
 my way -- that's why I like Python, after all:-).

That's the same reason why I like it.  I believe it is not a coincidence that
we both like writing Python code. 

But there are cases where investigating is more necessary than testing.  This
is where I see the need of the interactive session.  For program's features I
also write tests. 

 I do generally keep an interactive interpreter running in its own
 window, and help and dir are probably the functions I call most often
 there.  If I need to microbenchmark for speed, I use timeit (which I
 find far handier to use from the commandline).  I wouldn't frame this as
 worried with how to best use the language though; it's more akin to a
 handy reference manual (I also keep a copy of the Nutshell handy for
 exactly the same reason -- some things are best looked up on paper).

That's the same use -- and the same most used functions -- that I have here.
I believe that I wasn't clear on my previous post, and this is why you saw a
different meaning to it.

 I don't really see getting a bit big to setup as the motivation for
 writing automated, repeatable tests (including load-tests, if speed is
 such a hot topic in your case); rather, the key issue is, will you ever

It's not for writing tests.  It's for investigating things.  If I have to open
database connections, make several queries to get to a point where I have the
object that I want to dir(), it is easier to me to put that all in a file.
It isn't a test. 


 want to run this again?  For example, say you want to check the relative
 speeds of approaches A and B -- if you do that in a way that's not
 automated and repeatable (i.e., not by writing scripts), then you'll
 have to repeat those manual operations exactly every time you refactor
 your code, upgrade Python or your OS or some library, switch to another
 system (HW or SW), etc, etc.  Even if it's only three or four steps, who
 needs the aggravation?  Almost anything worth doing (in the realm of
 testing, measuring and variously characterizing software, at least) is
 worth automating, to avoid any need for repeated manual labor; that's
 how you get real productivity, by doing ever less work yourself and
 pushing ever more work down to your computer.

I won't write a script to write two commands and rerun them often.  But I
would for some more -- lets say starting from 5 commands I might start
thinking about having this somewhere where I can at least Cut'n'Past to the
interactive interpreter (even with readline's help). 


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 incompatible with Fedora Core 6 - packaging problems again

2007-03-04 Thread Jorge Godoy
Troy Melhase [EMAIL PROTECTED] writes:

 You're trying to install a package without using the package
 management tools provided by your system, you haven't read the docs
 (or at least all of them), you show a general lack of understanding of
 the different responsibilities in the free/open source software space
 (development vs. packaging)... and after all that, then you come here
 and complain?

Just to throw more on the fire: there are distributions that come with Python
2.5 packaged and working. ;-)

 Look, I'm sure lots of folks here would be glad to help you, but your
 post comes across as whiny and confrontational.  I'm sure you've had a
 frustrating experience, but please, don't blame python or the
 python developers, because that blame would be misplaced.

Anyway, if following the install after an error is true then some developer
should take a look at it.


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SAMBA-PYTHON ???

2007-03-04 Thread Jorge Godoy
WEBER Sébastien [EMAIL PROTECTED] writes:

 (I'm french and I speak english like a spanish cow : sorry.)

(Shouldn't it be French cow?  Or you're more fluent in Spanish? ;-))

 Does someone know how to use the samba-python tdb.so module ? I've been
 looking for information about this on Google for 3 days and I've found not
 a word. The only functions I can use are 'open()' and 'first_key()' : not
 enough.

Did you get to run the examples supplied in the package?  I remember that I
had run these a while ago, but I don't remember if I had any problem (probably
not).  In the end I didn't use the package because the project changed
requirements and we adopted an alternative solution, but I got the examples to
run (or code very similar to them).

What are the errors that you're getting?  Send them to the group...

(BTW, I've used the samba-python package that comes with opensuse.) 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How use XML parsing tools on this one specific URL?

2007-03-04 Thread Jorge Godoy
[EMAIL PROTECTED] [EMAIL PROTECTED] writes:

 I understand that the web is full of ill-formed XHTML web pages but
 this is Microsoft:

Yes...  And Microsoft is responsible for a lot of the ill-formed pages on the
web be it on their website or made by their applications. 

 http://moneycentral.msn.com/companyreport?Symbol=BBBY

 I can't validate it and xml.minidom.dom.parseString won't work on it.

 If this was just some teenager's web site I'd move on.  Is there any
 hope avoiding regular expression hacks to extract the data from this
 page?

It all depends on what data you want.  Probably a non-validating parser would
be able to extract some things.  Another option is pass the page through some
validator that can fix the page, like tidy... 


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Project organization and import

2007-03-04 Thread Jorge Godoy
Martin Unsal [EMAIL PROTECTED] writes:

 1) Namespace. Python wants my namespace heirarchy to match my filesystem
 heirarchy. I find that a well organized filesystem heirarchy for a
 nontrivial project will be totally unwieldy as a namespace. I'm either
 forced to use long namespace prefixes, or I'm forced to use from foo import
 * and __all__, which has its own set of problems.

I find it nice.  You have the idea of where is something just from the import
and you don't have to search for it everywhere.  Isn't, e.g., Java like that?
(It's been so long since I last worried with Java that I don't remember if
this is mandatory or just a convention...)

You might get bitten with that when moving files from one OS to another,
specially if one of them disconsider the case and the other is strict with
it. 

 1a) Module/class collision. I like to use the primary class in a file as the
 name of the file. However this can lead to namespace collisions between the
 module name and the class name. Also it means that I'm going to be stuck
 with the odious and wasteful syntax foo.foo everywhere, or forced to use
 from foo import *.

Your classes should be CamelCased and start with an uppercase letter.  So
you'd have foo.Foo, being foo the package and Foo the class inside of it.

 1b) The Pythonic way seems to be to put more stuff in one file, but I
 believe this is categorically the wrong thing to do in large projects.  The
 moment you have more than one developer along with a revision control
 system, you're going to want files to contain the smallest practical
 functional blocks. I feel pretty confident saying that put more stuff in
 one file is the wrong answer, even if it is the Pythonic answer.

Why?  RCS systems can merge changes.  A RCS system is not a substitute for
design or programmers communication.  You'll only have a problem if two people
change the same line of code and if they are doing that (and worse: doing that
often) then you have a bigger problem than just the contents of the file. 

Unit tests help being sure that one change doesn't break the project as a
whole and for a big project you're surely going to have a lot of those tests.

If one change breaks another, then there is a disagreement on the application
design and more communication is needed between developers or a better
documentation of the API they're implementing / using. 

 2) Importing and reloading. I want to be able to reload changes without
 exiting the interpreter. This pretty much excludes from foo import *,
 unless you resort to this sort of hack:

 http://www.python.org/search/hypermail/python-1993/0448.html

 Has anyone found a systematic way to solve the problem of reloading in an
 interactive interpreter when using from foo import *?

I don't reload...  When my investigative tests gets bigger I write a script
and run it with the interpreter.  It is easy since my text editor can call
Python on a buffer (I use Emacs). 

 I appreciate any advice I can get from the community.

This is just how I deal with it...  My bigger project has several modules
now each with its own namespace and package.  The API is very documented and
took the most work to get done.

Using setuptools, entrypoints, etc. helps a lot as well. 


The thing is that for big projects your design is the most important part.
Get it right and you won't have problems with namespaces and filenames.  If
you don't dedicate enough time on this task you'll find yourself in trouble
really soon. 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does Python have equivalent to MATLAB varargin, varargout, nargin, nargout?

2007-02-18 Thread Jorge Godoy
[EMAIL PROTECTED] writes:

 Thank you in advance for your response.

And those do ... ? 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: uml and python

2007-02-08 Thread Jorge Godoy
azrael [EMAIL PROTECTED] writes:

 hy guys

 i've been googling and got several posts, but nothing that is a
 satisfaction in my eyes. can someone tell me a nice uml diagram tool
 with python export (if possible nice gui), or at least nice uml tool

 gpl or freeware (widows) prefered

I like Umbrello (several OSs supported, including MacOS, Linux, *BSD and you
probably can get it running in Windows though it might be somewhat hard...). 



-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python does not play well with others

2007-02-04 Thread Jorge Godoy
Paul Boddie [EMAIL PROTECTED] writes:

 And while Python eggs may be useful for people managing additional
 software as some unprivileged user, hosting providers (and virtual
 private server administrators) will want packages that fit in with the
 rest of the software being managed in the hosting environment.

And why eggs wouldn't satisfy them?  Eggs can be installed globally as well,
making the package available to every client of this hosting server (if they
mount their libs from a unique NFS server then it would automatically be
available for all of their servers).  

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python does not play well with others

2007-02-03 Thread Jorge Godoy
Paul Rubin http://[EMAIL PROTECTED] writes:

 Diez B. Roggisch [EMAIL PROTECTED] writes:
 And they certainly require special treatment like putting them in the
 classpath, setting up the project directory and the like - no simple
 import will work out of the box, as it would witch python standard lib
 drivers.

 Well, that's nowhere near as big a deal as having yet another set of
 vendors or maintainer to deal with.  Minimizing configuration is nice,
 but getting your software from as few different sources as possible is
 also a big win.

So we should get a better egg support.  Then it would all be just a matter of
easy_install something.  As it is that easy for thousands of modules on CPAN
for Perl. 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT Annoying Habits

2007-01-20 Thread Jorge Godoy
John Machin [EMAIL PROTECTED] writes:

 [EMAIL PROTECTED] wrote:
 [snip]

 The information contained in this message and any attachment may be
 proprietary, confidential, and privileged or subject to the work
 product doctrine and thus protected from disclosure.  If the reader
 of this message is not the intended recipient, or an employee or
 agent responsible for delivering this message to the intended
 recipient, you are hereby notified that any dissemination,
 distribution or copying of this communication is strictly prohibited.
 If you have received this communication in error, please notify me
 immediately by replying to this message and deleting it and all
 copies and backups thereof.  Thank you.

 ... and while we're talking about annoyances ...

For those there is always http://www.goldmark.org/jeff/stupid-disclaimers/
:-) 


Be seeing you,
-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT Annoying Habits

2007-01-19 Thread Jorge Godoy
Carroll, Barry [EMAIL PROTECTED] writes:

 Secondly, can someone point me to the Standard Usenet Convention that
 mandates against top-posting.  This is not sarcasm; I would really like

You can read RFC 1855.  Section 3.1.3 talks about newsgroups.  

Section 3.1.1 has general guidelines and it includes this:

If you are sending a reply to a message or a posting be sure you
summarize the original at the top of the message, or include just

enough text of the original to give a context. This will make sure
readers understand when they start to read your response. Since
NetNews, especially, is proliferated by distributing the postings from
one host to another, it is possible to see a response to a message
before seeing the original. Giving context helps everyone. But do not
include the entire original. 


I've added the ^ to mark the part where it says what should be on the top of
the message.

You can check it: http://www.dtcc.edu/cs/rfc1855.html


Be seeing you,
-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Barcode recognition in Python

2007-01-13 Thread Jorge Godoy
PaoloB [EMAIL PROTECTED] writes:

 Hi everyone,

 I am searching for a python library for barcode recognition. We have
 developed a rather complex application for document tracking and
 document management in python/Zope, called PAFlow (www.paflow.it:
 sorry, most of the information is in Italian...).

 As our project is completely free software, we will need a library that
 is free software too.

 Is there something like this in python ?

Sorry, but what do you mean by barcode recognition?  A barcode reader
already decodes the barcode and sends the decoded output.  If it is one
plugged in a keyboard port, for example, reading the barcode or typing the
message is exactly the same thing.

Or are you willing some kind of OCR to process the barcodes without a barcode
reader (why having barcodes then?)?  

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: template engine

2007-01-13 Thread Jorge Godoy
piotr [EMAIL PROTECTED] writes:

(...)

 for user was not empty call function again with argument user/name
 then engine should replace specific placeholders with results of my
 callback function
 obviously this is just example syntax, I hope you catch the idea

 that would be nice if engine could work with non HTML documents.

 thanks in advance for your help, and sorry for my English :)

Take a look at Kid (http://www.kid-templating.org/) and Genshi
(http://genshi.edgewall.org/).

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlobject 0.8.0b1 and python 2.5

2007-01-13 Thread Jorge Godoy
Diez B. Roggisch [EMAIL PROTECTED] writes:

 To my knowledge, the 0.8.x series is the current line of development, and has
 made major progress over the previous versions. What makes you think it will
 be stopped developing? And where does a sqlobject2 come from?

http://www.sqlobject.org/2/


Be seeing you,
-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: strange for loop construct

2007-01-07 Thread Jorge Godoy
[EMAIL PROTECTED] writes:

 Gabriel Where do you find the What's new for previous releases? I
 Gabriel have to read them online.
  
  Google for
   what's new site:python.org

 Sorry, I took I have to read them online to mean that you needed to read
 them online because (perhaps) you don't have a source distribution on your
 computer.  My 2.5 source (Subversion sandbox) has 2.0 through 2.5 What's New
 source in Doc/whatsnew.

My SuSE installation has it as /usr/share/doc/packages/python/Misc/NEWS

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python re expr from Perl to Python

2007-01-06 Thread Jorge Godoy
Michael M. [EMAIL PROTECTED] writes:

 In Perl, it was:


   ## Example: Abc | def | ghi | jkl
   ##   - Abc ghi jkl
   ## Take only the text betewwn the 2nd pipe (=cut the text in the 1st pipe).
   $na =~ s/\ \|(.*?)\ \|(.*?)\ \|/$2/g;

   ## -- remove [ and ] in text
   $na =~ s/\[//g;
   $na =~ s/\]//g;
   # print DEB: \$na\\n;


 # input string
 na=Abc | def | ghi | jkl [gugu]
 # output
 na=Abc ghi jkl gugu


 How is it done in Python?

The simplest form:

 na=Abc | def | ghi | jkl [gugu]
 na_out = na.replace('def', '').replace(' | ', ' ').replace('  ', ' 
 ').replace('[', '').replace(']', '').strip()
 na_out
'Abc ghi jkl gugu'
 


Another form:

 na_out = ' '.join(na.split(' | ')).replace('[', '').replace(']', 
 '').replace(' def', '')
 na_out
'Abc ghi jkl gugu'
 


There is the regular expression approach as well as several other
alternatives.  I could list other (simpler, more advanced, etc.) alternatives,
but you can also play with Python by yourself.  If you have a more concrete
specification, send it to the group.



-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fuzzy string comparison

2006-12-27 Thread Jorge Godoy
Steve Bergman [EMAIL PROTECTED] writes:

 I'm looking for a module to do fuzzy comparison of strings.  I have 2
 item master files which are supposed to be identical, but they have
 thousands of records where the item numbers don't match in various
 ways.  One might include a '-' or have leading zeros, or have a single
 character missing, or a zero that is typed as a letter 'O'.  That kind
 of thing.  These tables currently reside in a mysql database.  I was
 wondering if there is a good package to let me compare strings and
 return a value that is a measure of their similarity.  Kind of like
 soundex but for strings that aren't words.

If you were using PostgreSQL there's a contrib package (pg_trgm) that could
help a lot with that.  It can show you the distance between two strings based
on a trigram comparison.

You can see how it works on the README
(http://www.sai.msu.su/~megera/postgres/gist/pg_trgm/README.pg_trgm) and maybe
port it for your needs.

But it probably won't be a one operation only search, you'll have to
post process results to decide what to do on multiple matches.

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Random image text generation?

2006-11-12 Thread Jorge Godoy
[EMAIL PROTECTED] writes:

 Is there a module out there that will generate an image with a random text
 string such as the confirmation images you see on various websites?  I'm
 thinking I'm going to have to add that to the forms on the Mojam websites.
 Over the past couple weeks we've begun to get lots of spam submission crap.

http://captchas.net/sample/python/
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440588

There are specific implementations for Zope, TurboGears and other frameworks. 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how is python not the same as java?

2006-11-10 Thread Jorge Godoy
Jorge Vargas [EMAIL PROTECTED] writes:

 code. In python noone runs the pyc files, the interpreter takes care
 of this for you.

This is not true.  It is one way to avoid having your source lying around.
The same can be done with .pyo... 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to create a multicolor font-string in pygame??

2006-11-09 Thread Jorge Godoy
[EMAIL PROTECTED] writes:

 Hi! I need to manipulate multicolor strings, i.e. strings with a color
 associated with each letter.
 Any suggestions?

If you're on Unix / Linux the curses module might help.

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-08 Thread Jorge Godoy
Cliff Wells [EMAIL PROTECTED] writes:

 I think this sums up my point of view as well (although I would have
 used around 3215 more words to say it). 

H...  Putting this on the discussion of the week: you'd have used
range(3215) or xrange(3215) more words?  ;-)

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Distilled

2006-11-06 Thread Jorge Godoy
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] writes:

 In [EMAIL PROTECTED], Simon Wittber
 wrote:

 I'd also like to remove any deprecated or stuff which is left in for
 backwards functionality (eg Classic classes).

 Classic classes are still needed for exceptions:

 class E(object):
 ...pass
 ...
 raise E
 Traceback (most recent call last):
   File stdin, line 1, in module
 TypeError: exceptions must be classes, instances, or strings (deprecated),
 not type

On the other hand...

 import exceptions
 class E(exceptions.Exception):
... pass
... 
 raise E
Traceback (most recent call last):
  File stdin, line 1, in ?
__main__.E
 


This also has the advantage to let it explicit in the code that E is an
exception. 


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDE that uses an external editor?

2006-10-16 Thread Jorge Godoy
Nick Craig-Wood [EMAIL PROTECTED] writes:

 Attempting to bring this discussion back on topic: Emacs has a few
 python modes also.  There is the basic python-mode which does
 everything expected of a major-mode.  Syntax colouring, indentation
 that sort of thing.  There is also IM-Python for code navigation, and
 bycycle repair man for refactoring support.  You can run stuff at the
 interactive python prompt from within emacs.

Besides, even though PyDev's indentation got a little better it isn't as smart
as Emacs'.  Being a language where indentation matters, I find Emacs much more
productive and this only feature is a major problem to migrate from Emacs to
Eclipse. 

But, who knows when Eclipse gets better it will have the power needed to
implement the same set of indentation rules...

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDE that uses an external editor?

2006-10-15 Thread Jorge Godoy
[EMAIL PROTECTED] writes:

  # I realize I can do a lot within Emacs/XEmacs, but I suspect with a
  # tool like Eclipse I could do more. However, I don't want to give
  # up the text editing power of Emacs to get it.
 ...
 Ramon I've tried using Eclipse several times, because several good
 Ramon meaning people told me things like you coud do more. 

 My observation about Eclipse comes simply from watching one of the other
 developers at work use it.  I'd like to give it a try, but not at the
 expense of giving up Emacs.

Eclipse: just a GUI over a subset of Emacs today.

One day, when it evolves, it will be something interesting...  I won't give up
on Emacs loading fast and allowing me to work remotely for something that
makes the machine crawl and requires almost all of the RAM I have.

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: People's names

2006-10-10 Thread Jorge Godoy
Theerasak Photha [EMAIL PROTECTED] writes:

 Also 'da' for Portuguese, which means roughly same as
 Nederlands/Vlaams. Maybe. As usual: IANAE.

It looks like the same but at least here in Brasil it isn't considered for
sorting (da Silva should be sorted under Silva, de Souza under Souza,
de Melo under Melo and so on) and it is even stripped in some cases.


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: People's names

2006-10-10 Thread Jorge Godoy
Steve Holden [EMAIL PROTECTED] writes:

 It seems like some sort of free text search on a full name field looks like
 the only realistic globally-acceptable (?) option.

This is what we opted doing.  Normalization to this level wouldn't add much
since there are a lot of Smiths that aren't relatives.

If finding relatives is something you need to do, demand that the mother's
name be filled in and put an optional field for father's name.  Then compare
and ask if there's something between two people with the same mother /
father.  (Remember about people with the same name!  There are a lot of John
Smith or José da Silva around :-))

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: windev vs python SOS

2006-10-01 Thread Jorge Godoy
Scott David Daniels [EMAIL PROTECTED] writes:

 While these statements do mean something to experienced programmers,
 they seem to contradict everything a power-point wielding IT executive
 who understands everything from a 5000 foot point of view knows to
 be true.  I really wish I knew how to explain these things politically.

If you find it out don't forget sharing with us. :-)

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: builtin regular expressions?

2006-09-30 Thread Jorge Godoy
Antoine De Groote [EMAIL PROTECTED] writes:

 Hello,

 Can anybody tell me the reason(s) why regular expressions are not built into
 Python like it is the case with Ruby and I believe Perl? Like for example in
 the following Ruby code

 line = 'some string'

 case line
   when /title=(.*)/
 puts Title is #$1
   when /track=(.*)/
 puts Track is #$1
   when /artist=(.*)/
 puts Artist is #$1
 end

 I'm sure there are good reasons, but I just don't see them.

 Python Culture says: 'Explicit is better than implicit'. May it be related to
 this?

See if this isn't better to read:


def print_message(some_str):
if some_str.startswith('track='):
print Your track is, some_str[6:]
elif some_str.startswith('title='):
print It's a title of, some_str[6:]
elif some_str.startswith('artist='):
print It was played by, some_str[7:]
else:
print Oops, I dunno the pattern for this line...
return

for line in ['track=My favorite track', 'title=My favorite song',
 'artist=Those Dudes', 'Something else']:
print_message(line)


Expected output:


Your track is My favorite track
It's a title of My favorite song
It was played by Those Dudes
Oops, I dunno the pattern for this line...



I came from Perl and was used to think with regular expressions for
everything.  Now I rarely use them.  They aren't needed to solve most of the
problems. 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: builtin regular expressions?

2006-09-30 Thread Jorge Godoy
Mirco Wahab [EMAIL PROTECTED] writes:

 I don't see the point here, this example can be
 translated amost 1:1 to Perl and gets much more
 readable in the end, consider:

I could make it shorter in Python as well.  But for a newbie that haven't seen
the docs for strings in Python I thought the terse version would be more
interesting. 

At least he'll see that there are methods to do what he wants already builtin
with the language.

 sub print_message {
if   (/^(track=)/ ){ print 'Your track is '   .substr($_, length $1).\n }
elsif(/^(title=)/ ){ print 'It\'s a title of '.substr($_, length $1).\n }
elsif(/^(artist=)/){ print 'It was played by '.substr($_, length $1).\n }
else   { print Oops, I dunno the pattern for this line...\n }
 }

 print_message for ( 'track=My favorite track', 'title=My favorite song',
 'artist=Those Dudes',  'Something else' );

If I were writing in Perl I'd not use substr like this and would write code
similar to the one the OP posted (i.e., /^track=(.*)/).

 OK, I do Perl and Python side by side and didn't reach
 that point so far, maybe beause I read the Friedel-Book
  ( http://www.oreilly.com/catalog/regex2/reviews.html )
 sometimes and actually *like* the concept of regular expressions.

I like them as well.  I just don't see the need to use them everywhere. :-) 


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: builtin regular expressions?

2006-09-30 Thread Jorge Godoy
Duncan Booth [EMAIL PROTECTED] writes:

 Or you could make it even clearer by using a loop:

Oops.  Should have read your message before replying to Mirco.  But again,
since the OP didn't read the docs for string operations I tried the terse
approach so that he actually sees the correspondence from Perl to Python. 

Dictionaries (and hashes in Perl) are very powerful and solve very interesting
problems (specially when one is looking for something like a case
implementation in Python). 


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: builtin regular expressions?

2006-09-30 Thread Jorge Godoy
Mirco Wahab [EMAIL PROTECTED] writes:

   sub print_message {
  if   (/^track=(.+?)/ ){ print Your track is $1\n }
  ...

 which has a more complicated regex that is usually
 not understood easily by newbies.

Specially the non-greedy part. :-) I don't believe that non-greedyness would
be adequate here since I believe he's willing to process the whole line.

===
$line = track='My favorite track';
if ($line =~ /^track=(.+?)/) { print My track is $1\n};
===

outputs

===
My track is '
===

While

===
$line = track='My favorite track';
if ($line =~ /^track=(.+)/) { print My track is $1\n};
===

outputs

===
My track is 'My favorite track'
===

and what I'd use

===
$line = track='My favorite track';
if ($line =~ /^track=(.*)/) { print My track is $1\n};
===

has the same output.  ;-)

All this running perl 5.8.8.


Be seeing you,
-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: builtin regular expressions?

2006-09-30 Thread Jorge Godoy
Antoine De Groote [EMAIL PROTECTED] writes:

 Just to get it clear at the beginning, I started this thread. I'm not a newbie

Sorry :-)  I got to this wrong conclusion because of the way I read your
message.

 an expert either, but I'm quite comfortable with the language by now. It's
 just that, when I started Python I loved it for its simplicity and for the
 small amount of code it takes to get something done. So the idea behind my

See that being small is not all that important.  From the Zen of Python:

Explicit is better than implicit.

 original post was that the Perl/Ruby way takes even less to type (for the
 regex topic of this discussion, I'm not generalizing), and that I like a
 lot. To me (and I may be alone) the Perl/Ruby way is more beautiful (Python
 culture: Beautiful is better than ugly) than the Python way (in this
 particular case) and therefore I couldn't see the reasons.

You can import the re module and use regular expressions in Python, but you
probably know that.

 Some of you say that this regex stuff is used rarely enough so that being
 verbose (and therefore more readable ?) is in these few cases the better
 choice. To me this a perfectly reasonable and maybe it is just true (as far as
 one can talk about true/false for something subjective as this). I dont' know
 (yet) ;-)

It is to me. :-)  If you're parsing simple structures then it might not be to
you (for complex structures you'd end up with some sort of parser).

 I just have to learn accept the fact that Python is more verbose more often
 than Ruby (I don't know Perl really). Don't get me wrong though, I know the
 benefits of this (at least in some cases) and I can understand that one opts
 for it. Hopefully I will end up some day preferring the Python way.

One thing that is also interesting: code completion.  One editor can help you
write startswith but it can't help with /^.  The same goes for endswith
compared to $/.  

I just mentioned this because in the argument of less code to write leads to
less bugs doesn't mean that we have typed all what is written :-)

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: There's another Timbot on the loose!

2006-09-29 Thread Jorge Godoy
Paul Rubin http://[EMAIL PROTECTED] writes:

 http://web.cecs.pdx.edu/~mpj/timbot/index.html

Should we tell them that we have the original and have a patent on him? :-) 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for the Perfect Editor

2006-09-14 Thread Jorge Godoy
OKB (not okblacke) [EMAIL PROTECTED] writes:

   What I'm interested in knowing is whether anyone has found any 
 editor other than TextPad and UltraEdit which allows soft word-wrap (no 
 line breaks stored in the file) which do NOT wrap the text to the left 
 edge of the screen but instead wrap it back only as far as the 
 indentation level of the beginning of the line.  So that if I start out 
 on a line indented halfway across the screen, and the line wraps, I get 
 a block of text, all of which is indented halfway across the screen -- 
 but then it's saved in the file as one long line.  In other words, an 
 editor that separates how the text is DISPLAYED from how it's SAVED.

WYSINWYG - What You See Is Not What You Get...

It doesn't make much sense to me, though.  With Emacs I get the wrapping the
way you want, but it really breaks the lines. 

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: filtered view upon lists?

2006-09-12 Thread Jorge Godoy
Wildemar Wildenburger [EMAIL PROTECTED] writes:

 I don't know how else to call what I'm currently implementing: An object that
 behaves like a list but doesn't store it's own items but rather pulls them
 from a larger list (if they match a certain criterion).
 Changes to the filter are instantly reflected in the underlying list.
 Clear enough?

It looks like you're implementing a callable to me.  This is a method that
returns results based on some input -- here your original list and filter.

Then you'll use this method wherever you need that filtered list.

 Ok, so I figured that this is generic enough to be found in some standard
 module already (I've had this often enough: Painfully implementing s/th and
 then finding it in the libs some weeks later.).

I don't believe it is generic.  Nobody knows your data specs or filtering
needs. 

 Any pointers?

Use of list comprehension might make it easier to code this:


def myCallable(my_list, filter):
filtered_list = [(item) for item in my_list if filter(item)]
return filtered_list


Example of full code:

 test_list = range(10)
 filter = lambda x: not x%2
 def myCallable(list, filter):
... filtered_list = [(item) for item in list if filter(item)]
... return filtered_list
... 
 myCallable(test_list, filter)
[0, 2, 4, 6, 8]
 for item in myCallable(test_list, filter):
... print See?  I'm, item
... 
See?  I'm 0
See?  I'm 2
See?  I'm 4
See?  I'm 6
See?  I'm 8
 


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread Jorge Godoy
Jaroslaw Zabiello [EMAIL PROTECTED] writes:

 [EMAIL PROTECTED] wrote:

 + SqlObject allows working with the DB tables without
 using SQL itself.

 Rails has ActiveRecord ORM, which IMO has nicer and simpler
 syntax than SQLObject. Rails has migrations, TB - not (Migrations is
 versioning system for evolving database schema)

TG supports SQL Alchemy as well.  With SQL Alchemy I believe you'll have a
better experience than with Rails' ORM.

With regards to Migrations, SQL Object does support something like that, but
you have to explicitly code it and then you can run sqlobject-admin upgrade
(or the equivalente tg-admin sql upgrade, since it is a wrapper...).

 But rhtml is much more flexible because it can generate *any content*,
 not only xml. But Rails has THREE template systems: rhtml (main), rxml
 (for rss and xml generation) and rjs (for javascript and AJAX).

Well, TG has a few templating systems...  MarkUp, Kid, Cheetah, ZPT, and
others.  You can choose the one that best fits your needs / brain.  You can
even have multiple template systems used depending on what was requested for
the same controller... 


Which one is better isn't of my concern.  I've already tested then and decided
what I want to use.  The best thing is try them and see what works.  You don't
have to choose only one -- but you have to use one per project to make it less
messy ;-)

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLObject or SQLAlchemy?

2006-08-31 Thread Jorge Godoy
BJörn Lindqvist [EMAIL PROTECTED] writes:

 I think this post by the author of SQLAlchemy perfectly summarizes the
 differences between the two ORMs:

 http://article.gmane.org/gmane.comp.python.sqlalchemy.user/1072/

And ActiveMapper is working to some extent better than it was by the time of
the post :-)

-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

  1   2   3   >