Opening an EXE without using os.system

2007-10-08 Thread Christopher Wessels
Hi, 

I am trying to open an EXE file without the command window popping up

At the moment I have got

 

Os.system("exe.exe args")

 

But as the program opens it flashes the command window.

 

It is going to be a WINDOWS program.

 

Thanks

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

pytz has so many timezones!

2007-10-08 Thread Sanjay
Hi All,

I am using pytz.common_timezones to populate the timezone combo box of
some user registration form. But as it has so many timezones (around
400), it is a bit confusing to the users. Is there a smaller and more
practical set? If not, some suggestions on how to handle the
registration form effectively would help me a lot.

thanks
Sanjay

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


Re: Off Topic: Gmail hates newsgroups!!!

2007-10-08 Thread James Matthews
I agree it annoys me also!


-- 
http://search.goldwatches.com/search.aspx?Search=Cufflinks
http://www.jewelerslounge.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: tkinter question

2007-10-08 Thread Eric Brunel
On Sun, 07 Oct 2007 18:09:16 +0200, Kevin Walzer <[EMAIL PROTECTED]>  
wrote:
> Hendrik van Rooyen wrote:
>> "Kevin Walzer" <[EMAIL PROTECTED]> wrote:
>>
>>> I find "pack" to be more flexible than "grid," so I prefer it for  
>>> complex layouts. "grid" is better for simple layouts.
>>  *does a double take*  are you serious? - my experience is that
>> pack is only good for simple single row or single column stuff.

I agree with Hendrik, here...

> Well, I guess it depends on your viewpoint. I find "pack" flexible  
> because it allows me to think in terms of top, bottom, right, and left  
> in terms of arranging UI elements--it's an elegant way to do it in my  
> view. I tend to use "grid" if I have, say, a window with several  
> preference items: a label, an entry field, and a button, all arranged in  
> rows. "grid" is better for stuff like that, I agree.
>
> See http://www.codebykevin.com/blosxom/business/phynchronicity-new.png:  
> this is an application I develop. The layout is all handled by "pack"  
> and paned windows. Where you you use "grid" in a layout like this?

I personally use grid almost everywhere, except for basic rows or columns  
of widgets with no resizing policy. I find pack confusing, for the very  
same reason you find it flexible apparently; for me, this  
top/bottom/left/right stuff is not clear at all, and even after all the  
explanations I read (including yours), I still don't get the resize policy  
with pack. The single 'sticky' option with the row & column weights with  
grid is just clearer for me. And there are layouts that you just can't do  
with pack (canvas or text with vertical and horizontal scrollbars, for  
example...).

But apparently, even this is - again - a matter of taste. So I guess I'll  
have to stop telling everyone that grid is better... ;-)
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pytz has so many timezones!

2007-10-08 Thread Diez B. Roggisch
Sanjay wrote:

> Hi All,
> 
> I am using pytz.common_timezones to populate the timezone combo box of
> some user registration form. But as it has so many timezones (around
> 400), it is a bit confusing to the users. Is there a smaller and more
> practical set? If not, some suggestions on how to handle the
> registration form effectively would help me a lot.

I'm not a timezone-guru - but I _think_ if there are 400 timezones defined,
it should list them, shouldn't it? What if you lived in the one that's not
part of the "practical subset"? 

The only one who can define what that practical subset is supposed to
consist of is _you_. You know where your app is being used, from whom.

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


Re: pytz has so many timezones!

2007-10-08 Thread BJörn Lindqvist
On 10/8/07, Sanjay <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I am using pytz.common_timezones to populate the timezone combo box of
> some user registration form. But as it has so many timezones (around
> 400), it is a bit confusing to the users. Is there a smaller and more
> practical set? If not, some suggestions on how to handle the
> registration form effectively would help me a lot.

Windows timezone selector only lists about 80 timezones. But why force
the user to select timezone? Let them select from a list of countries
and then infer the timezone from that data. With multiple alternatives
for countries with more than one timezone, United States EST, United
States PST and so on.

-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Top Programming Languages of 2013

2007-10-08 Thread Wildemar Wildenburger
Tim Roberts wrote:
> Wildemar Wildenburger <[EMAIL PROTECTED]> wrote:
>> import friends
>> import sex
>>
>> try:
>> sex.have()
>> except ErrectionError, PrematureError:
>> pass
>> finally:
>> sex.brag(friends)
> 
> Well, if "ErrectionError" ever becomes a real exception, I certainly get a
> boatload of email every day from people offering to help me deal with it.

Yeah, because they'va actually spell-checked it. ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Really basic problem

2007-10-08 Thread tomamil
i know this example is stupid and useless, but that's not the answer
to my question.
here it goes:

status = 0.0
for i in range(10):
   status = status + 0.1

   if status == 0.1:
   print status
   elif status == 0.2:
   print status
   elif status == 0.3:
   print status
   elif status == 0.4:
   print status
   elif status == 0.5:
   print status
   elif status == 0.6:
   print status
   elif status == 0.7:
   print status
   elif status == 0.8:
   print status
   elif status == 0.9:
   print status
   elif status == 1.0:
   print status

the expected output:
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0

but it gives me instead:
0.1
0.2
0.4
0.5
0.6
0.7

why?

thanks,

m.

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


Re: Top Programming Languages of 2013

2007-10-08 Thread Michael
I'd guess that by 2013 we'll be using a slightly more graceful, but still
horribly wrong (and unsupported by IE 7.666), redo of HTML, CSS, Javascript,
Flash, and Java with a poorly conceived back-end marriage of PHP + MySQL or
some horrible Microsoft technology for most apps. I'll also venture that as
great as Python is it won't have settled on a really good web development
framework by then because half it's fans want to copy bloat like Ruby on
Rails or .NET and the other half want to be able to develop every line of
code themselves and none of them can agree on a single stable easy-to-use
Pythonic platform. We still won't have a Python-based Javascript replacement
either because nobody can get motivated to replace the crappy client-side
scripting language web developers have come to know and hate.

2013 isn't that far away. A few buzzwords will become boring by then and
we'll mostly be doing what we're doing now.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Really basic problem

2007-10-08 Thread John Machin
On 8/10/2007 7:39 PM, tomamil wrote:
> i know this example is stupid and useless, but that's not the answer
> to my question.
> here it goes:
> 
> status = 0.0
> for i in range(10):
>status = status + 0.1
> [snip]

0.1 can not be represented exactly as a binary floating-point number. to 
see what is really happening, use repr(), e.g. like this:

 >>> t = 0.0
 >>> for i in range(10):
... t += 0.1
... print i, t, repr(t)
...
0 0.1 0.10001
1 0.2 0.20001
2 0.3 0.30004
3 0.4 0.40002
4 0.5 0.5
5 0.6 0.59998
6 0.7 0.69996
7 0.8 0.79993
8 0.9 0.89991
9 1.0 0.99989
 >>>

Read this: http://docs.python.org/tut/node16.html

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


RE: Really basic problem

2007-10-08 Thread Andreas Tawn
> i know this example is stupid and useless, but that's not the answer
> to my question.
> here it goes:
> 
> status = 0.0
> for i in range(10):
>status = status + 0.1
> 
>if status == 0.1:
>print status
>elif status == 0.2:
>print status
>elif status == 0.3:
>print status
>elif status == 0.4:
>print status
>elif status == 0.5:
>print status
>elif status == 0.6:
>print status
>elif status == 0.7:
>print status
>elif status == 0.8:
>print status
>elif status == 0.9:
>print status
>elif status == 1.0:
>print status
> 
> the expected output:
> 0.1
> 0.2
> 0.3
> 0.4
> 0.5
> 0.6
> 0.7
> 0.8
> 0.9
> 1.0
> 
> but it gives me instead:
> 0.1
> 0.2
> 0.4
> 0.5
> 0.6
> 0.7
> 
> why?
> 
> thanks,
> 
> m.

You've just discovered the joys of floating point number comparisons.

Consider this snippet:

status = 0.0
print (repr(status))

for i in range(10):
status += 0.1
print (repr(status))

Output:

0.0
0.10001
0.20001
0.30004
0.40002
0.5
0.59998
0.69996
0.79993
0.89991
0.99989

The issue is that 0.1 etc don't have an exact representation as floating
point.

Interestingly:

>>> 0.10001 == 0.1
True
>>> 0.30004 == 0.3
False

I guess this means that Python has some concept of "close enough", but
I'll have to defer to someone more knowledgeable to explain that.

Cheers,

Andreas Tawn
Lead Technical Artist
Ubisoft Reflections
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Off Topic: Gmail hates newsgroups!!!

2007-10-08 Thread Andrii V. Mishkovskyi
2007/10/4, Robert Dailey <[EMAIL PROTECTED]>:
> I don't know how many other people subscribe to the python mailing list and
> use the mailing list using the web-based interface for Gmail, but I do. I
> use it mainly because Gmail doesn't support IMAP and I use my email from
> multiple locations. Gmail web based works fine except that it starts your
> caret off BEFORE the reply instead of AFTER it. They don't even have an
> option to change this either. I'm just ranting this because it upsets me :)
>
> If anyone might know of a firefox plugin or something to fix this I'd be
> more than willing to use it. I've looked a bit myself for such an extension
> and I've been unsuccessful in finding one.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
JFGI

If you are using Firefox use this Greasemonkey script:
http://userscripts.org/scripts/show/8041
or this extension:
https://addons.mozilla.org/en-US/firefox/addon/4866

-- 
Wbr, Andrii Mishkovskyi.

He's got a heart of a little child, and he keeps it in a jar on his desk.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Really basic problem

2007-10-08 Thread A.T.Hofkamp
On 2007-10-08, Andreas Tawn <[EMAIL PROTECTED]> wrote:
>> i know this example is stupid and useless, but that's not the answer
>> to my question.
>> here it goes:
>> 
> You've just discovered the joys of floating point number comparisons.
>
> Consider this snippet:
>
> status = 0.0
> print (repr(status))
>
> for i in range(10):
> status += 0.1
> print (repr(status))
>
> Output:
>
> 0.0
> 0.10001
> 0.20001
> 0.30004
> 0.40002
> 0.5
> 0.59998
> 0.69996
> 0.79993
> 0.89991
> 0.99989
>
> The issue is that 0.1 etc don't have an exact representation as floating
> point.
>
> Interestingly:
>
 0.10001 == 0.1
> True
 0.30004 == 0.3
> False
>
> I guess this means that Python has some concept of "close enough", but
> I'll have to defer to someone more knowledgeable to explain that.

It's not Python, it is the computer, ie you have this problem with any program
that uses floating point calculations. However, some programs hide it from you
so you think there is no problem...

Plz read the FAQ for an answer to this and many other questions:
http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate


Sincerely,
Albert
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pytz has so many timezones!

2007-10-08 Thread gatti
On Oct 8, 10:40 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Sanjay wrote:
> > Hi All,
>
> > I am using pytz.common_timezones to populate the timezone combo box of
> > some user registration form. But as it has so many timezones (around
> > 400), it is a bit confusing to the users. Is there a smaller and more
> > practical set? If not, some suggestions on how to handle the
> > registration form effectively would help me a lot.
>
> I'm not a timezone-guru - but I _think_ if there are 400 timezones defined,
> it should list them, shouldn't it? What if you lived in the one that's not
> part of the "practical subset"?

I think the problem is displaying a dropdown list of timezones. People
have little idea of how their timezones are called; it would be better
to list countries, which are many but nicely alphabetized, and map the
country to its only timezone, or for the few large countries with more
than a TZ offer a choice later.

Lorenzo Gatti

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


Paned Window Widget Resize/ Refresh Trouble

2007-10-08 Thread Mridula Ramesh
Hi.

I am trying to show data using the paned window widget, and am encountering
this problem: whenever the vertical/horizontal resizing bars are moved, the
widgets and data on the panels are thrown out of alignment and sometimes
totally disappear. They only reappear when you sort of drag the panes across
in a trial-and-error manner. Also, when i update the labels to reflect a
current recordset, some of the labels disappear. Can someone please explain
what I am doing wrong?

I don't know if this will help, but this is what the problematic code looks
like:

def showtagcloud(self):
rts = Tk()
rts.title("Similarly Tagged Files")
rts.geometry("900x600")

pane1 = PanedWindow(rts)
pane1.pack(fill=BOTH, expand=1)
#LEFT PANE
left = Label(pane1, width=30)
pane1.add(left)
pane2 = PanedWindow(pane1, orient=VERTICAL)
pane1.add(pane2)
#TOP PANE
top = Label(pane2, height=210, width=45)
pane2.add(top)
#BOTTOM PANE
bottom = Label(pane2, height=5)
pane2.add(bottom)
pane1.paneconfig(left,minsize=400)
pane2.paneconfig(top,minsize=450)

LbForm = Label(left, text="File titles", justify=LEFT)
LbForm.pack(anchor=N, padx=5, pady=20)

LbDet = Label(top, text="File details", justify=LEFT)
LbDet.pack(anchor=N, padx=5, pady=20)

self.LbID = Label(top)
self.LbID.pack(padx=10, pady=3, anchor=NW)
self.LbTID = Label(top)
self.LbTID.pack(padx=15, pady=5, anchor=NW)
self.LbTitl = Label(top)
self.LbTitl.pack(padx=10, pady=3, anchor=NW)
self.LbTitle = Label(top)
self.LbTitle.pack(padx=15, pady=5, anchor=NW)
self.LbAu = Label(top)
self.LbAu.pack(padx=10, pady=3, anchor=NW)
self.LbAuth = Label(top)
self.LbAuth.pack(padx=15, pady=5, anchor=NW)
self.LbLoc = Label(top)
self.LbLoc.pack(padx=10, pady=3, anchor=NW)
self.LbPathway = Label(top)
self.LbPathway.pack(padx=15, pady=5, anchor=NW)
self.LbAbs = Label(top)
self.LbAbs.pack(padx=10, pady=3, anchor=NW)
self.LbAbst = Label(top)
self.LbAbst.pack(padx=15, pady=5, anchor=NW)


LbTc = Label(bottom, text="Other tags for this file:")
LbTc.pack(anchor=NW, padx=5, pady=20)
self.LbT1 = Label(bottom)
self.LbT1.pack(padx=10, pady=5)
self.LbT2 = Label(bottom)
self.LbT2.pack(padx=10, pady=5)
self.LbT3 = Label(bottom)
self.LbT3.pack(padx=10, pady=5)
self.LbT4 = Label(bottom)
self.LbT4.pack(padx=10, pady=5)
self.LbT5 = Label(bottom)
self.LbT5.pack(padx=10, pady=5)

self.LstTag = Listbox(left, selectmode=BROWSE)
ScrBarV = Scrollbar(left)
ScrBarH = Scrollbar(left, orient=HORIZONTAL)
self.LstTag.pack(side=LEFT,fill=Y)
ScrBarV.pack(side=RIGHT,fill=Y)
ScrBarV.config(command=self.LstTag.yview)
self.LstTag.config(width=60, yscrollcommand = ScrBarV.set)
for xno in range(0, self.gsmax-1):
self.LstTag.insert(END,str(self.pundoos[xno][1]))
self.LstTag.bind("<>", self.elaborate)

def elaborate(self, event):
temphold = self.LstTag.get(self.LstTag.curselection()[0])
for xno in range(0, self.gsmax-1):
if self.pundoos[xno][1]==temphold:
self.LbID.config(text="Index No.")
self.LbTID.config(text=self.pundoos[xno][0])
self.LbTitl.config(text="Title")
self.LbTitle.config(text=self.pundoos[xno][1],
wraplength=300, justify=LEFT)
self.LbAu.config(text="Author(s)")
self.LbAuth.config(text=self.pundoos[xno][2],
wraplength=300, justify=LEFT)
self.LbLoc.config(text="Path")
self.LbPathway.config(text=self.pundoos[xno][3],
wraplength=300, justify=LEFT)
self.LbAbs.config(text="Abstract")
self.LbAbst.config(text=self.pundoos[xno][4],
wraplength=300, justify=LEFT)

self.LbT1.config(text=self.pundoos[xno][5],wraplength=200,
justify=LEFT)
self.LbT2.config(text=self.pundoos[xno][6],wraplength=200,
justify=LEFT)
self.LbT3.config(text=self.pundoos[xno][7],wraplength=200,
justify=LEFT)
self.LbT4.config(text=self.pundoos[xno][8],wraplength=200,
justify=LEFT)
self.LbT5.config(text=self.pundoos[xno][9],wraplength=200,
justify=LEFT)

Thanks.

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

Re: Problem of Readability of Python

2007-10-08 Thread Bruno Desthuilliers
Brian Elmegaard a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]>
> writes:
> 
>> Use dicts, not lists or tuples:
>>
>> a = dict(name='yadda', val=42)
>> print a['name']
>> print a['val']
> 
> I guess you will then need a list or tuple to store the dicts?

Should be a list then IMHO. But then it's the correct use of a list : an 
homegenous collection.

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-10-08 Thread Joost Kremers
[EMAIL PROTECTED] wrote:
> Don't both "man" and those words for measurement come ultimately from
> words for "hand" (similarly to words like "manual", as in labor)?

no. "manual" is derived from latin "manus" meaning "hand". the word "man"
is related to (though not directly derived from) "mind", and the latin word
"mens", which means "mind".


-- 
Joost Kremers  [EMAIL PROTECTED]
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: weakrefs and bound methods

2007-10-08 Thread Steven D'Aprano
On Mon, 08 Oct 2007 04:06:55 +, Michele Simionato wrote:

> > Hmmm... I'm not sure I understand how a with statement is meant to
> > replace class.__del__ in practice. It seems to me that the two things
> > have different uses. with is useful when you create an object, do
> > something with it, dispose of it in an orderly fashion, and then
> > continue. How does that help when you create an unknown number of 
> > long-lasting objects where you can't predict how and when they will be
> > disposed of?

[snip]

>> Now, I don't think the above is feasible. What am I missing?
> 
> Rename your __del__ to close and call it explicitely:
> 
> p.close()
> alist[3].close()
> alist[853].close()
> alist[701].close()

Well, that utterly sucks. If I wanted to call finalizers explicitly, I'd 
be writing in C.

You say that using __del__ leads to hard-to-debug "bombs in my code 
waiting to explode at some unknown moment". Maybe so -- but so does 
explicitly managing resources by hand in the way you suggest, and quite 
frankly, I suspect I'd have a hell of a lot fewer bugs by relying on 
__del__ and the garbage collector than I would from managing resources 
manually in a big project.



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


Re: Don't use __slots__ (was Re: Problem of Readability of Python)

2007-10-08 Thread Steven D'Aprano
On Sun, 07 Oct 2007 21:27:31 -0700, Aahz wrote:

> In article <[EMAIL PROTECTED]>, Steven
> Bethard  <[EMAIL PROTECTED]> wrote:
>>
>>You can use __slots__  [...]
> 
> Aaaugh!  Don't use __slots__!
> 
> Seriously, __slots__ are for wizards writing applications with huuuge
> numbers of object instances (like, millions of instances).  For an
> extended thread about this, see
> 
> http://groups.google.com/group/comp.lang.python/browse_thread/
thread/8775c70565fb4a65/0e25f368e23ab058

Well, I've read the thread, and I've read the thread it links to, and for 
the life of me I'm still no clearer as to why __slots__ shouldn't be used 
except that:

1 Aahz and Guido say __slots__ are teh suxxor;

2 rumour (?) has it that __slots__ won't make it into Python 3.0;

3 inheritance from classes using __slots__ doesn't inherit the slot-
nature of the superclass.


Point 1 is never to be lightly dismissed, but on the other hand Guido 
doesn't like reduce(), and I'm allergic to "Cos I Said So" arguments.

History is full of things which were invented for one purpose being used 
for something else. So, that being the case, suppose I accept that using 
__slots__ is not the best way of solving the problem, and that people of 
the skill and experience of Guido and Aahz will roll their eyes and 
snicker at me.

But is there actually anything *harmful* that can happen if I use 
__slots__?



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


Re: Really basic problem

2007-10-08 Thread Steven D'Aprano
On Mon, 08 Oct 2007 12:09:28 +0200, Andreas Tawn wrote:

> The issue is that 0.1 etc don't have an exact representation as floating
> point.
> 
> Interestingly:
> 
 0.10001 == 0.1
> True
 0.30004 == 0.3
> False
> 
> I guess this means that Python has some concept of "close enough", but
> I'll have to defer to someone more knowledgeable to explain that.

No, not really, except in the sense that any floating point calculation 
will be necessarily imprecise in that sense.

The first example: when you type 0.1 as a float, it can't be stored as 
exactly 1/10 in binary, so you actually get a tiny bit more than 1/10:

>>> 0.1
0.10001

That means that whether you type 0.1 or 0.10001 makes no 
difference. Hence the following result:

>>> 0.10001 == 0.1
True

It isn't that Python looks at 0.10001 and 0.1 and says "well, 
the difference is only 0.1 which is too tiny to worry 
about, so they're equal". Proof by example:

>>> 0.10001 == 0.10002
False


The second example: when you type 0.3, it too can't be represented 
precisely in binary as 3/10, and so you get this:

>>> 0.3
0.2
>>> 0.30001
0.2

So typing 0.3 is the same as typing 0.2 or 
0.30001 as far as floating point binary values are concerned.



(Although note that these results are platform dependent. Your mileage 
may vary.)



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


Re: Really basic problem

2007-10-08 Thread tomamil
thanks you all guys for your help, it's really appreciated...

m.

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


Re: Pil image module, "mode" bug..

2007-10-08 Thread [EMAIL PROTECTED]
On Oct 7, 8:17 pm, Michal Bozon <[EMAIL PROTECTED]> wrote:
> On Sun, 07 Oct 2007 09:02:09 -0700, Abandoned wrote:
> > On Oct 7, 4:47 pm, Michal Bozon <[EMAIL PROTECTED]> wrote:
> >> On Sun, 07 Oct 2007 06:03:06 -0700, Abandoned wrote:
> >> > Hi..
> >> > I find the picture color with:
> >> > im=Image.open("/%s" %name)
> >> > color=im.mode   #p=black & beyaz rgb=color L=grey
>
> >> > This usually work true but in these pictures:
> >> >http://malatya.meb.gov.tr/images/alt/ilsis_logo.gif
> >> >http://malatya.meb.gov.tr/images/meb.gif
>
> >> > Say me P (black&white) but these pictures are color..
>
> >> > What is the reason of this ?
>
> >> > I'm sorry my bad english
>
> >> P does mean palette, black&white is a special case of palette, with two
> >> colors.
>
> > How can i understand the picture color ? (black &white or color or
> > grey)
>
> If you know how to work with RGB images, you can convert the image
> from the palette mode easily:
>
> img2 = img.convert(mode='RGB')
>
> Anyway, always is helpful to read the tutorial or basic documentation.. ;)
>
>  MB- Hide quoted text -
>
> - Show quoted text -

no no no this is not professionalism
are there anybody who know that

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


Re: Pil image module, "mode" bug..

2007-10-08 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote:

> On Oct 7, 8:17 pm, Michal Bozon <[EMAIL PROTECTED]> wrote:
>> On Sun, 07 Oct 2007 09:02:09 -0700, Abandoned wrote:
>> > On Oct 7, 4:47 pm, Michal Bozon <[EMAIL PROTECTED]> wrote:
>> >> On Sun, 07 Oct 2007 06:03:06 -0700, Abandoned wrote:
>> >> > Hi..
>> >> > I find the picture color with:
>> >> > im=Image.open("/%s" %name)
>> >> > color=im.mode   #p=black & beyaz rgb=color L=grey
>>
>> >> > This usually work true but in these pictures:
>> >> >http://malatya.meb.gov.tr/images/alt/ilsis_logo.gif
>> >> >http://malatya.meb.gov.tr/images/meb.gif
>>
>> >> > Say me P (black&white) but these pictures are color..
>>
>> >> > What is the reason of this ?
>>
>> >> > I'm sorry my bad english
>>
>> >> P does mean palette, black&white is a special case of palette, with
>> >> two colors.
>>
>> > How can i understand the picture color ? (black &white or color or
>> > grey)
>>
>> If you know how to work with RGB images, you can convert the image
>> from the palette mode easily:
>>
>> img2 = img.convert(mode='RGB')
>>
>> Anyway, always is helpful to read the tutorial or basic documentation..
>> ;)
>>
>>  MB- Hide quoted text -
>>
>> - Show quoted text -
> 
> no no no this is not professionalism

What professionalism? This isn't a paid support service, you are aware of
that?

> are there anybody who know that

Who knows what? That PIL has e.g. a histogram-function that delivers what
you need (after some thinking, I suggest you try and see at it's output
with various source images)

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


python graphics

2007-10-08 Thread [EMAIL PROTECTED]
hello all
i researching a graphics table with python.haeve you got this how it
have got design and fast making
thanks for your help

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


Re: Don't use __slots__ (was Re: Problem of Readability of Python)

2007-10-08 Thread Diez B. Roggisch
Steven D'Aprano wrote:

> On Sun, 07 Oct 2007 21:27:31 -0700, Aahz wrote:
> 
>> In article <[EMAIL PROTECTED]>, Steven
>> Bethard  <[EMAIL PROTECTED]> wrote:
>>>
>>>You can use __slots__  [...]
>> 
>> Aaaugh!  Don't use __slots__!
>> 
>> Seriously, __slots__ are for wizards writing applications with huuuge
>> numbers of object instances (like, millions of instances).  For an
>> extended thread about this, see
>> 
>> http://groups.google.com/group/comp.lang.python/browse_thread/
> thread/8775c70565fb4a65/0e25f368e23ab058
> 
> Well, I've read the thread, and I've read the thread it links to, and for
> the life of me I'm still no clearer as to why __slots__ shouldn't be used
> except that:
> 
> 1 Aahz and Guido say __slots__ are teh suxxor;
> 
> 2 rumour (?) has it that __slots__ won't make it into Python 3.0;
> 
> 3 inheritance from classes using __slots__ doesn't inherit the slot-
> nature of the superclass.
> 
> 
> Point 1 is never to be lightly dismissed, but on the other hand Guido
> doesn't like reduce(), and I'm allergic to "Cos I Said So" arguments.
> 
> History is full of things which were invented for one purpose being used
> for something else. So, that being the case, suppose I accept that using
> __slots__ is not the best way of solving the problem, and that people of
> the skill and experience of Guido and Aahz will roll their eyes and
> snicker at me.
> 
> But is there actually anything *harmful* that can happen if I use
> __slots__?

Point 3 clearly is harmful. As is the fact that __slots__ gives you troubles
if you e.g. pass objects to code that tries to set arbitrary attributes on
an object. While this might be frowned upon, it can be useful in situations
where you e.g. link GUI-code/objects with data-objects: instead of creating
cumbersome, explicit mappings (as you have to in C/C++/Java) or wrappers,
just set a well-named property.

The question is: what does a slot buy you for this kind of problem? And
while arguing with "then I can't set an attribute I didn't want to be set"
is certainly possible, it ultimately leads to the darn
static-vs-dynamic-discussion. Which we might spare us this time.

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


RE: Really basic problem

2007-10-08 Thread Andreas Tawn
> > I guess this means that Python has some concept of "close 
> enough", but
> > I'll have to defer to someone more knowledgeable to explain that.
> 
> No, not really, except in the sense that any floating point 
> calculation 
> will be necessarily imprecise in that sense.
[snip]
> So typing 0.3 is the same as typing 0.2 or 
> 0.30001 as far as floating point binary values 
> are concerned.
> 
> (Although note that these results are platform dependent. 
> Your mileage 
> may vary.)
> 
> -- 
> Steven
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

After some caffeine and a head-smack, I realise that you're absolutely
right and I just made the same mistake as the OP (doh).

It does demonstrate just how sneaky floating point representations are
though.

Cheers,

Andreas Tawn
Lead Technical Artist
Ubisoft Reflections
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Don't use __slots__ (was Re: Problem of Readability of Python)

2007-10-08 Thread Steven D'Aprano
On Mon, 08 Oct 2007 15:15:36 +0200, Diez B. Roggisch wrote:

>> Well, I've read the thread, and I've read the thread it links to, and
>> for the life of me I'm still no clearer as to why __slots__ shouldn't
>> be used except that:
>> 
>> 1 Aahz and Guido say __slots__ are teh suxxor;
>> 
>> 2 rumour (?) has it that __slots__ won't make it into Python 3.0;
>> 
>> 3 inheritance from classes using __slots__ doesn't inherit the slot-
>> nature of the superclass.
>> 
>> 
>> Point 1 is never to be lightly dismissed, but on the other hand Guido
>> doesn't like reduce(), and I'm allergic to "Cos I Said So" arguments.
>> 
>> History is full of things which were invented for one purpose being
>> used for something else. So, that being the case, suppose I accept that
>> using __slots__ is not the best way of solving the problem, and that
>> people of the skill and experience of Guido and Aahz will roll their
>> eyes and snicker at me.
>> 
>> But is there actually anything *harmful* that can happen if I use
>> __slots__?
> 
> Point 3 clearly is harmful. 

No, it is DIFFERENT, not harmful. At worst, it's a "gotcha" -- a really 
well-documented gotcha.


> As is the fact that __slots__ gives you
> troubles if you e.g. pass objects to code that tries to set arbitrary
> attributes on an object.

You mean like this?

>>> x = 1
>>> x.label = "foo"
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'int' object has no attribute 'label'

I guess that means ints and floats and strings and tuples and lists are 
all harmful too, yes?



> The question is: what does a slot buy you for this kind of problem?

Simplicity and explicitness.



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


changes on disk not visible to script ?

2007-10-08 Thread Bruce
Hi,
I am trying to have my script automate a task, by using os.system, but
I cant get it to work.

manually, outside the script I can do this thing by

C:\echo argument_file | the_program

This works very well when argument_file is created before my script is
started

In the script I try to do it like this:
f = open("argument_file",'w')
f.write(argument)
f.close()
cmd = "echo %s | %s"%(argument_file,the_program)
os.system(cmd)

The script works if the argument_file is already in the directory
before os.system(cmd), but the script must create argument_file before
using os.system. Problem is the_program cannot find argument_file or
the_program cannot find anything inside argument_file.

The python script cannot see changes on disk. In the "My computer"
window, if I do a refresh, I can see the argument_file is created
during the script. I have also tried delays with time.sleep right
after creating the file, but still no success.

Is there some way to around this? must use windows I`m afraid.

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


Re: pytz has so many timezones!

2007-10-08 Thread Sanjay
> Windows timezone selector only lists about 80 timezones. But why force
> the user to select timezone? Let them select from a list of countries
> and then infer the timezone from that data. With multiple alternatives
> for countries with more than one timezone, United States EST, United
> States PST and so on.

> I think the problem is displaying a dropdown list of timezones. People
> have little idea of how their timezones are called; it would be better
> to list countries, which are many but nicely alphabetized, and map the
> country to its only timezone, or for the few large countries with more
> than a TZ offer a choice later.

Thanks for the suggestions!

1. I am unable to understand how Windows manages with only 80 whereas
pytz has 400. Understanding this can be a nice clue for my work. Any
insights?
2. Mapping the timezones to countries is a nice idea. Any idea how to
go about it - I mean whether I have to collect the data manually and
do it, or some better way is available - will help me a lot.

thanks
Sanjay

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


Re: How to create a file on users XP desktop

2007-10-08 Thread goldtech

> from win32com.shell import shell, shellcon
>
> desktop = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
>
> 
>

I have a general problem with using win32com. It's the documentation.
I never know what is available, what classes, methods, what they do.
Even some of the existing documentation admits existing documentation
is scant e.g. "you're just expected to know".

Other than the O'Reilly book. People say to browse COM with PythonWin.
When I try this I'm confronted with a dizzying array, there's tons of
stuff in there. Where's  win32com? If I find it will there be a
synopsis on each class, each classes methods? Will there be usage
examples?

If I'm wrong please educate me.

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


Re: changes on disk not visible to script ?

2007-10-08 Thread kyosohma
On Oct 8, 8:27 am, Bruce <[EMAIL PROTECTED]> wrote:
> Hi,
> I am trying to have my script automate a task, by using os.system, but
> I cant get it to work.
>
> manually, outside the script I can do this thing by
>
> C:\echo argument_file | the_program
>
> This works very well when argument_file is created before my script is
> started
>
> In the script I try to do it like this:
> f = open("argument_file",'w')
> f.write(argument)
> f.close()
> cmd = "echo %s | %s"%(argument_file,the_program)
> os.system(cmd)
>
> The script works if the argument_file is already in the directory
> before os.system(cmd), but the script must create argument_file before
> using os.system. Problem is the_program cannot find argument_file or
> the_program cannot find anything inside argument_file.
>
> The python script cannot see changes on disk. In the "My computer"
> window, if I do a refresh, I can see the argument_file is created
> during the script. I have also tried delays with time.sleep right
> after creating the file, but still no success.


You can test for the existence of the file using os.path.exists() to
prove whether or not Python can "see" the file. You can also have
Python read the file and show what it finds, if anything. I think you
can flush data to the file before closing it...


>
> Is there some way to around this? must use windows I`m afraid.

If the path to the file or the program's executable has spaces in it,
you may have issues. If so, you'll need to put double quotes around
the path(s) and single or triple quote the string. Also, you might try
it with the subprocess module.

Hopefully that gave you some ideas.

Mike


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


Re: changes on disk not visible to script ?

2007-10-08 Thread Richie Hindle
[Bruce]
> f.close()
> cmd = "echo %s | %s"%(argument_file,the_program)

Either: you are a VB programmer and you've actually typed "f.close" rather
than "f.close()",

Or: you meant "type" (or "cat") rather than "echo",

Or: I need a new crystal ball.  8-)

-- 
Richie Hindle
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a file on users XP desktop

2007-10-08 Thread kyosohma
On Oct 7, 12:30 pm, Tim Golden <[EMAIL PROTECTED]> wrote:
> Tim Chase wrote:
> >> You are assuming the system is not localized, that won't work if you
> >> distribute your applications internationally. In my system it is not
> >> "Desktop", it is "Escritorio", and I guess it will vary with every
> >> locale. Does someone know a way to find out what name does the desktop
> >> have?
>
> > I believe you need to read the Desktop value from
>
> > """
> > HKEY_CURRENT_USER\software\microsoft\windows\currentversion\explorer\shell
> > folders
> > """
>
> > which should (in my understanding) hold the full path of the
> > particular folder(s) of interest at that location, including
> > across localizations.
>
> > -tkc
>
> Ideally, use the shell API exposed by pywin32:
>
> 
> from win32com.shell import shell, shellcon
>
> desktop = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
>
> 
>
> For slight convenience:
>
>http://timgolden.me.uk/python/winshell.html
>
> TJG

What happened to your winshell module? I would have thought it perfect
for this.

http://timgolden.me.uk/python/winshell.html

Mike

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


Re: Don't use __slots__ (was Re: Problem of Readability of Python)

2007-10-08 Thread Diez B. Roggisch
Steven D'Aprano wrote:

> On Mon, 08 Oct 2007 15:15:36 +0200, Diez B. Roggisch wrote:
> 
>>> Well, I've read the thread, and I've read the thread it links to, and
>>> for the life of me I'm still no clearer as to why __slots__ shouldn't
>>> be used except that:
>>> 
>>> 1 Aahz and Guido say __slots__ are teh suxxor;
>>> 
>>> 2 rumour (?) has it that __slots__ won't make it into Python 3.0;
>>> 
>>> 3 inheritance from classes using __slots__ doesn't inherit the slot-
>>> nature of the superclass.
>>> 
>>> 
>>> Point 1 is never to be lightly dismissed, but on the other hand Guido
>>> doesn't like reduce(), and I'm allergic to "Cos I Said So" arguments.
>>> 
>>> History is full of things which were invented for one purpose being
>>> used for something else. So, that being the case, suppose I accept that
>>> using __slots__ is not the best way of solving the problem, and that
>>> people of the skill and experience of Guido and Aahz will roll their
>>> eyes and snicker at me.
>>> 
>>> But is there actually anything *harmful* that can happen if I use
>>> __slots__?
>> 
>> Point 3 clearly is harmful.
> 
> No, it is DIFFERENT, not harmful. At worst, it's a "gotcha" -- a really
> well-documented gotcha.

To the casual observer? I doubt it. I wasn't aware of that until a recent
discussion about slots. But then, I've so far _never_ felt the need to  use
them...
 
> 
>> As is the fact that __slots__ gives you
>> troubles if you e.g. pass objects to code that tries to set arbitrary
>> attributes on an object.
> 
> You mean like this?
> 
 x = 1
 x.label = "foo"
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'int' object has no attribute 'label'
> 
> I guess that means ints and floats and strings and tuples and lists are
> all harmful too, yes?

You are very well aware that I was talking about complex objects. And I
didn't say that they are harmful, but that using __slots__ to constrain
object attribute will lead to surprising results here in comparison to
the "usual" behavior. And with usual I mean
most-of-the-classes-work-that-way. Which might be considered as reason to
_not_ do it. But you are free to limit yourself, be my guest.

>> The question is: what does a slot buy you for this kind of problem?
> 
> Simplicity and explicitness.

Where is that more simple? Additional notation that will lead to
runtime-errors, the same way misspelled attribute-names do?

And yes, it is more explicit. As are interfaces, and type declarations. 

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


Re: Tkinter text widget

2007-10-08 Thread goldtech
On Oct 7, 11:00 am, Simon Forman <[EMAIL PROTECTED]> wrote:
> On Oct 6, 11:18 pm, goldtech <[EMAIL PROTECTED]> wrote:
>
>
>
> > I thought the "DISABLED" made it so I could not edit it. But it also
> > makes it so I can not scroll down. If you make the window smaller than
> > the content then try to put a cursor in there to use up/down arrow you
> > can't.
>
> > What I want is not to be able to change text content, but no other
> > action is disabled. Is this complicated to do?
>
> > Thanks.
>
> > from Tkinter import *
> > root = Tk()
> > text = Text(root, font=("Courier"))
> > text.pack()
> > i='123456789abcdefghijklmnopqrstuvwxyz\n'
> > for x in range(30):
> > text.insert(END, i)
> > text.config(state=DISABLED)
> > mainloop()
>
> I just tried this script.  You can select text and if you drap the
> selection outside the window then scrolling occurs, also Tk's default
> behavior of scrolling with the middle button still works (i.e. click-
> and-drag with the middle button to scroll.)

Yes, if I depress the mouse's scroll wheel (the middle button) I can
drag the content up/down. Interesting...I didn't know that. But I
can't select, XP Python 2.1.

I'll try adding scroll bars. Thanks.

...snip...

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


Re: changes on disk not visible to script ?

2007-10-08 Thread Bruce
On 8 Okt, 15:56, Richie Hindle <[EMAIL PROTECTED]> wrote:
> [Bruce]
>
> > f.close()
> > cmd = "echo %s | %s"%(argument_file,the_program)
>
> Either: you are a VB programmer and you've actually typed "f.close" rather
> than "f.close()",
>
> Or: you meant "type" (or "cat") rather than "echo",
>
> Or: I need a new crystal ball.  8-)
>
> --
> Richie Hindle
> [EMAIL PROTECTED]

You are right, I forgot the () in f.close() !
thanks for pointing that out.

VB programmer!? Thats really harsh..

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


Variable scoping rules in Python?

2007-10-08 Thread joshua . davies
Ok, I'm relatively new to Python (coming from C, C++ and Java).  I'm
working on a program that outputs text that may be arbitrarily long,
but should still line up, so I want to split the output on a specific
column boundary.  Since I might want to change the length of a column,
I tried defining the column as a constant (what I would have made a
"#define" in C, or a "static final" in Java).  I defined this at the
top level (not within a def), and I reference it inside a function.
Like this:

COLUMNS = 80

def doSomethindAndOutputIt( ):
  ...
  for i in range( 0, ( len( output[0] ) / COLUMNS ) ):
print output[0][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
print output[1][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
..

etc. etc.  It works fine, and splits the output on the 80-column
boundary just like I want.

Well, I decided that I wanted "COLUMNS = 0" to be a special "don't
split anywhere" value, so I changed it to look like this:

COLUMNS = 80

def doSomethindAndOutputIt( ):
  ...
  if COLUMNS == 0:
COLUMNS = len( output[ 0 ] )

  for i in range( 0, ( len( output[0] ) / COLUMNS ) ):
print output[0][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
print output[1][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
..

Now, when I run it, I get the following error:

Traceback (most recent call last):
  File "Test.py", line 140, in ?
doSomethingAndOutput( input )
  File "Test.py", line 123, in doSomethingAndOutput
if COLUMNS == 0:
UnboundLocalError: local variable 'COLUMNS' referenced before
assignment

I went back and re-read chapter 13 of "Learning Python", which talks
about variable scoping rules, and I can't figure out why Python is
saying this variable in Unbound.  It works if I insert:

  global COLUMNS

before the "if" statement... but I don't understand why.  Is the
interpreter scanning my entire function definition before executing
it, recognizing that I *might* assign COLUMNS to a value, and deciding
that it's a local on that basis?

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


Re: How to create a file on users XP desktop

2007-10-08 Thread goldtech

> from win32com.shell import shell, shellcon
>
> desktop = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
>
> 

Tim,

How did you learn Win32com?

Other than the O'Reilly book, I've never found a lot of
documentation.

Trying to browse COM in PythonWin is tough - there's tons of stuff in
there. I've never been able to find the Win32com classes, methods,
usage examples when I browse COM in PythonWin.

For example where is, shell.SHGetFolderPath and shellcon.CSIDL_DESKTOP
officially documented?

Did you learn from using Visual C++ or VB? How did you learn this
stuff?

Thanks,
Lee G.

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


Re: Variable scoping rules in Python?

2007-10-08 Thread Diez B. Roggisch
 [EMAIL PROTECTED] wrote:

> Ok, I'm relatively new to Python (coming from C, C++ and Java).  I'm
> working on a program that outputs text that may be arbitrarily long,
> but should still line up, so I want to split the output on a specific
> column boundary.  Since I might want to change the length of a column,
> I tried defining the column as a constant (what I would have made a
> "#define" in C, or a "static final" in Java).  I defined this at the
> top level (not within a def), and I reference it inside a function.
> Like this:
> 
> COLUMNS = 80
> 
> def doSomethindAndOutputIt( ):
>   ...
>   for i in range( 0, ( len( output[0] ) / COLUMNS ) ):
> print output[0][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> print output[1][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> ..
> 
> etc. etc.  It works fine, and splits the output on the 80-column
> boundary just like I want.
> 
> Well, I decided that I wanted "COLUMNS = 0" to be a special "don't
> split anywhere" value, so I changed it to look like this:
> 
> COLUMNS = 80
> 
> def doSomethindAndOutputIt( ):
>   ...
>   if COLUMNS == 0:
> COLUMNS = len( output[ 0 ] )
> 
>   for i in range( 0, ( len( output[0] ) / COLUMNS ) ):
> print output[0][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> print output[1][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> ..
> 
> Now, when I run it, I get the following error:
> 
> Traceback (most recent call last):
>   File "Test.py", line 140, in ?
> doSomethingAndOutput( input )
>   File "Test.py", line 123, in doSomethingAndOutput
> if COLUMNS == 0:
> UnboundLocalError: local variable 'COLUMNS' referenced before
> assignment
> 
> I went back and re-read chapter 13 of "Learning Python", which talks
> about variable scoping rules, and I can't figure out why Python is
> saying this variable in Unbound.  It works if I insert:
> 
>   global COLUMNS
> 
> before the "if" statement... but I don't understand why.  Is the
> interpreter scanning my entire function definition before executing
> it, recognizing that I *might* assign COLUMNS to a value, and deciding
> that it's a local on that basis?

Yep. That's essentially it. Because python has no explicit variable
declaration, it looks on the left hand side of assignments to determine the
locals. 

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


Re: changes on disk not visible to script ?

2007-10-08 Thread Nick Craig-Wood
Bruce <[EMAIL PROTECTED]> wrote:
>  I am trying to have my script automate a task, by using os.system, but
>  I cant get it to work.
> 
>  manually, outside the script I can do this thing by
> 
>  C:\echo argument_file | the_program
> 
>  This works very well when argument_file is created before my script is
>  started
> 
>  In the script I try to do it like this:
>  f = open("argument_file",'w')
>  f.write(argument)
>  f.close()
>  cmd = "echo %s | %s"%(argument_file,the_program)
>  os.system(cmd)
> 
>  The script works if the argument_file is already in the directory
>  before os.system(cmd), but the script must create argument_file before
>  using os.system. Problem is the_program cannot find argument_file or
>  the_program cannot find anything inside argument_file.

Send some real code, plus a sequence of steps to be followed to
replicate the problem and you'll get some real help.  The above is
just too vague.

The above code has a syntax error in it so obviously isn't from
working code.

PS I really doubt the problem is windows not seeing the created file...

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Howto Launch a windows application ?

2007-10-08 Thread Hyuga
On Oct 3, 5:39 pm, stef mientki <[EMAIL PROTECTED]> wrote:
>
> from subprocess import *
>
> cmd =[]
> cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
> cmd.append ( '-long-start' )
> cmd.append ( '-d')
> cmd.append ( '-clear' )
> cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
> cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.jal' )
> cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )

This is sort of aside from your original question, but I should also
point out how unnecessary all those 'cmd.append's are.  You can
initialize the list all at once simply like so:

cmd =['D:\\PIC-tools\\JALxxx\\jalv2_3.exe',
  '-long-start',
  '-d',
  '-clear',
  '-sD:\\PIC-tools\\JAL\\libs2',
  'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.jal',
  '>d:\\data_actueel\\d7_test_browser\\temp.log']

Hyuga

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


Re: How to create a file on users XP desktop

2007-10-08 Thread kyosohma
On Oct 8, 9:19 am, goldtech <[EMAIL PROTECTED]> wrote:
> > from win32com.shell import shell, shellcon
>
> > desktop = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
>
> > 
>
> Tim,
>
> How did you learn Win32com?
>
> Other than the O'Reilly book, I've never found a lot of
> documentation.
>
> Trying to browse COM in PythonWin is tough - there's tons of stuff in
> there. I've never been able to find the Win32com classes, methods,
> usage examples when I browse COM in PythonWin.
>
> For example where is, shell.SHGetFolderPath and shellcon.CSIDL_DESKTOP
> officially documented?
>
> Did you learn from using Visual C++ or VB? How did you learn this
> stuff?
>
> Thanks,
> Lee G.

Pretty much the only place to learn stuff that's not in the PyWin32
docs is on one of the MSDN sites. Yes, that can suck. Here's the
general page: http://msdn2.microsoft.com/en-us/default.aspx

You can google for them too to get direct links to the MSDN page.

The ActiveState Python (AKA ActivePython) has an IDE that allows you
to browse the COM module. It also has a help file that allows you to
browse the PyWin32 docs locally. I think you can download that without
downloading ActivePython.

Mike

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


Re: Override 'and' and 'or'

2007-10-08 Thread Andrew Durdin
On 10/7/07, Dekker <[EMAIL PROTECTED]> wrote:
>
> Well I think it is not possible what I wanted to achieve. By
> overriding the "and" and "or" keyword I wanted to return a new object:
>
> SqlValueInt(4) and SqlValueInt(5) --> SqlOpAnd(SqlValueInt(4),
> SqlValueInt(5))

PEP 335 is a proposal to allow overriding of the logical 'and', 'or' operators:

See  and the discussion of
it at 

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


www.yedil.com best hindi entertainment site

2007-10-08 Thread diprat7
www.yedil.com best hindi entertainment site
with vidoes,photo sharing,photo rating features
its really gona rock you
www.yedil.com

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


Re: Tkinter text widget

2007-10-08 Thread goldtech
After some Google searching I found "ScrolledText", this does what I
want :^)


from Tkinter import *
from ScrolledText import ScrolledText
root = Tk()
text = ScrolledText(root, font=("Courier"))
ScrolledText
text.pack()
i='123456789abcdefghijklmnopqrstuvwxyz\n'
for x in range(30):
text.insert(END, "%3d " % x + i)
text.config(state=DISABLED)
mainloop()

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


Re: Variable scoping rules in Python?

2007-10-08 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
> Ok, I'm relatively new to Python (coming from C, C++ and Java).  I'm
> working on a program that outputs text that may be arbitrarily long,
> but should still line up, so I want to split the output on a specific
> column boundary.

FWIW :
http://docs.python.org/lib/module-textwrap.html


>  Since I might want to change the length of a column,
> I tried defining the column as a constant (what I would have made a
> "#define" in C, or a "static final" in Java).  I defined this at the
> top level (not within a def), and I reference it inside a function.
> Like this:
> 
> COLUMNS = 80
> 
> def doSomethindAndOutputIt( ):
>   ...
>   for i in range( 0, ( len( output[0] ) / COLUMNS ) ):
> print output[0][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> print output[1][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> ..
> 
> etc. etc.  It works fine, and splits the output on the 80-column
> boundary just like I want.
> 
> Well, I decided that I wanted "COLUMNS = 0" to be a special "don't
> split anywhere" value, so I changed it to look like this:
> 
> COLUMNS = 80
> 
> def doSomethindAndOutputIt( ):
>   ...
>   if COLUMNS == 0:
> COLUMNS = len( output[ 0 ] )
 >
>   for i in range( 0, ( len( output[0] ) / COLUMNS ) ):
> print output[0][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> print output[1][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> ..

Since you don't want to modify a global (and even worse, a CONSTANT), 
the following code may be a bit cleaner:

def doSomethindAndOutputIt( ):
   ...
   if COLUMNS == 0:
  columns = len( output[ 0 ] )
   else:
  columns = COLUMNS
   for i in range( 0, ( len( output[0] ) / COLUMNS ) ):
  print output[0][ i * columns : i * columns + ( columns - 1 ) ]
   ..


> Now, when I run it, I get the following error:
> 
> Traceback (most recent call last):
>   File "Test.py", line 140, in ?
> doSomethingAndOutput( input )
>   File "Test.py", line 123, in doSomethingAndOutput
> if COLUMNS == 0:
> UnboundLocalError: local variable 'COLUMNS' referenced before
> assignment
> 
> I went back and re-read chapter 13 of "Learning Python", which talks
> about variable scoping rules, and I can't figure out why Python is
> saying this variable in Unbound.  It works if I insert:
> 
>   global COLUMNS
> 
> before the "if" statement... but I don't understand why.  Is the
> interpreter scanning my entire function definition before executing
> it, recognizing that I *might* assign COLUMNS to a value, and deciding
> that it's a local on that basis?

You name it. That's *exactly* what happens.

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


RE: tkinter question

2007-10-08 Thread Hamilton, William
> -Original Message-
> From: Kevin Walzer
> 
> See
http://www.codebykevin.com/blosxom/business/phynchronicity-new.png:
> this is an application I develop. The layout is all handled by "pack"
> and paned windows. Where you you use "grid" in a layout like this?
> 

I'd use a three row grid, with the middle row containing a frame with
another grid in it.  I don't try to create a single massive grid that
manages everything, I break it up into subgrids of related widgets.

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


ANN: Pyrex 0.9.6.1

2007-10-08 Thread Greg Ewing
Pyrex 0.9.6.1 is now available:

   http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/

This version fixes a few minor problems that turned
up in the initial 0.9.6 release.

What is Pyrex?
--

Pyrex is a language for writing Python extension modules.
It lets you freely mix operations on Python and C data, with
all Python reference counting and error checking handled
automatically.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a file on users XP desktop

2007-10-08 Thread Tim Golden
[EMAIL PROTECTED] wrote:
> On Oct 8, 9:19 am, goldtech <[EMAIL PROTECTED]> wrote:
>>> from win32com.shell import shell, shellcon
>>> desktop = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
>>> 
>> Tim,
>>
>> How did you learn Win32com?
>>
>> Other than the O'Reilly book, I've never found a lot of
>> documentation.
>>
>> Trying to browse COM in PythonWin is tough - there's tons of stuff in
>> there. I've never been able to find the Win32com classes, methods,
>> usage examples when I browse COM in PythonWin.
>>
>> For example where is, shell.SHGetFolderPath and shellcon.CSIDL_DESKTOP
>> officially documented?
>>
>> Did you learn from using Visual C++ or VB? How did you learn this
>> stuff?
>>
>> Thanks,
>> Lee G.
> 
> Pretty much the only place to learn stuff that's not in the PyWin32
> docs is on one of the MSDN sites. Yes, that can suck. Here's the
> general page: http://msdn2.microsoft.com/en-us/default.aspx
> 
> You can google for them too to get direct links to the MSDN page.
> 
> The ActiveState Python (AKA ActivePython) has an IDE that allows you
> to browse the COM module. It also has a help file that allows you to
> browse the PyWin32 docs locally. I think you can download that without
> downloading ActivePython.
> 
> Mike

FWIW, the pywin32 distribution itself also comes with a local
.chm file. But aside from that, there have been several abortive
attempts -- including by Mike & myself! -- to get some kind of
online help going for pywin32, but nothing's really gained traction,
and we've all got more interesting things to be doing...

One point to bear in mind that, more or less, the pywin32 stuff
just wraps the MS API really closely, mostly doing just enough
of the messy plumbing to present the API "objects" as Python
objects. That's to say: find out how to do it from a C++ or VB
or Delphi tutorial and translating into Python often isn't hard.

As it happens I've been using Windows APIs for a few years,
so I have a bit of a head start. But I've answered quite
a few questions on python-win32 by putting the subject line
into Google, picking a likely-looking response and translating
it into Python.

In this case ("How to create a file on users XP desktop") the
question was too broad and tended to throw up user-oriented
answers. I tried a few permutations, including limiting the
search to msdn.microsoft.com, none of which showed much on the
first couple of pages. A search of the pywin32.chm files does
point in the right direction, but the fact is that the shell
functionality exposed by Windows which does this kind of
stuff is non-intuitive.

While I think everyone agrees that the Windows side of Python
could benefit from more and better docs, the general answer to:
How do I do X in Python under Windows? is: How do I X under Windows?

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


Re: weakrefs and bound methods

2007-10-08 Thread Chris Mellon
On 10/8/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> On Mon, 08 Oct 2007 04:06:55 +, Michele Simionato wrote:
>
> > > Hmmm... I'm not sure I understand how a with statement is meant to
> > > replace class.__del__ in practice. It seems to me that the two things
> > > have different uses. with is useful when you create an object, do
> > > something with it, dispose of it in an orderly fashion, and then
> > > continue. How does that help when you create an unknown number of
> > > long-lasting objects where you can't predict how and when they will be
> > > disposed of?
>
> [snip]
>
> >> Now, I don't think the above is feasible. What am I missing?
> >
> > Rename your __del__ to close and call it explicitely:
> >
> > p.close()
> > alist[3].close()
> > alist[853].close()
> > alist[701].close()
>
> Well, that utterly sucks. If I wanted to call finalizers explicitly, I'd
> be writing in C.
>
> You say that using __del__ leads to hard-to-debug "bombs in my code
> waiting to explode at some unknown moment". Maybe so -- but so does
> explicitly managing resources by hand in the way you suggest, and quite
> frankly, I suspect I'd have a hell of a lot fewer bugs by relying on
> __del__ and the garbage collector than I would from managing resources
> manually in a big project.
>

The point that is being made is that "relying on __del__" is stupid,
because __del__ isn't reliable. It's akin to a Java finalizer - there
is no guarantee that it will be called at all. So you can use __del__,
and have to be continually aware of the dangers of circular references
and  refcounting, or you use explicit finalizers, or you can use
context managers. If you have arbitrary numbers of long-lived,
potentially self-referential objects that you can't control in any
other way, you're screwed - you're going to *have* to have a manual
destruction somewhere.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a file on users XP desktop

2007-10-08 Thread kyosohma
On Oct 8, 10:11 am, Tim Golden <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On Oct 8, 9:19 am, goldtech <[EMAIL PROTECTED]> wrote:
> >>> from win32com.shell import shell, shellcon
> >>> desktop = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
> >>> 
> >> Tim,
>
> >> How did you learn Win32com?
>
> >> Other than the O'Reilly book, I've never found a lot of
> >> documentation.
>
> >> Trying to browse COM in PythonWin is tough - there's tons of stuff in
> >> there. I've never been able to find the Win32com classes, methods,
> >> usage examples when I browse COM in PythonWin.
>
> >> For example where is, shell.SHGetFolderPath and shellcon.CSIDL_DESKTOP
> >> officially documented?
>
> >> Did you learn from using Visual C++ or VB? How did you learn this
> >> stuff?
>
> >> Thanks,
> >> Lee G.
>
> > Pretty much the only place to learn stuff that's not in the PyWin32
> > docs is on one of the MSDN sites. Yes, that can suck. Here's the
> > general page:http://msdn2.microsoft.com/en-us/default.aspx
>
> > You can google for them too to get direct links to the MSDN page.
>
> > The ActiveState Python (AKA ActivePython) has an IDE that allows you
> > to browse the COM module. It also has a help file that allows you to
> > browse the PyWin32 docs locally. I think you can download that without
> > downloading ActivePython.
>
> > Mike
>
> FWIW, the pywin32 distribution itself also comes with a local
> .chm file. But aside from that, there have been several abortive
> attempts -- including by Mike & myself! -- to get some kind of
> online help going for pywin32, but nothing's really gained traction,
> and we've all got more interesting things to be doing...
>
> One point to bear in mind that, more or less, the pywin32 stuff
> just wraps the MS API really closely, mostly doing just enough
> of the messy plumbing to present the API "objects" as Python
> objects. That's to say: find out how to do it from a C++ or VB
> or Delphi tutorial and translating into Python often isn't hard.
>
> As it happens I've been using Windows APIs for a few years,
> so I have a bit of a head start. But I've answered quite
> a few questions on python-win32 by putting the subject line
> into Google, picking a likely-looking response and translating
> it into Python.
>
> In this case ("How to create a file on users XP desktop") the
> question was too broad and tended to throw up user-oriented
> answers. I tried a few permutations, including limiting the
> search to msdn.microsoft.com, none of which showed much on the
> first couple of pages. A search of the pywin32.chm files does
> point in the right direction, but the fact is that the shell
> functionality exposed by Windows which does this kind of
> stuff is non-intuitive.
>
> While I think everyone agrees that the Windows side of Python
> could benefit from more and better docs, the general answer to:
> How do I do X in Python under Windows? is: How do I X under Windows?
>
> TJG

I'm planning on working on that PyWin32 site some more this fall/
winter. Unfortunately, I shouldn't have volunteered my time during the
summer as I have very irregular a/c at home, and thus it was very
uncomfortable to use my PC when I was off work. Lame maybe, but I
dislike using a computer when it's above 90 degrees and the humidity
is higher than 70%. Bleh!

Sorry about that. I am experimenting with MediaWiki to see if it's any
faster than MoinMoin. If you know of a fast, easy-to-use wiki that's
better than both of those, let me know.

Mike

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


Re: changes on disk not visible to script ?

2007-10-08 Thread Richie Hindle
[Bruce]
> VB programmer!? Thats really harsh..

No offence intended!  8-)

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


Re: Really basic problem

2007-10-08 Thread Zentrader
You can use Python's decimal class if floating point arithmetic is not
exact enough

import decimal
status = decimal.Decimal( 0 )
for i in range(10):
   status += decimal.Decimal( "0.1" )
   if status == decimal.Decimal( "0.1" ):
   print status
   elif status == decimal.Decimal( "0.2" ):
   print status
   elif status == decimal.Decimal( "0.3" ):
   print status
   elif status == decimal.Decimal( "0.4" ):
   print status
   elif status == decimal.Decimal( "0.5" ):
   print status
   elif status == decimal.Decimal( "0.6" ):
   print status
   elif status == decimal.Decimal( "0.7" ):
   print status
   elif status == decimal.Decimal( "0.8" ):
   print status
   elif status == decimal.Decimal( "0.9" ):
   print status
   elif status == decimal.Decimal( "1.0" ):
   print status
   else:
   print "status not equal -->", status

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


Adding extra modules to a Pyinstaller build

2007-10-08 Thread Craig
Hello all:

I need to add several Python standard modules to a Pyinstaller
project. The modules are not (and cannot be) explicitly imported in my
project script, so is there a way to add them to my .spec file in
order to allow Pyinstaller to search for them in PYTHONPATH and add
them to the project?

Regards,
Craig

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


Re: Really basic problem

2007-10-08 Thread Diez B. Roggisch
Zentrader wrote:

> You can use Python's decimal class if floating point arithmetic is not
> exact enough

This is a misleading statement. While it's true that decimal can be more
precise in the sense that smaller fractions are representable, the
underlying problem of certain values not being representable properly &
leading to rounding errors still exists:



>>> import decimal
>>> d = decimal.Decimal
>>> d("1") / d("3")
Decimal("0.")
>>> otrd = d("1") / d("3")
>>> otrd * 3
Decimal("0.")
>>> otrd * d("3")
Decimal("0.")
>>>


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


[OT] Re: Variable scoping rules in Python?

2007-10-08 Thread Peter Otten
joshua.davies wrote:

> Ok, I'm relatively new to Python (coming from C, C++ and Java).  I'm
> working on a program that outputs text that may be arbitrarily long,
> but should still line up, so I want to split the output on a specific
> column boundary.  Since I might want to change the length of a column,
> I tried defining the column as a constant (what I would have made a
> "#define" in C, or a "static final" in Java).  I defined this at the
> top level (not within a def), and I reference it inside a function.
> Like this:
> 
> COLUMNS = 80
> 
> def doSomethindAndOutputIt( ):
>   ...
>   for i in range( 0, ( len( output[0] ) / COLUMNS ) ):
> print output[0][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> print output[1][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> ..
> 
> etc. etc.  It works fine, and splits the output on the 80-column
> boundary just like I want.

Just in case it's not intentional: You'll lose every 80th character as
python intervals do not include the upper bound. The same problem
affects the for loop -- e. g. when output[0] has less than COLUMNS
columns nothing is printed:

>>> range(0, 79/80)
[]

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


Re: Variable scoping rules in Python?

2007-10-08 Thread Steven D'Aprano
On Mon, 08 Oct 2007 07:17:36 -0700, joshua.davies wrote:

> I went back and re-read chapter 13 of "Learning Python", which talks
> about variable scoping rules, and I can't figure out why Python is
> saying this variable in Unbound.  It works if I insert:
> 
>   global COLUMNS
> 
> before the "if" statement... but I don't understand why.  Is the
> interpreter scanning my entire function definition before executing it,
> recognizing that I *might* assign COLUMNS to a value, and deciding that
> it's a local on that basis?

Almost right, but not quite.

You are right that Python decides that COLUMNS is local, but you're wrong 
about when that decision gets made. Python does not re-scan your function 
every time you execute it, but only once, when it is compiled.

Compiling the function might take one pass of the source code, or two, or 
a thousand for all we know; that's an irrelevant detail of interest only 
to compiler designers and the chronically curious. What's important is 
that once the function is compiled, the decision is already made about 
whether COLUMNS is local or not, and the virtual machine that executes 
your function only needs to interpret the byte-code in a single pass.



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


Re: changes on disk not visible to script ?

2007-10-08 Thread Nick Craig-Wood
Bruce <[EMAIL PROTECTED]> wrote:
>  On 8 Okt, 15:56, Richie Hindle <[EMAIL PROTECTED]> wrote:
> > [Bruce]
> >
> > > f.close()
> > > cmd = "echo %s | %s"%(argument_file,the_program)
> >
> > Either: you are a VB programmer and you've actually typed "f.close" rather
> > than "f.close()",
> 
>  You are right, I forgot the () in f.close() !
>  thanks for pointing that out.
> 
>  VB programmer!? Thats really harsh..

I used to make that mistake a lot as an ex-perl programmer.  I think
ruby is the same.

pychecker will warn about it though.

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a file on users XP desktop

2007-10-08 Thread Julius
On Monday 08 October 2007 17:11:25 Tim Golden wrote:
> [EMAIL PROTECTED] wrote:
> > On Oct 8, 9:19 am, goldtech <[EMAIL PROTECTED]> wrote:
> >>> from win32com.shell import shell, shellcon
> >>> desktop = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
> >>> 
> >>
> >> Tim,
> >>
> >> How did you learn Win32com?
> >>
> >> Other than the O'Reilly book, I've never found a lot of
> >> documentation.
> >>
> >> Trying to browse COM in PythonWin is tough - there's tons of stuff in
> >> there. I've never been able to find the Win32com classes, methods,
> >> usage examples when I browse COM in PythonWin.
> >>
> >> For example where is, shell.SHGetFolderPath and shellcon.CSIDL_DESKTOP
> >> officially documented?
> >>
> >> Did you learn from using Visual C++ or VB? How did you learn this
> >> stuff?
> >>
> >> Thanks,
> >> Lee G.
> >
> > Pretty much the only place to learn stuff that's not in the PyWin32
> > docs is on one of the MSDN sites. Yes, that can suck. Here's the
> > general page: http://msdn2.microsoft.com/en-us/default.aspx
> >
> > You can google for them too to get direct links to the MSDN page.
> >
> > The ActiveState Python (AKA ActivePython) has an IDE that allows you
> > to browse the COM module. It also has a help file that allows you to
> > browse the PyWin32 docs locally. I think you can download that without
> > downloading ActivePython.
> >
> > Mike
>
> FWIW, the pywin32 distribution itself also comes with a local
> .chm file. But aside from that, there have been several abortive
> attempts -- including by Mike & myself! -- to get some kind of
> online help going for pywin32, but nothing's really gained traction,
> and we've all got more interesting things to be doing...
>
> One point to bear in mind that, more or less, the pywin32 stuff
> just wraps the MS API really closely, mostly doing just enough
> of the messy plumbing to present the API "objects" as Python
> objects. That's to say: find out how to do it from a C++ or VB
> or Delphi tutorial and translating into Python often isn't hard.
>
> As it happens I've been using Windows APIs for a few years,
> so I have a bit of a head start. But I've answered quite
> a few questions on python-win32 by putting the subject line
> into Google, picking a likely-looking response and translating
> it into Python.
>
> In this case ("How to create a file on users XP desktop") the
> question was too broad and tended to throw up user-oriented
> answers. I tried a few permutations, including limiting the
> search to msdn.microsoft.com, none of which showed much on the
> first couple of pages. A search of the pywin32.chm files does
> point in the right direction, but the fact is that the shell
> functionality exposed by Windows which does this kind of
> stuff is non-intuitive.
>
> While I think everyone agrees that the Windows side of Python
> could benefit from more and better docs, the general answer to:
> How do I do X in Python under Windows? is: How do I X under Windows?
>
> TJG
--
Free version Zoner Photo Studio 9 - http://www.zps9.com/

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


Re: pytz has so many timezones!

2007-10-08 Thread [EMAIL PROTECTED]
On Oct 8, 2:32 am, Sanjay <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I am using pytz.common_timezones to populate the timezone combo box of
> some user registration form. But as it has so many timezones (around
> 400),

There are only 25 timezones: -12, -11, ... -1, 0 (GMT), +1, ... +11,
+12.

A handful of countries set their clocks offset by a half hour,
but those aren't timezones.

And there is one country whose clock setting is the product of
a diseased mind (GMT+13), but that isn't a timezone either.

The 400 you're seeing are duplications based on locality. Of the 86
shown in Windows, all but 33 are dulplicate references to the same
timezones.

For example, Windows has seperate listings for

Central America
Central Time (US & Canada)
Guadalahara, Mexico City, Monterry - New
Guadalahara, Mexico City, Monterry - Old
Saskatchewan

but they are all GMT-6

> it is a bit confusing to the users. Is there a smaller and more
> practical set?

Filter the list by location.

> If not, some suggestions on how to handle the
> registration form effectively would help me a lot.
>
> thanks
> Sanjay


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


mailman.bounces

2007-10-08 Thread kalin mintchev

hi all..

i'm a bit confused by the bounces behavior of mailman. the idea is that
each address from which a bounce comes back should be immediately removed
from the list. right now they are not. or testing i'm purposely putting
addresses that do not exist. in the mail log i get:

stat=Deferred: Connection timed out with dd.com

is that considered 'soft' or 'hard' bounce severity. is it considered
bounce at all?

here are the relevant settings:

Should Mailman perform automatic bounce processing?  => Yes

The maximum member bounce score before the member's subscription is
disabled. This value can be a floating point number. => 0.0  (tested 1.0
and 0.1 also)

The number of days after which a member's bounce information is discarded,
if no new bounces have been received in the interim. This value must be an
integer. => 7

How many Your Membership Is Disabled warnings a disabled member should get
before their address is removed from the mailing list. Set to 0 to
immediately remove an address from the list once their bounce score
exceeds the threshold. This value must be an integer.  => 0


thanks

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


Re: pytz has so many timezones!

2007-10-08 Thread J. Clifford Dyer
On Mon, Oct 08, 2007 at 10:41:03AM -0700, [EMAIL PROTECTED] wrote regarding Re: 
pytz has so many timezones!:
> 
> On Oct 8, 2:32 am, Sanjay <[EMAIL PROTECTED]> wrote:
> > Hi All,
> >
> > I am using pytz.common_timezones to populate the timezone combo box of
> > some user registration form. But as it has so many timezones (around
> > 400),
> 
> There are only 25 timezones: -12, -11, ... -1, 0 (GMT), +1, ... +11,
> +12.
> 
> A handful of countries set their clocks offset by a half hour,
> but those aren't timezones.
> 

I'm sorry.  By what even vaguely useful definition of "Timezone" is it not a 
timezone if it's offset by half an hour?  

> 
> The 400 you're seeing are duplications based on locality. Of the 86
> shown in Windows, all but 33 are dulplicate references to the same
> timezones.
> 
> For example, Windows has seperate listings for
> 
> Central America
> Central Time (US & Canada)
> Guadalahara, Mexico City, Monterry - New
> Guadalahara, Mexico City, Monterry - Old
> Saskatchewan
> 
> but they are all GMT-6
> 

Those are non-duplicate (and perhaps inaccurate, I'm not sure).  US time 
switches from standard to Daylight Savings earlier than Mexico, and switches 
back later, as of this year.  Reducing them to a single time zone will result 
in aberrant functionality in one or more locales.

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


Re: pytz has so many timezones!

2007-10-08 Thread Carsten Haese
On Mon, 2007-10-08 at 10:41 -0700, [EMAIL PROTECTED] wrote:
> For example, Windows has seperate listings for
> 
> Central America
> Central Time (US & Canada)
> Guadalahara, Mexico City, Monterry - New
> Guadalahara, Mexico City, Monterry - Old
> Saskatchewan
> 
> but they are all GMT-6

But they could have different rules for Daylight Saving Time.

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


HCL Technologies:Software Engineer/Senior software Engineer ..:: JobMaguz Update ::..

2007-10-08 Thread janaki . parasuraman
..:: Job Update from JobMaguz ::..

Today's Highlighted Job:
HCL Technologies:Software Engineer/Senior software Engineer
http://www.jobmaguz.com/viewFresherJobs.aspx?jobid=981&cycle=1

26 jobs posted today in JobMaguz

Jobs posted today:

Freshers Section
HCL Technologies:Software Engineer/Senior software Engineer
http://www.jobmaguz.com/viewFresherJobs.aspx?jobid=981&cycle=1

Willis Trinity recruits Freshers (ITES)
http://www.jobmaguz.com/viewFresherJobs.aspx?jobid=980&cycle=1

INTERNET PROTOCOL ENGG [Telecom Software] - ZTE Corporation
http://www.jobmaguz.com/viewFresherJobs.aspx?jobid=978&cycle=1

Plexus Microelectronics Pte Ltd
http://www.jobmaguz.com/viewFresherJobs.aspx?jobid=977&cycle=1

Saviance Technologies
http://www.jobmaguz.com/viewFresherJobs.aspx?jobid=975&cycle=1

More: www.jobmaguz.com/freshers.aspx


Experienced Section
Ansys Fluent India Pvt. Ltd
http://www.jobmaguz.com/viewExperiencedJobs.aspx?jobid=985&cycle=1

Keane:Support Professionals
http://www.jobmaguz.com/viewExperiencedJobs.aspx?jobid=984&cycle=1

 PTC Software India Pvt Ltd
http://www.jobmaguz.com/viewExperiencedJobs.aspx?jobid=982&cycle=1

Siyaram Silk Mills Ltd
http://www.jobmaguz.com/viewExperiencedJobs.aspx?jobid=979&cycle=1

i-flex Solutions - 13th Sept 2007 - Mumbai - Oracle Pl/SQL
http://www.jobmaguz.com/viewExperiencedJobs.aspx?jobid=965&cycle=1

More: www.jobmaguz.com/experienced.aspx


Referral Section
More: www.jobmaguz.com/referrals.aspx


Happy Job Hunting!!

..:: Team JobMaguz ::..

FOR REGULAR JOB UPDATES
--
Join our Orkut community
http://www.orkut.com/Community.aspx?cmm=29823377

Subscribe our fresher jobs' Feed
http://www.feedburner.com/fb/a/emailverifySubmit?feedId=1038318

Subscribe our experienced jobs' Feed
http://www.feedburner.com/fb/a/emailverifySubmit?feedId=1039530
--

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


Re: Variable scoping rules in Python?

2007-10-08 Thread Paul Hankin
On Oct 8, 3:17 pm, [EMAIL PROTECTED] wrote:
> Ok, I'm relatively new to Python (coming from C, C++ and Java).  I'm
> working on a program that outputs text that may be arbitrarily long,
> but should still line up, so I want to split the output on a specific
> column boundary.  Since I might want to change the length of a column,
> I tried defining the column as a constant (what I would have made a
> "#define" in C, or a "static final" in Java).  I defined this at the
> top level (not within a def), and I reference it inside a function.
> Like this:
>
> COLUMNS = 80
>
> def doSomethindAndOutputIt( ):
>   ...
>   if COLUMNS == 0:
> COLUMNS = len( output[ 0 ] )

Often it's better to make your global 'constant' an optional argument,
especially if certain values have special meanings to your function.

def doSomethingAndOutputIt(columns = 80):
...
columns = columns or len(output[0])

--
Paul Hankin

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


Re: Don't use __slots__ (was Re: Problem of Readability of Python)

2007-10-08 Thread Steven Bethard
Aahz wrote:
> In article <[EMAIL PROTECTED]>,
> Steven Bethard  <[EMAIL PROTECTED]> wrote:
>> You can use __slots__  [...]
> 
> Aaaugh!  Don't use __slots__!
> 
> Seriously, __slots__ are for wizards writing applications with huuuge
> numbers of object instances (like, millions of instances).

You clipped me saying that __slots__ are for performance tweaks:

 You can use __slots__ to make objects consume less memory and have
 slightly better attribute-access performance. Classes for objects
 that need such performance tweaks should start like...

I fully agree that __slots__ are for applications with huge numbers of 
instances. But if you have that situation, you really do want to be 
using __slots__.

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


WARNING ABOUT ROGUE OPERATORS Re: The secret of hand compiling LISP/Scheme

2007-10-08 Thread thermate
This William D Clinger is a YANK MOTHER F*CKER, a 911 controlled
demolition operator group member or a ROGUE bastard in FBI whose
job and RACIST tendency is to CONTROL FREEDOM of information.
These MOTHERF*CKERS using fake accounts use "FULL LONG NAMES"
to FOOL simple and honest people that they are some genuine
people. They have multiple accounts and their sole job is to
derail conversations on the threads where there is exchange of
knowledge. That is their FULL TIME JOB. They use ebooks from
where they cut and paste to look they have multiple specialities
but this could be even 3 bastards working full time daily with
150 nicks and accounts all automated.

Please look at my articles on google. just click my profile on
groups.google.com to find out the potent truth I have written.

I am sure you have seen that video of a student being tasered
in University of Florida because these bastards hate our freedoms.

These are corporatist bastards whose whole goal is to keep the
public ignorant. THESE MOTHERFUCKERS hid the anthrax mailer who
was really one of them. THE FBI Bastards never caught the anthrax
mailer based in the USA>

On Oct 8, 1:55 am, William D Clinger <[EMAIL PROTECTED]> wrote:
> The gnuist wrote:
> > Many years ago I went to an MIT prof on a technique I had become aware
> > of. Its not McCarthy. When I asked him for his class notes on the
> > subject to self-study, first he stared at me as if I was some kind of
> > thief. Then as we were coming down to the first floor of the high
> > voltage lab, I asked him why didnt he publish it? He said, and these
> > are exact words: "you can make us as much guilty as you want, but we
> > did not publish it."
>
> An MIT prof who is not fluent in English and is also not
> McCarthy?  That narrows it down.
>
> > You may want to be clear about SI and SC.
> > what language is source interpreter written in?
> > what language is source compiler written in?
>
> It doesn't matter.
>
> > I would actually prefer that there was no environment
> > available like no C compiler.
>
> That doesn't matter either.
>
> > All the processes would have to be created.
> > Plz note that I am neither a CS nor a logician.
>
> Nor does that.
>
> > I prefer detailed treatment of this subject that is actually useful.
>
> It would be hard to improve upon the advice that Jens gave
> you.  I will add this:  If you don't have a compiler SC for
> the language in which SI is written, then you have to write
> SC before you hand-simulate it (or execute it, if you happen
> to have a compiler for the language in which SC is written).
>
> I will also add this:  If SC is written in the same language
> as SI, then hand-simulating SC on SC itself gives you an
> executable compiler, which you can then use to compile SI.
>
> Been there, done that.
>
> Will


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


Re: pytz has so many timezones!

2007-10-08 Thread andrew clarke
On Mon, Oct 08, 2007 at 12:32:19AM -0700, Sanjay wrote:

> I am using pytz.common_timezones to populate the timezone combo box of
> some user registration form. But as it has so many timezones (around
> 400), it is a bit confusing to the users. Is there a smaller and more
> practical set? If not, some suggestions on how to handle the
> registration form effectively would help me a lot.

Use something like:

for zone in common_timezones:
  continent, region = zone.split('/')

Then have two list boxes, one for the continent and the other for the region.

[Australia  ]

[Melbourne  ]

('Continent' is probably not the right word.)

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


Re: Cross platform way of finding number of processors on a machine?

2007-10-08 Thread Lawrence Oluyede
Nicholas Bastin <[EMAIL PROTECTED]> wrote:
> This is really bad on linux.  You really want to parse /proc/cpuinfo
> because HT 'cpus' are almost useless, and can be bad in situations
> where you try to treat them as general purpose cpus.

I'm not the author of the library. I think you should address these bug
reports elsewhere...

-- 
Lawrence, oluyede.org - neropercaso.it
"It is difficult to get a man to understand 
something when his salary depends on not
understanding it" - Upton Sinclair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WARNING ABOUT ROGUE OPERATORS Re: The secret of hand compiling LISP/Scheme

2007-10-08 Thread thermate
If you sheeple are ignorant of what I say, look at this link:
and the papers therein.

911blogger.com
st911.org
stj911.org

(1) Why did FBI bastards not catch the ANTHRAX mailer?
(2) Why did building 7 commit suicide?
(3) Where is the Pentagon video, of the plane hitting it ?

On Oct 8, 11:30 am, [EMAIL PROTECTED] wrote:
> This William D Clinger is a YANK MOTHER F*CKER, a 911 controlled
> demolition operator group member or a ROGUE bastard in FBI whose
> job and RACIST tendency is to CONTROL FREEDOM of information.
> These MOTHERF*CKERS using fake accounts use "FULL LONG NAMES"
> to FOOL simple and honest people that they are some genuine
> people. They have multiple accounts and their sole job is to
> derail conversations on the threads where there is exchange of
> knowledge. That is their FULL TIME JOB. They use ebooks from
> where they cut and paste to look they have multiple specialities
> but this could be even 3 bastards working full time daily with
> 150 nicks and accounts all automated.
>
> Please look at my articles on google. just click my profile on
> groups.google.com to find out the potent truth I have written.
>
> I am sure you have seen that video of a student being tasered
> in University of Florida because these bastards hate our freedoms.
>
> These are corporatist bastards whose whole goal is to keep the
> public ignorant. THESE MOTHERFUCKERS hid the anthrax mailer who
> was really one of them. THE FBI Bastards never caught the anthrax
> mailer based in the USA>
>
> On Oct 8, 1:55 am, William D Clinger <[EMAIL PROTECTED]> wrote:
>
>
>
> > The gnuist wrote:
> > > Many years ago I went to an MIT prof on a technique I had become aware
> > > of. Its not McCarthy. When I asked him for his class notes on the
> > > subject to self-study, first he stared at me as if I was some kind of
> > > thief. Then as we were coming down to the first floor of the high
> > > voltage lab, I asked him why didnt he publish it? He said, and these
> > > are exact words: "you can make us as much guilty as you want, but we
> > > did not publish it."
>
> > An MIT prof who is not fluent in English and is also not
> > McCarthy?  That narrows it down.
>
> > > You may want to be clear about SI and SC.
> > > what language is source interpreter written in?
> > > what language is source compiler written in?
>
> > It doesn't matter.
>
> > > I would actually prefer that there was no environment
> > > available like no C compiler.
>
> > That doesn't matter either.
>
> > > All the processes would have to be created.
> > > Plz note that I am neither a CS nor a logician.
>
> > Nor does that.
>
> > > I prefer detailed treatment of this subject that is actually useful.
>
> > It would be hard to improve upon the advice that Jens gave
> > you.  I will add this:  If you don't have a compiler SC for
> > the language in which SI is written, then you have to write
> > SC before you hand-simulate it (or execute it, if you happen
> > to have a compiler for the language in which SC is written).
>
> > I will also add this:  If SC is written in the same language
> > as SI, then hand-simulating SC on SC itself gives you an
> > executable compiler, which you can then use to compile SI.
>
> > Been there, done that.
>
> > Will- Hide quoted text -
>
> - Show quoted text -


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


Convert obejct string repr to actual object

2007-10-08 Thread Tor Erik Sønvisen
Hi,

I've tried locating some code that can recreate an object from it's
string representation...
The object in question is really a dictionary containing other
dictionaries, lists, unicode strings, floats, ints, None, and
booleans.

I don't want to use eval, since I can't trust the source sending the
object I'm sure someone must have had the same need and created
code for it... Maybe Pypy has what I need??? Haven't looked though...

Regards,
Tor Erik

PS: The string repr is created by a server outside of my control...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convert obejct string repr to actual object

2007-10-08 Thread Carsten Haese
On Mon, 2007-10-08 at 21:19 +0200, Tor Erik Sønvisen wrote:
> Hi,
> 
> I've tried locating some code that can recreate an object from it's
> string representation...
> The object in question is really a dictionary containing other
> dictionaries, lists, unicode strings, floats, ints, None, and
> booleans.
> 
> I don't want to use eval, since I can't trust the source sending the
> object.

You could still use eval, but run a separate algorithm first to make
sure the string is "legal." For example, you could whip up a simple
PyParsing grammar to restrict the set of allowable strings, or compile
the string into byte code and inspect the byte code to look for red
flags like LOAD_NAME (with a name other than None) and CALL_FUNCTION.

HTH,

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


Re: Convert obejct string repr to actual object

2007-10-08 Thread Chris Mellon
On 10/8/07, Tor Erik Sønvisen <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've tried locating some code that can recreate an object from it's
> string representation...
> The object in question is really a dictionary containing other
> dictionaries, lists, unicode strings, floats, ints, None, and
> booleans.
>
> I don't want to use eval, since I can't trust the source sending the
> object I'm sure someone must have had the same need and created
> code for it... Maybe Pypy has what I need??? Haven't looked though...
>
> Regards,
> Tor Erik
>
> PS: The string repr is created by a server outside of my control...
> --


You'll need to write your own parser. PyParsing has an example that
can parse much of the Python syntax, you can probably extract the
object-literal parts of that and use it as a base for your
implementation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Don't use __slots__

2007-10-08 Thread Hrvoje Niksic
Steven D'Aprano <[EMAIL PROTECTED]> writes:

> Well, I've read the thread, and I've read the thread it links to,
> and for the life of me I'm still no clearer as to why __slots__
> shouldn't be used except that:
[...]
> But is there actually anything *harmful* that can happen if I use
> __slots__?

Here is one harmful consequence: __slots__ breaks multiple
inheritance:

class A(object):
  __slots__ = ['a', 'b']

class B(object):
  __slots__ = ['c']

class AB(A, B):
  pass

Traceback (most recent call last):
  File "", line 1, in 
TypeError: Error when calling the metaclass bases
multiple bases have instance lay-out conflict

Even if A and B had the exact same slots, for example ['a', 'b'], it
wouldn't make a difference.  AB explicitly setting __slots__ to
something like ['a', 'b', 'c'] doesn't help either.  But that is only
a technical answer to your technical question which misses the real
problem people like Aahz and Guido have with __slots__.  (I don't
claim to represent them, of course, the following is my
interpretation.)

The backlash against __slots__ is a consequence of it being so easy to
misunderstand what __slots__ does and why it exists.  Seeing __slots__
has led some people to recommend __slots__ to beginners as a way to
"catch spelling mistakes", or as a way to turn Python's classes into
member-declared structures, a la Java.  For people coming from Java
background, catching mistakes as early as possible is almost a dogma,
and they are prone to accept the use of __slots__ (and living with the
shortcomings) as a rule.

Python power users scoff at that because it goes against everything
that makes Python Python.  Use of __slots__ greatly reduces class
flexibility, by both disabling __dict__ and __weakref__ by default,
and by forcing a tight instance layout that cripples inheritance.
With people using __slots__ for the majority of their classes, it
becomes much harder for 3rd-party code to attach an unforeseen
attribute to an existing object.  Even with single inheritance,
__slots__ has unintuitive semantics because subclasses automatically
get __dict__ and __weakref__, thereby easily breaking the "benefits"
of their use.

__slots__ is a low-level tool that allows creation of dict-less
objects without resorting to Python/C.  As long as one understands it
as such, there is no problem with using it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Facebook app give feedback -Send birthday cards to buds http://apps.facebook.com/groupcards/start

2007-10-08 Thread fringo
Facebook app give feedback -Send birthday cards to buds
http://apps.facebook.com/groupcards/start

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


Re: pytz has so many timezones!

2007-10-08 Thread [EMAIL PROTECTED]
On Oct 8, 1:00 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote:
> On Mon, Oct 08, 2007 at 10:41:03AM -0700, [EMAIL PROTECTED] wrote regarding 
> Re: pytz has so many timezones!:
>
>
>
> > On Oct 8, 2:32 am, Sanjay <[EMAIL PROTECTED]> wrote:
> > > Hi All,
>
> > > I am using pytz.common_timezones to populate the timezone combo box of
> > > some user registration form. But as it has so many timezones (around
> > > 400),
>
> > There are only 25 timezones: -12, -11, ... -1, 0 (GMT), +1, ... +11,
> > +12.
>
> > A handful of countries set their clocks offset by a half hour,
> > but those aren't timezones.
>
> I'm sorry.  By what even vaguely useful definition of "Timezone" is it not a 
> timezone if it's offset by half an hour?  

The miltary doesn't recognize them as timezones. They'll make
a not that the local time observed doesn't match the timezone,
but they don't call it a seperate timezone.

>
> > The 400 you're seeing are duplications based on locality. Of the 86
> > shown in Windows, all but 33 are dulplicate references to the same
> > timezones.
>
> > For example, Windows has seperate listings for
>
> > Central America
> > Central Time (US & Canada)
> > Guadalahara, Mexico City, Monterry - New
> > Guadalahara, Mexico City, Monterry - Old
> > Saskatchewan
>
> > but they are all GMT-6
>
> Those are non-duplicate (and perhaps inaccurate, I'm not sure).  US time 
> switches from standard to Daylight Savings earlier than Mexico, and switches 
> back later, as of this year.  

Duplicate timezones doesn't mean duplicate time,
as you point out. Does the OP want to know the truth
or does he want to know something he can understand.

> Reducing them to a single time zone will result in aberrant functionality in 
> one or more locales.

I would hardly think that's an issue on the user registration
form the OP is trying to create.

>
> Cheers,
> Cliff


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


Re: pytz has so many timezones!

2007-10-08 Thread [EMAIL PROTECTED]
On Oct 8, 1:03 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Mon, 2007-10-08 at 10:41 -0700, [EMAIL PROTECTED] wrote:
> > For example, Windows has seperate listings for
>
> > Central America
> > Central Time (US & Canada)
> > Guadalahara, Mexico City, Monterry - New
> > Guadalahara, Mexico City, Monterry - Old
> > Saskatchewan
>
> > but they are all GMT-6
>
> But they could have different rules for Daylight Saving Time.

Which only matters if you're setting your clock.

>
> --
> Carsten Haesehttp://informixdb.sourceforge.net


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


Re: pytz has so many timezones!

2007-10-08 Thread J. Clifford Dyer
On Mon, Oct 08, 2007 at 01:12:32PM -0700, [EMAIL PROTECTED] wrote regarding Re: 
pytz has so many timezones!:
>  [ I wrote ]
> > Reducing them to a single time zone will result in aberrant functionality 
> > in one or more locales.
> 
> I would hardly think that's an issue on the user registration
> form the OP is trying to create.
> 

You don't think that it's an issue that the OPs users will complain about their 
time being inaccurate?  If I register in what we in the US call Eastern Time 
Zone, I don't want to have to switch to Atlantic time zone just because the 
form designer couldn't be bothered to include a time zone that actually matched 
the function of the clocks in my area.  

Pedantry about the definition of a time zone is not going to win you points 
with irate users.  

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


Re: pytz has so many timezones!

2007-10-08 Thread J. Clifford Dyer
On Mon, Oct 08, 2007 at 01:13:24PM -0700, [EMAIL PROTECTED] wrote regarding Re: 
pytz has so many timezones!:
> 
> On Oct 8, 1:03 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
> > On Mon, 2007-10-08 at 10:41 -0700, [EMAIL PROTECTED] wrote:
> > > For example, Windows has seperate listings for
> >
> > > Central America
> > > Central Time (US & Canada)
> > > Guadalahara, Mexico City, Monterry - New
> > > Guadalahara, Mexico City, Monterry - Old
> > > Saskatchewan
> >
> > > but they are all GMT-6
> >
> > But they could have different rules for Daylight Saving Time.
> 
> Which only matters if you're setting your clock.
> 

Maybe this is where I'm not understanding you:  Do you have another use for 
setting a timezone?  The only thing a time zone does, as far as I can tell, is 
set clocks relative to a shared conception of time.


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


Re: pytz has so many timezones!

2007-10-08 Thread Chris Mellon
On 10/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> On Oct 8, 1:00 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote:
> > On Mon, Oct 08, 2007 at 10:41:03AM -0700, [EMAIL PROTECTED] wrote regarding 
> > Re: pytz has so many timezones!:
> >
> >
> >
> > > On Oct 8, 2:32 am, Sanjay <[EMAIL PROTECTED]> wrote:
> > > > Hi All,
> >
> > > > I am using pytz.common_timezones to populate the timezone combo box of
> > > > some user registration form. But as it has so many timezones (around
> > > > 400),
> >
> > > There are only 25 timezones: -12, -11, ... -1, 0 (GMT), +1, ... +11,
> > > +12.
> >
> > > A handful of countries set their clocks offset by a half hour,
> > > but those aren't timezones.
> >
> > I'm sorry.  By what even vaguely useful definition of "Timezone" is it not 
> > a timezone if it's offset by half an hour?
>
> The miltary doesn't recognize them as timezones. They'll make
> a not that the local time observed doesn't match the timezone,
> but they don't call it a seperate timezone.
>

What do you mean by "the military" and why do you think they're
authoritative on the topic of timezones? The US timekeeping authority
is a branch of the US Navy, but as far as I know they don't define
timezones.

> >
> > > The 400 you're seeing are duplications based on locality. Of the 86
> > > shown in Windows, all but 33 are dulplicate references to the same
> > > timezones.
> >
> > > For example, Windows has seperate listings for
> >
> > > Central America
> > > Central Time (US & Canada)
> > > Guadalahara, Mexico City, Monterry - New
> > > Guadalahara, Mexico City, Monterry - Old
> > > Saskatchewan
> >
> > > but they are all GMT-6
> >
> > Those are non-duplicate (and perhaps inaccurate, I'm not sure).  US time 
> > switches from standard to Daylight Savings earlier than Mexico, and 
> > switches back later, as of this year.
>
> Duplicate timezones doesn't mean duplicate time,
> as you point out. Does the OP want to know the truth
> or does he want to know something he can understand.
>
> > Reducing them to a single time zone will result in aberrant functionality 
> > in one or more locales.
>
> I would hardly think that's an issue on the user registration
> form the OP is trying to create.
>

It's not clear at all from the OPs post exactly what functionality he
is trying to derive from the timezone. Since timezones (obviously)
contain more information than just the GMT offset (otherwise we
wouldn't even have them), he may very well want to use the timezone
given by the user to display correct local time to them. In this case,
the actual, correct, political timezone is important, not just the GMT
offset.

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


ANN: NUCULAR fielded text searchable indexing

2007-10-08 Thread aaron . watters
ANNOUNCE:
  NUCULAR fielded text searchable indexing

Nucular is a system for creating disk based full text indices
for fielded data. It can be accessed via a Python API
or via a suite of command line interfaces.

Nucular is intended to help store and retrieve
searchable information in a manner somewhat similar
to the way that "www.hotjobs.com" stores and
retrieves job descriptions, for example.

Nucular archives fielded documents and retrieves them
based on field value, field prefix, field word prefix,
or full text word prefix, or combinations of these.

Features:

 -- Nucular is very light weight. Updates and accesses
do not require any server process or other system
support such as shared memory locking.

 -- Nucular supports concurrency. Arbitrary concurrent
updates and accesses by multiple processes or threads
are supported, with no possible locking issues.

 -- Nucular indexes and retrieves large collections quickly.

Read more and download at:
   http://nucular.sourceforge.net

Online demos:

http://www.xfeedme.com/nucular/gut.py/go
http://www.xfeedme.com/nucular/mondial.py/go

I hope you like!
   -- Aaron Watters

===
I don't know ka-RAH-tee
But I know ka-RAY-zee
   -- James Browne

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


Re: csv module and Unicode

2007-10-08 Thread Robert Dailey
Wow; I guess this is a REAL problem! I would have thought that something as
common as Unicode CSV would have been supported by SOMEONE.

On 10/5/07, Robert Dailey <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> According to the Python 2.5 documentation, Unicode is not supported
> through the CSV module. Is there some third-party CSV module I can use that
> has Unicode support? Thanks.
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python + Shoutpy + Twisted Locks

2007-10-08 Thread Chris Mellon
On 10/7/07, Michel Albert <[EMAIL PROTECTED]> wrote:
> On Oct 6, 4:21 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> > En Fri, 05 Oct 2007 04:55:55 -0300, exhuma.twn <[EMAIL PROTECTED]> escribi?:
> >
> > > [...] What I found
> > > is that "libshout" is blocking, which should be fine as the whole
> > > thing runs in it's separate thread. But the application hangs
> > > nevertheless while streaming. This effectively blocks out the other
> > > thread that checks the player status, which then fails to append new
> > > songs to the queue. So only one song is played when streaming.
> >
> > > The other threads in my application run fine and don't block the rest
> > > of the app. So I guess, that the main problem is that blocking occurs
> > > "outside" the python world and "inside" the libshout world.
> >
> > Only one thread at a time may be executing Python code; the Global
> > Interpreter Lock (GIL) ensures the mutual exclusion. Extension modules
> > (written in C) may use the macros
> > Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS to release/acquire the GIL
> > before/after an external blocking call.
> > I don't know libshout, or how you are doing the binding python-libshout,
> > but if your analysis is correct it means that the code is not releasing
> > the GIL at the appropiate points.
> >
> > --
> > Gabriel Genellina
>
> Hmmm... ok. I suppose rewriting the whole thing using twisted's
> deferreds could then solve the problem. Which are basically nothing
> more than callbacks with a weird name ;) Unfortunately this means that
> I have to re-think a lot. But in the end I suppose it will pay off.
>
> Thanks for taking the time and reading my little essay Gabriel ;)
>


Using Twisted won't help if the libshout calls are really blocking the
main thread. You need to fix the libshout wrapper to release the GIL
when it makes blocking C calls.

I also believe that Twisted has a native (perhaps only
semi-functional?) shoutcast protocol implementation, so a pure-python
implementation might be possible as well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convert obejct string repr to actual object

2007-10-08 Thread Diez B. Roggisch
Tor Erik Sønvisen schrieb:
> Hi,
> 
> I've tried locating some code that can recreate an object from it's
> string representation...
> The object in question is really a dictionary containing other
> dictionaries, lists, unicode strings, floats, ints, None, and
> booleans.
> 
> I don't want to use eval, since I can't trust the source sending the
> object I'm sure someone must have had the same need and created
> code for it... Maybe Pypy has what I need??? Haven't looked though...


Try using simplejson.

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


Re: pytz has so many timezones!

2007-10-08 Thread Joe Holloway
On 10/8/07, Sanjay <[EMAIL PROTECTED]> wrote:
> 2. Mapping the timezones to countries is a nice idea. Any idea how to
> go about it - I mean whether I have to collect the data manually and
> do it, or some better way is available - will help me a lot.

You might find some good information by brushing up on the Olson time
zone database:

http://en.wikipedia.org/wiki/Zoneinfo
http://www.twinsun.com/tz/tz-link.htm
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: round-trip from egg to code and back to egg

2007-10-08 Thread John Nagle
Bruno Desthuilliers wrote:
> Catherine a écrit :
>> Three possibilities come to mind -
>>
>> 1. I'm missing something simple
> 
> Probably. I'd say, something like unzip .egg !-)

That's generally the solution to "egg" files.  They usually
do the wrong thing, and the "egg" system is still in beta.
They're really .zip files, so just unzip them and ignore the
"egg" crap.

My experience is that every .egg file adds about a half
hour of headaches to an install, since you have to figure
out why it didn't work, or why Python is still using the
old version, or something.

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


Re: pytz has so many timezones!

2007-10-08 Thread Travis Jensen
How about a calendar entry: I've got six people in places all over the world
to get on the phone together.  If the app doesn't know their notion of a
time zone, that will never happen.

How about financial transactions: time-stamping transactions that move
around the world seems pretty useful to me.  How do I know when said
transaction started if I can't convert the user's time into the server's
time?

Timezone is just another localization setting.  It is no different than
language or keyboard layout.  It is a piece of data that describes the
"world" the user lives in.  Unfortunately, DST makes them very complex
because DST is determined by the country and can change from year to year.
I think the US' DST change this year had more of a real-world impact than
Y2K (of course, people actually planned for Y2K, but that is a different
story :).

tj

On 10/8/07, J. Clifford Dyer <[EMAIL PROTECTED]> wrote:
>
> On Mon, Oct 08, 2007 at 01:13:24PM -0700, [EMAIL PROTECTED] wrote
> regarding Re: pytz has so many timezones!:
> >
> > On Oct 8, 1:03 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
> > > On Mon, 2007-10-08 at 10:41 -0700, [EMAIL PROTECTED] wrote:
> > > > For example, Windows has seperate listings for
> > >
> > > > Central America
> > > > Central Time (US & Canada)
> > > > Guadalahara, Mexico City, Monterry - New
> > > > Guadalahara, Mexico City, Monterry - Old
> > > > Saskatchewan
> > >
> > > > but they are all GMT-6
> > >
> > > But they could have different rules for Daylight Saving Time.
> >
> > Which only matters if you're setting your clock.
> >
>
> Maybe this is where I'm not understanding you:  Do you have another use
> for setting a timezone?  The only thing a time zone does, as far as I can
> tell, is set clocks relative to a shared conception of time.
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Travis Jensen
[EMAIL PROTECTED]
http://cmssphere.blogspot.com/
Software Maven * Philosopher-in-Training * Avenged Nerd
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Variable scoping rules in Python?

2007-10-08 Thread MRAB
On Oct 8, 4:06 pm, Bruno Desthuilliers  wrote:
> [EMAIL PROTECTED] a écrit :
>
> > Ok, I'm relatively new to Python (coming from C, C++ and Java).  I'm
> > working on a program that outputs text that may be arbitrarily long,
> > but should still line up, so I want to split the output on a specific
> > column boundary.
>
> FWIW :http://docs.python.org/lib/module-textwrap.html
>
>
>
>
>
> >  Since I might want to change the length of a column,
> > I tried defining the column as a constant (what I would have made a
> > "#define" in C, or a "static final" in Java).  I defined this at the
> > top level (not within a def), and I reference it inside a function.
> > Like this:
>
> > COLUMNS = 80
>
> > def doSomethindAndOutputIt( ):
> >   ...
> >   for i in range( 0, ( len( output[0] ) / COLUMNS ) ):
> > print output[0][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> > print output[1][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> > ..
>
> > etc. etc.  It works fine, and splits the output on the 80-column
> > boundary just like I want.
>
> > Well, I decided that I wanted "COLUMNS = 0" to be a special "don't
> > split anywhere" value, so I changed it to look like this:
>
> > COLUMNS = 80
>
> > def doSomethindAndOutputIt( ):
> >   ...
> >   if COLUMNS == 0:
> > COLUMNS = len( output[ 0 ] )
>
> >   for i in range( 0, ( len( output[0] ) / COLUMNS ) ):
> > print output[0][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> > print output[1][ i * COLUMNS : i * COLUMNS + ( COLUMNS - 1 ) ]
> > ..
>
> Since you don't want to modify a global (and even worse, a CONSTANT),
> the following code may be a bit cleaner:
>
> def doSomethindAndOutputIt( ):
>...
>if COLUMNS == 0:
>   columns = len( output[ 0 ] )
>else:
>   columns = COLUMNS
>for i in range( 0, ( len( output[0] ) / COLUMNS ) ):
>   print output[0][ i * columns : i * columns + ( columns - 1 ) ]
>..
>
[snip]
range() can accept 3 arguments (start, stop and step) so you could
write:

for i in range( 0, len( output[0] ), columns ):
   print output[0][ i : i + columns ]
..

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

Re: Convert obejct string repr to actual object

2007-10-08 Thread Steven D'Aprano
On Mon, 08 Oct 2007 21:19:50 +0200, Tor Erik Sønvisen
wrote:

> I don't want to use eval, since I can't trust the source sending the
> object I'm sure someone must have had the same need and created code
> for it... Maybe Pypy has what I need??? Haven't looked though...


For the benefit of those who think they can make eval "safe", start here:

http://effbot.org/zone/librarybook-core-eval.htm


Here's a good solution:

http://effbot.org/zone/simple-iterator-parser.htm



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

Re: Python + Shoutpy + Twisted Locks

2007-10-08 Thread John Nagle
Chris Mellon wrote:
> On 10/7/07, Michel Albert <[EMAIL PROTECTED]> wrote:
>> On Oct 6, 4:21 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>>> En Fri, 05 Oct 2007 04:55:55 -0300, exhuma.twn <[EMAIL PROTECTED]> escribi?:
>>>
 [...] What I found
 is that "libshout" is blocking, which should be fine as the whole
 thing runs in it's separate thread. But the application hangs
 nevertheless while streaming. This effectively blocks out the other
 thread that checks the player status, which then fails to append new
 songs to the queue. So only one song is played when streaming.
 The other threads in my application run fine and don't block the rest
 of the app. So I guess, that the main problem is that blocking occurs
 "outside" the python world and "inside" the libshout world.
>>> Only one thread at a time may be executing Python code; the Global
>>> Interpreter Lock (GIL) ensures the mutual exclusion. Extension modules
>>> (written in C) may use the macros
>>> Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS to release/acquire the GIL
>>> before/after an external blocking call.
>>> I don't know libshout, or how you are doing the binding python-libshout,
>>> but if your analysis is correct it means that the code is not releasing
>>> the GIL at the appropiate points.
>>>
>>> --
>>> Gabriel Genellina
>> Hmmm... ok. I suppose rewriting the whole thing using twisted's
>> deferreds could then solve the problem. Which are basically nothing
>> more than callbacks with a weird name ;) Unfortunately this means that
>> I have to re-think a lot. But in the end I suppose it will pay off.
>>
>> Thanks for taking the time and reading my little essay Gabriel ;)
>>
> 
> Using Twisted won't help if the libshout calls are really blocking the
> main thread.

 Right.

 The whole point of Twisted is that you can't do anything that takes
very long in a Twisted thread, or the whole server will stall.  If you
try to do something ongoing, like streaming, in a Twisted server, you
have to have long-running threads of your own and a scheduling system
to coordinate them with the Twisted threads.

 libshout's "nonblocking" mode isn't very nonblocking.  See

https://trac.xiph.org/browser/icecast/trunk/libshout/examples/nonblocking.c

There's a thread in a loop during playout.  All "nonblocking" seems to do is
defer the waiting from shout_write() to shout_sync().

 It looks like you'll need a separate thread for each stream being played
out, on top of the Twisted machinery.  Or a completely event-driven version
of "libshout" designed for Twisted.

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


Re: pytz has so many timezones!

2007-10-08 Thread J. Cliff Dyer
On 10/8/07, *J. Clifford Dyer* <[EMAIL PROTECTED]
> wrote:

On Mon, Oct 08, 2007 at 01:13:24PM -0700, [EMAIL PROTECTED]
 wrote regarding Re: pytz has so many
timezones!:
>
> On Oct 8, 1:03 pm, Carsten Haese < [EMAIL PROTECTED]
> wrote:
> > On Mon, 2007-10-08 at 10:41 -0700, [EMAIL PROTECTED]
 wrote:
> > > For example, Windows has seperate listings for
> >
> > > Central America
> > > Central Time (US & Canada)
> > > Guadalahara, Mexico City, Monterry - New
> > > Guadalahara, Mexico City, Monterry - Old
> > > Saskatchewan
> >
> > > but they are all GMT-6
> >
> > But they could have different rules for Daylight Saving Time.
>
> Which only matters if you're setting your clock.
>

Maybe this is where I'm not understanding you:  Do you have another
use for setting a timezone?  The only thing a time zone does, as far
as I can tell, is set clocks relative to a shared conception of time.


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





> How about a calendar entry: I've got six people in places all over the
> world to get on the phone together.  If the app doesn't know their
> notion of a time zone, that will never happen.
>
> How about financial transactions: time-stamping transactions that move
> around the world seems pretty useful to me.  How do I know when said
> transaction started if I can't convert the user's time into the
> server's time?
>
> Timezone is just another localization setting.  It is no different
> than language or keyboard layout.  It is a piece of data that
> describes the "world" the user lives in.  Unfortunately, DST makes
> them very complex because DST is determined by the country and can
> change from year to year.  I think the US' DST change this year had
> more of a real-world impact than Y2K (of course, people actually
> planned for Y2K, but that is a different story :).
>
> tj
>


OK.  Those all make sense, but I think they contradict mensanator's
statement that DST and half-hour offsets "only matter[] if you're
setting your clock."  None of those are meaningful with 25 generic time
zones, which was what I was trying to understand.  Under what normal
circumstances (outside of the US military creating an approximation for
their own internal usage) could 25 tzs be a useful abstraction?

Cheers,
Cliff

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


Re: Convert obejct string repr to actual object

2007-10-08 Thread Michael Spencer
Tor Erik Sønvisen wrote:
> Hi,
> 
> I've tried locating some code that can recreate an object from it's
> string representation...
> The object in question is really a dictionary containing other
> dictionaries, lists, unicode strings, floats, ints, None, and
> booleans.
> 
> I don't want to use eval, since I can't trust the source sending the
> object I'm sure someone must have had the same need and created
> code for it... Maybe Pypy has what I need??? Haven't looked though...
> 
> Regards,
> Tor Erik
> 
> PS: The string repr is created by a server outside of my control...

This recipe should get you most of what you need:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469

HTH

Michael

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


Re: pytz has so many timezones!

2007-10-08 Thread [EMAIL PROTECTED]
On Oct 8, 5:48 pm, "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote:
> On 10/8/07, *J. Clifford Dyer* <[EMAIL PROTECTED]
>
> > wrote:
>
> On Mon, Oct 08, 2007 at 01:13:24PM -0700, [EMAIL PROTECTED]
>  wrote regarding Re: pytz has so many
> timezones!:
> >
> > On Oct 8, 1:03 pm, Carsten Haese < [EMAIL PROTECTED]
> > wrote:
> > > On Mon, 2007-10-08 at 10:41 -0700, [EMAIL PROTECTED]
>  wrote:
> > > > For example, Windows has seperate listings for
> > >
> > > > Central America
> > > > Central Time (US & Canada)
> > > > Guadalahara, Mexico City, Monterry - New
> > > > Guadalahara, Mexico City, Monterry - Old
> > > > Saskatchewan
> > >
> > > > but they are all GMT-6
> > >
> > > But they could have different rules for Daylight Saving Time.
> >
> > Which only matters if you're setting your clock.
> >
>
> Maybe this is where I'm not understanding you:  Do you have another
> use for setting a timezone?  The only thing a time zone does, as far
> as I can tell, is set clocks relative to a shared conception of time.
>
> --
>http://mail.python.org/mailman/listinfo/python-list
>
>
>
>
>
> > How about a calendar entry: I've got six people in places all over the
> > world to get on the phone together.  If the app doesn't know their
> > notion of a time zone, that will never happen.
>
> > How about financial transactions: time-stamping transactions that move
> > around the world seems pretty useful to me.  How do I know when said
> > transaction started if I can't convert the user's time into the
> > server's time?
>
> > Timezone is just another localization setting.  It is no different
> > than language or keyboard layout.  It is a piece of data that
> > describes the "world" the user lives in.  Unfortunately, DST makes
> > them very complex because DST is determined by the country and can
> > change from year to year.  I think the US' DST change this year had
> > more of a real-world impact than Y2K (of course, people actually
> > planned for Y2K, but that is a different story :).
>
> > tj
>
> OK.  Those all make sense, but I think they contradict mensanator's
> statement that DST and half-hour offsets "only matter[] if you're
> setting your clock."  None of those are meaningful with 25 generic time
> zones, which was what I was trying to understand.  Under what normal
> circumstances (outside of the US military creating an approximation for
> their own internal usage) could 25 tzs be a useful abstraction?

It's how the world goes around.

Some people can't see the forest for the trees.

Is it obvious from all this timezone crap that

 - a day lasts 48 hours?

 - it can never be the same day everywhere in the world
   simultaneously?

Isn't that just as important for worldwide transactions
as Daylight Savings Time (or lack thereof)?

Perhaps, once the basics

are understood, the details won't be so confusing.

>
> Cheers,
> Cliff

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


Memory leak/gc.get_objects()/Improved gc in version 2.5

2007-10-08 Thread crazy420fingers
I'm running a python program that simulates a wireless network
protocol for a certain number of "frames" (measure of time).  I've
observed the following:

1. The memory consumption of the program grows as the number of frames
I simulate increases.

To verify this, I've used two methods, which I invoke after every
frame simulated:

--  Parsing the /proc//status file as in:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286222
--  Using ps vg | grep python | awk '!/grep/ {print " ",$8}'  in an
os.system() call.

The memory usage vs. frame number graph shows some big "jumps" at
certain points, and, after a large number of frames, shows a steady
upward slope

2. I think I've verified that the objects I instantiate are actually
freed-- I'm therefore assuming that this "leak" is "caused" by
python's garbage collection mechanism. I count the number of objects I
generate that are being tracked by gc as follows:

gc.collect()
objCount = {}
objList = gc.get_objects()
for obj in objList:
if getattr(obj, "__class__", None):
name = obj.__class__.__name__
if objCount.has_key(name):
objCount[name] += 1
else:
objCount[name] = 1

for name in objCount:
print name, " :", objCount[name]

   del objList

Running this snippet every hundred frames or so, shows that the number
of objects managed by gc is not growing.

I upgraded to Python 2.5. in an attempt to solve this problem. The
only change in my observations from version 2.4 is that the absolute
memory usage level seems to have dropped. However, I still see the
jumps in memory usage at the same points in time.

Can anybody explain why the memory usage shows significant jumps (~200
kB or ~500 kb) over time (i.e. "frames") even though there is no
apparent increase in the objects managed by gc? Note that I'm calling
gc.collect() regularly.

Thanks for your attention,

Arvind

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


Re: pytz has so many timezones!

2007-10-08 Thread [EMAIL PROTECTED]
On Oct 8, 3:23 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote:
> On Mon, Oct 08, 2007 at 01:12:32PM -0700, [EMAIL PROTECTED] wrote regarding 
> Re: pytz has so many timezones!:
>
> >  [ I wrote ]
> > > Reducing them to a single time zone will result in aberrant functionality 
> > > in one or more locales.
>
> > I would hardly think that's an issue on the user registration
> > form the OP is trying to create.
>
> You don't think that it's an issue that the OPs users will complain about 
> their time being inaccurate?  If I register in what we in the US call Eastern 
> Time Zone, I don't want to have to switch to Atlantic time zone just because 
> the form designer couldn't be bothered to include a time zone that actually 
> matched the function of the clocks in my area.  

That wasn't my point. If you know you're in GMT-5 and your computer
knows you're in GMT-5, why do you have to peruse a list of 400
choices,
most of which don't match your GMT offset?

>
> Pedantry about the definition of a time zone is not going to win you points 
> with irate users.  

Fine. Then make the user scroll through 400 choices. See how many
points that gets you.

>
> Cliff


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


Re: pytz has so many timezones!

2007-10-08 Thread [EMAIL PROTECTED]
On Oct 8, 3:27 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On 10/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On Oct 8, 1:00 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote:
> > > On Mon, Oct 08, 2007 at 10:41:03AM -0700, [EMAIL PROTECTED] wrote 
> > > regarding Re: pytz has so many timezones!:
>
> > > > On Oct 8, 2:32 am, Sanjay <[EMAIL PROTECTED]> wrote:
> > > > > Hi All,
>
> > > > > I am using pytz.common_timezones to populate the timezone combo box of
> > > > > some user registration form. But as it has so many timezones (around
> > > > > 400),
>
> > > > There are only 25 timezones: -12, -11, ... -1, 0 (GMT), +1, ... +11,
> > > > +12.
>
> > > > A handful of countries set their clocks offset by a half hour,
> > > > but those aren't timezones.
>
> > > I'm sorry.  By what even vaguely useful definition of "Timezone" is it 
> > > not a timezone if it's offset by half an hour?
>
> > The miltary doesn't recognize them as timezones. They'll make
> > a not that the local time observed doesn't match the timezone,
> > but they don't call it a seperate timezone.
>
> What do you mean by "the military" and why do you think they're
> authoritative on the topic of timezones?

Because they publish maps?

> The US timekeeping authority
> is a branch of the US Navy,

Isn't that "the military"?

> but as far as I know they don't define timezones.

Ok, maybe they don't define them. But they get them from somewhere
and the zones are labeled A-Z (don't ask which letter isn't used).
Zone Z is equivalent to GMT and the time is refered to as Zulu time.

That's 25 zones, not 400. Under that system there are no half-hour
offset zones, no zones based on sunset and no lunatic GMT+13 zones.

You'll never learn to run without first learning how to walk.

>
>
>
>
> > > > The 400 you're seeing are duplications based on locality. Of the 86
> > > > shown in Windows, all but 33 are dulplicate references to the same
> > > > timezones.
>
> > > > For example, Windows has seperate listings for
>
> > > > Central America
> > > > Central Time (US & Canada)
> > > > Guadalahara, Mexico City, Monterry - New
> > > > Guadalahara, Mexico City, Monterry - Old
> > > > Saskatchewan
>
> > > > but they are all GMT-6
>
> > > Those are non-duplicate (and perhaps inaccurate, I'm not sure).  US time 
> > > switches from standard to Daylight Savings earlier than Mexico, and 
> > > switches back later, as of this year.
>
> > Duplicate timezones doesn't mean duplicate time,
> > as you point out. Does the OP want to know the truth
> > or does he want to know something he can understand.
>
> > > Reducing them to a single time zone will result in aberrant functionality 
> > > in one or more locales.
>
> > I would hardly think that's an issue on the user registration
> > form the OP is trying to create.
>
> It's not clear at all from the OPs post exactly what functionality he
> is trying to derive from the timezone.

Yep, we can't read his mind.

> Since timezones (obviously)
> contain more information than just the GMT offset

Of course. But the GMT offset could be used to filter his list
of 400 choices, couldn't it?

> (otherwise we
> wouldn't even have them), he may very well want to use the timezone
> given by the user to display correct local time to them. In this case,
> the actual, correct, political timezone is important, not just the GMT
> offset.

Agreed. But if someone gave me a list of 400 choices, I would look
for some way to reduce the list to a manageable choice. Isn't that
what the OP wants?

Why not teach him the truth, starting from the top level? Shouldn't
you teach him to fish rather than just give him one?

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

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


Re: weakrefs and bound methods

2007-10-08 Thread Bruno Desthuilliers
Mathias Panzenboeck a écrit :

About the lost weakref problem: in Python, methods are just tiny 
wrappers around the object, class and function created at lookup time 
(yes, on *each* lookup) (and WWAI, they are by the function object 
itself, which implements the descriptor protocol).

> When I change the class Wrapper to following, the class Foo works:
> 
> class Wrapper(object):
>   def __init__(self,x):
>   self.func_name = x.func_name
>   self.x = weakref.ref(x.im_self)

>   def __call__(self,*args,**kwargs):
>   x = self.x()
>   if x is None:
>   print "lost reference"
>   else:
>   return getattr(x,self.func_name)(*args,**kwargs)

Anyway, the whole thing looks quite baroque to me - and I'm known for my 
immoderate appetite for brain-melting features

If I understand correctly, you're doing all this to avoid circular 
references while keeping track of a list of methods to call ?

If yes, then you're thru much pain for nothing. Mostly because there are 
  other much more simpler solutions. The first one is obviously to use 
names and getattr. In it's most naïve implementation, this would look like:

class Foo(object):
 def __init__(self):
self._methods = set()
self._methods.add('_foo')

 def _foo(self):
print "_foo"

 def callMethods(self):
 for name in self._methods:
  meth = getattr(self, name, None)
  if callable(meth):
  meth()




Now if _methods is supposed to have the same content class-wise (which 
is the case in your exemple), no need to have it as an instance method:

class Foo(object):
 _methods = set('_foo')

 def _foo(self):
print "_foo"

 def callMethods(self):
 for name in self._methods:
  meth = getattr(self, name, None)
  if callable(meth):
  meth()

We could go further, like using a decorator to mark methods to add to 
_methods, and a metaclass to set the whole thing up, but this would 
probably be overkill. Unless there are other requirements, I'd 
personnaly stop here.

Oh, and yes, while we're at it : Python usually knows how to deal with 
circular references

> But that's ugly. 

Indeed.

> Any better idea?

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


Re: pytz has so many timezones!

2007-10-08 Thread Nicholas Bastin
On 10/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > What do you mean by "the military" and why do you think they're
> > authoritative on the topic of timezones?
>
> Because they publish maps?

I'm not sure what this has to do with it.

> > but as far as I know they don't define timezones.
>
> Ok, maybe they don't define them. But they get them from somewhere
> and the zones are labeled A-Z (don't ask which letter isn't used).
> Zone Z is equivalent to GMT and the time is refered to as Zulu time.

They get them from NATO.  NGO's outside of NATO do not use NATO time
zones for describing time data, mostly because NATO doesn't care about
daylight savings time.  Works fine for the military, but not so well
for your civilian users.

> That's 25 zones, not 400. Under that system there are no half-hour
> offset zones, no zones based on sunset and no lunatic GMT+13 zones.

Yes, but lucky for us, we live in the real world, so we have to deal
with 400 time zones.  The reality is that people LIVE in those
'lunatic' time zones, and software needs to address that.

If I schedule a meeting with someone in Indiana, and I'm in Ohio,
they're in the same military time zone, but they don't observe
daylight savings time, so in fact our times are different.  Users
probably want our applications to handle these problems.

> > Since timezones (obviously)
> > contain more information than just the GMT offset
>
> Of course. But the GMT offset could be used to filter his list
> of 400 choices, couldn't it?

Sortof.  First, your user has to understand what GMT is, so that's
already going to cause problems.   Secondly, you need to handle time
zones which drift from different GMT offsets depending on the time of
year.  At the very least your algorithm needs to be greedy.

> Agreed. But if someone gave me a list of 400 choices, I would look
> for some way to reduce the list to a manageable choice. Isn't that
> what the OP wants?
>
> Why not teach him the truth, starting from the top level? Shouldn't
> you teach him to fish rather than just give him one?

Because the truth is that there are upwards of 400 different time
zones, accounting for local custom and law.  The military can
conveniently ignore that, but we as application writers cannot.

There is no central authority which defines global time zones.  The
functional definition of a time zone is merely a geographical area of
the earth that has adopted the same local time rules.

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


Re: Adding extra modules to a Pyinstaller build

2007-10-08 Thread GaryLee
> I need to add several Python standard modules to a Pyinstaller
> project. The modules are not (and cannot be) explicitly imported in my
> project script, so is there a way to add them to my .spec file in
> order to allow Pyinstaller to search for them in PYTHONPATH and add
> them to the project?

Have you read the "Listing Hidden Imports" section in the PyInstaller
document?
Check this out.
http://pyinstaller.hpcf.upr.edu/docs/Manual_v1.1.html#listing-hidden-imports

Regards,
Gary

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


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-10-08 Thread Damien Kick
Wildemar Wildenburger wrote:
> Frank Goenninger wrote:
>> On 2007-09-29 01:27:04 +0200, Damien Kick <[EMAIL PROTECTED]> said:
>>
>>> If you were referring to the "free" in "free Mumia Abu Jamal", I 
>>> would agree with you.  I don't think anyone would imagine that this 
>>> phrase meant that someone was going to get Mumia Abu Jamal gratis.  
>>> Like it or not, "free software" referring to "free as in beer" is 
>>> probably the most common interpretation of the phrase for a native 
>>> English speaker. [...]
>>
>> Fully true for non-native English speakers as well. Just did the "wife 
>> test" also - she is a pure software user - and yes, free is "no money, 
>> do what you want" and that's it.

I should have used the phrase "fluent English speaker"...

>> I *never* use the term "free" if I don't want to imply "free beer" 
>> (which is a Good Thing and as such highly valuated - ask any 
>> Bavarian). Using "free" as by FSF or any other lawyer-style 6 pixel 
>> font printed phrasing is pure perfidiousness.
>>
> I appearantly missed a lot of that conversation, but what is your point? 
> While I agree that the word "free" implies "free of monetary cost" to 
> many people societies, that is by no means set in stone [...].

For some odd reason, this reminded me of an old episode of Mork & Mindy:

http://www.salon.com/ent/movies/feature/1999/09/03/robin/";>
What made Mork think eggs could fly? And yet when he tried to release 
them from the tyranny of gravity ("Fly, be free!"), flinging them into 
the air only to have them land with a soft thwack, it seemed like 
nothing so much as a stroke of loopy brilliance.


The term "free eggs" can only sensibly mean one thing, eggs which can be 
obtained without an exchange of money.  To think of it meaning anything 
else--"fly, be free!"--is comedy (or not, depending on one's opinion of 
Mork & Mindy).  When Free Software Foundationistas try to insist on the 
phrase "free software" meaning anything other than the obvious 
interpretation of the term it is annoying (or not, depending on one's 
opinion of RMS's skills as a wordsmith).  I've got this great mental 
image of some farcical Free Software Liberation Army running around, 
removing hard drives from boxen, and throwing them in the air with the 
moral imperative to "fly, be free!"

> But that aside: The word free with respect to the FSF and GPL have a 
> perfectly well defined meaning. People may misunderstand that from not 
> knowing the definition but that doesnt make it any less well defined.

This thread of conversation also popped into my head when I was waiting 
in line at the Starbucks in the building in which I work.  I've been 
ordering a lot of Americanos lately.  I always ask for a small Americano 
and the person taking my order always calls out my drink as a "tall". 
With respect to Starbucks, calling a beverage which comes in the 
shortest cup used in the store a "tall" has a perfectly well defined 
meaning.  But that doesn't make it any less ridiculous.  Of course, it 
was mentioned elsewhere in this thread that context is important.  And 
it is.  To use the Starbucks analogy, for someone to criticize Starbucks 
because their tall drinks really are actually quite short would be 
ignoring the significance of the context of Starbucks' abuse of the 
English language.  But, again, that doesn't make Starbuck's use of the 
word any less ridiculous.  However, at least at Starbucks, when I use 
the "wrong" word, they don't start lecturing me.  They know what I mean 
and simply go ahead and translate it to Starbucks newspeak.

> Again, why this discussion?

Hello, Pot?  This is the kettle.  You are so black.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >