Re: Crackly sound in pygame

2007-11-30 Thread David Tweet
Before calling pygame.init(), you can call pygame.mixer.pre_init.
Make sure the sample rate and sample size matches your audio file.
But most likely the issue is that the default audio buffer size of
1024 doesn't cut it for some sound cards; try increasing to the next
power of two.

Ex.
  pygame.mixer.pre_init(44100, -16, 2, 2048)


On Nov 29, 2007 7:33 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hey guys I am running Windows XP and am having an issue with a game
> that my team has created.  Whenever an audio file is played it creates
> a very distorted, crackly sound.  Any ideas what could be the issue?
>
> Thanks
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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


Benchmark...

2007-11-30 Thread ArShAm Shirvani
Hi
I need a benchmark for speed , comparing with other languages

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

Re: Interfaces to high-volume discussion forums (was: Science list)

2007-11-30 Thread Dotan Cohen
On 30/11/2007, Ben Finney <[EMAIL PROTECTED]> wrote:
> "Dotan Cohen" <[EMAIL PROTECTED]> writes:
>
> > On 29/11/2007, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> > > Regardless of what Google/Yahoo/M$/AOL want you to think,
> > > using a web-based mail client is typically the worst way to follow
> > > mailing lists and/or news-groups; much better to use a decent
> > > client program that can download posts in the background, then
> > > sort/thread/filter them as desired.
> >
> > With the exception of Gmail. I really could not follow 20+ high
> > volume lists (such as Python, PHP, Fedora, MySQL, OOo, and some
> > other very high traffic lists) without Gmail.
>
> I'm not interested in learning some centralised web-application
> interface, and far prefer the discussion forum to be available by a
> standard *protocol*, that I can use my choice of *local client*
> application with.
>
> Most of the high-volume discussion lists I participate in are made
> available as NNTP forums via news.gmane.org. I find that immeasurably
> superior to any email interface, not least because I can use *any*
> NNTP client to manage my interaction with those forums.
>
> The metaphor of discussion-forum-as-NNTP-newsgroup is, for my
> purposes, far superior to discussion-forum-as-mailing-list. For those
> forums only available as mailing lists, I find them much more awkward
> to manage.
>
> The proliferation of "web forums", where the *only* way to participate
> is to use an excreable web application that works differently to
> everything else and has no connection to anything else I do on my
> computer, is of course utterly antithesis to my needs.
>
> I would, of course, welcome an increase in the number of discussion
> forums made available as NNTP groups, whether via Gmane or any other
> service — including the same people who host the mailing list (or,
> gods forbid, "web forum").
>

Ben, I agree with you! VBforum, PHPBB, Inforum, and countless other
interfaces to learn drive me nuts. Add to that every web based email
client's "Betas" and random changes, and the situation is a mess.

That said, I _still_ prefer Gmail to any other option. I can tag and
star messages and threads for later retrieval. The search function is
great. I could go on and on.

Yes, there are bugs in Gmail but every app I've tried has bugs. I
didn't care much for any of gmane's webbased interfaces, and although
I prefer work email locally (Kmail||Tbird) I now prefer a web-based
mailing list || forum interface. Gmail is perfect for that.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Accessing a URL file Remotely

2007-11-30 Thread mcl
On 29 Nov, 22:32, TheSeeker <[EMAIL PROTECTED]> wrote:
> On Nov 29, 3:13 pm, mcl <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have been given a url ofCSVfile (http://hostname/dir/file.csv),
> > which when I put the full URL in a web browser shows the contents of
> > the file.
>
> > I want to be able to use theCSVmodule to read that file, which I
> > have successfully used with a localCSVfile.
>
> > Any examples anywhere would be appreciated.
>
> > My basic research suggests URLLIB, but I can not find a suitable
> > example.
>
> > I do not understand what additional information, needs to be given to
> > the remote site in order for it to expose the contents of the file as
> > though I was reading it locally.
>
> > Do I need to copy it to my local machine or can I read it directly
> > from the remote site.
>
> > As you can probably tell, I have never done anything like this, so any
> > help will be gratefully received.
>
> > Thanks
>
> > Richard
>
> -untested--
>
> import urllib,csv
>
> fp_page = urllib.urlopen("http://URL_of_file";)
> reader =csv.reader(fp_page)
> for row in reader:
> print row
>
> Duane

Duane,

Brilliant - I had fears of much more complication.

Thank you very much

Richard

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


Re: Oh no, my code is being published ... help!

2007-11-30 Thread rm
On Nov 30, 1:59 am, Vidyadhar74 <[EMAIL PROTECTED]> wrote:
> Please check your hard disk partition is NTFS or FAT32 if it is FAT32
> then Convert the partition to NTFS and unzip the 7zipped file on NTFS
> partition.

Ok, I admit I don't understand what you mean by this.

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


Re: Need to call functions/class_methods etc using string ref :How

2007-11-30 Thread Bruno Desthuilliers
George Sakkis a écrit :
> On Nov 26, 2:04 pm, Bruno Desthuilliers
> 
> <[EMAIL PROTECTED]> wrote:
> 
>>Donn Ingle a écrit :
>>
>>
I see someone already showed you eval.  Eval is evil.  Don't use it.
Especially if the functions are coming to you from a public URL!
>>
>>>Yes, I suggested to him (by email) this:
>>
>>>thisinstance =  SomeObject.__class__.__dict__
>>>
>>
>>This will only get attributes defined in SomeObject.__class__ - not the
>>one defined in the parent classes. Nor methods dynamically bound to a
>>specific instance.
>>
>>
>>
>>
>>>for f in yourlist:
>>> if f in thisinstance: eval(f)(params)
>>
>>>Which would vet the functions too.
>>
>>You *still* don't need eval here.
>>
>>target = 
>>for funcname in funclist:
>>   func = getattr(target, funcname, None)
>>   if callable(func):
>> func(*args, **kwargs)
>>
>>I've almost never had a real use case for eval (or exec) in 7 years.
> 
> 
> That's not to say there aren't any.

Indeed. But most of the time, I found that Python provides a more 
appropriate solution.

> In one project I'm using exec to
> parse user provided function bodies from a web interface into real
> python functions (the function signatures are auto generated).

A problem I've never had to solve so far, so you're the expert here - 
but what about compiling the source with compile, then instanciating a 
function object from it ?

(snip)
-- 
http://mail.python.org/mailman/listinfo/python-list


getpixel with Python Imaging Library

2007-11-30 Thread jorma kala
Hi,
I read that the getpixel function of the PIL library is relatively slow.
Which alternative is therefore faster and more efficient, accesing the
result of getdata() as a flat list or
using  the function load(), and accessing pixels through the resulting
2-dimensional array?

Thanks a lot.

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

Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread John Machin
On Dec 1, 1:58 am, [EMAIL PROTECTED] wrote:
> Python is a good programming language,  but "Python" is not a good
> name.
>
> First, python also means snake, Monty Python. If we search "python" in
> google, emule, many results are not programming resource. If we search
> PHP, all results are programming resource.
>
> Second, python also means snake, snake is not a good thing in western
> culture. Many people dislike any things relevant to snake. We must
> have high regard for the custom.
>

Pythons are good snakes; they hypnotise the meaninglessly chattering
bandarlog and eat them. Beware!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is __import__ known to be slow in windows?

2007-11-30 Thread Joshua Kugler
> What modules are you __import__ing, and what is platform-dependent in
> each?

The only thing we're importing __import__ are some modules of ours, with no
sytem dependent code in them at all.  Some of them are even empty modules,
as was suggested by one response (for benchmarking purposes).

Turning off Symantec's on-access checking shaved about a bunch of time off
the time spent in __import__ (10 seconds vs 16), but still too high.

Commenting out the import of the only system dependent code we have in our
project (which we don't "manually" import via an __import__ call) produced
no change in run time.

So, we've found a major culprit.  I'll see if I can find more.

Thanks for the pointers so far.

j

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


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread greg
[EMAIL PROTECTED] wrote:
> If we search "python" in
> google, emule, many results are not programming resource.

Have you actually tried this? When I do a google search
for "python", the very *first* result I get is "Python
Programming Language - Official Website".

Also, out of the first 10 results, 7 are about the
Python language, and only 3 are about snakes.

Results are likely to be even better if you include
something programming-related along with "python".

> Second, python also means snake, snake is not a good thing in western
> culture.

Not necessarily. A python is a sleek and powerful
creature, which are good associations for a programming
language. The word also hints at a bit of danger and
excitement. On the whole, I think it's a good name.

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


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Yeef
we search "python" in
google, emule, many results are not programming resource. If we search
PHP, all results are programming resource.
i'm agree!

On Dec 1, 2007 12:08 PM, <[EMAIL PROTECTED]> wrote:

>  Pytn
>
> New name "Pytn" may be better, do you think so ?
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
new city  new thoughts  new men
please choose the freesoftware
to:[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

(More) Re: Is __import__ known to be slow in windows?

2007-11-30 Thread Joshua Kugler
Ok, so we have this code:

t = timeit.Timer(stmt='r()', setup='from __main__ import r')

sys.path.insert(0,'/path/to/code')

def r():
for m in ['three','module','names']:
try:
x = __import__(m)
except ImportError, e:
if not e.message.startswith('No module named'):
raise
x = None

Each of those three module names is a directory under /path/to/code with an
empty __init_.py.

On Linux, the run of that code for 1000 iterations takes 0.014 CPU seconds
with 0.007 of that spent in __import__().

On Windows (with on-access checking turned off), 1000 iterations takes 7.9
seconds, with 7.851 seconds of that spent in __import__().

Let's try something...let's modify the code a bit:

sys.path = ['/path/to/code']

def r():
for m in ['three','module','names']:
x = __import__(m)
x = None

cProfile.run('t.timeit(number=%s)' % number, 'stat_file')
p = pstats.Stats('stat_file')
p.sort_stats('time', 'cum').print_stats(.5)

Now, with only my directory in sys.path, the run times are:
Linux: 0.0013 (0.006 spent in __import__)
Windows: 0.0012 (0.007 spent in __import__)

So, it appears walking the directory trees is what is costing the time.

sys.path on Windows:
['', 'C:\\Python25\\lib\\site-packages\\paste-1.5.1-py2.5.egg',
'C:\\WINDOWS\\system32\\python25.zip',
'C:\\Python25\\DLLs',
'C:\\Python25\\lib',
'C:\\Python25\\lib\\plat-win',
'C:\\Python25\\lib\\lib-tk',
'C:\\Python25',
'C:\\Python25\\lib\\site-packages',
'C:\\Python25\\lib\\site-packages\\win32',
'C:\\Python25\\lib\\site-packages\\win32\\lib',
'C:\\Python25\\lib\\site-packages\\Pythonwin']

On Linux:
['', '/usr/lib/python2.5/site-packages/setuptools-0.6c7-py2.5.egg',
'/usr/lib/python2.5/site-packages/simplejson-1.7.3-py2.5-linux-i686.egg',
'/usr/lib/python2.5/site-packages/Paste-1.5.1-py2.5.egg',
'/usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev-py2.5.egg',
'/home/jkugler/programming',
'/usr/lib/python25.zip',
'/usr/lib/python2.5',
'/usr/lib/python2.5/plat-linux2',
'/usr/lib/python2.5/lib-tk',
'/usr/lib/python2.5/lib-dynload',
'/usr/local/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages',
'/var/lib/python-support/python2.5',
'/usr/lib/site-python']

So, not identical (actually, longer on linux) but similar.

Interesting, at any rate.

j

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


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Russ P.
On Nov 30, 6:58 am, [EMAIL PROTECTED] wrote:
> Python is a good programming language,  but "Python" is not a good
> name.

I agree that Python is not a good name for a programming language, but
I'm afraid we're stuck with it.

If I had invented Python, I would have called it Newton or Euler,
arguably the greatest scientist and mathematician ever, respectively.
Then again, if pigs could fly ...

Speaking of stupid names, what does "C++" mean? I think it's the grade
you get when you just barely missed a "B--". But I can't deny that it
*is* good for searching.


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


Re: Is __import__ known to be slow in windows?

2007-11-30 Thread John Machin
On Dec 1, 10:08 am, Joshua Kugler <[EMAIL PROTECTED]> wrote:
> [I tried googling for this, didn't find anything relevant.]
>
> We've recently been doing some profiling on a project of ours.  It runs
> quite fast on Linux but *really* bogs down on Windows 2003.  We initially
> thought it was the simplejson libraries (we don't use the C extensions) but
> profiling proved otherwise.
>
> We have a function that does some runtime imports via calls to __import__.
> We ran 1000 iterations (we used cProfile) of the application (web app).
> There were eight calls to __import__ per iteration, so 8000 calls total.
> Identical hardware, by the way.
>
> On Linux (Debian Etch, Python 2.5.1)
> Total time was 2.793 CPU seconds, with __import__ using 1.059 seconds of
> that.  So, 37% of the time was spent in import.  Not great, but not a show
> stopper.
>
> On Windows 2003 (R2, Python 2.5.1)
> Total time was 18.532 CPU seconds, with __import__ using 16.330 seconds
> (88%) of that.
>
> So, Linux spends 1.734 seconds on non-import activities, and Windows spends
> 2.202 seconds on non-import activities.  Pretty close.  But 16.3 seconds on
> import!?
>
> Is this a known deficiency in Windows' Python import calls, or is there
> something deeper going on here?
>
> Pointers, suggestions, and URLs welcome.
>
> j

What modules are you __import__ing, and what is platform-dependent in
each?

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


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Basilisk96
Matt Nordhoff <[EMAIL PROTECTED]> wrote:
<..snip..>
> Great, now the Google results will just be filled with AMD typoes. :-P

Clever! But "typoes" is a typo :-P

>From m-w.com:

typo
Function:
noun
Inflected Form(s):
plural: typos
Etymology:
short for typographical (error)
Date:
1878
: an error (as of spelling) in typed or typeset material

===
But seriously guys (and gals, if any?), this has to be the most
senseless thread I have seen..
tum-dee-dum...
the OP must have been "counting flowers on the wall"...

If the OP's advice is to be followed - what shall we do, pray tell,
with the names of all the existing lovely libraries and apps that we
are so used to? Surely they all have to be changed over to keep up
with such progress?!

Numpy => NumAth?
wxPython => wxAthon?
PyAlaMode => AthAlaMode?
etc.

FWIW, an ASP is also a snake...but that's another discussion. Shall we
start one? I think NOT..

This has been an entertaining break from the ordinary, but let's get
back to something more useful.

Cheers,
-Basilisk96
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is __import__ known to be slow in windows?

2007-11-30 Thread Paul McGuire
On Nov 30, 5:08 pm, Joshua Kugler <[EMAIL PROTECTED]> wrote:
> [I tried googling for this, didn't find anything relevant.]
>
> We've recently been doing some profiling on a project of ours.  It runs
> quite fast on Linux but *really* bogs down on Windows 2003.  We initially
> thought it was the simplejson libraries (we don't use the C extensions) but
> profiling proved otherwise.
>
> We have a function that does some runtime imports via calls to __import__.
> We ran 1000 iterations (we used cProfile) of the application (web app).
> There were eight calls to __import__ per iteration, so 8000 calls total.
> Identical hardware, by the way.
>
> On Linux (Debian Etch, Python 2.5.1)
> Total time was 2.793 CPU seconds, with __import__ using 1.059 seconds of
> that.  So, 37% of the time was spent in import.  Not great, but not a show
> stopper.
>
> On Windows 2003 (R2, Python 2.5.1)
> Total time was 18.532 CPU seconds, with __import__ using 16.330 seconds
> (88%) of that.
>
> So, Linux spends 1.734 seconds on non-import activities, and Windows spends
> 2.202 seconds on non-import activities.  Pretty close.  But 16.3 seconds on
> import!?
>
> Is this a known deficiency in Windows' Python import calls, or is there
> something deeper going on here?
>
> Pointers, suggestions, and URLs welcome.
>
> j

Imagine you have two laundry baskets, one is green, one is purple.
Both contain 10 pairs of pants, but the pockets of the pants in the
purple basket are filled with rocks.

You pick up the green basket - kind of heavy, but not terrible.  Then
you pick up the purple basked - wow!  Really heavy!

Who would have had any idea that the color of the laundry basket would
make such a difference in the weight? :)

Of course, to clear up this question, you empty both baskets, try to
lift each one, and then find out that they both weigh about the same.
(Or one does weigh more than the other, but now you have ruled out the
possibility that the baskets' contents were a factor in the
comparison.)

Ok, back to your question.  __import__ doesn't just load up a module.
At import time, all of the top-level code in the module is executed
also.  So if you want to really assess the impact of *just* __import__
on different platforms, then you should try importing:
- empty .py modules
- .py modules containing no top-level executable statements, but some
class or method definitions
- modules that have already been imported

It's possible that your imported module imports additional modules
which have significant platform-dependent logic, or import modules
which are compiled builtins on one platform, but written in Python on
the other.

As it stands, your experiment still has too many unknowns to draw any
decent conclusion, and it certainly is too early to jump to "wow!
__import__ on Windows is sure slower than __import__ on Linux!"

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


ANN: wxPython 2.8.7.1

2007-11-30 Thread Robin Dunn

Announcing
--

The 2.8.7.1 release of wxPython is now available for download at
http://wxpython.org/download.php.  This release has had some bugs
fixed, some minor patches applied, and also incorporates the Google
Summer of Code 2007 version of XRCed, and adds the Editra source code
editor.

Source code is available, as well as binaries for Python 2.3, 2.4 and
2.5, for Windows and Mac, as well some packages for various Linux
distributions.  A summary of changes is listed below and also at
http://wxpython.org/recentchanges.php.

NOTE: On Mac OS X 10.5 (Leopard) the Python 2.5 binaries of wxPython
expect to be used with the user-installed version of MacPython, not
the Apple installed version.  A fix for this issue is being worked on
for the next release.  In the meantime you can either install
MacPython 2.5.1 and adjust your paths so that that Python is used, or
you can stick with Apple's Python and the wxPython 2.8.4.0 that comes
with Leopard.



What is wxPython?
-

wxPython is a GUI toolkit for the Python programming language. It
allows Python programmers to create programs with a robust, highly
functional graphical user interface, simply and easily. It is
implemented as a Python extension module that wraps the GUI components
of the popular wxWidgets cross platform library, which is written in
C++.

wxPython is a cross-platform toolkit. This means that the same program
will usually run on multiple platforms without modifications.
Currently supported platforms are 32-bit Microsoft Windows, most Linux
or other Unix-like systems using GTK2, and Mac OS X 10.3+, in most
cases the native widgets are used on each platform to provide a 100%
native look and feel for the application.


Changes in 2.8.7.1
--

Applied Patch [ 1783958 ] to use the native renderer for drawing the
checkboxes in CheckListCtrlMixin.

Incorporated the new version of XRCed.  This is the result of a Google
Summer of Code 2007 project by Roman Rolinsky, and includes a number
of UI enhancements, as well as a mechanism for adding support for new
components without needing changes to XRCed itself.  These new
components can be those supported at the C++ layer of XRC, as well as
custom XRC handlers written in Python.  See
http://wiki.wxpython.org/XRCed_Refactoring_Project

wxMac: Fixed wx.BusyInfo so it doesn't steal the activated status
from the parent window.  (This actually applies to all frames with the
wx.FRAME_TOOL_WINDOW style and no decorations.)

wxMac: Fixed the lack of painting the area between scrollbars on
Leopard.

wxMac: Fixed assertion errors dealing with toolbars on Leopard.

wxMac: Multiline textcontrols now support attributes for margins and
alignement; only a single tab distance can be set though.

Added the wx.Image.AdjustChannels method.  This function muliplies all
4 channels (red, green, blue, alpha) with a factor (around
1.0). Useful for gamma correction, colour correction and to add a
certain amount of transparency to a image.

Added Editra to the distribution, to give us a simple yet powerful
programmer's code editor to replace the never finished PyAlaMode
editor and related tools.  Many thanks to Cody Precord for the work he
has done on this tool and for allowing us to make it part of wxPython.
Editra has syntax highlighting and other support for over 40
programming languages, excellent OS X integration, is extendable via
plugins, and for those that are on the VI side of the fence there is a
VI emulation mode.  For more information see the Editra website at
http://editra.org/

wxGTK: wx.Frame.ShowFullScreen now preserves the menubar's
accelerators.

wxGTK: wx.GetClientDisplayRect fixed.

Applied patch [1838043], which adds a demo of the wx.RendererNative
class functionality.

Applied patch [1837449], which uses wx.RenderNative for drawing the
combo button in the PopupControl.

Added GetDirItemData to wx.GenericDirCtrl, which returns a reference
to the data object associated with an item in the control.  (Patch
#1836326)


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!

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


Is __import__ known to be slow in windows?

2007-11-30 Thread Joshua Kugler
[I tried googling for this, didn't find anything relevant.]

We've recently been doing some profiling on a project of ours.  It runs
quite fast on Linux but *really* bogs down on Windows 2003.  We initially
thought it was the simplejson libraries (we don't use the C extensions) but
profiling proved otherwise.

We have a function that does some runtime imports via calls to __import__. 
We ran 1000 iterations (we used cProfile) of the application (web app).
There were eight calls to __import__ per iteration, so 8000 calls total.
Identical hardware, by the way.

On Linux (Debian Etch, Python 2.5.1)
Total time was 2.793 CPU seconds, with __import__ using 1.059 seconds of
that.  So, 37% of the time was spent in import.  Not great, but not a show
stopper.

On Windows 2003 (R2, Python 2.5.1)
Total time was 18.532 CPU seconds, with __import__ using 16.330 seconds
(88%) of that.

So, Linux spends 1.734 seconds on non-import activities, and Windows spends
2.202 seconds on non-import activities.  Pretty close.  But 16.3 seconds on
import!?

Is this a known deficiency in Windows' Python import calls, or is there
something deeper going on here?

Pointers, suggestions, and URLs welcome.

j



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


Python's doc problems

2007-11-30 Thread Xah Lee
Every few months, i receive a hearty letter about how well people
agree with my criticism of Python's docs.
(see
http://xahlee.org/perl-python/python_doc_index.html
)

Here's one received this week:
--
Hello,
  I landed on your website's comments about the Python documentation.
I could not agree more. I could scream about it!

The documentation's discussion of character encodings is a disgrace.
It's so bad I would not be able to improve it much, because I dont
understand it. The end result being that I never understood the topic
correctly.

I was a technical writer and would not have been able to get away with
that level of quality.

yours truly
<>
--

  Xah
  [EMAIL PROTECTED]
\xAD\xF4 http://xahlee.org/

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

Re: How to Split a String

2007-11-30 Thread Siah
> I hope you don't use Python to access the database, get a tuple back,
> convert it to a string and then try to break up that string into a list!?

Sadly, that is the case. Well, kinda. I'm using psycopg2 to access
postgresql, which is great. Though postgres has more features than
psycopg2 supports, such as nested arrays within a row, that psycopg2
provides to me as a string, which leaves it to me to try to make sense
out of it. I hate it, its dirty and uncool, but oh well.

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


issue with cookielib.LWPCookieJar

2007-11-30 Thread JD Smith
Greetings:

My cookiejar contains the cookie that I need however when I do
cj.save(file) it does not actually save out to the cookies.lwj  Does
anyone have any clue what would keep this from saving?  It CREATED my
cookies.lwj file so I know it's not permissions.

cookies.lwp:
#LWP-Cookies-2.0


test.py:
def requestXML(frag, server='US', data=None):
  import urllib
  import urllib2
  import os.path
  import cookielib

  base_urls = {
"US":"http://www.wowarmory.com/";,
"EU":"http://eu.wowarmory.com/";,
"US_SECURE":"https://www.wowarmory.com/";,
"EU_SECURE":"https://eu.wowarmory.com/";
  }

  COOKIEFILE = 'cookies.lwp'
  cj = cookielib.LWPCookieJar()

  if os.path.isfile(COOKIEFILE):
cj.load(COOKIEFILE)

  opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

  try:
if data is not None:
  data = urllib.urlencode(data)

req = urllib2.Request(base_urls[server] + frag, data)
req.add_header('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT
6.0; en-US; rv:1.8.1.10) Gecko/20071115 Firefox/2.0.0.10')
handle = opener.open(req)
  except IOError, e:
if hasattr(e, 'code'):
  return 'We failed to open "%s".' % base_urls[server] + frag
elif hasattr(e, 'reason'):
  return "The error object hast he following 'reason' attribute:
%s" % e.reason

  headers = handle.info()
  xml = handle.read()
  print xml
  print headers
  print data

  for index, cookie in enumerate(cj):
print index, '  :  ', cookie
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Witch editor to use!

2007-11-30 Thread barberomarcelo
On 30 nov, 06:10, SMALLp <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I'm new in wxPython and before i start doing anything I have one qustion.
>
> Shoul I use some of editors like boa, spe or shoud i use my favorite
> text editor!
>
> i used IDLE on windows and it seamd nice. Now i have linux installed on
> my mashine and boa works, spe wont start, IDLE crashes when compailinfg!
>
> And if editor is bether choice witch one to use!

I have spe installed and working in Ubuntu 7.10. See some feedback
here:

http://pythonide.blogspot.com/2007/02/spe-now-works-on-wxpython28-and-how-to.html

When I installed spe, it didn't start, but there was a previous fix
(editing a file that I can't remember now). It was a wx version
problem.

HTH

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


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote:
> First, python also means snake, Monty Python. If we search
> "python" in google, emule, many results are not programming
> resource. If we search PHP, all results are programming resource.

Who cares? No one looking for special Python programming tips will
use only "python" as search term.
 
> Second, python also means snake, snake is not a good thing in
> western culture. Many people dislike any things relevant to snake.
> We must have high regard for the custom.

You're not serious, are you?

BTW, PHP has already been confused with a drug in USA.
 
> Now, python3000 is coming. It's the best time to rename!

IMHO: No. Python has a good reputation and renaming would create
confusion.
 
> Athon is a good candidate, you could provide better names.
>
> In Athon, the first letter "A" could pronounce as [ e ] .

This is confusing and a boring of-the-shelf name.

Regards,


Björn

-- 
BOFH excuse #399:

We are a 100% Microsoft Shop.

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


Re: Witch editor to use!

2007-11-30 Thread Ben Finney
SMALLp <[EMAIL PROTECTED]> writes:

> Shoul I use some of editors like boa, spe or shoud i use my favorite
> text editor!

Any text editor will, in a minimal way, do the job, so there's nothing
to enforce "should". But since it seems you're asking for opinions:

A text editor is an indispensible tool for a programmer, and it needs
to be used very frequently, to the point of being able to use it
without conscious interruption of thought to figure out how to do
something.

I think you should learn one powerful general-purpose extensible
cross-platform popular free-software text editor, learn to use it well
over time, and use that for as much of your text editing as possible.

It seems ludicrous to me that people choose editors that are any of:

  * too simple (can't increase expressiveness as you grow in
competence using it)

  * too narrow-focus (can't leverage the investment of learning that
tool by using it for every text editing task)

  * exclude a major operating system (can't leverage the leraning
investment when moving to a new platform)

  * too little community base (can't take advantage of a user
community sharing improvements and features)

  * not free software (can't install it with impunity on any
workstation one finds oneself needing an editor, and can't be
confident the software will continue to be available for as long
as users want it available)

> And if editor is bether choice witch one to use!

The two main choices that meet the criteria above are Vim and Emacs.
In my opinion, either is a good choice.

-- 
 \   "I got food poisoning today. I don't know when I'll use it."  |
  `\  -- Steven Wright |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interfaces to high-volume discussion forums

2007-11-30 Thread Michael Spencer
Ben Finney wrote:
> 
> I'm not interested in learning some centralised web-application
> interface, and far prefer the discussion forum to be available by a
> standard *protocol*, that I can use my choice of *local client*
> application with.
> 
I agree:  I use Thunderbird, and it works well.  But I read NNTP newsgroups on 
several devices, and I would really like to have the read-status synchronized 
across them.

Can anyone recommend a solution that also synchronizes post read status?  If 
Google Reader or something like it handled NNTP, I imagine I'd use it to 
achieve 
this benefit.

Michael

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


Re: Witch editor to use!

2007-11-30 Thread [EMAIL PROTECTED]
Try  the free komodo edit.
it works on both windows,  Linux and Mac OS X

http://www.activestate.com/Products/komodo_edit/
It is what is drawing me away from the kde editor "kate"

and I will close my message with a linke to the features list
http://www.activestate.com/Products/komodo_edit/features.plex
I sound like a commercial.
-- 
http://mail.python.org/mailman/listinfo/python-list


OT: Dovetail (was "Re: Yet another database question, please")

2007-11-30 Thread Tim Chase
>> and what Dabo does dovetails nicely.
> 
> Dovetails?
> 
> Sorry, English is not my native language ;)

A carpentry term where two pieces of wood are formed to fit
together to create the joint:

http://images.google.com/images?q=dovetail

Used metaphorically to mean "as if they were meant to fit together".

(I would have replied off-list, as it's not really apropos, but
your email address was bogus)

-tkc



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


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Dan Upton
On Nov 30, 2007 11:17 AM, Matt Nordhoff <[EMAIL PROTECTED]> wrote:
> Tim Chase wrote:
> > (You'd think this was the Lisp ML, not Python... )
>
> Atsp? :-)
> --

Athp?  Wait, no, Microsoft already claimed that one...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread ureuffyrtu955
  Pytn

New name "Pytn" may be better, do you think so ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error: UnboundLocalError: local variable 'PfFlag' referenced before assignment

2007-11-30 Thread Calvin
On Nov 30, 3:07 pm, "Wang, Harry" <[EMAIL PROTECTED]> wrote:
> $$ TestCase ID : 001
> Step : deleteDvc,206268
> Result Eval type : XmlChk
> Step : deleteDvc,206269
> Result Eval type : XmlChk
> Traceback (most recent call last):
>   File "C:\UDR2\UDRxmlGateway.py", line 388, in 
> ParseAll()
>   File "C:\UDR2\UDRxmlGateway.py", line 371, in ParseAll
> if (PfFlag == 1):
> UnboundLocalError: local variable 'PfFlag' referenced before assignment
>
> PfFlag gets assigned in a for loop in line 365
> for i in range(PfFlagArrSize):
> if (PfFlagArr[i] == 1):
> ---> PfFlag = int(1)
> break
> else:
> PfFlag = int(-1)
>
> No idea what is going on here
>
> Harry C. Wang
> Sr. Test Engineer (Automation)
> Phone 206 - 268 - 7502
> temporary e-mail: [EMAIL PROTECTED]
> Personal e-mail: [EMAIL PROTECTED]
> Ciber EmpID # 36219

OK this problem has been solved.  Duh???  The variable thingy is not
initialized.
-- 
http://mail.python.org/mailman/listinfo/python-list


Error: UnboundLocalError: local variable 'PfFlag' referenced before assignment

2007-11-30 Thread Wang, Harry
$$ TestCase ID : 001
Step : deleteDvc,206268
Result Eval type : XmlChk
Step : deleteDvc,206269
Result Eval type : XmlChk
Traceback (most recent call last):
  File "C:\UDR2\UDRxmlGateway.py", line 388, in 
ParseAll()
  File "C:\UDR2\UDRxmlGateway.py", line 371, in ParseAll
if (PfFlag == 1):
UnboundLocalError: local variable 'PfFlag' referenced before assignment
 
 
PfFlag gets assigned in a for loop in line 365
for i in range(PfFlagArrSize):
if (PfFlagArr[i] == 1):
---> PfFlag = int(1)
break
else:
PfFlag = int(-1)

No idea what is going on here
 
Harry C. Wang
Sr. Test Engineer (Automation)
Phone 206 - 268 - 7502
temporary e-mail: [EMAIL PROTECTED] 
Personal e-mail: [EMAIL PROTECTED] 
Ciber EmpID # 36219
-- 
http://mail.python.org/mailman/listinfo/python-list


Check if a symlink is broken or circular

2007-11-30 Thread Giampaolo Rodola'
Hi there,
I would like to know if such function would be correct for verifying
if a link is broken and/or circular.

def isvalidlink(path):
assert os.path.islink(path)
try:
os.stat(path)
except os.error:
return 1
return 0
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet Another Tabular Data Question

2007-11-30 Thread Ricardo Aráoz
[EMAIL PROTECTED] wrote:
> On Nov 29, 5:46 pm, [EMAIL PROTECTED] wrote:
>> Hi all,
>>
>> Fairly new Python guy here.  I am having a lot of trouble trying to
>> figure this out.  I have some data on some regulations in Excel and I
>> need to basically add up the total regulations for each country--a
>> statistical analysis thing that I'll copy to another Excel file.
>> Writing with pyExcelerator has been easier than reading with xlrd for
>> me...So that's what I did first, but now I'd like to learn how to
>> crunch some data.
>>
>> The input looks like this:
>>
>> Country Module
>> Topic  # of Docs
>> Argentina   Food and Consumer Products  Cosmetics1
>> Argentina   Food and Consumer Products  Cosmetics8
>> Argentina   Food and Consumer Products  Food Additives  1
>> Argentina   Food and Consumer Products  Food Additives  1
>> Australia   Food and Consumer Products  Drinking Water   7
>> Australia   Food and Consumer Products  Food Additives   3
>> Australia   Food and Consumer Products  Food Additives   1
>> etc...
>>
>> So I need to add up all the docs for Argentina, Australia, etc...and
>> add up the total amount for each Topic for each country so, Argentina
>> has 9 Cosmetics laws and 2 Food Additives Laws, etc...
>>
>> So, here is the reduced code that can't add anything...Any thoughts
>> would be really helpful.
>>
>> import xlrd
>> import pyExcelerator
>> from pyExcelerator import *
>>
>> #Open Excel files for reading and writing
>> path_file = "c:\\1\\data.xls"
>> book = xlrd.open_workbook(path_file)
>> Counts = book.sheet_by_index(1)
>> wb=pyExcelerator.Workbook()
>> matrix = wb.add_sheet("matrix")
>>
>> #Get all Excel data
>> n=1
>> data = []
>> while n> data.append(Counts.row_values(n, start_colx=0, end_colx=None))
>> n=n+1
>>
>> COUNTRY, MODULE, TOPIC,DOCS = range(4)
>> COUNTRY_TOT = []
>> n=0
>> while n> x=n
>> while data[n][COUNTRY]==data[n+1][COUNTRY]:
>> n=n+1
>> print sum(data[x:n][FT_DOCS])
>>
>> wb.save('c:\\1\\matrix.xls')
> 

Check itertools.groupby() and operator.itemgetter()


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


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Tim Golden
Tim Couper wrote:
> but it would mean that a version for large duration projects would be 
> "MarAthon" ...

Can't decide whether you were deliberately avoiding "long-running"
there, Tim, or just missed the opportunity :)

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


Re: Job posting on the site is broken

2007-11-30 Thread sjol
Does any one know who would be the webmaster ?

On Nov 29, 4:41 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> sjol <[EMAIL PROTECTED]> writes:
> > To the webmaster of python.org,
>
> > I have tried to have a job posted on the job board but! Alas, it
> > doesn't work and I cannot get a response from the webmaster.
>
> > Shall I post here ?
>
> No.
>
> But, since you say webmaster is not responding, asking here (as you
> have done) seems the correct next action to find someone responsible
> for the website.
>
> --
>  \ "Experience is that marvelous thing that enables you to |
>   `\  recognize a mistake when you make it again."  -- Franklin P. |
> _o__)Jones |
> Ben Finney

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


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Greg Lindstrom
>
> > In Athon, the first letter "A" could pronounce as [ e ] .
>
> For English speakers that pronunciation is just plain wrong.
>

Going back to my shell scripting days, I nominate "nothyP"  as the new name.
--greg
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Tim Couper
but it would mean that a version for large duration projects would be 
"MarAthon" ...

Dr Tim Couper
CTO, SciVisum Ltd

www.scivisum.com



Gerardo Herzig wrote:
> [EMAIL PROTECTED] wrote:
>
>> Python is a good programming language,  but "Python" is not a good
>> name.
>>
>> First, python also means snake, Monty Python. If we search "python" in
>> google, emule, many results are not programming resource. If we search
>> PHP, all results are programming resource.
>>
>> Second, python also means snake, snake is not a good thing in western
>> culture. Many people dislike any things relevant to snake. We must
>> have high regard for the custom.
>>
>> Now, python3000 is coming. It's the best time to rename!
>>
>> Athon is a good candidate, you could provide better names.
>>
>> In Athon, the first letter "A" could pronounce as [ e ] .
>>  
>>
> You will be eaten by the Snake-Ra god tonight!
>
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reading raw variables from file

2007-11-30 Thread Martin Blume
"Bruno Desthuilliers"  schrieb 
> >> I have a file that might contain literal python 
> >> variable statements at every line. For example 
> >> the file info.dat looks like this:
> >> users = ["Bob", "Jane"]
> >> status = {1:"ok",2:users[0]}
> >> the problem is I want to read this file and load 
> >> whatever variables written in it as normal python 
> >> variable statements so that when i read the file, 
> >> my users var will be ["Bob","Jane"] and my status 
> >> var will be {1:"ok",2:users[0]} . 
> >> Is there an easy way of doing this instead of 
> >> parsing the files and checking said types?
> >>
> > 
> > You might want to look at the eval, exec and execfile;
> 
> Or just import...
> 
> > but bear in in mind Paddy's warning about security.
> 
> +10
> 

If I have understood python naming scoping correctly, 
doing
   my_var="hello"
   import stuff
   print my_var
is not the same as
   my_var="hello"
   exec open("stuff.py").read()
   print my_var
with stuff.py containing
   my_var="bye"

I use this exec open("stuff.py").read() mechanism to set
values in my scripts: the script sets a useful default, 
a command-line argument in the form a valid python program
may override it. Why bother with inventing or using another
mechanism when this is perfectly simple, easy and self-explaining?

The one and only thing against it is that a malicious user 
can sneak in an os.system("cd / && rm -rf *"). 

IMHO. YMMV.
Martin








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


Re: Witch editor to use!

2007-11-30 Thread rm
> > And if editor is bether choice witch one to use!
>
> The two main choices that meet the criteria above are Vim and Emacs.
> In my opinion, either is a good choice.

Both Vim and Emacs are hard to learn.  In other words, they will
require that you spend at least some time studying how they work and
practicing.  They have a learning curve that is much larger than using
something simple like NEdit, Gedit, KWrite, etc.  But, they are a lot
more powerful.  One thing that I think favors Vim over Emacs, is that
Vim seems to be installed by default on almost all Linux distros.  So,
if you learn Vim you will never (almost) be without an editor, even if
you just have access through a terminal.  So, I recommend that you do
learn at least the basics of Vim.  Just my 2 cents.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another database question, please

2007-11-30 Thread Bruno Desthuilliers
nmp a écrit :
> Bruno Desthuilliers wrote:
> 
>> nmp a écrit :
>>> Hello to all. I am only just learning both Python and PyGTK (with
>>> Glade). I also need to learn how to use databases in my programs. My
>>> preliminary research leads me in the direction of SQLAlchemy, which
>>> seems to be what everybody else is using.
>>
>> Since it's not quite clear from your question: SQLAlchemy is a pretty
>> good package, but you need still need to know SQL to use it effectively
>> (if it's your case, please forget this remark).
> 
> I will forget the remark then ;)
> 
Sorry, was not obvious from your question !-)

(snip)
>>> So, does anyone have a good example that shows how to tie these things
>>> toegether? I would like to have the GUI dialogs and treeviews directly
>>> interacting with the underlying tables and/or views.
>>>
>>> [cough]Like Borland Delphi 1.0, in the nineties...[/cough]
>>  From experience (with Delphi, VB and a couple related but less known
>> systems), directly tying widgets to database is a pretty brittle
>> architecture for anything else than Q&D Simple Stupid GUI/DB pipelines.
> 
> Well, that's one of the reasons I mentioned Delphi within a cough... I 
> remember using that some years ago for precisely the quick and dirty 
> hacks that you speak of. I am sure there are better ways, but can you 
> please point me to them?

Well... I'm afraid I never done any serious rich-client programming in 
Python - I'm mostly doing web and sysadmin related stuff nowadays (that 
is, for the  or more past years). I just know that when I was doing 
rich-client business apps on Window (that is: in a former life...), I 
always ended up removing all those pesky "db-widgets" and manually 
writing the code to tie GUI and model together - I guess that's what is 
called a "controler" in the MVC triad ?-)

(snip)

> Of course I would like a very robust solution, this is very important. 
> However, fast and relatively "easy" development and prototyping are 
> important too. Python was "sold" to me as a language that is very 
> ceonvenient for this.

Yeps, that's how they got me hooked too !-)

(snip)

> Accessing databases seems to be a bigger step though. There doesn't seem 
> to be a standardised way to do it. And I am slightly nervous about having 
> to reinvent any wheels.

About DB access, there are two major APIs : the official (low-level - 
that is,relatively to the other one...) db-api, and the higher-level 
SQLAlchemy package. Note that while having an ORM part, SQLAlchemy is 
first an higher-level SQL/Python integration layer, so you can still 
think "relational" - but with something much more powerful than strings 
to build your queries.

Tying the model (wether relational or not) with the UI is quite a 
different problem. I assume you know what MVC mean, and from then I'm 
afraid I can't help more.

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

Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Tim Chase
>> In Athon, the first letter "A" could pronounce as [ e ] .
> 
> For English speakers that pronunciation is just plain wrong.
> 
> You're trolling, right?

Yeth, obviouthly he ith... ;)

(You'd think this was the Lisp ML, not Python... )

-tkc




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


Re: Yet another database question, please

2007-11-30 Thread Peter Decker
On Nov 30, 2007 9:20 AM,  <[EMAIL PROTECTED]> wrote:
>
> On Nov 30, 7:23 am, nmp <[EMAIL PROTECTED]> wrote:
> > Hello to all. I am only just learning both Python and PyGTK (with Glade).
> > I also need to learn how to use databases in my programs. My preliminary
> > research leads me in the direction of SQLAlchemy, which seems to be what
> > everybody else is using.
> >
> > So, does anyone have a good example that shows how to tie these things
> > toegether? I would like to have the GUI dialogs and treeviews directly
> > interacting with the underlying tables and/or views.
> >
> > [cough]Like Borland Delphi 1.0, in the nineties...[/cough]
> >
> > Another question: I found that in Ubuntu, I was able to install the Glade
> > widgets for libgnomedb (libgnomedb3-glade3). Would these be usable with
> > Python/PyGTK, too? As is too common, the documentation provided is
> > somewhat scarce.
> >
> > Any sort of pointers or suggestions welcome, of course.
>
> You should try Dabo. It sounds like what you want to do and what Dabo
> does dovetails nicely.
>
> http://dabodev.com/

Dabo doesn't work with PyGTK, so if he goes with Dabo, he'll have to
settle for a GUI toolkit that looks native on all platforms instead of
just Gnome.  ;-)

-- 

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Grant Edwards
On 2007-11-30, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> In Athon, the first letter "A" could pronounce as [ e ] .

For English speakers that pronunciation is just plain wrong.

You're trolling, right?

-- 
Grant Edwards   grante Yow! As President I have
  at   to go vacuum my coin
   visi.comcollection!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing a URL file Remotely

2007-11-30 Thread Grant Edwards
On 2007-11-30, mcl <[EMAIL PROTECTED]> wrote:

> Brilliant - I had fears of much more complication.

I've been writing Python programs for almost 10 years, and I
still have that reaction not infrequently.

-- 
Grant Edwards   grante Yow! I like the way ONLY
  at   their mouths move ...  They
   visi.comlook like DYING OYSTERS
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting array

2007-11-30 Thread Chris Hulan
the list.sort method seems to do exactly what you want?

Unless your array() method is creating a custom array object with
different sort functionality than list?

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


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Gerardo Herzig
[EMAIL PROTECTED] wrote:

>Python is a good programming language,  but "Python" is not a good
>name.
>
>First, python also means snake, Monty Python. If we search "python" in
>google, emule, many results are not programming resource. If we search
>PHP, all results are programming resource.
>
>Second, python also means snake, snake is not a good thing in western
>culture. Many people dislike any things relevant to snake. We must
>have high regard for the custom.
>
>Now, python3000 is coming. It's the best time to rename!
>
>Athon is a good candidate, you could provide better names.
>
>In Athon, the first letter "A" could pronounce as [ e ] .
>  
>
You will be eaten by the Snake-Ra god tonight!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Oh no, my code is being published ... help!

2007-11-30 Thread Neil Cerutti
On 2007-11-30, Eduardo O. Padoan <[EMAIL PROTECTED]> wrote:
> On Nov 30, 2007 11:18 AM, Peter Decker <[EMAIL PROTECTED]> wrote:
>> On Nov 30, 2007 1:19 AM, Tim Roberts <[EMAIL PROTECTED]> wrote:
>>
>> > You also have a couple of instances of:
>> > print("Error Squeezing %s...")
>> >
>> > The parentheses serve no purpose here, and are unidiomatic.
>>
>> I thought that with the eventual dropping of 'print' as a
>> statement in Python 3, that writing it this way (as if it were
>> a print function) is preferred, since that will be one fewer
>> thing to convert.
>
> No, writing this way will confound the 2to3 tool. Just try for
> yourself. You would have to write print(something) all the time
> and disable the fix_print convertion. It is easier and safer to
> write the common 2.Xish way and let 2to3 do the work.

Output ought be centralized to support maintenance, solving the
3.0 compatibility problem as a side-effect.

So the above would be something like:

  my_print("Error Squeezing %s..." % the_thingy)

With my_print defined appropriately for the time and place.

Moreover, publishing code today with print(...) will, at best,
require a needless digression.

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


Unicode string formating

2007-11-30 Thread nico
Hi,
I need to do a lot of string formating, and I have strings and/or
unicode strings and when I do the following:
"%s %s" % (u'Salut', 'H\xe4llo'), I get an exception :
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position
1: ordinal not in range(128)

How can I insure I don't get an exception?
Thanks,
Nicolas
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Different kinds of Import Errors

2007-11-30 Thread Graham Dumpleton
On Dec 1, 12:24 am, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> Sorry, but this does not work. If there is an ImportError
> during importing the existing module, it won't get inserted
> into sys.modules. I just tried it with a small example.
>
> An other solution would be to inspect the traceback. If the
> app_name+'.management' is in it, it exists.
>
> Graham Dumpleton schrieb:
>
> > On Nov 28, 12:35 am, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> >> If you look at this code, you see there are two kind of ImportErrors:
>
> >> 1. app_name has no attribute or file managment.py: That's OK.
> >> 2. managment.py exists, but raises an ImportError: That's not OK: reraise
>
> >> # Import the 'management' module within each installed app, to 
> >> register
> >> # dispatcher events.
> >> for app_name in settings.INSTALLED_APPS:
> >> try:
> >> __import__(app_name + '.management', {}, {}, [''])
> >> except ImportError, exc:
> >> if exc.args[0]!='No module named management':
> >> raise
>
> >> I am searching a better solution, since in a future version of python
> >> the string 'No module namend management' might be changed.
>
> >> Any better solution?
>
> > Perhaps check for the presence of the module in sys.modules.
>
> >   if (app_name + '.management') in sys.modules:
> > raise
>
> > If not there, module couldn't be found. If module there but exception
> > occurred then some other import related error occurred.

What example did you use to test it? What version of Python are you
using?

Curious, as at least for Python 2.3 it behaves as I described with the
simple examples I tested. I do vaguely remember behaviour related to
this changing though, so possible that newer version works
differently.

First try case of importing module that doesn't exist:

>>> import sys
>>> import z
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: No module named z
>>> sys.modules['z']
Traceback (most recent call last):
  File "", line 1, in ?
KeyError: 'z'

Thus ImportError occurred, and not in sys.modules. Therefore module
must not have been able to be found.

Now lets try existing module, but non ImportError case first:

$ cat a.py
print 'a1'
xxx
print 'a2'

>>> import sys
>>> sys.modules['a']
Traceback (most recent call last):
  File "", line 1, in ?
KeyError: 'a'
>>> import a
a1
Traceback (most recent call last):
  File "", line 1, in ?
  File "a.py", line 2, in ?
xxx
NameError: name 'xxx' is not defined
>>> sys.modules['a']


Thus, although an exception occurred in importing file, the module is
still in sys.modules.

Now lets try for an ImportError for where target module exists:

$ cat a.py
print 'a1'
import z
print 'a2'

>>> import sys
>>> import a
a1
Traceback (most recent call last):
  File "", line 1, in ?
  File "a.py", line 2, in ?
import z
ImportError: No module named z
>>> sys.modules['a']


In this case ImportError occurred but is in sys.modules, thus
ImportError can only have been related to a sub module import as top
level module did actually exist.

I'll have to try this at work next week on newer version of Python
than my Mac has.

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


Re: Yet another database question, please

2007-11-30 Thread Bruno Desthuilliers
nmp a écrit :
> Bruno Desthuilliers wrote:
> 
> [..]
> 
>> About DB access, there are two major APIs : the official (low-level -
>> that is,relatively to the other one...) db-api, and the higher-level
>> SQLAlchemy package. Note that while having an ORM part, SQLAlchemy is
>> first an higher-level SQL/Python integration layer, so you can still
>> think "relational" - but with something much more powerful than strings
>> to build your queries.
>>
>> Tying the model (wether relational or not) with the UI is quite a
>> different problem. I assume you know what MVC mean, and from then I'm
>> afraid I can't help more.
> 
> MVC is one of those vague abbreviations that describe the architecture of 
> three-tier client/server applications, right? :)

Nope. It's one of those vague abbreviations that describes the 
architecture of GUI applications !-)

More seriously, the original MVC concept (which comes from Smalltalk) is 
still worth studying.

> Anyway, I think I have found some study material. I don't know whether 
> these are really good examples, but I will be studying the source code of 
>  and . 
> These seem to be two programs in the same style that I want to create, 
> using both SQLAlchemy and PyGTK.
> 
> I have also found  (looks trustworthy) and 
>  (website offline at the moment?) 
> which could be alternatives for SQLAlchemy. I am not sure at this point 
> if I want to go that course.
> 

Well, having used SQLAlchemy, I can tell you it's really worth it's 
weight in gold.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Oh no, my code is being published ... help!

2007-11-30 Thread Eduardo O. Padoan
On Nov 30, 2007 11:36 AM, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> "Eduardo O. Padoan" <[EMAIL PROTECTED]> writes:
>
> > No, writing this way will confound the 2to3 tool.
>
> Why?  print("foo") is a perfectly valid Python 2 statement.  Maybe
> it's simply a matter of fixing the tool.
>

print("foo") -> print(("foo"))

If you have any idea of how the tool could understand what you meant,
please report it at bugs.python.org :)

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another database question, please

2007-11-30 Thread kyosohma
On Nov 30, 7:23 am, nmp <[EMAIL PROTECTED]> wrote:
> Hello to all. I am only just learning both Python and PyGTK (with Glade).
> I also need to learn how to use databases in my programs. My preliminary
> research leads me in the direction of SQLAlchemy, which seems to be what
> everybody else is using.
>
> So, does anyone have a good example that shows how to tie these things
> toegether? I would like to have the GUI dialogs and treeviews directly
> interacting with the underlying tables and/or views.
>
> [cough]Like Borland Delphi 1.0, in the nineties...[/cough]
>
> Another question: I found that in Ubuntu, I was able to install the Glade
> widgets for libgnomedb (libgnomedb3-glade3). Would these be usable with
> Python/PyGTK, too? As is too common, the documentation provided is
> somewhat scarce.
>
> Any sort of pointers or suggestions welcome, of course.

You should try Dabo. It sounds like what you want to do and what Dabo
does dovetails nicely.

http://dabodev.com/

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


Re: Oh no, my code is being published ... help!

2007-11-30 Thread rm
On Nov 30, 10:01 am, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2007-11-30, Eduardo O. Padoan <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Nov 30, 2007 11:18 AM, Peter Decker <[EMAIL PROTECTED]> wrote:
> >> On Nov 30, 2007 1:19 AM, Tim Roberts <[EMAIL PROTECTED]> wrote:
>
> >> > You also have a couple of instances of:
> >> > print("Error Squeezing %s...")
>
> >> > The parentheses serve no purpose here, and are unidiomatic.
>
> >> I thought that with the eventual dropping of 'print' as a
> >> statement in Python 3, that writing it this way (as if it were
> >> a print function) is preferred, since that will be one fewer
> >> thing to convert.
>
> > No, writing this way will confound the 2to3 tool. Just try for
> > yourself. You would have to write print(something) all the time
> > and disable the fix_print convertion. It is easier and safer to
> > write the common 2.Xish way and let 2to3 do the work.
>
> Output ought be centralized to support maintenance, solving the
> 3.0 compatibility problem as a side-effect.
>
> So the above would be something like:
>
>   my_print("Error Squeezing %s..." % the_thingy)
>
> With my_print defined appropriately for the time and place.
>
> Moreover, publishing code today with print(...) will, at best,
> require a needless digression.
>
> --
> Neil Cerutti

Thanks for the great pointers.  Exactly what I was looking for.  At
least I hope it will save me some embarrassment. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Can't Find Headers on OSX

2007-11-30 Thread Calvin Spealman
I'm still on 10.4 and I'm trying to build pyOpenSSL, but I'm failing
with Python.h trying to include and failing to find any of the shared
libraries. I can't figure this one out because i just don't compile
anything non trivial often.

ironfroggy:~/Desktop/pyOpenSSL-0.6 ironfroggy$ python setup.py build
running build
running build_py
running build_ext
building 'OpenSSL.crypto' extension
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd
-fno-common -dynamic -DNDEBUG -g -O3 -I/sw/include
-I/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4
-c src/crypto/crypto.c -o
build/temp.macosx-10.4-fat-2.4/src/crypto/crypto.o
In file included from src/crypto/crypto.c:11:
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:18:20:
error: limits.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:21:2:
error: #error "Something's broken.  UCHAR_MAX should be defined in
limits.h."
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:25:2:
error: #error "Python's source code assumes C's unsigned char is an
8-bit type."
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:32:19:
error: stdio.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:34:5:
error: #error "Python.h requires that stdio.h define NULL."
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:37:20:
error: string.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:38:19:
error: errno.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:39:20:
error: stdlib.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:41:20:
error: unistd.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:53:20:
error: assert.h: No such file or directory
In file included from src/crypto/crypto.c:11In file included from
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:55,
 from src/crypto/crypto.c:11:
/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/pyport.h:7:20:
error: :

...

-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://ironfroggy-code.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: any Templating system help

2007-11-30 Thread Ravi Kumar
I havent looked much into string.template . I think i will have to now.
I went trying MAKO, Cheetah, Genshi and some others too. But in less time, I
got confused. I didn;t need a total language. Rather I just want to write my
xHTML/CSS/JS in a page with embedded placeholders like ${variableName}
or ${ModuleName.functiontoBeCaller(args, ...)}

etc. And that should return the lists of all placements, so i can call them
conditionally.
If they have such feature to call the req function by themself, it would be
good.

So please suggest me some better thing.


On Nov 29, 2007 7:56 PM, Yoram Hekma <[EMAIL PROTECTED]> wrote:

> On Thu, Nov 29, 2007 at 06:48:10PM +0530, Ravi Kumar wrote:
> > Hi,
> > I am stuck  a little. I am working on a demo site to propose for the my
> > company. Using mod_python and several python technologies. But the
> website
> > is simply using publisher handler, i dont want to use any framework such
> as
> > DJango etc.
> >
> > so the main idea is, i made many python files which has several defs
> inside,
> > such as index, getList, submitForm etc
> > now everything is working nice, means calling them in url. I need a
> > templating system now. But not slow and complex. The only things in
> > templating system i need is:
> >
> > fetching all the names of variables/placeholder in template. (i can then
> > call the suitable defs from files and apply the wrapper on it and return
> to
> > main caller)
> > setting the values
> >
> > Please suggest some ideas.
> >
> >
> >
> > --
> > -=Ravi=-
>
> > --
> > http://mail.python.org/mailman/listinfo/python-list
>
> Well, I personally like Genshi (http://genshi.edgewall.org/), but
> offcourse there are others (myghty, cheetah) and I know you can use the
> Django templating system apart from the framework (never did this
> though.
>
> But personally, when I only need a templating system and nothing more
> (for some html-reports for instance) I tend to use genshi.
>
> Yoram
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFHTswm6Y3ORTnySxURAvh3AKCtfxKGpHibuvxbw0p+DUZqZJ1LqQCfUDIz
> /c3cHk8FHqaja2vHCuRoPRY=
> =9cSn
> -END PGP SIGNATURE-
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

Re: Oh no, my code is being published ... help!

2007-11-30 Thread Eduardo O. Padoan
On Nov 30, 2007 11:18 AM, Peter Decker <[EMAIL PROTECTED]> wrote:
> On Nov 30, 2007 1:19 AM, Tim Roberts <[EMAIL PROTECTED]> wrote:
>
> > You also have a couple of instances of:
> > print("Error Squeezing %s...")
> >
> > The parentheses serve no purpose here, and are unidiomatic.
>
> I thought that with the eventual dropping of 'print' as a statement in
> Python 3, that writing it this way (as if it were a print function) is
> preferred, since that will be one fewer thing to convert.
>

No, writing this way will confound the 2to3 tool. Just try for
yourself. You would have to write print(something) all the time and
disable the fix_print convertion. It is easier and safer to write the
common 2.Xish way and let 2to3 do the work.

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Oh no, my code is being published ... help!

2007-11-30 Thread Peter Decker
On Nov 30, 2007 1:19 AM, Tim Roberts <[EMAIL PROTECTED]> wrote:

> You also have a couple of instances of:
> print("Error Squeezing %s...")
>
> The parentheses serve no purpose here, and are unidiomatic.

I thought that with the eventual dropping of 'print' as a statement in
Python 3, that writing it this way (as if it were a print function) is
preferred, since that will be one fewer thing to convert.

-- 

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Different kinds of Import Errors

2007-11-30 Thread Thomas Guettler
Sorry, but this does not work. If there is an ImportError
during importing the existing module, it won't get inserted
into sys.modules. I just tried it with a small example.

An other solution would be to inspect the traceback. If the
app_name+'.management' is in it, it exists.

Graham Dumpleton schrieb:
> On Nov 28, 12:35 am, Thomas Guettler <[EMAIL PROTECTED]> wrote:
>> If you look at this code, you see there are two kind of ImportErrors:
>>
>> 1. app_name has no attribute or file managment.py: That's OK.
>> 2. managment.py exists, but raises an ImportError: That's not OK: reraise
>>
>> # Import the 'management' module within each installed app, to 
>> register
>> # dispatcher events.
>> for app_name in settings.INSTALLED_APPS:
>> try:
>> __import__(app_name + '.management', {}, {}, [''])
>> except ImportError, exc:
>> if exc.args[0]!='No module named management':
>> raise
>>
>> I am searching a better solution, since in a future version of python
>> the string 'No module namend management' might be changed.
>>
>> Any better solution?
> 
> Perhaps check for the presence of the module in sys.modules.
> 
>   if (app_name + '.management') in sys.modules:
> raise
> 
> If not there, module couldn't be found. If module there but exception
> occurred then some other import related error occurred.
> 
> Graham
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bundling Python on Mac

2007-11-30 Thread Diez B. Roggisch
Benjamin schrieb:
> On Nov 29, 2:34 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
>> Benjamin schrieb:
>>
>>> Hello, I'm writing a Python/PyQt application. For my Mac distribution.
>>> I would like to include all the needed libraries in the Mac bundle.
>>> How should I go about doing this?
>> The py2app distutils extension should do that for you. It works flawless
>> for PyObjc-apps for me - it _should_ do so for Qt as well, but I have to
>> admit that it sometimes had errors related to Qt when creating bundles -
>> so maybe you need to tweak the support a bit.
> Does it bundle the Python library with it, so there are no (excepting
> system) dependencies?

It does.

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


CSharifi

2007-11-30 Thread CVC
C-Sharifi Cluster Engine: The Second Success Story on "Kernel-Level
Paradigm" for Distributed Computing Support

Contrary to two school of thoughts in providing system software
support for distributed computation that advocate either the
development of a whole new distributed operating system (like Mach),
or the development of library-based or patch-based middleware on top
of existing operating systems (like MPI, Kerrighed and Mosix), Dr.
Mohsen Sharifi hypothesized another school of thought as his thesis in
1986 that believes all distributed systems software requirements and
supports can be and must be built at the Kernel Level of existing
operating systems; requirements like Ease of Programming, Simplicity,
Efficiency, Accessibility, etc which may be coined as Usability.
Although the latter belief was hard to realize, a sample byproduct
called DIPC was built purely based on this thesis and openly announced
to the Linux community worldwide in 1993.  This was admired for being
able to provide necessary supports for distributed communication at
the Kernel Level of Linux for the first time in the world, and for
providing Ease of Programming as a consequence of being realized at
the Kernel Level. However, it was criticized at the same time as being
inefficient. This did not force the school to trade Ease of
Programming for Efficiency but instead tried hard to achieve
efficiency, alongside ease of programming and simplicity, without
defecting the school that advocates the provision of all needs at the
kernel level. The result of this effort is now manifested in the C-
Sharifi Cluster Engine.
 C-Sharifi is a cost effective distributed system software engine in
support of high performance computing by clusters of off-the-shelf
computers. It is wholly implemented in Kernel, and as a consequence of
following this school, it has Ease of Programming, Ease of Clustering,
Simplicity, and it can be configured to fit as best as possible to the
efficiency requirements of applications that need high performance.
It supports both distributed shared memory and message passing styles,
it is built in Linux, and its cost/performance ratio in some
scientific applications (like meteorology and cryptanalysis) has shown
to be far better than non-kernel-based solutions and engines (like
MPI, Kerrighed and Mosix).

Best Regard
~Ehsan Mousavi
C-Sharifi  Development Team
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python vs pythonw

2007-11-30 Thread has
On 30 Nov, 06:16, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> > New to mac.  I have leopard.  What's the difference between python and
> > pythonw?  So far (which isn't very far)  I can't tell the difference.
>
> IIUC, pythonw is linked with the WindowManager library, so it can do
> GUI operations; python can't.

True for Python 2.3.x and earlier. This limitation went away in 2.4,
however, and pythonw is now kept around solely for compatibility with
older scripts that still refer to it.


HTH

has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reading raw variables from file

2007-11-30 Thread Francesco Guerrieri
On Nov 30, 2007 5:57 AM, Astan Chee <[EMAIL PROTECTED]> wrote:
> Hi,
> I have a file that might contain literal python variable statements at
> every line. For example the file info.dat looks like this:
> users = ["Bob", "Jane"]
> status = {1:"ok",2:users[0]}
> the problem is I want to read this file and load whatever variables
> written in it as normal python variable statements so that when i read
> the file, my users var will be ["Bob","Jane"] and my status var will be
> {1:"ok",2:users[0]} . Is there an easy way of doing this instead of
> parsing the files and checking said types?


A much safer approach would be to use Yaml, which provides safely and
easily the requested feature
Give a look at:
http://pyyaml.org/

bye,
francesco
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Donloadin mail on the background

2007-11-30 Thread James Matthews
Use threads or sub processes

On Nov 29, 2007 9:17 PM, Francesco Pietra <[EMAIL PROTECTED]> wrote:

> Dennis:
>
> Why am I using web-based email? As I work on several machines scp linked.
> I
> find often useful to see the same mail on different machines around,
> without
> downloading anything, just to set up the files on-the-fly for local trial
> computation before sending a calculation to the mainframe. That I found
> easy
> with web-based email. I do not maintain locally on any machine any mail
> for
> longer than working on.
>
> I am sure you have, or can devise, a better strategy to the same purpose.
> I am
> not an expert in software.
>
> Regards
> francesco pietra
>
>
>
>
>  
> 
> Be a better sports nut!  Let your teams follow you
> with Yahoo Mobile. Try it now.
> http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Benchmark...

2007-11-30 Thread James Matthews
Google and wikipedia!

On Nov 30, 2007 9:39 AM, ArShAm Shirvani <[EMAIL PROTECTED]> wrote:

> Hi
> I need a benchmark for speed , comparing with other languages
>
> Regards
> Arsham
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.goldwatches.com
http://www.jewelerslounge.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: reading raw variables from file

2007-11-30 Thread Bruno Desthuilliers
Martin Blume a écrit :
> "Astan Chee" schrieb
>> I have a file that might contain literal python 
>> variable statements at every line. For example 
>> the file info.dat looks like this:
>> users = ["Bob", "Jane"]
>> status = {1:"ok",2:users[0]}
>> the problem is I want to read this file and load 
>> whatever variables written in it as normal python 
>> variable statements so that when i read the file, 
>> my users var will be ["Bob","Jane"] and my status 
>> var will be {1:"ok",2:users[0]} . 
>> Is there an easy way of doing this instead of 
>> parsing the files and checking said types?
>>
> 
> You might want to look at the eval, exec and execfile;

Or just import...

> but bear in in mind Paddy's warning about security.

+10

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


Re: Witch editor to use!

2007-11-30 Thread Bruno Desthuilliers
Carl Banks a écrit :
> On Nov 30, 4:40 am, Ant <[EMAIL PROTECTED]> wrote:
>> On Nov 30, 9:10 am, SMALLp <[EMAIL PROTECTED]> wrote:

(snip)

>>> And if editor is bether choice witch one to use!
>> One with a spell checker would be a good start.
> 
> Punny.

indeed !-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL + show() + Vista

2007-11-30 Thread M�ta-MCI (MVP)
Hi!


Sorry, I don't understand english.  But, with Babelfish-translation, I 
recovered essence...
(you should learn French ; yes! yes! yes!)


> I'm glad you found a solution

Thank you for your solicitude


> if that executable doesn't honour the wait

I have just try on another CPU,  with a very new Vista-premium 
(configuration of exit of factory). The assoc est made with the 
WindowsPhotoGallery.exe who don't respect the WAIT


> universally is the solution.

The universal solution, it's... you!


With forthcoming once.
-- 
Michel Claveau

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


Re: Oh no, my code is being published ... help!

2007-11-30 Thread Bruno Desthuilliers
Tim Roberts a écrit :
> rm <[EMAIL PROTECTED]> wrote:
(snip)
> You also have a couple of instances of:
> print("Error Squeezing %s...")
> 
> The parentheses serve no purpose here, and are unidiomatic.

And FWIW, error messages should go to sys.stderr, not to sys.stdout 
which is for normal program ouputs.

=>
   # assert you imported sys before, of course
   print >> sys.stderr, "Error yadda yadda %s " % anything
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reading raw variables from file

2007-11-30 Thread Martin Blume
"Astan Chee" schrieb
> I have a file that might contain literal python 
> variable statements at every line. For example 
> the file info.dat looks like this:
> users = ["Bob", "Jane"]
> status = {1:"ok",2:users[0]}
> the problem is I want to read this file and load 
> whatever variables written in it as normal python 
> variable statements so that when i read the file, 
> my users var will be ["Bob","Jane"] and my status 
> var will be {1:"ok",2:users[0]} . 
> Is there an easy way of doing this instead of 
> parsing the files and checking said types?
>

You might want to look at the eval, exec and execfile;
but bear in in mind Paddy's warning about security.

Regards
Martin


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


Re: PIL + show() + Vista

2007-11-30 Thread Tim Golden
Méta-MCI (MVP) wrote:
> Hi, Tim!
> 
> You are right, for  shimgvw.dll  (on XP / 2000, or some Vista). But 
> others Vista (ou users practice) had associate  images with 
> WindowsPhotoGallery.exe.
> 
> But  shimgvw.dll already exist.
> 
> I found that this line:
> 
> command = 'start "%s" /wait %s\\System32\\rundll32.exe 
> %s\\System32\\shimgvw.dll ImageView_Fullscreen %s && del /f "%s" ' % 
> (title,os.environ['SYSTEMROOT'],os.environ['SYSTEMROOT'],file,file)
> 
> launch a "Photo Gallery" who respect the WAIT.
> 
> For me (and my users), it's a solution.  Perhaps others PIL's users can 
> read that with interest.

I'm glad you found a solution. I think my point was that
you can use the FindExecutable API to determine whatever
is associated and use that (special-casing the shimgvw DLL
to use RunDLL). Obviously, if that executable doesn't
honour the wait then you're stuck, so maybe using shimgvw
universally is the solution.

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


Re: PIL + show() + Vista

2007-11-30 Thread M�ta-MCI (MVP)
Hi, Tim!

You are right, for  shimgvw.dll  (on XP / 2000, or some Vista). But 
others Vista (ou users practice) had associate  images with 
WindowsPhotoGallery.exe.

But  shimgvw.dll already exist.

I found that this line:

command = 'start "%s" /wait %s\\System32\\rundll32.exe 
%s\\System32\\shimgvw.dll ImageView_Fullscreen %s && del /f "%s" ' % 
(title,os.environ['SYSTEMROOT'],os.environ['SYSTEMROOT'],file,file)

launch a "Photo Gallery" who respect the WAIT.

For me (and my users), it's a solution.  Perhaps others PIL's users can 
read that with interest.

Have a good day.

Michel Claveau


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


Re: Witch editor to use!

2007-11-30 Thread Carl Banks
On Nov 30, 4:40 am, Ant <[EMAIL PROTECTED]> wrote:
> On Nov 30, 9:10 am, SMALLp <[EMAIL PROTECTED]> wrote:
>
> > Hello!
>
> > I'm new in wxPython and before i start doing anything I have one qustion.
>
> > Shoul I use some of editors like boa, spe or shoud i use my favorite
> > text editor!
>
> > i used IDLE on windows and it seamd nice. Now i have linux installed on
> > my mashine and boa works, spe wont start, IDLE crashes when compailinfg!
>
> > And if editor is bether choice witch one to use!
>
> One with a spell checker would be a good start.

Punny.


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


Re: PIL + show() + Vista

2007-11-30 Thread Tim Golden
Méta-MCI (MVP) wrote:
> Re!
> 
> I have found the problem. On Vista, the Windows-Photo-Galery (soft 
> default displayer) don't wait. Even with  START /WAIT  (in Image.py & 
> _showxv), it don't wait.
> 
> Then, like the preview don't wait, the (next) "DEL" run prior the end of 
> the launch of the software ; and Windows-Photo-Galery don't found the 
> file...
> 
> I don't have a good solution. For force view of image, it's possible to 
> delete the "DEL /F %s" part ; but that will involve many BMP/temporary 
> files.

I was going to suggest using FindExecutable to find out whatever
your system uses to show pictures... but then I tried it out and
found out that the association is actually via the shimgvw DLL.
So I suppose you'll have to special-case that.


import win32api
import subprocess

filepath = r"c:\temp\test.jpg"
res, exe = win32api.FindExecutable (filepath)
if exe.endswith ("shimgvw.dll"):
   cmd = "rundll32.exe %s,ImageView_Fullscreen %s" % (exe, filepath)
else:
   cmd = "%s %s" % (exe, filepath)

subprocess.call (cmd)



On my XP machine this waits for the ImageViewer to return.
Be interesting to see if that's different under Vista. At
least it offers you a little more control, perhaps?

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


Re: python vs pythonw

2007-11-30 Thread Ant
On Nov 30, 3:30 am, John Velman <[EMAIL PROTECTED]> wrote:
> New to mac.  I have leopard.  What's the difference between python and
> pythonw?  So far (which isn't very far)  I can't tell the difference.
>
> I have a small application using TKinter that I was working on under
> Linux.  Both python and pythonw run it, but on both it "stops
> responding"  (pinwheel of death) when I touch the vertical scrollbar.

On Windows, python runs in console mode (and pops up a console window
if you're not executing the script from a console already), pythonw
runs the script as a background process. I'd imagine that it is the
same for the Mac, and I shouldn't think it has anything to do with
your problem here.

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


Re: PIL + show() + Vista

2007-11-30 Thread M�ta-MCI (MVP)
Re!

I have found the problem. On Vista, the Windows-Photo-Galery (soft 
default displayer) don't wait. Even with  START /WAIT  (in Image.py & 
_showxv), it don't wait.

Then, like the preview don't wait, the (next) "DEL" run prior the end of 
the launch of the software ; and Windows-Photo-Galery don't found the 
file...

I don't have a good solution. For force view of image, it's possible to 
delete the "DEL /F %s" part ; but that will involve many BMP/temporary 
files.

@+ & sorry for my bad english

Michel Claveau


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


Re: Science list

2007-11-30 Thread J. Robertson
Hi,

A.T.Hofkamp wrote:
> So what is the focus in the list?
> 
> I think 'science' is both too broad and in many cases not at all relevant for
> the problem at hand.
> 
 > [snip]
> 
> Any particular brand of science (CS, Math, Physics, Bio, Chemistry, other)?
> 
> Should I use Python for programming a science problem?
> 
> [snip]
 >
> 
> I don't see a clear useful line called 'science', but YMMV.

I agree with your points here, but I feel that it's one of these things 
that is easily recognized yet can't be defined properly.

CS is well handled by this newsgroup (c.l.p) but many other topics 
(Physics, Bio..) have similar issues when it comes to Python: how do you 
use algebraic libraries efficiently (e.g. LAPACK, PGAPack and whatnot), 
how do you interface your piles of FORTRAN in order to waste all these 
dev*years, and what about visualization.

> If the sheer number of posts is a problem, skip subjects that you don't like,
> just like everybody else.
 >
> If your mailinglist idea fails you have a nicely quiet corner (but is 
> otherwise
> useless). That is however more easily achieved by not reading c.l.p.
> 
> If it succeeds, you may easily get the same amount of traffic as you have now
> here.
> 

I hope you're wrong :-)

How about that: anyone that care for such a mailing list please drop me 
a line privately.  I'll report how many people do.

Cheers,
J
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Witch editor to use!

2007-11-30 Thread Ant
On Nov 30, 9:10 am, SMALLp <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I'm new in wxPython and before i start doing anything I have one qustion.
>
> Shoul I use some of editors like boa, spe or shoud i use my favorite
> text editor!
>
> i used IDLE on windows and it seamd nice. Now i have linux installed on
> my mashine and boa works, spe wont start, IDLE crashes when compailinfg!
>
> And if editor is bether choice witch one to use!

One with a spell checker would be a good start.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL + show() + Vista

2007-11-30 Thread M�ta-MCI (MVP)
Hi!

Not a true solution ; because people who don't have IrfanView don't use 
it.

@-salutations

Michel Claveau

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


python newbie - question about lexical scoping

2007-11-30 Thread Matt Barnicle
hi everyone..  i've been chugging along learning python for a few months 
now and getting answers to all needed questions on my own, but this one 
i can't figure out nor can i find information on the internet about it, 
possibly because i don't understand the right words to type into google..

i have a very common scenario and need to know the python way to do it.  
take this example loop:

comments = []
for row in rows:
comment = models.comment()
comment.author = row[1]
comment.text = row[0]
comments.append(comment)

the problem is that when i go to retrieve the comments later, they are 
all the same object!  i assume this is due to there being no lexical 
scoping?  so what is the solution to this?

thank u all!

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


Re: Witch editor to use!

2007-11-30 Thread limodou
On Nov 30, 2007 5:10 PM, SMALLp <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I'm new in wxPython and before i start doing anything I have one qustion.
>
> Shoul I use some of editors like boa, spe or shoud i use my favorite
> text editor!
>
> i used IDLE on windows and it seamd nice. Now i have linux installed on
> my mashine and boa works, spe wont start, IDLE crashes when compailinfg!
>
> And if editor is bether choice witch one to use!

Maybe you can try UliPad.

-- 
I like python!
UliPad <>: http://code.google.com/p/ulipad/
meide <>: http://code.google.com/p/meide/
My Blog: http://www.donews.net/limodou
-- 
http://mail.python.org/mailman/listinfo/python-list


Witch editor to use!

2007-11-30 Thread SMALLp
Hello!

I'm new in wxPython and before i start doing anything I have one qustion.

Shoul I use some of editors like boa, spe or shoud i use my favorite 
text editor!

i used IDLE on windows and it seamd nice. Now i have linux installed on 
my mashine and boa works, spe wont start, IDLE crashes when compailinfg!

And if editor is bether choice witch one to use!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Split a String

2007-11-30 Thread Marc 'BlackJack' Rintsch
On Thu, 29 Nov 2007 12:12:20 -0800, Siah wrote:

> I need to convert the string: '(a, b, "c", d, "e")' into the following
> list ['a', 'b', 'c', 'd', 'e']. Much like a csv reader does. I usually
> use the split function, but this mini-monster wouldn't properly get
> split up due to those random quotations postgresql returns to me.

I hope you don't use Python to access the database, get a tuple back,
convert it to a string and then try to break up that string into a list!?

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Gnu/Linux dialogue boxes in python

2007-11-30 Thread Donn Ingle
Paul Boddie wrote:
> I didn't proceed any
> further than a simple wrapping around KDialog, Zenity and Xdialog,
> since the aim is to cover more than the usual UNIX-like platforms.
> However, I could make that code available separately
Thanks for the feedback and the links. I'd like to use your code (if you
don't mind! ) if it's GPL or something similar -- it may save me time.

Anyone know if zenity can be reliably assumed to be installed on a typical
Gnome desktop?

\d

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


Re: Bundling Python on Mac

2007-11-30 Thread Benjamin
On Nov 30, 6:48 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Benjamin schrieb:
>
> > On Nov 29, 2:34 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> >> Benjamin schrieb:
>
> >>> Hello, I'm writing a Python/PyQt application. For my Mac distribution.
> >>> I would like to include all the needed libraries in the Mac bundle.
> >>> How should I go about doing this?
> >> The py2app distutils extension should do that for you. It works flawless
> >> for PyObjc-apps for me - it _should_ do so for Qt as well, but I have to
> >> admit that it sometimes had errors related to Qt when creating bundles -
> >> so maybe you need to tweak the support a bit.
> > Does it bundle the Python library with it, so there are no (excepting
> > system) dependencies?
>
> It does.
Beautiful!
>
> Diez

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


Re: Announcing Apydia

2007-11-30 Thread Daniel Fetchinson
> Today, I am very excited to announce the first release of the Apydia
> API reference documentation generator for Python. It's designed as an
> instantly serviceable replacement for Pudge's API documentation
> generator. It won't generate complete websites from reST etc. like
> Pudge does, though - Apydia is only about the API.
>
> Features include:
>
> - Basic Pudge compatibility and a short and easy migration path
> - Rudimentary Trac-integration, that is links into Trac's sourcecode
> browser
> - Some fair amount of usability
> - Setuptools integration
> - Flexible, Genshi/XInclude-based themeability with theme inheritance
> - Support for various text formats like Markdown, Textile and reST
> - Other parsers can easily be plugged in on demand
> - Syntax highlighting thanks to Pygments
>
> For more information visit Apydia's web site at http://apydia.ematia.de
> and the Apydia Google Group at http://groups.google.com/group/apydia.


You might want to fix the typo in the title tag of the webpage.

Cheers,
Daniel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Gnu/Linux dialogue boxes in python

2007-11-30 Thread Donn Ingle
> [1] http://www.python.org/pypi/desktop
Oh, just saw this link and fetched the code -- will have a look around.

\d

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


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Matt Nordhoff
Tim Chase wrote:
> (You'd think this was the Lisp ML, not Python... )

Atsp? :-)
-- 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL + show() + Vista

2007-11-30 Thread Tim Golden
Méta-MCI (MVP) wrote:
[Excuse my execrable French below]

> Sorry, I don't understand english.  But, with Babelfish-translation, I 
> recovered essence...
> (you should learn French ; yes! yes! yes!)

Vraiment!

> I have just try on another CPU,  with a very new Vista-premium 
> (configuration of exit of factory). The assoc est made with the 
> WindowsPhotoGallery.exe who don't respect the WAIT

Ceci fonctionne sur XP et Vista, esperant jusqu'a que
termine le ImageViewer. C'est possible de utiliser le
subprocess, mais j'oublie toujours les options differents.

This works on XP and Vista, waiting until the ImageViewer
has exited. You could use the subprocess module, but I
never remember the different options.


import os

filepath = "c:/temp/test.jpg"
assoc = os.popen ("assoc .jpg").read ().splitlines ()[0]
_, filetype = assoc.split ("=")
ftype = os.popen ("ftype %s" % filetype).read ().splitlines ()[0]
_, exe = ftype.split ("=")

#
# NB *must* use correct slashes
#
cmd = exe.replace ("%1", os.path.normpath (filepath))
os.system (cmd)



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


Re: Can't Find Headers on OSX

2007-11-30 Thread Diez B. Roggisch
Calvin Spealman schrieb:
> I'm still on 10.4 and I'm trying to build pyOpenSSL, but I'm failing
> with Python.h trying to include and failing to find any of the shared
> libraries. I can't figure this one out because i just don't compile
> anything non trivial often.
> 
> ironfroggy:~/Desktop/pyOpenSSL-0.6 ironfroggy$ python setup.py build
> running build
> running build_py
> running build_ext
> building 'OpenSSL.crypto' extension
> gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
> -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd
> -fno-common -dynamic -DNDEBUG -g -O3 -I/sw/include
> -I/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4
> -c src/crypto/crypto.c -o
> build/temp.macosx-10.4-fat-2.4/src/crypto/crypto.o
> In file included from src/crypto/crypto.c:11:
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:18:20:
> error: limits.h: No such file or directory
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:21:2:
> error: #error "Something's broken.  UCHAR_MAX should be defined in
> limits.h."
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:25:2:
> error: #error "Python's source code assumes C's unsigned char is an
> 8-bit type."
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:32:19:
> error: stdio.h: No such file or directory
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:34:5:
> error: #error "Python.h requires that stdio.h define NULL."
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:37:20:
> error: string.h: No such file or directory
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:38:19:
> error: errno.h: No such file or directory
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:39:20:
> error: stdlib.h: No such file or directory
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:41:20:
> error: unistd.h: No such file or directory
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:53:20:
> error: assert.h: No such file or directory
> In file included from src/crypto/crypto.c:11In file included from
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:55,
>  from src/crypto/crypto.c:11:
> /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/pyport.h:7:20:
> error: :

Do you have the XCode tools insalled? The Python.h seems to pull in some 
basic headers that aren't found - usually, these should ship with the 
OSX SDK that is part of XCode

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


Re: reading raw variables from file

2007-11-30 Thread MonkeeSage
On Nov 30, 10:05 am, "Martin Blume" <[EMAIL PROTECTED]> wrote:
> "Bruno Desthuilliers"  schrieb
>
>
>
> > >> I have a file that might contain literal python
> > >> variable statements at every line. For example
> > >> the file info.dat looks like this:
> > >> users = ["Bob", "Jane"]
> > >> status = {1:"ok",2:users[0]}
> > >> the problem is I want to read this file and load
> > >> whatever variables written in it as normal python
> > >> variable statements so that when i read the file,
> > >> my users var will be ["Bob","Jane"] and my status
> > >> var will be {1:"ok",2:users[0]} .
> > >> Is there an easy way of doing this instead of
> > >> parsing the files and checking said types?
>
> > > You might want to look at the eval, exec and execfile;
>
> > Or just import...
>
> > > but bear in in mind Paddy's warning about security.
>
> > +10
>
> If I have understood python naming scoping correctly,
> doing
>my_var="hello"
>import stuff
>print my_var
> is not the same as
>my_var="hello"
>exec open("stuff.py").read()
>print my_var
> with stuff.py containing
>my_var="bye"

It's not the same...

from stuff import *

...is.

> I use this exec open("stuff.py").read() mechanism to set
> values in my scripts: the script sets a useful default,
> a command-line argument in the form a valid python program
> may override it. Why bother with inventing or using another
> mechanism when this is perfectly simple, easy and self-explaining?
>
> The one and only thing against it is that a malicious user
> can sneak in an os.system("cd / && rm -rf *").
>
> IMHO. YMMV.
> Martin

Regards,
Jordan
-- 
http://mail.python.org/mailman/listinfo/python-list


Gnu/Linux dialogue boxes in python

2007-11-30 Thread Donn Ingle
Hi,
 Okay, so I am in the mood to try this: Inform the user about what modules
the app requires in a graphical dialogue that can vary depending on what
the system already has installed. (It will fail-to output on cli)

I am running Kubuntu and I seem to have 'kdialog' installed by default (not
sure if it came as stock.)

What other 'stock' systems are there out there in the wild? Ubuntu? Suse?
Fedora? Others?

I would take a stab at wrapping them in python so that I can use the first
dialogue system found to popup messages for the user.

(Hoping, natch, that this has already been done ... ? )

\d

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


ANN: A Primer on Python for Life Science Researchers

2007-11-30 Thread Sebastian Bassi
I'm happy to report the release of a PLOS paper: "A Primer on Python
for Life Science Researchers".
It is a six page education paper introducing Python. If you have a
friend that is a researchers in a biological area and you think that
he may need to know Python, please send him this e-mail:

URL: 
http://compbiol.plosjournals.org/perlserv/?request=get-document&doi=10.1371/journal.pcbi.0030199
(short URL: http://tinyurl.com/2az5d5)

A Primer on Python for Life Science Researchers  Bassi S PLoS
Computational Biology Vol. 3, No. 11, e199
doi:10.1371/journal.pcbi.0030199

Thanks,
-- Sebastián Bassi

-- 
Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología.
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Global variables within classes.

2007-11-30 Thread Bruno Desthuilliers
Kevac Marko a écrit :
> On Nov 10, 8:39 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> Don't think so.  It's a surprise for many but then class attributes are
>> not that common in code or they even use this "gotcha" for
>> immutable default values.  As long a the value isn't changed the default
>> value is just referenced from the class then and not every instance.
>>
> 
> When changing default value, is there any way to change class
> attribute and all referenced attributes too?
> 
> class M:
> name = u"Marko"
> 
> a, b = M(), M()
> a.name = u"Kevac"
> print M.name, a.name, b.name
> -> Marko Kevac Marko
> 
> Is there any way to get here -> Kevac Kevac Kevac ?

class ClassAttribute(object):
   """
   If you dont understand this code, google for
   +python +descriptor +protocol
   """
   def __init__(self, attrname, default=""):
 self.attrname = attrname
 self.default = default

   def __get__(self, inst, cls):
 return getattr(cls, self.attrname, self.default)

   def __set__(self, inst, val):
 setattr(type(inst), self.attrname, val)

class M(object):
   name = ClassAttribute('_name', "Marko")

a, b = M(), M()
a.name = u"Kevac"
print M.name, a.name, b.name

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


Re: Global variables within classes.

2007-11-30 Thread Bruno Desthuilliers
Donn Ingle a écrit :

(about class attributes, instance attributes and lookup rules)
> Okay, I sort of see that. It's not a property

For clarity, better s/property/attribute/ here. In Python, property is a 
builtin class used for computed attributes.

> of 'j' so it looks upwards
> into the class. 
> This is kind of weird.

Given that methods and properties are (at least usually for methods) 
class attributes, this makes sens.

> It's not clear like Python usually is.

Mmm... It's certainly not obvious for newcomers, but this is easy to 
understand and IIRC well documented.

> Is this
> something intentional

Definitively, yes !-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Global variables within classes.

2007-11-30 Thread MarkE
> Kevac Marko <[EMAIL PROTECTED]> writes:
> > When changing default value, is there any way to change class
> > attribute and all referenced attributes too?
>
> > class M:
> > name = u"Marko"
>
> > a, b = M(), M()
> > a.name = u"Kevac"
> > print M.name, a.name, b.name
> > -> Marko Kevac Marko
>
> > Is there any way to get here -> Kevac Kevac Kevac ?
> > Or what is the right way of keeping global variables in classes?
>
I suppose this works, but I agree with Hrvoje Niksic that you're
fighting the language, since by forcing such low level features to
behave differently you're going to end up confusing potentially
yourself, and definitely other Python programmers in the long term.

I've probably skipped lots of edge cases which will catch you out in
exciting, fun ways but other than that good luck...
import types
class Meta(type):
def __new__(metacls, name, bases, dictionary):
newClass = super(Meta, metacls).__new__(metacls, name, bases,
dictionary)
def getInstanceAttribute(self, key):
typeSelf = type(self)
if not key.startswith('__'): #If normal key
try: #To get from class
return getattr(typeSelf, key)
except AttributeError: #Not in class
#Get from instance
return super(typeSelf, self).__getattribute__(key)
else: #Else special key
#Get from instance
return super(typeSelf, self).__getattribute__(key)
newClass.__getattribute__ =
types.MethodType(getInstanceAttribute,
 None,
 newClass)
def setInstanceAttribute(self, key, val):
typeSelf = type(self)
if not key.startswith('__'): #If normal key
if hasattr(typeSelf, key): #If in class
return setattr(typeSelf, key, val)
else: #Else not in class
#Set in instance
return super(typeSelf, self).__setattr__(key, val)
else: #Else special key
return super(typeSelf, self).__setattr__(key, val)
newClass.__setattr__ = types.MethodType(setInstanceAttribute,
None,
newClass)
return newClass

class M(object):
__metaclass__ = Meta
name = u"Marko"
a, b = M(), M()
a.name = u"Kevac"
print M.name, a.name, b.name
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Witch editor to use!

2007-11-30 Thread James Matthews
Eric

On Nov 30, 2007 12:26 PM, Bruno Desthuilliers <
[EMAIL PROTECTED]> wrote:

> Carl Banks a écrit :
> > On Nov 30, 4:40 am, Ant <[EMAIL PROTECTED]> wrote:
> >> On Nov 30, 9:10 am, SMALLp <[EMAIL PROTECTED]> wrote:
>
> (snip)
>
> >>> And if editor is bether choice witch one to use!
> >> One with a spell checker would be a good start.
> >
> > Punny.
>
> indeed !-)
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Accessing a URL file Remotely

2007-11-30 Thread James Matthews
Once you use urlopen you can read the website like a file

On Nov 30, 2007 10:58 AM, mcl <[EMAIL PROTECTED]> wrote:

> On 29 Nov, 22:32, TheSeeker <[EMAIL PROTECTED]> wrote:
> > On Nov 29, 3:13 pm, mcl <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > I have been given a url ofCSVfile (http://hostname/dir/file.csv),
> > > which when I put the full URL in a web browser shows the contents of
> > > the file.
> >
> > > I want to be able to use theCSVmodule to read that file, which I
> > > have successfully used with a localCSVfile.
> >
> > > Any examples anywhere would be appreciated.
> >
> > > My basic research suggests URLLIB, but I can not find a suitable
> > > example.
> >
> > > I do not understand what additional information, needs to be given to
> > > the remote site in order for it to expose the contents of the file as
> > > though I was reading it locally.
> >
> > > Do I need to copy it to my local machine or can I read it directly
> > > from the remote site.
> >
> > > As you can probably tell, I have never done anything like this, so any
> > > help will be gratefully received.
> >
> > > Thanks
> >
> > > Richard
> >
> > -untested--
> >
> > import urllib,csv
> >
> > fp_page = urllib.urlopen("http://URL_of_file";)
> > reader =csv.reader(fp_page)
> > for row in reader:
> > print row
> >
> > Duane
>
> Duane,
>
> Brilliant - I had fears of much more complication.
>
> Thank you very much
>
> Richard
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.goldwatches.com
http://www.jewelerslounge.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Crackly sound in pygame

2007-11-30 Thread alain
On Nov 30, 4:33 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hey guys I am running Windows XP and am having an issue with a game
> that my team has created.  Whenever an audio file is played it creates
> a very distorted, crackly sound.  Any ideas what could be the issue?
>
> Thanks

No,
and the more i look at your post, the more i can't see why.
Sorry for not being able to help.

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


Re: "Python" is not a good name, should rename to "Athon"

2007-11-30 Thread Hendrik van Rooyen
 "John Machin"  wrote:

> Pythons are good snakes; they hypnotise the meaninglessly chattering
> bandarlog and eat them. Beware!

What is a bandarlog - I know the bandersnatch and the boojum, but
bandarlog?

If it is something you can knit - 
If I get you the wool, will you make me one?

- Hendrik

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


Donloadin mail on the background

2007-11-30 Thread Francesco Pietra
Dennis:

Why am I using web-based email? As I work on several machines scp linked. I
find often useful to see the same mail on different machines around, without
downloading anything, just to set up the files on-the-fly for local trial
computation before sending a calculation to the mainframe. That I found easy
with web-based email. I do not maintain locally on any machine any mail for
longer than working on.

I am sure you have, or can devise, a better strategy to the same purpose. I am
not an expert in software.

Regards
francesco pietra



  

Be a better sports nut!  Let your teams follow you 
with Yahoo Mobile. Try it now.  
http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >