Re: Problem!!

2011-07-04 Thread TheSaint
Irmen de Jong wrote:

> No, I misplaced my crystal ball.

I'm waiting mine, brand new in HD :D, with remote control :D :D

-- 
goto /dev/null
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The end to all language wars and the great unity API to come!

2011-07-04 Thread Gregory Ewing

rantingrick wrote:


I agree however i see merit in both approaches. But why must we have
completely different languages just for that those two approaches?


We have different languages because different people have different
ideas about what a language should be like. Ruby people like user
defined control structures; Python people regard user defined
control structures as an anti-feature. It's fundamentally
impossible for one language to satisfy both sets of people.

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


Re: Why won't this decorator work?

2011-07-04 Thread Gregory Ewing

OKB (not okblacke) wrote:

	A decorator basically modifies a function/method, so that ALL 
subsequent calls to it will behave differently.


Furthermore, usually a decorator is used when for some
reason you *can't* achieve the same effect with code
inside the function itself.

For example, the classmethod() and staticmethod()
decorators return descriptors that have different
magical effects from a standard function object when
looked up in a class or instance. Since that magic
happens *before* the function is called, you can't
do the same thing using an ordinary function.

In this case, an ordinary function is quite sufficient,
and there is no need to involve a decorator.

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


HeaderParseError

2011-07-04 Thread Thomas Guettler
Hi,

I get a HeaderParseError during decode_header(), but Thunderbird can
display the name.

>>> from email.header import decode_header
>>> decode_header('=?iso-8859-1?B?QW5tZWxkdW5nIE5ldHphbnNjaGx1c3MgU_xkcmluZzNwLmpwZw==?=')
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib64/python2.6/email/header.py", line 101, in decode_header
raise HeaderParseError
email.errors.HeaderParseError


How can I parse this in Python?

  Thomas

Same question on Stackoverflow:
http://stackoverflow.com/questions/6568596/headerparseerror-in-python

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EVIL!

2011-07-04 Thread Gregory Ewing

rantingrick wrote:


Unlike most GUI libraries the Tkinter developers thought is would
"just wonderful" if the root GUI window just sprang into existence if
the programmer "somehow" forgot to create one.


IMO the real problem here is the existence of a privileged
"root" window at all. No GUI platform I know of has any
such concept (except for a "desktop" window that represents
the whole screen, which is not the same thing). All top-level
windows should have equal status.

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


Re: Implicit initialization is EVIL!

2011-07-04 Thread Chris Angelico
On Mon, Jul 4, 2011 at 6:33 PM, Gregory Ewing
 wrote:
> rantingrick wrote:
>
>> Unlike most GUI libraries the Tkinter developers thought is would
>> "just wonderful" if the root GUI window just sprang into existence if
>> the programmer "somehow" forgot to create one.
>
> IMO the real problem here is the existence of a privileged
> "root" window at all. No GUI platform I know of has any
> such concept (except for a "desktop" window that represents
> the whole screen, which is not the same thing). All top-level
> windows should have equal status.

I don't know Tkinter, but from the look of the example code, he's
creating a Label that's not attached to a window, and then packing it
into nothing. The toolkit kindly creates him a window. Is that the
"root GUI window" that he means? A basic top-level window?

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


Re: Virtual functions are virtually invisible!

2011-07-04 Thread Gregory Ewing

rantingrick wrote:

what concerns me is the fact that virtual methods in derived
classes just blend in to the crowd.



I think we really need some
sort of visual cue in the form of forced syntactical notation (just
like the special method underscores).


If you're suggesting that it should be impossible to override
a method unless it is specially marked somehow in the base
class, I think that would be a bad idea.

One of the principles behind the design of Eiffel is that
classes should *always* be open to modification in any way
by a subclass. The reason is that the author of a class
library can't anticipate all the ways people might want to
use it. Consequently Eiffel has no equivalent of C++'s
"private" declaration -- everything is at most "protected".
It also has no equivalent of Java's "final".

I like the fact that Python doesn't have these either.

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


Re: Problem!!

2011-07-04 Thread Gregory Ewing

TheSaint wrote:


On 4-7-2011 1:41, amir chaouki wrote:


No, I misplaced my crystal ball.


I'm waiting mine, brand new in HD :D, with remote control :D :D


The new digital models are great. But there's a
distressing tendency for visions to come with
DRM protection these days, so you can only share
them with at most 5 other users. :-(

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


Re: web hosting, first hand experiences?

2011-07-04 Thread Daniel Fetchinson
>> Hi folks, I know this comes up regularly but the thing is that the
>> quality of service changes also quite regularly with many of the
>> hosting companies. What's currently the best option for shared hosting
>> of a turbogears application? I'm thinking of dreamhost and webfaction
>> does anyone have any recent experiences with these two? Or others?
>>
>> Cheers,
>> Daniel
>>
>
> Hi Daniel,
>
> I can wholeheartedly recommend WebFaction.  I currently have an account
> running 3 different CherryPy applications (so TurboGears shouldn't pose
> any problems), and apart from initial teething problems, they have been
> running for months without interruption.  As well as an excellent
> control panel, they give you full Linux command-line access to your
> site(s).  The level of support is as good as you will get anywhere
> (short of having experts with you in the office!), and they know a huge
> amount about Python web applications.  Nothing seems to be too much
> trouble for them.  They also provide a 60-day money-back guarantee, so
> you can try-before-you-buy.
>
> Best wishes,
> Alan Harris-Reid

Thanks for all the responses, based on the feedback I'll go with
webfaction I guess.
They were my first choice anyway but wanted to double check with
people in the know about their current situation.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HeaderParseError

2011-07-04 Thread Peter Otten
Thomas Guettler wrote:

> I get a HeaderParseError during decode_header(), but Thunderbird can
> display the name.
> 
 from email.header import decode_header
 
decode_header('=?iso-8859-1?B?QW5tZWxkdW5nIE5ldHphbnNjaGx1c3MgU_xkcmluZzNwLmpwZw==?=')
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib64/python2.6/email/header.py", line 101, in decode_header
> raise HeaderParseError
> email.errors.HeaderParseError
> 
> 
> How can I parse this in Python?

Trying to decode as much as possible:

>>> s = "QW5tZWxkdW5nIE5ldHphbnNjaGx1c3MgU_xkcmluZzNwLmpwZw==?="
>>> for n in range(len(s), 0, -1):
... try: t = s[:n].decode("base64")
... except: pass
... else: break
...
>>> n, t
(49, 'Anmeldung Netzanschluss S\x19\x1c\x9a[\x99\xcc\xdc\x0b\x9a\x9c\x19')
>>> print t.decode("iso-8859-1")
Anmeldung Netzanschluss S[ÌÜ

>>> s[n:]
'w==?='

The characters after "...Netzanschluss " look like garbage. What does 
Thunderbird display?
-- 
http://mail.python.org/mailman/listinfo/python-list


Sending email in python

2011-07-04 Thread vijay swaminathan
Hi All,

I read through the smtplib and email modules of python and have come up with
a simple program to send a email as an attachment. This module sends out an
email but not as an attachment but in the body of the email.

Any problem with this code? any insight would be greatly appreciated.

import smtplib

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

testfile = 'test.txt'

msg = MIMEMultipart()
msg['Subject'] = 'Email with Attachment'
msg['From'] = 'swavi...@gmail.com'
msg['To'] = 'swavi...@gmail.com'

with open(testfile,'rb') as f:
# Open the files in binary mode.  Let the MIMEImage class automatically
# guess the specific image type.
img = MIMEText(f.read())
f.close()
msg.attach(img)

try:
s = smtplib.SMTP('localhost')
s.sendmail(msg['From'],[msg['To']],msg.as_string())
print 'Email with attachment sent successfully'
s.quit()
except:
print 'Email with attachment could not be sent !!'

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


Re: HeaderParseError

2011-07-04 Thread Thomas Guettler
On 04.07.2011 11:51, Peter Otten wrote:
> Thomas Guettler wrote:
> 
>> I get a HeaderParseError during decode_header(), but Thunderbird can
>> display the name.
>>
> from email.header import decode_header
>
> decode_header('=?iso-8859-1?B?QW5tZWxkdW5nIE5ldHphbnNjaGx1c3MgU_xkcmluZzNwLmpwZw==?=')
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File "/usr/lib64/python2.6/email/header.py", line 101, in decode_header
>> raise HeaderParseError
>> email.errors.HeaderParseError
>>
>>
>> How can I parse this in Python?
> 
> Trying to decode as much as possible:
> 
 s = "QW5tZWxkdW5nIE5ldHphbnNjaGx1c3MgU_xkcmluZzNwLmpwZw==?="
 for n in range(len(s), 0, -1):
> ... try: t = s[:n].decode("base64")
> ... except: pass
> ... else: break
> ...
 n, t
> (49, 'Anmeldung Netzanschluss S\x19\x1c\x9a[\x99\xcc\xdc\x0b\x9a\x9c\x19')
 print t.decode("iso-8859-1")
> Anmeldung Netzanschluss S[ÌÜ
> 
 s[n:]
> 'w==?='
> 
> The characters after "...Netzanschluss " look like garbage. What does 
> Thunderbird display?

Hi Peter, Thunderbird shows this:

Anmeldung Netzanschluss Südring3p.jpg

  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HeaderParseError

2011-07-04 Thread Peter Otten
Thomas Guettler wrote:

> On 04.07.2011 11:51, Peter Otten wrote:
>> Thomas Guettler wrote:
>> 
>>> I get a HeaderParseError during decode_header(), but Thunderbird can
>>> display the name.
>>>
>> from email.header import decode_header
>>
>> 
decode_header('=?iso-8859-1?B?QW5tZWxkdW5nIE5ldHphbnNjaGx1c3MgU_xkcmluZzNwLmpwZw==?=')
>>> Traceback (most recent call last):
>>>   File "", line 1, in 
>>>   File "/usr/lib64/python2.6/email/header.py", line 101, in
>>>   decode_header
>>> raise HeaderParseError
>>> email.errors.HeaderParseError

>> The characters after "...Netzanschluss " look like garbage. What does
>> Thunderbird display?
> 
> Hi Peter, Thunderbird shows this:
> 
> Anmeldung Netzanschluss Südring3p.jpg

>>> a = u"Anmeldung Netzanschluss 
Südring3p.jpg".encode("iso-8859-1").encode("base64")

>>> b = "QW5tZWxkdW5nIE5ldHphbnNjaGx1c3MgU_xkcmluZzNwLmpwZw==?="
>>> for i, (x, y) in enumerate(zip(a, b)):
... if x != y: print i, x, y
...
33 / _
52
?
>>> b.decode("base64")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/encodings/base64_codec.py", line 42, in 
base64_decode
output = base64.decodestring(input)
  File "/usr/lib/python2.6/base64.py", line 321, in decodestring
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
>>> b.replace("_", "/").decode("base64")
'Anmeldung Netzanschluss S\xfcdring3p.jpg'

Looks like you encountered a variant of base64 that uses "_" instead of "/" 
for chr(63). The wikipedia page http://en.wikipedia.org/wiki/Base64
calls that base64url.

You could try and make the email package accept that with a monkey patch 
like the following:

#untested
import binascii
def a2b_base64(s):
return binascii.a2b_base64(s.replace("_", "/"))

from email import base64mime
base64mime.a2b_base64 = a2b_base64

Alternatively monkey-patch the binascii module before you import the email 
package.


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


ONLY FOR MEN`

2011-07-04 Thread SAHITHI
  FOR FAST UPDATED IN TELUGU FILM INDUSTRY
  http://allyouwants.blogspot.com/
 PRIYAMANI SPICY PHOTOS IN COW GIRL
http://allyouwants.blogspot.com/2011/02/priyamani-spicy-photo-shoot-cow-girl.html
KAJAL HOT PHOTOS IN SAREE
http://allyouwants.blogspot.com/2011/06/kajal-very-spice-pics.html
   TAPSEE SISTER HOT STILLS FOR U
http://allyouwants.blogspot.com/2011/06/tapsee-sister-shagun-pannu-hot-photo.html
 NAMITHA LATEST HOT PHOTO STILLS
http://allyouwants.blogspot.com/2011/06/namithas-latest-stills-from-her.html

FOR GOOD JOBS SITES TO YOU
 http://goodjobssites.blogspot.com/

   FOR HOT PHOTO&VIDEOS
 KATRINA KAIF IN BEAUTIFUL RED DRESS
http://southactresstou.blogspot.com/2011/05/katrina-kaif_22.html
GOOD LOOKING DEEPIKA PADUKONE
http://southactresstou.blogspot.com/2011/05/deepika-padukone_22.html
  AISHWARYA RAI UNBELIVABLE PHOTO
http://southactresstou.blogspot.com/2011/05/aishwarya-rai.html
TAPSEE RARE PHOTOS
http://southactresstou.blogspot.com/2011/06/tapsee-rare-photos.html


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


Re: Implicit initialization is EVIL!

2011-07-04 Thread rantingrick
On Jul 4, 3:33 am, Gregory Ewing  wrote:

> IMO the real problem here is the existence of a privileged
> "root" window at all. No GUI platform I know of has any
> such concept (except for a "desktop" window that represents
> the whole screen, which is not the same thing). All top-level
> windows should have equal status.


I dunno, it's natural to create a parent-child hierarchy when GUI
programming with any library. So i am not completely sure what you are
implying here? When you close the main application widow you would
expect all child windows to close. Or likewise when you iconify the
main window you would expect the other windows to do the same. Sure
you could do this yourself by sending messages to all the other
windows but Tkinter does this for you automatically. And how does
Tkinter know which windows to configure? A parent-child relationship
that's how.

>>> a = set(dir(Tkinter.Toplevel))
>>> b = set(dir(Tkinter.Tk))
>>> len(a), len(b)
(222, 226)
>>> a.difference(b)
set(['_setup', '_do'])

You say "root" windows are bad however any parent-child relationship
has to BEGIN somewhere. For Tkinter the beginning of this dynasty is
an instance of the Tkinter.Tk[1] window from which all other windows
and widgets are made children. HOWEVER any of the windows ARE in fact
instances of Tk.Toplevel[1]. So they ARE all equal because they all
have the same methods available to them.

>>> import Tkinter
>>> Tkinter.Tk.__doc__
'Toplevel widget of Tk which represents mostly the main window\nof
an appliation. It has an associated Tcl interpreter.'
>>> import inspect
>>> inspect.getmro(Tkinter.Tk)
(, ,
)
>>> inspect.getmro(Tkinter.Toplevel)
(, , , )

But let's dig a little deeper here. Your comment suggests that you
"personally" need to create multiple windows for your applications. Is
this correct? If so i pity any users of such application as they would
be thoroughly confused. Most applications consist of one main window
(a Tkinter.Tk instance). The only need for extra Toplevel windows is
in the form of modal dialogs (use tkSimpleDialog.Dialog) or tool
windows (use Tk.Toplevel with attribute '-toolwindow'=True).

I don't see how your statements carry any weight here. Could you
explain please?

[1] http://effbot.org/tkinterbook/tkinter-application-windows.htm
[2] http://effbot.org/tkinterbook/toplevel.htm
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EVIL!

2011-07-04 Thread rantingrick
On Jul 4, 3:44 am, Chris Angelico  wrote:

> I don't know Tkinter, but from the look of the example code, he's
> creating a Label that's not attached to a window, and then packing it
> into nothing. The toolkit kindly creates him a window. Is that the
> "root GUI window" that he means? A basic top-level window?

Yes. But to be specific the "root" is an instance of Tkinter.Tk which
is a toplevel that has a TCL interpreter attached.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EVIL!

2011-07-04 Thread Chris Angelico
On Tue, Jul 5, 2011 at 1:19 AM, rantingrick  wrote:
> But let's dig a little deeper here. Your comment suggests that you
> "personally" need to create multiple windows for your applications. Is
> this correct? If so i pity any users of such application as they would
> be thoroughly confused. Most applications consist of one main window
> (a Tkinter.Tk instance). The only need for extra Toplevel windows is
> in the form of modal dialogs (use tkSimpleDialog.Dialog) or tool
> windows (use Tk.Toplevel with attribute '-toolwindow'=True).

Uhh, sorry. No. There are plenty of good reasons for one application
to make multiple top-level windows, and if I ever find myself using a
toolkit that makes this difficult, I'll either be hacking the toolkit
or using a different one. I've been building GUI applications for far
too long to not want features like that.

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


Re: Implicit initialization is EVIL!

2011-07-04 Thread rantingrick
On Jul 4, 10:40 am, Chris Angelico  wrote:

> Uhh, sorry. No. There are plenty of good reasons for one application
> to make multiple top-level windows, and if I ever find myself using a
> toolkit that makes this difficult, I'll either be hacking the toolkit
> or using a different one. I've been building GUI applications for far
> too long to not want features like that.

And those reasons are...?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EVIL!

2011-07-04 Thread rantingrick
oops. should have used symmetric_difference!

>>> a.symmetric_difference(b)
set(['_w', '_setup', 'report_callback_exception', '_do',
'__getattr__', 'loadtk', '_loadtk', 'readprofile'])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EVIL!

2011-07-04 Thread Chris Angelico
On Tue, Jul 5, 2011 at 1:46 AM, rantingrick  wrote:
> On Jul 4, 10:40 am, Chris Angelico  wrote:
>
>> Uhh, sorry. No. There are plenty of good reasons for one application
>> to make multiple top-level windows, and if I ever find myself using a
>> toolkit that makes this difficult, I'll either be hacking the toolkit
>> or using a different one. I've been building GUI applications for far
>> too long to not want features like that.
>
> And those reasons are...?

As varied as the applications that call on them. One example that
springs to mind: Our database front end has "table view" and "record
view", where you get one table view and from that you can view as many
records as you like. Users may choose to effectively switch from one
view to the other, or they may open up two or more record views and
have them and the table view all on screen simultaneously. This is not
a modal dialog; it's not even a modeless dialog - it's a completely
stand-alone window that can be moved around the Z order independently
of the parent. There's a definite ownership based on process, though;
terminate the process (by closing the table view) and it must close
all record views first. I've done other applications where this has
not been the case - where all top-level windows are truly equal - but
not in this instance.

As an aside, that particular program is one that we are currently
using (I glance over and can see it running on one of our terminals
here), and the interface has not changed since about 2002 (actually
earlier - 2002 had a major code rewrite without much UI change).
Multiple top-level windows fulfills the Law of Least Astonishment
admirably, and has done so for a decade.

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


Re: The end to all language wars and the great unity API to come!

2011-07-04 Thread rantingrick
On Jul 4, 12:06 am, alex23  wrote:
> rantingrick  wrote:
> > But why must we have
> > completely different languages just for that those two approaches?
>
> Because monocultures die.

That's an interesting statement Alex (even though you parrot it
constantly). So what IS a mono culture exactly? Lemme see...

   """A single, homogeneous culture without diversity or dissension.
"""

Interesting. Would you consider the Python community to be a
monoculture? We are working towards a singular goal so i would say so.
We should be working towards the language that is best for all but
instead we are working towards the language that is best for US.

How about the Ruby community?

Here's a good one; How about the programming community? These groups
would ALL classify as monocultures Alex. So why are they NOT dying?
Well maybe they are and you just cannot see past your own nose (it
does get fairly long from time to time you know).

I believe (unlike most people) that nature is striving for perfection
NOT for diversity. Diversity is just a byproduct of feeble attempts to
GUESS the correct answer. Here is a thought exercise for the advanced
reader...Which is more efficient; Numerous groups working to create
languages that satisfy their selfish needs OR one group of all the
bright minds working to destroy multiplicity and bring about the one
true language that meets the needs of productivity?

In order to achieve perfection we must propagate unity within the
system and we must destroy multiplicity with a vengeance. We must
unite to defeat multiplicity and in doing so we create innovation.
That is the job of intelligent agents, to BRING ORDER TO THE NATURAL
CHAOS OF THIS UNIVERSE! Your natural instincts are of propagating
diversity (read as selfishness) HOWEVER the future exists only in
unity.

What do you think will be the eventual outcome of the human existence
Alex? Since you have no imagination i will tell you, a singular
intelligence. However an intelligence that is the product of many
"intelligent agents". A unity intelligence if you will. Just think of
it as a botnet alex, i am sure you have plenty of experience in this
area!

> Because having broader diversity leads to more evolutionary leaps.

Do you think that if we combine all the worthwhile attributes of the
high level languages that somehow everyone is just going to accept
that forever? No, of course not. HOWEVER instead of splitting off into
sects (and damaging our hive mind capabilities) we need to focus our
efforts on one goal... CREATING THE BEST LANGUAGE WE CAN AT ANY ONE
TIME IN HISTORY... and we will all learn TOGETHER not APART. Diversity
only propagates multiplicity and slows our evolution Alex. It is
selflessness on a grand scale.

> Because the implementations are so fundamentally different.

In the big picture that's untrue. Between say Ruby and Python you a
few LARGE differences and many SMALL differences (and even some
replication). I propose that we combine the Ruby and Python languages
using all the best ideas, however dropping the multiplicity.

> Because the people who ACTUALLY WROTE THE LANGUAGES wanted to explore
> different implementations.

Why can they not explore within the hive mind? Why must they hide
their explorations from the greater group. SELFISHNESS

Here is another thought exercise for the advanced reader. Remember in
the old days when furniture was crafted by hand? Not only was the
furniture EXPENSIVE it was also scarce to come by. Why was this the
case. Because human nature is to be selfish. And our selfishness slows
evolution. But one day some very intelligent chap realized that he
could build furniture not only faster but cheaper by using the
assembly line. Now we have furniture stores on practically every
corner at prices almost anyone can afford. Yes i realize "some" of the
products are not of good quality but that is a result of economics
(and greed) not unity.

> Because the people who ACTUALLY WROTE THE LANGUAGES wanted to explore
> different syntax & semantics.

We should have nailed down syntax and semantics long ago alex! This
should have been step one. No instead we have groupA, groupB, and
groupC still fighting about what is best for their selfish needs
without concerning themselves wit the big picture. It's not what is
best for ME, NO, it's what is best for US.

 * What syntax is most widely intuitive?
 * What semantics are the best for productivity?
 * etc...

> Because learning different approaches expands your appreciation of &
> informs your understanding of both.

Yes, and i agree. But instead of learning in small groups we need to
learn together. Of course we are going to make mistakes along the way.
Heck we may even have to re write the whole spec a time or two. But i
would argue that the chances of making mistakes decrease as the number
of agents increase. I dunno, have you ever heard of a little thing
called Open Source Software. Where people from all over the world
maintain a piece of software. AMAZIN

Re: Anyone want to critique this program?

2011-07-04 Thread OKB (not okblacke)
John Salerno wrote:

> On Jul 3, 1:06 pm, "OKB (not okblacke)"
>  wrote:
> 
>> > Yeah, I considered that, but I just hate the way it looks when the
>> > line wraps around to the left margin. I wanted to line it all up
>> > under the opening quotation mark. The wrapping may not be as much
>> > of an issue when assigning a variable like this, but I especially
>> > don't like triple-quoted strings that wrap around inside function
>> > definitions. That seems to completely throw off the indentation. Do
>> > people still use triple-quotes in that situation? 
>>
>>         I do, because I use an editor that intelligently indents 
>> wrapped text to the same indent level as the beginning of the line,
>> instead of wrapping it all the way back to the margin. 
> 
> But isn't wrapped text something different than text that is purposely
> split across multiple lines with a newline character? That's usually
> the case when I need to split up a long string.

Well, what I'm saying is I use an editor that lets me make the 
lines as long as I want, and it still wraps them right, so I never 
explicitly hit enter to break a line except at the end of a string (or 
paragraph).

-- 
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is
no path, and leave a trail."
--author unknown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EVIL!

2011-07-04 Thread rantingrick
On Jul 4, 11:01 am, Chris Angelico  wrote:
> On Tue, Jul 5, 2011 at 1:46 AM, rantingrick  wrote:
> > On Jul 4, 10:40 am, Chris Angelico  wrote:
>
> >> Uhh, sorry. No. There are plenty of good reasons for one application
> >> to make multiple top-level windows, and if I ever find myself using a
> >> toolkit that makes this difficult, I'll either be hacking the toolkit
> >> or using a different one. I've been building GUI applications for far
> >> too long to not want features like that.
>
> > And those reasons are...?
>
> As varied as the applications that call on them. One example that
> springs to mind: Our database front end has "table view" and "record
> view", where you get one table view and from that you can view as many
> records as you like. Users may choose to effectively switch from one
> view to the other, or they may open up two or more record views and
> have them and the table view all on screen simultaneously.

> This is not
> a modal dialog; it's not even a modeless dialog - it's a completely
> stand-alone window that can be moved around the Z order independently
> of the parent.

You can do the exact same thing with Tkinter's windows.

> There's a definite ownership based on process, though;
> terminate the process (by closing the table view) and it must close
> all record views first. I've done other applications where this has
> not been the case - where all top-level windows are truly equal - but
> not in this instance.

Tkinters Toplevels ARE equal!

However in this case you should spawn a new instance of the
application "opened" at that particular table view. It's as simple as
a few command line arguments in your script.

It's like a text editor, you never want a "New" command that resets
the current document or an open command that resets the current
document and loads the file into the existing editor. Each application
instance should only create one document and stick with it until it is
closed.

Instead you want to spawn a new instance of the editor and tell the
editor (via command line arguments) to load file data (if applicable).
Simple command line arguments (of which you should be using anyway)
are the key here. All part of proper software design.

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


Re: The end to all language wars and the great unity API to come!

2011-07-04 Thread Chris Angelico
On Tue, Jul 5, 2011 at 2:35 AM, rantingrick  wrote:
> I believe (unlike most people) that nature is striving for perfection
> NOT for diversity. Diversity is just a byproduct of feeble attempts to
> GUESS the correct answer. Here is a thought exercise for the advanced
> reader...Which is more efficient; Numerous groups working to create
> languages that satisfy their selfish needs OR one group of all the
> bright minds working to destroy multiplicity and bring about the one
> true language that meets the needs of productivity?

You assume that there is one right answer. I'm not sure whether this
is provably wrong or just utterly unfounded, but I see no reason to
believe that it is so.

> In order to achieve perfection we must propagate unity within the
> system and we must destroy multiplicity with a vengeance. We must
> unite to defeat multiplicity and in doing so we create innovation.
> That is the job of intelligent agents, to BRING ORDER TO THE NATURAL
> CHAOS OF THIS UNIVERSE!

You join a long line of Lawful Evil villains who have made that
statement. Look at such as Darth Vader, is that your goal? Bringing
order to the universe even if it means choking it to death? Yes,
humans will tend to bring orderliness to what used to be chaotic. But
this cannot be the ultimate goal; order is but a means to an end. What
end? What IS the end of programming? Is it not productivity?

> What do you think will be the eventual outcome of the human existence
> Alex? Since you have no imagination i will tell you, a singular
> intelligence. However an intelligence that is the product of many
> "intelligent agents". A unity intelligence if you will. Just think of
> it as a botnet alex, i am sure you have plenty of experience in this
> area!

Thanks. Mind if I borrow your crystal ball for a moment? Seems to be a
good one, since you can see *with certainty* the eventual outcome of
all humans. I can't help thinking, though, that you're aligning
yourself with villains again - in this case the Borg.

> Do you think that if we combine all the worthwhile attributes of the
> high level languages that somehow everyone is just going to accept
> that forever? No, of course not. HOWEVER instead of splitting off into
> sects (and damaging our hive mind capabilities) we need to focus our
> efforts on one goal... CREATING THE BEST LANGUAGE WE CAN AT ANY ONE
> TIME IN HISTORY... and we will all learn TOGETHER not APART. Diversity
> only propagates multiplicity and slows our evolution Alex. It is
> selflessness on a grand scale.

Once again, you assume that there is one ultimate language, just
waiting to be discovered/developed. One language which will be perfect
in every way, for every purpose.

> Why can they not explore within the hive mind? Why must they hide
> their explorations from the greater group. SELFISHNESS

If they explore anything that the whole hive isn't doing, they're
making that disagreement again. Suppose we had that one language that
I described earlier - the "clean slate representation" (CSR, but
that's just syntactic sugar - if you'll pardon the awful pun) one
where the only thing you have is "define operator". We then, as a
single unified collective hive mind unity, develop a Standard Library
for this language. Putting "#include std" or "import std" or whatever
at the top of your code gives you a fairly normal set of things you
can do. Well and good; we all use the same language. As soon as anyone
explores anything within that language that hasn't yet been done, he
has created a new dialect - a new language, if you will. It's right
back with what you are ripping on, except that we now call it the same
language.

> We should have nailed down syntax and semantics long ago alex! This
> should have been step one. No instead we have groupA, groupB, and
> groupC still fighting about what is best for their selfish needs
> without concerning themselves wit the big picture. It's not what is
> best for ME, NO, it's what is best for US.

Actually no. It's still about what's best for ME. I can't think of
what would be best for you - you're the best one to think about that.
Open source actually encourages and allows selfishness in ways that
are far too awkward else; groupA can code to groupA's needs, then
groupB adds code to that to make it do what groupB needs, and offers
their enhancements back to the world, meaning that groupC need only
code what groupC needs.

>  * What syntax is most widely intuitive?
>  * What semantics are the best for productivity?
>  * etc...

These are subjective questions. I happen to be able to work very well
with a bracey language, but other people can't. To me, Pike was
incredibly intuitive, because it has so many similarities to languages
I already know. To someone who knows only lisp, that would not be the
case. Incidentally, your questions cross-multiply too: What semantics
are more intuitive, and what syntax is best for productivity? Four
good questions.

> Yes, and i agree. But instead of lear

Re: Anyone want to critique this program?

2011-07-04 Thread Chris Angelico
On Tue, Jul 5, 2011 at 2:37 AM, OKB (not okblacke)
 wrote:
>        Well, what I'm saying is I use an editor that lets me make the
> lines as long as I want, and it still wraps them right, so I never
> explicitly hit enter to break a line except at the end of a string (or
> paragraph).

In this instance, I believe the OP was paragraphing his text. Is there
a convenient way to do that in a triple-quoted string?

My personal inclination would be to simply back-tab it. It looks ugly,
but at least it works, and doesn't require a run-time re-parse. The
run-time translation is good for docstrings, though (which are
syntactically the same thing as this situation).

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


i have configured proxy but fiddler can't capture python's network requests

2011-07-04 Thread 成都七中2002级7班_大家都是天才~
here's my code. I've change the port from  to .

import urllib2
proxy_support = urllib2.ProxyHandler({'http':'http://127.0.0.1:'})
opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)
urllib2.install_opener(opener)
content = urllib2.urlopen('http://www.google.com').read()
print content

The weird thing is:
1. If I close fiddler, python throws error when running

Traceback (most recent call last):
  File "C:\Users\Micky\test.py", line 5, in 
content = urllib2.urlopen('http://www.google.com').read()
  File "D:\Python27\lib\urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
  File "D:\Python27\lib\urllib2.py", line 394, in open
response = self._open(req, data)
  File "D:\Python27\lib\urllib2.py", line 412, in _open
'_open', req)
  File "D:\Python27\lib\urllib2.py", line 372, in _call_chain
result = func(*args)
  File "D:\Python27\lib\urllib2.py", line 1199, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File "D:\Python27\lib\urllib2.py", line 1174, in do_open
raise URLError(err)
URLError: 

2. If I open fiddler, everything works great. But I can't see the
traffic in fiddler. And if I change port from  to any other
number, it works find too.

Any clues?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EVIL!

2011-07-04 Thread Chris Angelico
On Tue, Jul 5, 2011 at 3:09 AM, rantingrick  wrote:
> On Jul 4, 11:01 am, Chris Angelico  wrote:
>> This is not
>> a modal dialog; it's not even a modeless dialog - it's a completely
>> stand-alone window that can be moved around the Z order independently
>> of the parent.
>
> You can do the exact same thing with Tkinter's windows.

I didn't say Tkinter couldn't do this; I said that it was a good thing
to be able to do, which you earlier decried.

> However in this case you should spawn a new instance of the
> application "opened" at that particular table view. It's as simple as
> a few command line arguments in your script.

No! Definitely not. Initializing the application includes logging in
to the database. Suppose the user had to log in again... or, worse,
suppose I transmitted the username and password via command line
arguments. No, forcing programmers into a particular coding model is a
bad idea. Let the individual programmer decide what tool is best for
what job.

> It's like a text editor, you never want a "New" command that resets
> the current document or an open command that resets the current
> document and loads the file into the existing editor. Each application
> instance should only create one document and stick with it until it is
> closed.

What, never? Well, hardly ever! (As per HMS Pinafore, if you're wondering.)

Actually, I quite frequently do want exactly that. Replace the current
buffer with a new document. Keeping the previous document involves one
of two choices (maybe more, but I can't think of any off hand):

* Leave the other document visible on the screen, cluttering things up
and forcing the user to switch to the other window, close it, and then
return to his work; or
* Have the new window completely and exactly mask the old one, making
it unobvious that the previous document is actually still open,
leaving enormous possibilities for confusion.

Audacity takes the first option (at least, the Windows version that I
used five years ago did). You choose New or Open, it brings up another
window. This astonished me when I first saw it (strike one), annoys me
85% of the time and is useful only 15% (strike two), and tends to get
in the way of rapid keyboard-oriented navigation (strike three and
out). I'd much rather Audacity kept all its "stuff" in one window,
unless I explicitly asked it for another window.

For another example, look at where web browsers are going. By your
description, one instance of a browser should work with precisely one
"document" (which in this case would be a web page). That's how
browsers were in the early days, but by the early 2000s most browsers
had some form of tabs, letting you keep that application in one
window.

> Instead you want to spawn a new instance of the editor and tell the
> editor (via command line arguments) to load file data (if applicable).
> Simple command line arguments (of which you should be using anyway)
> are the key here. All part of proper software design.

Of course I could spawn a new instance. But why? Why do it? And if I
have to have a completely new copy of all the editor's state, this is
hopelessly inefficient on memory and startup work. Why should
File|Open incur such a cost? (Ameliorated if you fork() but that has
its own consequences.) But the memory cost is nothing compared to the
extra interference it puts on "mindspace".

I currently have precisely two slots in mindspace for web browsers:
Chrome and Firefox. Chrome currently has about a dozen tabs up;
Firefox about the same, but most of them are long-term status reports
that I keep handy. If I had to have 20-30 separate windows, I would
not be able to use alt-tab to find the one I want, but would have to
use some other kind of "window picker". How would you write a
user-friendly picker that can cope with myriad instances of
everything? My guess is that it'd use some kind of tree structure with
applications at one level and windows at the next. Is this not exactly
what we already have?

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


[RELEASED] Python 3.2.1 rc 2

2011-07-04 Thread Georg Brandl
On behalf of the Python development team, I am pleased to announce the
second release candidate of Python 3.2.1.

Python 3.2.1 will the first bugfix release for Python 3.2, fixing over 120
bugs and regressions in Python 3.2.

For an extensive list of changes and features in the 3.2 line, see

http://docs.python.org/3.2/whatsnew/3.2.html

To download Python 3.2.1 visit:

http://www.python.org/download/releases/3.2.1/

This is a testing release: Please consider trying Python 3.2.1 with your code
and reporting any bugs you may notice to:

http://bugs.python.org/


Enjoy!

-- 
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and 3.2's contributors)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: i have configured proxy but fiddler can't capture python's network requests

2011-07-04 Thread Chris Angelico
2011/7/5 成都七中2002级7班_大家都是天才~ :
> 2. If I open fiddler, everything works great. But I can't see the
> traffic in fiddler. And if I change port from  to any other
> number, it works find too.
>

It sounds to me like the traffic's going through fiddler, but you're
just not seeing any log entries. The reactions from the Python end are
exactly what I'd expect. Look at fiddler's documentation to see if you
can enable verbose logging, or something of the sort.

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


Testing if a global is defined in a module

2011-07-04 Thread Tim Johnson
Using Python 2.6 on ubuntu 10.04.
inspect module :
I want to 'inspect' a module and get a list of all
functions, classes and global variables in that module.

## A module has been imported, and we call `getmembers'
members = inspect.getmembers(mod)

## While iterating thru `members', we test to see
## if an object is defined in the module.
for m in members:
  obj = m[1]
  res = inspect.getmodule(obj)
## It appears that getmodule returns None for
## all but functions and classes.

Example, for a module name `mvcInstall', when a class
name `Install' that is defined in the module
is passed as an argument to inspect.getmodule, the
values returned is something like
""
Likewise for functions defined in the module.

** But ** when global variables such as strings, booleans,
integers are passed as an argument to getmodule, the
value returned is `None'.

What else can I do here?
thanks
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: emacs lisp text processing example (html5 figure/figcaption)

2011-07-04 Thread S.Mandl
Nice. I guess that XSLT would be another (the official) approach for
such a task.
Is there an XSLT-engine for Emacs?

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


Re: Implicit initialization is EVIL!

2011-07-04 Thread rantingrick
On Jul 4, 12:41 pm, Chris Angelico  wrote:

> For another example, look at where web browsers are going. By your
> description, one instance of a browser should work with precisely one
> "document" (which in this case would be a web page). That's how
> browsers were in the early days, but by the early 2000s most browsers
> had some form of tabs, letting you keep that application in one
> window.

Umm, if you want to see where things are "going" you should learn
about the inner workings of chrome which actually spawns a new process
for every tab created; which has the benefit of avoiding application
lock up when one page decides to crash.

> I currently have precisely two slots in mindspace for web browsers:
> Chrome and Firefox. Chrome currently has about a dozen tabs up;
> Firefox about the same, but most of them are long-term status reports
> that I keep handy. If I had to have 20-30 separate windows, I would
> not be able to use alt-tab to find the one I want, but would have to
> use some other kind of "window picker". How would you write a
> user-friendly picker that can cope with myriad instances of
> everything?

psst: it's called a notebook in GUI jargon. Again, study up on chrome
internals.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Testing if a global is defined in a module

2011-07-04 Thread rantingrick
On Jul 4, 1:11 pm, Tim Johnson  wrote:
> Using Python 2.6 on ubuntu 10.04.
> inspect module :
> I want to 'inspect' a module and get a list of all
> functions, classes and global variables in that module.
>
> ## A module has been imported, and we call `getmembers'
> members = inspect.getmembers(mod)
>
> ## While iterating thru `members', we test to see
> ## if an object is defined in the module.
> for m in members:
>   obj = m[1]
>   res = inspect.getmodule(obj)
> ## It appears that getmodule returns None for
> ## all but functions and classes.
>
> Example, for a module name `mvcInstall', when a class
> name `Install' that is defined in the module
> is passed as an argument to inspect.getmodule, the
> values returned is something like
> " '/home/tim/prj/cgi/libraries/python/mvcInstall.py'>"
> Likewise for functions defined in the module.
>
> ** But ** when global variables such as strings, booleans,
> integers are passed as an argument to getmodule, the
> value returned is `None'.
>
> What else can I do here?
> thanks
> --
> Tim
> tim at johnsons-web dot com or akwebsoft dot comhttp://www.akwebsoft.com

Well if you follow the python style guide (and most accepted styles
for global notation) then it's a trial exercise. You don't even have
to import anything!!! :)

>>> GLOBAL_STR = 'str'
>>> GLOBAL_FLOAT = 1.3
>>> GLoBaL_Bs = ''
>>> dir()
['GLOBAL_FLOAT', 'GLOBAL_STR', 'GLoBaL_Bs', '__builtins__', '__doc__',
'__name__', '__package__', 'item']
>>> for item in dir():
if item.isupper():
print 'Found Global!', item


Found Global! GLOBAL_FLOAT
Found Global! GLOBAL_STR

;-)

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


Re: Compiling Python 3.2 on Cygwin fails

2011-07-04 Thread Aly Tawfik
On Jun 20, 12:44 pm, sewpafly  wrote:
> I was able to a little further by changing 2 lines in Makefile.pre.in.
>
> On line 170, changed:
>     DLLLIBRARY= @DLLLIBRARY@
> to:
>     DLLLIBRARY= libpython$(VERSION).dll
>
> On line 509 it had:
>     $(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
>
> which I changed to:
>     $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
>
> Compile finishes with:
> Python build finished, but the necessary bits to build these modules
> were not found:
> _gdbm              _sqlite3           _tkinter
> nis                ossaudiodev        spwd
> To find the necessary bits, look in setup.py in detect_modules() for
> the module's name.
>
> Failed to build these modules:
> _curses            _curses_panel
>
> But 'make test' returns many errors.
>
> I'm thinking I'll try Python 3.1 instead.



Yes! I am facing the same problem. I, too, will try to install Python
3.1.4 instead. Did it work for you?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling Python 3.2 on Cygwin fails

2011-07-04 Thread Aly Tawfik
On Jun 20, 12:44 pm, sewpafly  wrote:
> I was able to a little further by changing 2 lines in Makefile.pre.in.
>
> On line 170, changed:
>     DLLLIBRARY= @DLLLIBRARY@
> to:
>     DLLLIBRARY= libpython$(VERSION).dll
>
> On line 509 it had:
>     $(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
>
> which I changed to:
>     $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
>
> Compile finishes with:
> Python build finished, but the necessary bits to build these modules
> were not found:
> _gdbm              _sqlite3           _tkinter
> nis                ossaudiodev        spwd
> To find the necessary bits, look in setup.py in detect_modules() for
> the module's name.
>
> Failed to build these modules:
> _curses            _curses_panel
>
> But 'make test' returns many errors.
>
> I'm thinking I'll try Python 3.1 instead.

I, too, am facing the same problem. Which version of Python 3.1 did
you install, and did it work? Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] Allow isinstance second argument to be a set of types

2011-07-04 Thread MRAB

On 04/07/2011 20:41, Amaury Forgeot d'Arc wrote:

Hi,

2011/7/4 Antoine Pitrou:

Le lundi 04 juillet 2011 à 10:52 -0700, Gregory P. Smith a écrit :

note that a fast lookup implies exact type and not subclass making my
point silly... at which point you're back to iterating so I suspect
supporting arbitrary iterables is actually how this will be
implemented regardless.


Indeed. Note that the tuple case should remain fast, and therefore
special-cased (or the general list/tuple case, since the difference in C
is rather small).


Arbitrary iterables, arbitrarily nested...
beware of objects which are also their first element, like str('a')...


Probably not arbitrarily nested, just a type (type(t) is type) or an
iterable yielding types. Anything else would raise an exception.
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] Allow isinstance second argument to be a set of types

2011-07-04 Thread Chris Rebert
On Mon, Jul 4, 2011 at 12:53 PM, MRAB  wrote:
> On 04/07/2011 20:41, Amaury Forgeot d'Arc wrote:
>>> Le lundi 04 juillet 2011 à 10:52 -0700, Gregory P. Smith a écrit :

 note that a fast lookup implies exact type and not subclass making my
 point silly... at which point you're back to iterating so I suspect
 supporting arbitrary iterables is actually how this will be
 implemented regardless.
>>
>> Arbitrary iterables, arbitrarily nested...
>> beware of objects which are also their first element, like str('a')...
>>
> Probably not arbitrarily nested, just a type (type(t) is type) or an
> iterable yielding types. Anything else would raise an exception.

What about a type that is itself iterable (via metaclass magic)?
Gotta consider the wacky edge cases.

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


Re: Testing if a global is defined in a module

2011-07-04 Thread Tim Johnson
* rantingrick  [110704 12:00]:
> On Jul 4, 1:11 pm, Tim Johnson  wrote:
> 
> Well if you follow the python style guide (and most accepted styles
> for global notation) then it's a trial exercise. You don't even have
> to import anything!!! :)
> 
> >>> GLOBAL_STR = 'str'
> >>> GLOBAL_FLOAT = 1.3
> >>> GLoBaL_Bs = ''
> >>> dir()
> ['GLOBAL_FLOAT', 'GLOBAL_STR', 'GLoBaL_Bs', '__builtins__', '__doc__',
> '__name__', '__package__', 'item']
> >>> for item in dir():
>   if item.isupper():
>   print 'Found Global!', item
  Thanks for the reply: *but*

  dir() will also show globals from other modules imported
  by the target module. So I would need a way to distinguish between
  those imported and those defined in 
  print(dir(targetmodule)) => 
   ['Install', 'TestAddresses', '__builtins__', '__doc__',
   '__file__', '__name__', '__package__', 'chmod', 'consoleMessage',
   'cp', 'debug', 'erh', 'exists', 'halt', 'is_list', 'load',
   'makePath', 'mkdir', 'process', 'sys', 'traceback', 'usingCgi'] 
   where 'TestAddresses' is a member of an imported module and
   'usingCgi' is the only data variable defined in 

  regards
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Testing if a global is defined in a module

2011-07-04 Thread Chris Rebert
On Mon, Jul 4, 2011 at 11:11 AM, Tim Johnson  wrote:
> Using Python 2.6 on ubuntu 10.04.
> inspect module :
> I want to 'inspect' a module and get a list of all
> functions, classes and global variables in that module.
You meant "first defined in" that module.

> Example, for a module name `mvcInstall', when a class
> name `Install' that is defined in the module
> is passed as an argument to inspect.getmodule, the
> values returned is something like
> " '/home/tim/prj/cgi/libraries/python/mvcInstall.py'>"
> Likewise for functions defined in the module.
>
> ** But ** when global variables such as strings, booleans,
> integers are passed as an argument to getmodule, the
> value returned is `None'.
>
> What else can I do here?

Look at the names in the module's import statements using the `ast`
module, and exclude those from the set of names defined in the module.
Won't work for `from foo import *`, but that's bad practice and should
be refactored anyway.

Cheers,
Chris
--
http://rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Testing if a global is defined in a module

2011-07-04 Thread rantingrick
On Jul 4, 3:30 pm, Tim Johnson  wrote:
>
>   Thanks for the reply: *but*
>   dir() will also show globals from other modules imported
>   by the target module. So I would need a way to distinguish between
>   those imported and those defined in 

Okay, then do some processing on the source. You can use regexps or
the module mentioned earlier by Chris.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Testing if a global is defined in a module

2011-07-04 Thread Tim Johnson
* Chris Rebert  [110704 13:16]:
> >
> > What else can I do here?
> 
> Look at the names in the module's import statements using the `ast`
> module, and exclude those from the set of names defined in the module.
> Won't work for `from foo import *`, but that's bad practice and should
> be refactored anyway.
  I'm completely new to the `ast' module, so I will have to research
  that one. 
  Thanks for the tip
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EVIL!

2011-07-04 Thread Chris Angelico
On Tue, Jul 5, 2011 at 5:30 AM, rantingrick  wrote:
> Umm, if you want to see where things are "going" you should learn
> about the inner workings of chrome which actually spawns a new process
> for every tab created; which has the benefit of avoiding application
> lock up when one page decides to crash.

There is still one application. There's a single process which is the
master; all the other processes die if the master dies. Chrome's
isolation of tab-groups has nothing to do with the GUI design question
of whether one top-level window is allowed to do more than one thing,
which you claimed it should not.

>> How would you write a
>> user-friendly picker that can cope with myriad instances of
>> everything?
>
> psst: it's called a notebook in GUI jargon. Again, study up on chrome
> internals.

No, that would not be what it would be called. Also, a notebook is a
very specific widget, and it's not quite identical to Chrome's or
Firefox's tabbed browsing setup; but again, that has nothing to do
with the case. The question is one of UI design.

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


Re: Testing if a global is defined in a module

2011-07-04 Thread Tim Johnson
* rantingrick  [110704 13:47]:
> On Jul 4, 3:30 pm, Tim Johnson  wrote:
> >
> >   Thanks for the reply: *but*
> >   dir() will also show globals from other modules imported
> >   by the target module. So I would need a way to distinguish between
> >   those imported and those defined in 
> 
> Okay, then do some processing on the source. You can use regexps or
> the module mentioned earlier by Chris.
  I think I'm making this unnecessarily complicated. I had used
  something like:

  from spam import TestAddresses ## just for grins

  Which is something that I almost never do in practice.

  Also, you pointed out the UC naming convention, which I was
  unacquainted with, being self-employed, self-taught and a one-man
  crew who doesn't spend as much time as he should reading PEPs.

  I'm going to go for the predicate test as second argument to
  getmembers with something like:
def isdata(self,obj,name):
"""Check if an object is of a type that probably means it's data."""
return (not (inspect.ismodule(obj) or inspect.isclass(obj) or
inspect.isroutine(obj) or inspect.isframe(obj) or
inspect.istraceback(obj) or inspect.iscode(obj)))
and name.issupper()
## Untested code

thanks again
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Testing if a global is defined in a module

2011-07-04 Thread Steven D'Aprano
Tim Johnson wrote:

>   dir() will also show globals from other modules imported
>   by the target module. So I would need a way to distinguish between
>   those imported and those defined in 

Why would you want to do that? Importing *is* a definition in
.

Consider these two code snippets:

#1
from math import pi

#2
import math
tau = 2*math.pi
del math


Why do you think it is necessary to distinguish pi from tau? Both names are
local to the current namespace.



>   print(dir(targetmodule)) =>
>['Install', 'TestAddresses', '__builtins__', '__doc__',
>'__file__', '__name__', '__package__', 'chmod', 'consoleMessage',
>'cp', 'debug', 'erh', 'exists', 'halt', 'is_list', 'load',
>'makePath', 'mkdir', 'process', 'sys', 'traceback', 'usingCgi']
>where 'TestAddresses' is a member of an imported module and

You are mistaken. TestAddresses is *not* a member of an imported module. It
is a member of the current module, which may or may not happen to point to
the same object as the other module as well.


>'usingCgi' is the only data variable defined in 

It seems to me that your approach here is unnecessarily complex and fragile.
I don't know what problem you are trying to solve, but trying to solve it
by intraspecting differences that aren't differences is surely the wrong
way to do it.



-- 
Steven

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


Re: Testing if a global is defined in a module

2011-07-04 Thread Tim Johnson
* Steven D'Aprano  [110704 15:18]:
> 
> You are mistaken. TestAddresses is *not* a member of an imported module. It
> is a member of the current module, which may or may not happen to point to
> the same object as the other module as well.
 You are correct. I mispoke or misapplied. See my last post.
> 
> >'usingCgi' is the only data variable defined in 
> 
> It seems to me that your approach here is unnecessarily complex and fragile.
> I don't know what problem you are trying to solve, but trying to solve it
> by intraspecting differences that aren't differences is surely the wrong
> way to do it.
  See my last post...
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The end to all language wars and the great unity API to come!

2011-07-04 Thread Steven D'Aprano
rantingrick wrote:

> On Jul 4, 12:06 am, alex23  wrote:
>> rantingrick  wrote:
>> > But why must we have
>> > completely different languages just for that those two approaches?
>>
>> Because monocultures die.
> 
> That's an interesting statement Alex (even though you parrot it
> constantly). So what IS a mono culture exactly? Lemme see...
> 
>"""A single, homogeneous culture without diversity or dissension.
> """
> 
> Interesting. Would you consider the Python community to be a
> monoculture? We are working towards a singular goal so i would say so.

We are? Certainly not.

Some people want to make Python more dynamic. Some want it to be less
dynamic. Some care about integrating it with Java or .Net, some don't care
about either. Some are interested in clever optimization tricks, some
oppose adding any more complexity.

Some want it to be faster, and are happy to throw more memory at it to do
so. Some want it to use less memory, because on embedded devices and smart
phones memory is the bottleneck, not time.

Some only program in Python. Some treat Python as merely one language out of
many that they use.

Some come to Python from the C/C++ community, and their wants are influenced
by C. Some come to Python from Lisp, Scheme or Haskell, and their wants are
influenced by functional programming ideas. Some have never programmed
before, and don't know want they want.


> We should be working towards the language that is best for all but

Define "best for all", and try not to make it "what Rick wants".


No, Python is not a monoculture. There are the Stackless, Jython, PyPy and
IronPython sub-cultures, all with their own needs, wants and desires. There
are sub-cultures for embedded devices and smart phones, sub-cultures for
those who use Python as a teaching language, for web development, for GUI
development, and for system administration. There are the Numpy and Scipy
sub-cultures, sub-cultures in the fields of linguistics and biology.


> I believe (unlike most people) that nature is striving for perfection
> NOT for diversity. 

Nature isn't striving for anything. 

Rick, you think that you're an iconoclast bravely swimming against the tide
of wrong-headed public opinion, but what you believe is not new and it is
not a minority view. It is old, obsolete, and the vast majority of people
with no modern biology education believe something like it. It is,
essentially, just the Victorian concept of the "Great Chain of Being" --
not that it was unique to the Victorians, of course.


> Diversity is just a byproduct of feeble attempts to 
> GUESS the correct answer. Here is a thought exercise for the advanced
> reader...Which is more efficient; Numerous groups working to create
> languages that satisfy their selfish needs OR one group of all the
> bright minds working to destroy multiplicity and bring about the one
> true language that meets the needs of productivity?

The first: numerous groups. Anything else is false efficiency. If you think
otherwise, you have seriously missed the point.

Efficiency requires that all needs are met first. "The most efficient way to
build a house" is NOT "Don't build a house, live in a cardboard box, it's
cheaper". Who cares if it is cheaper or not, it's not a house, and doesn't
meet the required needs.

Since needs are frequently in opposition (e.g. the speed/memory trade-off),
a single "true language" must be a compromise language that leaves nobody
happy. Or some dictator (Rick?) declares that such-and-such a set of
features is, by definition, the "perfect" language and those who want
something else have to miss out.

Imagine a world where *every* shop was Walmart. That would be good for
Walmart, but terrible for everyone else. That's Rick's plan for
programming.

Screw that. We don't want "the perfect language", because there is no such
thing and there is no point in wanting square circles or five-sided
triangles or invisible pink unicorns. And even if we did, we wouldn't want
YOUR idea of the perfect language.

Rick, stop trying to "help" the community with these over-reaching grand
schemes that nobody but you wants, that always involve you telling everyone
else that they have to build the system you think you want. Go do something
useful.



-- 
Steven

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


Re: Problem!!

2011-07-04 Thread Steven D'Aprano
amir chaouki wrote:

> the problem is when i use the seek function on windows it gives me
> false results 

What do you mean "false results"? What does this even mean?

Please show us:

* what you do
* what result you expect
* what result you actually get



-- 
Steven

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


Re: Testing if a global is defined in a module

2011-07-04 Thread Steven D'Aprano
Tim Johnson wrote:

>> It seems to me that your approach here is unnecessarily complex and
>> fragile. I don't know what problem you are trying to solve, but trying to
>> solve it by intraspecting differences that aren't differences is surely
>> the wrong way to do it.
>   See my last post...


Yes, but what are you actually *trying to do*? "Detecting data members" is
not an end in itself. Why do you think you need to detect data members?


-- 
Steven

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


Re: Testing if a global is defined in a module

2011-07-04 Thread Tim Johnson
* Steven D'Aprano  [110704 15:48]:
> Tim Johnson wrote:
> 
> >> It seems to me that your approach here is unnecessarily complex and
> >> fragile. I don't know what problem you are trying to solve, but trying to
> >> solve it by intraspecting differences that aren't differences is surely
> >> the wrong way to do it.
> >   See my last post...
> 
> 
> Yes, but what are you actually *trying to do*? "Detecting data members" is
> not an end in itself. Why do you think you need to detect data members?

  Steven, I'm building a documentation system. I have my own MVC framework
  and the goal is to have a documentation module for each project.

  Thanks again for the clarifications. I always learn a lot from
  you.
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anyone want to critique this program?

2011-07-04 Thread Ben Finney
Chris Angelico  writes:

> In this instance, I believe the OP was paragraphing his text.

What is “paragraphing”?

> Is there a convenient way to do that in a triple-quoted string?

Did I answer this earlier in the thread (also at
http://stackoverflow.com/questions/2504411/proper-indentation-for-python-multiline-strings/2504454#2504454>)?

> My personal inclination would be to simply back-tab it. It looks ugly,
> but at least it works, and doesn't require a run-time re-parse.

Readability counts. Why is “doesn't require a run-time re-parse” more
valuable than readability?

-- 
 \   “Because of the impropriety of entertaining guests of the |
  `\opposite sex in the bedroom, it is suggested that the lobby be |
_o__)   used for this purpose.” —hotel, Zurich |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Testing if a global is defined in a module

2011-07-04 Thread Chris Angelico
On Tue, Jul 5, 2011 at 10:01 AM, Tim Johnson  wrote:
>  Steven, I'm building a documentation system. I have my own MVC framework
>  and the goal is to have a documentation module for each project.
>

Is there a reason for not using Doxygen / Autodoc / etc, or at least
something in the same style? They work from specially-formatted
comments in the source code, rather than the compiled module object.

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


Re: Problem!!

2011-07-04 Thread Dan Stromberg
It turned out that switching to binary I/O made seek do what he was
expecting.  I'm guessing the transparent crlf to lf conversions in windows
text I/O get seek() a bit perplexed, because it transparently changes the
number of bytes.

On Mon, Jul 4, 2011 at 4:30 PM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> amir chaouki wrote:
>
> > the problem is when i use the seek function on windows it gives me
> > false results
>
> What do you mean "false results"? What does this even mean?
>
> Please show us:
>
> * what you do
> * what result you expect
> * what result you actually get
>
>
>
> --
> Steven
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anyone want to critique this program?

2011-07-04 Thread Chris Angelico
On Tue, Jul 5, 2011 at 10:03 AM, Ben Finney  wrote:
> Chris Angelico  writes:
>
>> In this instance, I believe the OP was paragraphing his text.
>
> What is “paragraphing”?

If you look at the original code, you'll see embedded newlines used to
create multiple paragraphs. Hence, paragraphing as opposed to simply
wrapping in order to keep his source lines <80 chars.

>> My personal inclination would be to simply back-tab it. It looks ugly,
>> but at least it works, and doesn't require a run-time re-parse.
>
> Readability counts. Why is “doesn't require a run-time re-parse” more
> valuable than readability?

Readability definitely counts. But having a string literal require an
extra call to make it what you want also costs readability. It's like
pushing your literals off to an i18n file - what you gain in
flexibility, you lose in simplicity.

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


Re: Testing if a global is defined in a module

2011-07-04 Thread Tim Johnson
* Chris Angelico  [110704 16:19]:
> On Tue, Jul 5, 2011 at 10:01 AM, Tim Johnson  wrote:
> >  Steven, I'm building a documentation system. I have my own MVC framework
> >  and the goal is to have a documentation module for each project.
> >
> 
> Is there a reason for not using Doxygen / Autodoc / etc, or at least
> something in the same style? They work from specially-formatted
> comments in the source code, rather than the compiled module object.

  I want this as a component of my system. It will be bound to a
  relational data-structure-based 'core' that defines relationships
  between all files in the project.

  :) It's called *collateral*

  And yes, I have worked with comment-based systems, including my
  own, that worked with multi-language projects. 

  Best regards
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem!!

2011-07-04 Thread Dave Angel

On 01/-10/-28163 02:59 PM, amir chaouki wrote:

the problem is when i use the seek function on windows it gives me
false results other then the results on *ux. the file that i work with
are very large about 10mb.



If you still care about this problem, you should take some of the other 
suggestions to heart;  post some code, state what you expected, and what 
actually happened, and how they're different.


But my crystal ball says you're trying to do a seek on a text file, 
which has restrictions.  Once you've called it a text file, you're 
telling the system to translate cr/lf pairs into lf, which changes the 
apparent size.  So seek has no way to reproduce what reading lines does.



To quote the docs at   http://docs.python.org/library/stdtypes.html :
"If the file is opened in text mode (without 'b'), only offsets returned 
by tell()  are 
legal. Use of other offsets causes undefined behavior."


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


Re: The end to all language wars and the great unity API to come!

2011-07-04 Thread alex23
rantingrick  wrote:
> I believe (unlike most people) that nature is striving for perfection

Your belief is wrong. "Nature" doesn't "strive" for _anything_. Things
in the world are either fit enough to continue their existence or not.
As circumstances change, some things that were once suitably fit for
the environment are no longer so and are replaced. Same with ideas.
There is no "perfection", there is only "what works best now".

> What do you think will be the eventual outcome of the human existence
> Alex? Since you have no imagination i will tell you, a singular
> intelligence.

Firstly: cite some kind of evidence that this "will be the eventual
outcome" or admit you're talking shit.

Secondly: I can imagine humanity evolving into a great many things and
something as limited as a 'botnet' is certainly nothing to be proud of
as a species.

> It is selflessness on a grand scale.

I don't really know if you're a troll, have no self-reflective
capability, delusionally believe what you're spouting, or are on or
off medication, but sometimes your hypocrisy is just funny as hell.

>> Because the people who ACTUALLY WROTE THE LANGUAGES wanted to explore
>> different implementations.
> Why can they not explore within the hive mind? Why must they hide
> their explorations from the greater group. SELFISHNESS

You mean like how Guido hid the Python code base and never let anyone
else touch or influence it in any way?

Rick, you remind me a lot of Bill Hicks yelling, "You are free to do
as we tell you! YOU ARE FREE TO DO AS WE TELL YOU!!" Using terms like
"hive mind" kinda shows that I'm wasting my time pushing the value of
diversity to you.

> * What syntax is most widely intuitive?
> * What semantics are the best for productivity?

You're inability to recognise the importance of the context in which a
language is used explains your misguided position a lot.

What if a particular language syntax is the best fit for the way 52%
of the population think? What about the other 48%? What if it's a
80/20 split? 90/10? 99/1? At what point are you prepared to sacrifice
the needs and best interests of others for your quest for mythical
perfection?

No need to answer that last one, we already know the answer: from the
very beginning.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Testing if a global is defined in a module

2011-07-04 Thread Ian Kelly
On Mon, Jul 4, 2011 at 6:01 PM, Tim Johnson  wrote:
>> Yes, but what are you actually *trying to do*? "Detecting data members" is
>> not an end in itself. Why do you think you need to detect data members?
>
>  Steven, I'm building a documentation system. I have my own MVC framework
>  and the goal is to have a documentation module for each project.

It sounds like what you really want is to detect the names *exported*
by the module, then.  Why not do it the same way Python does it?  If
the module defines an "__all__" attribute, then it is taken to be a
sequence of strings which are the exported names.  Otherwise, the
exported names are taken to be all the names in the module dict that
don't begin with an underscore.

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


Re: from module import * using __import__?

2011-07-04 Thread Gabriel Genellina
En Sat, 02 Jul 2011 16:52:11 -0300, Dan Stromberg   
escribió:


Is there a decent way of running "from  import *"?  Perhaps  
using

__import__?

Does it mean using the copy module or adding an element to globals()
somehow?

Yes, I think I do have a good use for this: importing either pure python  
or

cython versions of a module into a single namespace that can provide the
same interface (transparent to the caller), whether C extension modules  
are

viable in the current interpreter or not.  So you have a stub module that
provides one or the other, depending on availability and suitability.


See pickle.py in Python 3 as an example: the slow (pure Python) code  
resides in pickle.py; the fast (C code) in _pickle.so (on Windows, a  
built-in module). Near the end of pickle.py, there is a line "from _pickle  
import *" which, if successful, overrides (replaces) any previous  
definitions; if not, the ImportError is trapped and the previously defined  
Python code remains valid.


Unlike the 2.x series, where you should decide to "import cPickle" or  
"import pickle" (or attempt both, cathcing the ImportError), here you only  
have to "import pickle" in your code; if the fast module is present, it is  
automatically loaded and used; else, the slow but compatible version is  
used. You don't even have to know that an alternative implementation  
exists.


--
Gabriel Genellina

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


Embedding a thin python

2011-07-04 Thread victor lucio
Hi All,

I would like to remove some modules for embedding a thin python.
how to do that?
I would be grateful for your suggestions
-- 
http://mail.python.org/mailman/listinfo/python-list