Re: When will Python go mainstream like Java?

2010-02-23 Thread Krister Svanlund
On Tue, Feb 23, 2010 at 1:01 AM, Edward A. Falk  wrote:
> You mean it's not?
>
> --
>        -Ed Falk, f...@despams.r.us.com
>        http://thespamdiaries.blogspot.com/

Javas popularity was very much a product of its time. It was something
new and exciting and people got a bit too excited maybe, Python just
does the same thing but better really, therefor it will not become as
popular.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bizarre arithmetic results

2010-02-23 Thread Steven D'Aprano
On Mon, 22 Feb 2010 18:01:44 +, Albert van der Horst wrote:

> In article ,
> Terrence Cole   wrote:
>>Can someone explain to me what python is doing here?
>>
>>Python 3.1.1 (r311:74480, Feb  3 2010, 13:36:47) [GCC 4.3.4] on linux2
>>Type "help", "copyright", "credits" or "license" for more information.
> -0.1 ** 0.1
> 
> Python 4.0
> Warning: misleading blank space, expected:
>   - 0.1**0.1
> 
>>-0.7943282347242815


Making spaces significant in that fashion is mind-bogglingly awful. Let's 
look at a language that does this:

[st...@sylar ~]$ cat ws-example.rb
def a(x=4)
x+2
end

b = 1
print (a + b), (a+b), (a+ b), (a +b), "\n"


[st...@sylar ~]$ ruby ws-example.rb
7773




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


wgv berufsunfähigkeitsversicherung, berufsunfähigk eitsversicherung testsieger, berufsunfähigkeitsversicherung mlp, berufsunfähigkeitsversicherung preis, hdi gerling ber ufsunfähigkeitsversicherung,

2010-02-23 Thread gabi meier
wgv berufsunfähigkeitsversicherung, berufsunfähigkeitsversicherung
testsieger, berufsunfähigkeitsversicherung mlp,
berufsunfähigkeitsversicherung preis, hdi gerling
berufsunfähigkeitsversicherung,

+
+
+
HAUSRAT VERSICHERUNG +++ HAUSRATVERSICHERUNG BILLIG +++ BILLIGE
HAUSRATSVERSICHERUNG
+
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://WWW.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
+
+
+
+




















http://berufsunfaehigkeitsversicherung-arzt.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://berufsunfaehigkeitsversicherung-test-2009.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://berufsunfaehigkeitsversicherung-neue-leben.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL
http://die-beste-berufsunfaehigkeitsversicherung.BERUFSUNFAEHIGKEITSVERSICHERUNGEN.NL


autoversicherungen testsieger berufsunfähigkeit in Schleswig
berufsunfähigkeitsversicherung freiberufler metallrente bu in Guinea
konkrete verweisbarkeit alte leipziger versicherung in Namibia
steuererklärung versicherungen abstrakte verweisung in Schleiz
berufsunfähigkeit versicherung vergleich berufsunfähig versicherung in
Homburg
nürnberger bu versicherung berufsunfähigkeit rechner in Osnabrück
berufsunfähigkeit versicherung berufsunfähigkeitsversicherung kündigen
in Oranienburg
bu alte leipziger berufsunfähigkeits versicherung vergleich in Sachsen



http://suche.aol.de/aol/search?query=berufsunfähigkeitsversicherungen+im+test+inurl%3Afor-um&invocationType=no.omittWeb&filter=false







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


Re: When will Python go mainstream like Java?

2010-02-23 Thread Ishwor Gurung
On 23 February 2010 08:56, AON LAZIO  wrote:
> That will be superb
Yes it would - but I'll just add in few words.

Java - Monstrous language that was Sun's flagship language. Now, it's Oracles.
Python - Hobby-ish hacking language that we all love so much (that we
wish everything was written using Python).

Java - The JVM code been hacked to death by Sun engineers (optimised)
Python - The PVM code has seen speed-ups in Unladen or via Pyrex..
ad-infinitum but nowhere as near to JVM

I like both Python and Java but given the amount of resources put into
JVM and Java (JEE is _huge_ in Enterprise if you didn't know that
already and there are universities that speak Java fluently), it's
kind of sad that Python till the day hasn't seen speedup in mainline
releases.

I see Python more as a hacker's language which will gradually evolve
and support SMEs and alike in the long run than Java (and of course we
write our weekend-only hacking projects in it :-) but for a
market-uptake like Java requires universities, colleges and students
to learn this wonderful little language and requests energetic hackers
to fix lock-contention issues and the like in the core implementation.

Perhaps I see a light, perhaps I see nothing.. but I feel the day is
coming nearer when Python would run as fast as Java/C. Only time can
tell - I hope the time is right about this.
--
Regards
Ishwor Gurung
Key id:0xa98db35e
Key fingerprint:FBEF 0D69 6DE1 C72B A5A8  35FE 5A9B F3BB 4E5E 17B5
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: DreamPie - The Python shell you've always dreamed about!

2010-02-23 Thread Processor-Dev1l
On Feb 21, 10:42 am, Noam Yorav-Raphael  wrote:
> I'm pleased to announce DreamPie 1.0 - a new graphical interactive
> Python shell!
>
> Some highlights:
>
> * Has whatever you would expect from a graphical Python shell -
> attribute completion, tooltips which show how to call functions,
> highlighting of matching parentheses, etc.
> * Fixes a lot of IDLE nuisances - in DreamPie interrupt always works,
> history recall and completion works as expected, etc.
> * Results are saved in the Result History.
Very good work, Noam,
I am looking forward to test this with IronPython :)

> * Long output is automatically folded so you can focus on what's
> important.
> * Jython and IronPython support makes DreamPie a great tool for
> exploring Java and .NET classes.
> * You can copy any amount of code and immediately execute it, and you
> can also copy code you typed interactively into a new file, with the
> Copy Code Only command. No tabs are used!
> * Free software licensed under GPL version 3.
>
> Check it out athttp://dreampie.sourceforge.net/and tell me what you
> think!
>
> Have fun,
> Noam

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


Re: os.pipe() + os.fork()

2010-02-23 Thread sebastian.no...@googlemail.com
On Feb 20, 8:13 pm, Gary Herron  wrote:
> Here's a thought:  Consider the subprocess module.   It can do thefork
> and any necessary pipes and can do so in an OS independent way.   It
> might make you life much easier.

As far as i know the subprocess module provides only functionality for
running any program as subprocess. But I just want to fork the current
process without putting some code in an external python script.

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


Re: When will Python go mainstream like Java?

2010-02-23 Thread Richard Lamboj

Am Tuesday 23 February 2010 09:07:43 schrieb Krister Svanlund:
> On Tue, Feb 23, 2010 at 1:01 AM, Edward A. Falk  
wrote:
> > You mean it's not?
> >
> > --
> >        -Ed Falk, f...@despams.r.us.com
> >        http://thespamdiaries.blogspot.com/
>
> Javas popularity was very much a product of its time. It was something
> new and exciting and people got a bit too excited maybe, Python just
> does the same thing but better really, therefor it will not become as
> popular.

Good morning,

i don't like Java/JSP, the synthax is blown up and the programs are damn slow. 
For ecllipse you should buy a cluster. There is C/C++/D, Python, Ruby, 
Gambas, TCL, PHP, SmallTalk and some other nice Programming Languages, so i 
don't understand why people use Java. "Java is the one an only OOP Language, 
the best one" - Yeah and whats with multiple inheritance? I'am in love with 
Python ;-)

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


Re: MODULE FOR I, P FRAME

2010-02-23 Thread DANNY
@James I am thinkinhg about effect of errors that are within the
sequence of P frames. Where the P frames have only the information
about the changes in previous frames, so that errors are present until
the next I frame. So I would like to see how is this seen in different
GoP sized clips.

@Tim Thanks for the advice, now I will try to do that so I have a lot
of work in front of me. I will post any problems if they occure.

Guys thank you again for the help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: When will Python go mainstream like Java?

2010-02-23 Thread hackingKK

On Tuesday 23 February 2010 03:10 PM, Richard Lamboj wrote:

Am Tuesday 23 February 2010 09:07:43 schrieb Krister Svanlund:
   

On Tue, Feb 23, 2010 at 1:01 AM, Edward A. Falk
 

wrote:
   

You mean it's not?

--
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
   

Javas popularity was very much a product of its time. It was something
new and exciting and people got a bit too excited maybe, Python just
does the same thing but better really, therefor it will not become as
popular.
 

Good morning,

i don't like Java/JSP, the synthax is blown up and the programs are damn slow.
For ecllipse you should buy a cluster. There is C/C++/D, Python, Ruby,
Gambas, TCL, PHP, SmallTalk and some other nice Programming Languages, so i
don't understand why people use Java. "Java is the one an only OOP Language,
the best one" - Yeah and whats with multiple inheritance? I'am in love with
Python ;-)
   


There are a few reasons why we don't see python as a "buz word".  Java 
was well marketed and the time when it came out with libraries like 
swing, there was no popularly known alternative.
As a matter of fact I don't really go by popularity with technologies, 
specially when it comes to programming languages.
Just show me 2 or 3 big apps or web sites which are scalable and take 
multiple requests.  show me just 2 instances where heavy number 
crunching is done efficiently and I am convinced.
I don't care how many apps are developed using java as long as they 
remain heavy and slw.

google runs on python and so do many other big applications.
marketing is more about exaggeration, which Sun did for Java.
Python was always in the hands of programmers who wanted their work done 
and wanted scalable apps.
So the conclusion is that "all that is popular need not be good for 
every thing ".


Happy hacking.
Krishnakant.
--
http://mail.python.org/mailman/listinfo/python-list


Re: When will Python go mainstream like Java?

2010-02-23 Thread Stefan Behnel
Chris Rebert, 23.02.2010 06:45:
> Indeed. Python is at position 7, just behind C#, in the TIOBE Index:
> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

That index is clearly flawed. A language like PHP (whatever that is
supposed to be comparable with) can't possibly be on the rise, can it?

Stefan

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


Fascism is coming to Internet

2010-02-23 Thread Joan Miller
*Sorry by this message off topic, but this is too important*

Fascism is coming fastly to Internet because is the only communication
way that governements (managed by the bank and multinationals) cann't
control

http://www.boingboing.net/2010/02/21/acta-internet-enforc.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Spam from gmail (Was: fascism)

2010-02-23 Thread D'Arcy J.M. Cain
On Tue, 23 Feb 2010 02:54:25 -0800 (PST)
Joan Miller  wrote:
> *Sorry by this message off topic, but this is too important*

Is it just me or has the spew from gmail on this list radically
increased in the last week?  Anyone else considering blocking all gmail
posts to this list?

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Combining C and Python programs

2010-02-23 Thread General Cody

Well... This is really a RTFM question.
It's all in the Python docs...

And it's really simple.

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


Re: Re: DreamPie - The Python shell you've always dreamed about!

2010-02-23 Thread Alan Harris-Reid

gorauskas wrote:

I installed it on a Windows 7 machine with CPython 2.6.4 and I get the
following error:

Traceback (most recent call last):
  File "dreampie.py", line 3, in 
  File "dreampielib\gui\__init__.pyc", line 73, in 
  File "dreampielib\gui\load_pygtk.pyc", line 49, in load_pygtk
ImportError: DLL load failed: The specified module could not be found.

What am I doing wrong?

Thanks,  JGG
And I installed it on WinXP sp3 and Python 3.1 - when launched a window 
flashes before my eyes, then disappears!  Has the installation package 
been checked for all common Windows versions?


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


Re: DreamPie - The Python shell you've always dreamed about!

2010-02-23 Thread Noam Yorav-Raphael
‎Thanks! I'm happy you like it!
Thanks for the feedback too. Here are my replies.

On Sun, Feb 21, 2010 at 7:13 PM, Chris Colbert  wrote:
> This is bloody fantastic! I must say, this fixes everything I hate about
> Ipython and gives me the feature I wished it had (with a few minor
> exceptions).
> I confirm this working on Kubuntu 9.10 using the ppa listed on the sites
> download page.
Great. It's important to know.

> I also confirm that it works interactively with PyQt4 and PyGtk (as to be
> expected since these toolkits use the PyOS_inputhook for the mainloop).
> However, it does not work interactively with wx (again, this is as expected
> since wx doesn't use the PyOS_inputhook). In short, the gui toolkit support
> is the same as in Ipython if you dont use any of the magic threading
> switches, which are now deprecated anyway.
Actually, currently DreamPie doesn't use PyOS_inputhook, but
implements the GUI hooks by itself. So it should be possible to
implement wx support if there's a way to handle events for a few
milliseconds. I tried it a bit and didn't find how to do it - if you
are interested in wx support and think you can help, please do.

> Matplotlib does not work interactively for me. Is there a special switch
> that needs to be used? or should a pick a non-wx backend? (i'm thinking the
> latter is more likely)
You should set "interactive:True" in your matplotlibrc file. The next
DreamPie version will warn about this.

> A couple of things I would like to see (and will help implement if I can
> find the time):
> 1) A shortcut to show the docstring of an object. Something like Ipython's
> `?`. i.e.  `object.foo?` translates to `help(object.foo)`
I wrote this at http://wiki.python.org/moin/DreamPieFeatureRequests .
I hope I will manage to implement this soon.

> 2) How do I change the color of the blinking cursor at the bottom? I can't
> see the damn thing!
It should be in the color of the default text. If this is not the
case, please file a bug!

> 3) line numbers instead of the `>>>` prompt
I know IPython does this, but I thought you needed it only if placing
the cursor on top of the command doesn't do anything. Can you tell me
why do you need this in the context of a graphical user interface?

> 4) a plugin facility where we can define our own `magic` commands. I use
> Ipython's %timeit ALL the time.
Added it to the feature request page.

> 5) Double-click to re-fold the output section as well.
I don't think that's a good idea, because usually double-click selects
the word, and I don't want to change that behavior for regular text.
You can use ctrl-minus to fold the last output section!

> Thanks for making this
Thanks for the feedback!

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


Re: When will Python go mainstream like Java?

2010-02-23 Thread Roald de Vries

On Feb 22, 2010, at 10:56 PM, AON LAZIO wrote:

That will be superb


I guess static typing will have to be added, so that tools like  
eclipse can inspect (and autocomplete) your programs [better].




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


Re: Avoid converting functions to methods in a class

2010-02-23 Thread Jean-Michel Pichavant

Steven D'Aprano wrote:
I have a convention when writing unit tests to put the target of the test 
into a class attribute, as follows:


class MyTest(unittest.TestCase):
target = mymodule.someclass

def test_spam(self):
"""Test that someclass has a spam attribute."""
self.failUnless(hasattr(self.target, 'spam'))


It works well until I write a test for stand-alone functions:

class AnotherTest(unittest.TestCase):
target = mymodule.function

def test_foo(self):
self.assertEquals(self.target('a', 'b'), 'foo')

The problem is that target is turned into a method of my test class, not 
a standalone function, and I get errors like:


TypeError: function() takes exactly 2 arguments (3 given)

The solution I currently use is to drop the target attribute in this 
class, and just refer to mymodule.function in each individual test. I 
don't like this solution because it violates Once And Only Once: if the 
function changes name, I have to make many edits to the test suite rather 
than just one.


Are there any better solutions?


  


It looks like it works when declaring foo as static:

import unittest

def foo(a,b):
   return 'fooo'

class AnotherTest(unittest.TestCase):
   target = staticmethod(foo)

   def test_foo(self):
   self.assertEquals(self.target('a', 'b'), 'foo')
  
   def runTest(self):

   self.test_foo()

AnotherTest().runTest()
...AssertionError: 'fooo' != 'foo'

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


Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread W. eWatson
In the last day, I posted a message titled "What's Going on between 
Python and win7?" I'd appreciate it if someone could verify my claim. A 
sample program to do this is below. I'm using IDLE in Win7 with Py 2.5.


My claim is that if one creates a program in a folder that reads a file 
in the folder it and then copies it to another folder, it will read  the 
data file in the first folder, and not a changed file in the new folder. 
I'd appreciate it if some w7 users could try this, and let me know what 
they find.


My experience is that if one checks the properties of the copied file, 
it will point to the original py file and execute it and not the copy.



# Test program. Examine strange link in Python under Win7
# when copying py file to another folder.
# Call the program vefifywin7.py
# To verify my situation use IDLE, save and run this program there.
# Put this program into a folder along with a data file
# called verify.txt. Create a single text line with a few characters in it
# Run this program and note if the output
# Copy the program and txt file to another folder
# Change the contents of the txt file
# Run it again, and see if the output is the same as in the other folder
track_file = open("verify.txt")
aline = track_file.readline();
print aline
track_file.close()
--
http://mail.python.org/mailman/listinfo/python-list


Re: DreamPie - The Python shell you've always dreamed about!

2010-02-23 Thread Olof Bjarnason
2010/2/23 Noam Yorav-Raphael :
> ‎Thanks! I'm happy you like it!
> Thanks for the feedback too. Here are my replies.
>
> On Sun, Feb 21, 2010 at 7:13 PM, Chris Colbert  wrote:
>> This is bloody fantastic! I must say, this fixes everything I hate about
>> Ipython and gives me the feature I wished it had (with a few minor
>> exceptions).
>> I confirm this working on Kubuntu 9.10 using the ppa listed on the sites
>> download page.
> Great. It's important to know.
>
>> I also confirm that it works interactively with PyQt4 and PyGtk (as to be
>> expected since these toolkits use the PyOS_inputhook for the mainloop).
>> However, it does not work interactively with wx (again, this is as expected
>> since wx doesn't use the PyOS_inputhook). In short, the gui toolkit support
>> is the same as in Ipython if you dont use any of the magic threading
>> switches, which are now deprecated anyway.
> Actually, currently DreamPie doesn't use PyOS_inputhook, but
> implements the GUI hooks by itself. So it should be possible to
> implement wx support if there's a way to handle events for a few
> milliseconds. I tried it a bit and didn't find how to do it - if you
> are interested in wx support and think you can help, please do.
>
>> Matplotlib does not work interactively for me. Is there a special switch
>> that needs to be used? or should a pick a non-wx backend? (i'm thinking the
>> latter is more likely)
> You should set "interactive:True" in your matplotlibrc file. The next
> DreamPie version will warn about this.
>
>> A couple of things I would like to see (and will help implement if I can
>> find the time):
>> 1) A shortcut to show the docstring of an object. Something like Ipython's
>> `?`. i.e.  `object.foo?` translates to `help(object.foo)`
> I wrote this at http://wiki.python.org/moin/DreamPieFeatureRequests .
> I hope I will manage to implement this soon.
>
>> 2) How do I change the color of the blinking cursor at the bottom? I can't
>> see the damn thing!
> It should be in the color of the default text. If this is not the
> case, please file a bug!
>
>> 3) line numbers instead of the `>>>` prompt
> I know IPython does this, but I thought you needed it only if placing
> the cursor on top of the command doesn't do anything. Can you tell me
> why do you need this in the context of a graphical user interface?
>
>> 4) a plugin facility where we can define our own `magic` commands. I use
>> Ipython's %timeit ALL the time.
> Added it to the feature request page.
>
>> 5) Double-click to re-fold the output section as well.
> I don't think that's a good idea, because usually double-click selects
> the word, and I don't want to change that behavior for regular text.
> You can use ctrl-minus to fold the last output section!
>
>> Thanks for making this
> Thanks for the feedback!

I installed latest .exe from LP on my Win7/32-bit machine, nothing
happens when I start DreamPie. Is there a bug report file somewhere I
could send you Noam?

(Python2.6.4 installed on my machine)

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



-- 
http://olofb.wordpress.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: When will Python go mainstream like Java?

2010-02-23 Thread Bruno Desthuilliers

hackingKK a écrit :
(snip)
I don't care how many apps are developed using java as long as they 
remain heavy and slw.

google runs on python


Please get your facts right.

Python is one of the languages used internally at Google, true, but so 
is Java.


And google-the-search-engine does not "run on python".

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


Re: When will Python go mainstream like Java?

2010-02-23 Thread Bruno Desthuilliers

Roald de Vries a écrit :

On Feb 22, 2010, at 10:56 PM, AON LAZIO wrote:

That will be superb


I guess static typing will have to be added, so that tools like eclipse 
can inspect (and autocomplete) your programs [better].


Yet another troll...

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


Re: Bizarre arithmetic results

2010-02-23 Thread Mark Dickinson
On Feb 23, 8:11 am, Steven D'Aprano
 wrote:
> Making spaces significant in that fashion is mind-bogglingly awful. Let's
> look at a language that does this:
>
> [st...@sylar ~]$ cat ws-example.rb
> def a(x=4)
>     x+2
> end
>
> b = 1
> print (a + b), (a+b), (a+ b), (a +b), "\n"
>
> [st...@sylar ~]$ ruby ws-example.rb
> 7773

Hmm.  That's pretty nasty, all right.  Not that Python can claim to be
immune to such behaviour:

>>> 3 .real
3
>>> 3. real
  File "", line 1
3. real
  ^
SyntaxError: invalid syntax


Though the fact that one of the cases raises an exception (rather than
silently giving some different behaviour) ameliorates things a bit.

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


ANN: Leo 4.7 final released

2010-02-23 Thread Edward K Ream

Leo 4.7 finalFebruary 23, 2009

Leo 4.7 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.7 final fixes all known bugs in Leo.

Leo is a text editor, data organizer, project manager and much more.
See:
http://webpages.charter.net/edreamleo/intro.html

The highlights of Leo 4.7:
--

- Leo now uses the simplest possible internal data model.
  This is the so-called "one-node" world.
- Leo supports Python 3.x.
- Leo requires Python 2.6 or above.
- Several important improvements in file handling.
- Leo converts @file nodes to @thin nodes automatically.
- Leo creates a 'Recovered Nodes' node to hold data that
  otherwise might be lost due to clone conflicts.
- @auto-rst now works much more reliably reliably.
- Leo no longer supports @noref trees.  Such trees are not
  reliable in cooperative environments.
- A new Windows installer.
- Many other features, including new command line options and new
plugins.
- Dozens of bug fixes.

Links:
--
Leo:  http://webpages.charter.net/edreamleo/front.html
Forum:http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:  http://code.launchpad.net/leo-editor/
Quotes:   http://webpages.charter.net/edreamleo/testimonials.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to transmit a crash report ?

2010-02-23 Thread Thomas
On Feb 22, 9:27 pm, MRAB  wrote:
> Stef Mientki wrote:
> > hello,
>
> > in my python desktop applications,
> > I'ld like to implement a crash reporter.
> > By redirecting the sys.excepthook,
> > I can detect a crash and collect the necessary data.
> > Now I want that my users sends this information to me,
> > and I can't find a good way of doing this.
>
> > The following solutions came into my mind:
> > (most of my users are on Windows, and the programs are written in Python
> > 2.6)
>
> > 1. mailto:
> > doesn't work if the the user didn't install a default email client,
> > or if the user uses a portable email client (that isn't started yet)
> > Besides this limits the messages to small amounts of data.
>
> > 2.other mail options: smtp
> > AFAIK such a solution needs smtp authorization, and therefor I've to put
> > my username and password in the desktop application.
>
> Try reading the documentation for Python's smtplib module.
>
> You don't need to provide any password.
>
>
>
> > 3. http-post
> > Although post is also limited in size,
> > I could store information in cookies (don't know yet how), and cookies
> > are sent parallel to the post message.
> > On the server site I can use a small php script, that stores the
> > post-data, cookies and/or send's a (long) email.
>
> > are there better options ?- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Try http://code.activestate.com/recipes/442459/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's Going on between Python and win7?

2010-02-23 Thread Jerry Hill
On Mon, Feb 22, 2010 at 8:25 PM, W. eWatson  wrote:
> So what's the bottom line? This link notion is completely at odds with XP,
> and produces what I would call something of a mess to the unwary Python/W7
> user. Is there a simple solution?

I know people went off on a tangent talking about symbolic links and
hard links, but it is extremely unlikely that you created something
like that by accident.  Windows just doesn't create those without you
doing quite a bit of extra work.  It certainly doesn't create them
when you drag & drop files around through the normal interface.

> How do I get out of this pickle? I just want to duplicate the  program in
> another folder, and not link to an ancestor.

You need to dig into the technical details of what's happening on your
hard drive.  You say you "copied a program from folder A to folder B".
 Can you describe, exactly, what steps you took?  What was the file
name of the program?  Was it just one file, or a directory, or several
files? What was the path to directory A?  What is the the path to
directory B?  When you open a CMD window and do a dir of each
directory, what exactly do you see?

You've given a pretty non-technical description of the problem you're
experiencing.  If you want more than wild speculation, you'll need to
give more specifics for people to help you with.

My wild guess: you held down control and shift while copying your
program.  That's the keyboard command to create a shortcut instead of
moving or copying a file.

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


Is this secure?

2010-02-23 Thread mk

Hello,

I need to generate passwords and I think that pseudo-random generator is 
not good enough, frankly. So I wrote this function:


import struct

def gen_rand_string():
fileobj = open('/dev/urandom','rb')
rstr = fileobj.read(4)
rnum = struct.unpack('L',rstr)[0]
rstr = '%i' % rnum
rnuml = []
while len(rstr) >= 2:
c = rstr[:2]
try:
num = int(c)
rnuml.append(num)
except ValueError:
pass
rstr = rstr[2:]
rnuml = map(lambda x: 97+x/4, rnuml)
rnumc = map(chr, rnuml)
return ''.join(rnumc)

if __name__ == "__main__":
print gen_rand_string()

(yes I know that this way generated string will not contain 'z' because 
99/4 + 97 = 121 which is 'y')


The question is: is this secure? That is, can the string generated this 
way be considered truly random? (I abstract from not-quite-perfect 
nature of /dev/urandom at the moment; I can always switch to /dev/random 
which is better)



Regards,
mk

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


Re: When will Python go mainstream like Java?

2010-02-23 Thread mk

AON LAZIO wrote:

That will be superb


Well I for one wouldn't want Python to go exactly Java way, see this:

http://www.itjobswatch.co.uk/charts/permanent-demand-trend.aspx?s=java&l=uk

This is the percentage of job offers in UK where the keyword "Java" appears.


Same for C#, it looks like C# is eating Java's lunch now:

http://www.itjobswatch.co.uk/charts/permanent-demand-trend.aspx?s=csharp&l=uk



What worries me somewhat (although not much) is that after long period 
of solid growth the market can't decide about Python:


http://www.itjobswatch.co.uk/charts/permanent-demand-trend.aspx?s=python&l=uk


I learned painfully that in corporate setting merits of a programming 
language do not matter much, it's more like "whatever catches the 
groupthink" at the moment. "Java is good because big ones select Java", 
"static typing is good because compiler catches programmer's errors" 
(this one is particularly appealing to managers I found), etc.


Although all my "internal use" tools are written in Python, there's no 
way I could convince managers to use Python as the main application 
devel language.


This, however, is not of itself a problem: as long as language is lively 
and has at least a few percent of programmers using it -- which is 
important for existence of libraries, not much more -- there's no 
problem for people who want to get ahead of competition / waste less 
time by using advanced programming langauges. Frankly, I have yet to 
encounter a problem for which either a sizable Python extension or 
bindings to a popular library wouldn't exist. This in itself is a 
hallmark of a language being "enough of mainstream to actually matter in 
practice".


This I find quite insightful: http://www.paulgraham.com/avg.html



Regards,
mk



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


Re: When will Python go mainstream like Java?

2010-02-23 Thread mk

Stefan Behnel wrote:

Chris Rebert, 23.02.2010 06:45:

Indeed. Python is at position 7, just behind C#, in the TIOBE Index:
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html


That index is clearly flawed. A language like PHP (whatever that is
supposed to be comparable with) can't possibly be on the rise, can it?


Well it looks like it is at least stabilized:

http://www.itjobswatch.co.uk/charts/permanent-demand-trend.aspx?s=php&l=uk

I find job offers to be rather good index of the extent to which the 
language is actually used, and this is what this index is based on 
(percentage of job offers with the keyword "php" in them).


Regards,
mk

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


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-23 Thread Anh Hai Trinh
On Feb 23, 1:03 pm, "Alf P. Steinbach"  wrote:
>
> Uhm, Paganini...
>
> As I understand it he invented the "destroy your instruments on stage". :-)
>
> Cheers,
>
> - Alf (off-topic)

You probably meant Franz Liszt, who regularly broke piano strings.
Paganini was also a "rock-star" virtuoso but he did not destroy any
Guarnerius or Stradivarius violins in his possession (at least not to
anyone's knowledge :)

As for functional programming, different people take it to mean
different things. For some, simply using first-class functions
qualifies as functional programming.  Others require their functions
to be pure so that their call graphs can be automatically reduced and
their results can be lazily evaluated.  If you takes the former view,
most Python programmers already do functional programming :p

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


Re: Writing an assembler in Python

2010-02-23 Thread mk

Giorgos Tzampanakis wrote:
I'm implementing a CPU that will run on an FPGA. I want to have a  
(dead) simple assembler that will generate the machine code for 
me. I want to use Python for that. Are there any libraries that 
can help me with the parsing of the assembly code?


I'm not sure about your field of application (never done anything like 
that), but I found pyparsing highly usable.


Regards,
mk

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


Re: Re: DreamPie - The Python shell you've always dreamed about!

2010-02-23 Thread Chris Colbert
Do you have gtk and PyGTK installed? Sounds like a missing dependency to me.

On Tue, Feb 23, 2010 at 6:56 AM, Alan Harris-Reid <
aharrisr...@googlemail.com> wrote:

> gorauskas wrote:
>
>> I installed it on a Windows 7 machine with CPython 2.6.4 and I get the
>> following error:
>>
>> Traceback (most recent call last):
>>  File "dreampie.py", line 3, in 
>>  File "dreampielib\gui\__init__.pyc", line 73, in 
>>  File "dreampielib\gui\load_pygtk.pyc", line 49, in load_pygtk
>> ImportError: DLL load failed: The specified module could not be found.
>>
>> What am I doing wrong?
>>
>> Thanks,  JGG
>>
> And I installed it on WinXP sp3 and Python 3.1 - when launched a window
> flashes before my eyes, then disappears!  Has the installation package been
> checked for all common Windows versions?
>
> Regards,
> Alan
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: When will Python go mainstream like Java?

2010-02-23 Thread Martin P. Hellwig

Actually I am still waiting for Java to be mainstream :-)
You could say it is popular, which it is without doubt but in my opinion 
after C handed over it's pseudo de facto standard (mostly because a lot 
of OS'es are written in it) nobody else has had enough momenta to reach 
for that crown.


Actually I quite like the soup of languages these days, what amuses me 
though, that Python seems to emerge as the de facto glue language to 
bind them all :-)


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


Re: Writing an assembler in Python

2010-02-23 Thread Anh Hai Trinh
On Feb 23, 10:08 am, Lawrence D'Oliveiro  wrote:
>
> Let me suggest an alternative approach: use Python itself as the assembler.
> Call routines in your library to output the code. That way you have a
> language more powerful than any assembler.
>
> See  for an example.

SyntaxError: Non-matching "#end if" in crosscode8.py:345
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Grant Edwards
On 2010-02-23, D'Arcy J.M. Cain  wrote:
> On Tue, 23 Feb 2010 02:54:25 -0800 (PST)
> Joan Miller  wrote:
>> *Sorry by this message off topic, but this is too important*
>
> Is it just me or has the spew from gmail on this list radically
> increased in the last week?  Anyone else considering blocking all gmail
> posts to this list?

I did that a long time ago for all of the Usenet groups I read
and all but one of the mailing lists I read.

-- 
Grant Edwards   grante Yow! I'm wearing PAMPERS!!
  at   
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Grant Edwards
On 2010-02-23, Grant Edwards  wrote:
> On 2010-02-23, D'Arcy J.M. Cain  wrote:
>> On Tue, 23 Feb 2010 02:54:25 -0800 (PST)
>> Joan Miller  wrote:
>>> *Sorry by this message off topic, but this is too important*
>>
>> Is it just me or has the spew from gmail on this list radically
>> increased in the last week?  Anyone else considering blocking all gmail
>> posts to this list?
>
> I did that a long time ago for all of the Usenet groups I read
> and all but one of the mailing lists I read.

Wait, I misread the posting.  I block everything from
google.groups, not everything from gmail.

-- 
Grant Edwards   grante Yow! I have accepted
  at   Provolone into my life!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The future of "frozen" types as the number of CPU cores increases

2010-02-23 Thread mk

sjdevn...@yahoo.com wrote:

On Feb 20, 9:58 pm, John Nagle  wrote:

sjdevn...@yahoo.com wrote:

On Feb 18, 2:58 pm, John Nagle  wrote:

Multiple processes are not the answer.  That means loading multiple
copies of the same code into different areas of memory.  The cache
miss rate goes up accordingly.

A decent OS will use copy-on-write with forked processes, which should
carry through to the cache for the code.

That doesn't help much if you're using the subprocess module.  The
C code of the interpreter is shared, but all the code generated from
Python is not.



Of course.  Multithreading also fails miserably if the threads all try
to call exec() or the equivalent.



It works fine if you use os.fork().


What about just using subprocess module to run system commands in worker 
threads? Is this likely to have problems?


Regards,
mk


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


Re: Avoid converting functions to methods in a class

2010-02-23 Thread Daniel Fetchinson
> I have a convention when writing unit tests to put the target of the test
> into a class attribute, as follows:
>
> class MyTest(unittest.TestCase):
> target = mymodule.someclass
>
> def test_spam(self):
> """Test that someclass has a spam attribute."""
> self.failUnless(hasattr(self.target, 'spam'))
>
>
> It works well until I write a test for stand-alone functions:
>
> class AnotherTest(unittest.TestCase):
> target = mymodule.function
>
> def test_foo(self):
> self.assertEquals(self.target('a', 'b'), 'foo')
>
> The problem is that target is turned into a method of my test class, not
> a standalone function, and I get errors like:
>
> TypeError: function() takes exactly 2 arguments (3 given)
>
> The solution I currently use is to drop the target attribute in this
> class, and just refer to mymodule.function in each individual test. I
> don't like this solution because it violates Once And Only Once: if the
> function changes name, I have to make many edits to the test suite rather
> than just one.

Isn't staticmethod the trick you need?

HTH,
Daniel


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


Re: DreamPie - The Python shell you've always dreamed about!

2010-02-23 Thread Alan Harris-Reid

Chris Colbert wrote:
Do you have gtk and PyGTK installed? Sounds like a missing dependency 
to me.


On Tue, Feb 23, 2010 at 6:56 AM, Alan Harris-Reid 
mailto:aharrisr...@googlemail.com>> wrote:


gorauskas wrote:

I installed it on a Windows 7 machine with CPython 2.6.4 and I
get the
following error:

Traceback (most recent call last):
 File "dreampie.py", line 3, in 
 File "dreampielib\gui\__init__.pyc", line 73, in 
 File "dreampielib\gui\load_pygtk.pyc", line 49, in load_pygtk
ImportError: DLL load failed: The specified module could not
be found.

What am I doing wrong?

Thanks,  JGG

And I installed it on WinXP sp3 and Python 3.1 - when launched a
window flashes before my eyes, then disappears!  Has the
installation package been checked for all common Windows versions?

Regards,
Alan

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




Hi Chris, thanks for the reply,

That explains it.  No, I don't have gtk installed - I wasn't aware of 
that dependency.


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


Bay Area PUG Meeting Thursday in Mountain View, CA

2010-02-23 Thread W. eWatson
Anyone here going to the meeting,Subject? As far as I can tell, it meets 
from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to 
be an informal group dinner at 6 pm at some place yet unknown. Comments?

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


AKKA vs Python

2010-02-23 Thread mk

Hello everyone,

Is there smth like AKKA in Python?

http://akkasource.org/

Regards,
mk

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


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread D'Arcy J.M. Cain
On Tue, 23 Feb 2010 15:31:12 + (UTC)
Grant Edwards  wrote:
> >> Is it just me or has the spew from gmail on this list radically
> >> increased in the last week?  Anyone else considering blocking all gmail
> >> posts to this list?
> >
> > I did that a long time ago for all of the Usenet groups I read
> > and all but one of the mailing lists I read.
> 
> Wait, I misread the posting.  I block everything from
> google.groups, not everything from gmail.

Yes, I did that a long time ago as well.  But now there seems to be
more and more actual spam coming from gmail.com itself.  It may just be
a minor blip on the spam graph but I'm keeping my eye on it.

Most mailing lists that I am on are pretty good at filtering spam
before it gets to the list.  The only spam I ever see on my NetBSD
lists are the ones that I moderate and I block them before anyone else
sees them.  A little more pain for me in return for a lot less pain for
everyone else.  I guess that's not possible on a list that is gatewayed
to UseNet like this one is.

Hmm.  I wonder if all the spam is coming from the NG side.  I'll have
to look at that.  One of the reasons that I stopped reading UseNet over
ten years ago was because of the diminishinig S/N ratio.  I have always
felt that it was a mistake to gateway this group.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: AKKA vs Python

2010-02-23 Thread Chris Rebert
On Tue, Feb 23, 2010 at 7:59 AM, mk  wrote:
> Hello everyone,
>
> Is there smth like AKKA in Python?
>
> http://akkasource.org/

Minus the "distributed" part, yes; there are a few implementations of
actors for Python:
http://www.doc.ic.ac.uk/~jwa/stage/
http://osl.cs.uiuc.edu/parley/
http://candygram.sourceforge.net/candygram.html

It's a variant on the vanilla actor model, but I've heard good buzz about:
http://www.kamaelia.org/

(Unless it wasn't already clear, I haven't used any of these myself.)

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


Re: Writing an assembler in Python

2010-02-23 Thread Robert Kern

On 2010-02-22 21:47 PM, Ed Keith wrote:

Subject: Re: Writing an assembler in Python
Giorgos
Tzampanakis wrote:


I'm implementing a CPU that will run on an FPGA. I

want to have a

(dead) simple assembler that will generate the machine

code for

me.


Let me suggest an alternative approach: use Python itself
as the assembler.
Call routines in your library to output the code. That way
you have a
language more powerful than any assembler.

See  for
an example.
--
http://mail.python.org/mailman/listinfo/python-list



Not a bad idea, has anyone tried this for x86 machine code?


http://www.corepy.org/

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Rick Dooling
No telling what Windows will do. :)

I am a mere hobbyist programmer, but I think real programmers will
tell you that it is a bad habit to use relative paths. Use absolute
paths instead and remove all doubt.

http://docs.python.org/library/os.path.html

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


Re: When will Python go mainstream like Java?

2010-02-23 Thread sstein...@gmail.com

On Feb 23, 2010, at 10:10 AM, Martin P. Hellwig wrote:

> Actually I am still waiting for Java to be mainstream :-)
> You could say it is popular, which it is without doubt but in my opinion 
> after C handed over it's pseudo de facto standard (mostly because a lot of 
> OS'es are written in it) nobody else has had enough momenta to reach for that 
> crown.
> 
> Actually I quite like the soup of languages these days, what amuses me 
> though, that Python seems to emerge as the de facto glue language to bind 
> them all :-)

I'm sure there's a Tolkien 1-liner in there somewhere ;-).

S

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


SMTPServerDisconnected

2010-02-23 Thread Victor Subervi
Hi;
I think the last main thing I have to do on my server is get a running email
server up. Now that I've nuked sendmail and given up on postfix, I'm back to
trying to get qmail up and running again. Of course, there are no active
discussion lists for *any* email server, so I have to turn here for help.
While running a script that worked perfectly well on another server to send
an email, I get the following error:

A problem occurred in a Python script. Here is the sequence of function
calls leading up to the error, in the order they occurred.

A problem occurred in a Python script. Here is the sequence of function
calls leading up to the error, in the order they occurred.

 /var/www/html/globalsolutionsgroup.vi/simplemail/mail2.py
   52 
   53 '''
   54 my_mail()
   55 print '''
   56 
my_mail = 
 /var/www/html/globalsolutionsgroup.vi/simplemail/mail2.py in my_mail()
   33   to_address = ourEmail1,
   34   subject = subject,
   35   message = message
   36   ).send()
   37   Email(
message = 'Name: beno -\nMessage: test'
 /var/www/html/globalsolutionsgroup.vi/simplemail/simplemail.py in
send(self=)
  344 smtp = smtplib.SMTP()
  345 if self.smtp_server:
  346 smtp.connect(self.smtp_server)
  347 else:
  348 smtp.connect()
smtp = , smtp.connect = >, self = , self.smtp_server
= 'localhost'
 /usr/lib64/python2.4/smtplib.py in connect(self=,
host='localhost', port=25)
  305 if not self.sock:
  306 raise socket.error, msg
  307 (code, msg) = self.getreply()
  308 if self.debuglevel > 0: print>>stderr, "connect:", msg
  309 return (code, msg)
code undefined, msg = 'getaddrinfo returns an empty list', self =
, self.getreply = >
 /usr/lib64/python2.4/smtplib.py in getreply(self=)
  349 if line == '':
  350 self.close()
  351 raise SMTPServerDisconnected("Connection unexpectedly
closed")
  352 if self.debuglevel > 0: print>>stderr, 'reply:',
repr(line)
  353 resp.append(line[4:].strip())
global SMTPServerDisconnected = 
SMTPServerDisconnected: Connection unexpectedly closed
  args = ('Connection unexpectedly closed',)

I cannot find the qmail logs. I assumed they'd be in either
/var/qmail/supervise/qmail-send
or
/var/qmail/supervise/qmail-smtpd
but I find no logs there.


[SSH] Protocol Version 2 (OpenSSH_4.3)
[SSH] Cipher: aes128-cbc

Logged in (password)

Last login: Tue Feb 23 05:24:00 2010 from 66.248.168.67
[b...@13gems ~]$ su
Password:
[r...@13gems beno]# man netstat
[r...@13gems beno]# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address   Foreign Address
State
getnameinfo failed
tcp0268 nrelectric.com:ssh  [UNKNOWN]:61912
ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags   Type   State I-Node Path
unix  7  [ ] DGRAM10842  /dev/log
unix  2  [ ] DGRAM10370
 @/org/kernel/udev/udevd
unix  2  [ ] DGRAM6077731
unix  3  [ ] STREAM CONNECTED 6077679
unix  3  [ ] STREAM CONNECTED 6077678
unix  2  [ ] DGRAM6077675
unix  2  [ ] DGRAM11556
unix  2  [ ] DGRAM11511
unix  2  [ ] DGRAM10990
[r...@13gems beno]#


How do I trouble-shoot this?
TIA,
beno

-- 
The Logos has come to bear
http://logos.13gems.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Free check of $253 with your name.

2010-02-23 Thread ranga...............
Just open below site and select any one of the four red color links
present below sponsors and enter your payename and address where to
get your check.

The secret link is 
http://highpayingkeywordsofadsense.blogspot.com/2010/01/google-yahoo-msn-adsense-high-paying_29.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread W. eWatson

On 2/23/2010 8:26 AM, Rick Dooling wrote:

No telling what Windows will do. :)

I am a mere hobbyist programmer, but I think real programmers will
tell you that it is a bad habit to use relative paths. Use absolute
paths instead and remove all doubt.

http://docs.python.org/library/os.path.html

RD
You may be right. The actual 300 line program just reads the folder 
without specifying any path. I'm not that familiar with os path, but 
have seen it used.

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


Re: Fascism is coming to Internet

2010-02-23 Thread Joan Miller
On 23 feb, 10:54, Joan Miller  wrote:
> *Sorry by this message off topic, but this is too important*
>
> Fascism is coming fastly to Internet because is the only communication
> way that governements (managed by the bank and multinationals) cann't
> control
>
> http://www.boingboing.net/2010/02/21/acta-internet-enforc.html

This is something that affects to all programmers:

"This calls on all parties to ensure that "third party liability" (the
idea that ISPs, web-hosts, application developers, mobile carriers,
universities, apartment buildings, and other "third parties" to
infringement are sometimes liable for their users' copyright
infringements) is on the books in their countries. It doesn't spell
out what that liability should be, beyond "knowingly and materially
aiding" an infringement"

http://craphound.com/acta_digital_chapter-1.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The future of "frozen" types as the number of CPU cores increases

2010-02-23 Thread John Nagle

mk wrote:

sjdevn...@yahoo.com wrote:

On Feb 20, 9:58 pm, John Nagle  wrote:

sjdevn...@yahoo.com wrote:

On Feb 18, 2:58 pm, John Nagle  wrote:
Multiple processes are not the answer.  That means loading 
multiple

copies of the same code into different areas of memory.  The cache
miss rate goes up accordingly.

A decent OS will use copy-on-write with forked processes, which should
carry through to the cache for the code.

That doesn't help much if you're using the subprocess module.  The
C code of the interpreter is shared, but all the code generated from
Python is not.



Of course.  Multithreading also fails miserably if the threads all try
to call exec() or the equivalent.



It works fine if you use os.fork().


What about just using subprocess module to run system commands in worker 
threads? Is this likely to have problems?


Regards,
mk


   The discussion above was about using "fork" to avoid duplicating the
entire Python environment for each subprocess.  If you use the subprocess
module, you load a new program, so you don't get much memory sharing.
This increases the number of cache misses, which is a major bottleneck
in many-CPU systems with shared caches.

   The issue being discussed was scaling Python for CPUs with many cores.
With Intel shipping 4 cores/8 hyperthread CPUs, the 6/12 part working,
and the 8/16 part coming along, this is more than a theoretical
issue.

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


Re: Modifying Class Object

2010-02-23 Thread NevilleDNZ
Hi Groetjes Albert,

I spotted your comment - re: pointers
http://groups.google.com/group/comp.lang.python/msg/5c1e25919b6a74bf

On Feb 22, 11:44 pm, Albert van der Horst 
wrote:
(I once studied algol 68, and never got confused about these
> subjects anymore, recommended.)

Having used Algol68, then switching to C to discover "*" for manual
dereferencing I immediately wanted to be back using A68 again, but
alas...  Then when I switched to C++ I immediately understood the
"Zen" of C++'s "&"... but still wanted to switch back to A68.  Was
there ever a version with "Objects"... I saw a version with "Areas"
but have no idea what an "Area" is.

@Albert: Given the domain name "xs4all" in your email address I am
sure YOU have spotted: http://www.xs4all.nl/~jmvdveer/algol.html by
Marcel

Also: I invite you to join one of the below groups (my .sig below) and
deposit some of your Algol68 impressions

There is also a chrestomathy site http://rosettacode.org/wiki/ALGOL_68
where you can pick out an code sample unimplemented in Algol68 and
torture test your Algol68 memories.  (Be warned: Most of the easy
samples are done)

Keep in touch
NevilleDNZ
--
For Algol68-user mailinglist with archives & subscription:
* https://lists.sourceforge.net/lists/listinfo/algol68-user
To download Linux's Algol68 Compiler, Interpreter & Runtime:
* http://sourceforge.net/projects/algol68
Join the linkedin.com's Algol68 group, follow:
* http://www.linkedin.com/groups?gid=2333923
-- 
http://mail.python.org/mailman/listinfo/python-list


Signature-based Function Overloading in Python

2010-02-23 Thread Michael Rudolf
Just a quick question about what would be the most pythonic approach in 
this.


In Java, Method Overloading is my best friend, but this won't work in 
Python:


>>> def a():
pass
>>> def a(x):
pass
>>> a()
Traceback (most recent call last):
  File "", line 1, in 
a()
TypeError: a() takes exactly 1 argument (0 given)

So - What would be the most pythonic way to emulate this?
Is there any better Idom than:

>>> def a(x=None):
if x is None:
pass
else:
pass

?

Thanks,
Michael
--
http://mail.python.org/mailman/listinfo/python-list


Re: Signature-based Function Overloading in Python

2010-02-23 Thread Daniel Fetchinson
> In Java, Method Overloading is my best friend, but this won't work in
> Python:
>
>  >>> def a():
>   pass
>  >>> def a(x):
>   pass
>  >>> a()
> Traceback (most recent call last):
>File "", line 1, in 
>  a()
> TypeError: a() takes exactly 1 argument (0 given)
>
> So - What would be the most pythonic way to emulate this?
> Is there any better Idom than:
>
>  >>> def a(x=None):
>   if x is None:
>   pass
>   else:
>   pass

This is generally considered to be the pythonic idiom for what you describe.

Cheers,
Daniel


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


Re: What's Going on between Python and win7?

2010-02-23 Thread chris grebeldinger
Have you tried opening file explorer in administrative mode before
performing the copy?  I think if there isn't sufficient permissions,
it does something weird like that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's Going on between Python and win7?

2010-02-23 Thread Gib Bogle

chris grebeldinger wrote:

Have you tried opening file explorer in administrative mode before
performing the copy?  I think if there isn't sufficient permissions,
it does something weird like that.


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


Re: Signature-based Function Overloading in Python

2010-02-23 Thread John Posner

On 2/23/2010 1:25 PM, Michael Rudolf wrote:

Just a quick question about what would be the most pythonic approach in
this.

In Java, Method Overloading is my best friend, but this won't work in
Python:

 >>> def a():
pass
 >>> def a(x):
pass
 >>> a()
Traceback (most recent call last):
File "", line 1, in 
a()
TypeError: a() takes exactly 1 argument (0 given)

So - What would be the most pythonic way to emulate this?
Is there any better Idom than:

 >>> def a(x=None):
if x is None:
pass
else:
pass



Consider this:

#--
def myfunc(*arglist):
if not arglist:
print "no arguments"
return
for i, arg in enumerate(arglist):
print "Argument %d is a %s, with value:" % (i, type(arg)),
print arg


myfunc()
print "---"
myfunc(1)
print "---"
myfunc(2, "three", [4, 5,6])
#--

program output:

no arguments
---
Argument 0 is a , with value: 1
---
Argument 0 is a , with value: 2
Argument 1 is a , with value: three
Argument 2 is a , with value: [4, 5, 6]


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


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Gib Bogle

Rick Dooling wrote:

No telling what Windows will do. :)


It isn't useful to respond to a serious question with OS bigotry.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-23 Thread Timothy N. Tsvetkov
On Feb 16, 10:41 pm, Andrej Mitrovic 
wrote:
> On Feb 16, 7:38 pm, Casey Hawthorne 
> wrote:
>
> > Interesting talk on Python vs. Ruby and how he would like Python to
> > have just a bit more syntactic flexibility.
>
> >http://blog.extracheese.org/2010/02/python-vs-ruby-a-battle-to-the-de...
> > --
> > Regards,
> > Casey
>
> Gary's friend Geoffrey Grosenbach says in his blog post (which Gary
> linked to): "Python has no comparable equivalent to Ruby’s do end
> block. Python lambdas are limited to one line and can’t contain
> statements (for, if, def, etc.). Which leaves me wondering, what’s the
> point?"
>
> I'm sorry, lambda's do support if's and for's. Also, lambda's are
> expressions, not statements, but you can pass them around, keep them
> in a dictionary if you want to. And if you need more than one line of
> statements, for crying out loud use a def? And who needs those "do-
> end" blocks anyway, trying to turn Python into Pascal?

I think there are some nice use-cases for anonymous functions /
blocks. First, mentioned above, is pretty DSL. And the second is using
blocks in map/reduce functions. Yes, you can pass there a function but
I believe that in most situations it is more readable to pass a
multiline anonymous function / block than defined somewhere function
written only for a single map/reduce operation. And often when you use
reduce it is a bit more complicated then just one line function.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Gib Bogle

W. eWatson wrote:

On 2/23/2010 8:26 AM, Rick Dooling wrote:

No telling what Windows will do. :)

I am a mere hobbyist programmer, but I think real programmers will
tell you that it is a bad habit to use relative paths. Use absolute
paths instead and remove all doubt.

http://docs.python.org/library/os.path.html

RD
You may be right. The actual 300 line program just reads the folder 
without specifying any path. I'm not that familiar with os path, but 
have seen it used.


How do you invoke the program?  Do you use a Command Prompt window?
--
http://mail.python.org/mailman/listinfo/python-list


RE: Python won't run

2010-02-23 Thread Nardin, Cory L.
Thanks so much for that suggestion.  I used the tool and found two
missing libraries: MSVCR90.DLL and DWMAPI.DLL.  I located and copied the
first library to my python directory (and resolved that dependency), but
I am still missing the other.  I have done a Google search and found
that DWMAPI is a Vista library.  I am have XP, so I am not sure why it
is a required dependency?  I made sure that I have all the MS updates
(presumably MS would include a new library in an update if it became a
required library) and that did not solve the problem.  Is this a bug or
should I have that library on my computer and the fact that it isn't
there is the sign of some other problem?

 

Thanks

Cory

 



From: Sridhar Ratnakumar [mailto:sridh...@activestate.com] 
Sent: Monday, February 22, 2010 11:54 AM
To: Nardin, Cory L.
Cc: python-list@python.org
Subject: Re: Python won't run

 

Have you tried using   
http://dependencywalker.com/ ?

 

-srid

 

On 2010-02-18, at 1:00 PM, Nardin, Cory L. wrote:





Quickly, I have a Mac Intel with Windows XP installed.  Tried installing
Python 2.6.4 from the binary and also ActivePython 2.6.4.10.  Both
installations acted the same.  There seemed to be no problems during
installation (used default options), but when I try to run Python I get
an error message: "This application has failed to start because the
application configuration is incorrect.  Reinstalling the application
may fix this problem."

 

Of course I searched on that error and it seems to be related to a MS
library.  In a few different places it was recommended to install the MS
Visual Studio redistributable package, which I did with no change in
outcome.  I really have no idea what to do.

 

Any help is appreciated.

 

Thanks,

Cory

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

 

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


Re: Fascism is coming to Internet

2010-02-23 Thread Olof Bjarnason
2010/2/23 Joan Miller :
> On 23 feb, 10:54, Joan Miller  wrote:
>> *Sorry by this message off topic, but this is too important*
>>
>> Fascism is coming fastly to Internet because is the only communication
>> way that governements (managed by the bank and multinationals) cann't
>> control
>>
>> http://www.boingboing.net/2010/02/21/acta-internet-enforc.html
>
> This is something that affects to all programmers:
>
> "This calls on all parties to ensure that "third party liability" (the
> idea that ISPs, web-hosts, application developers, mobile carriers,
> universities, apartment buildings, and other "third parties" to
> infringement are sometimes liable for their users' copyright
> infringements) is on the books in their countries. It doesn't spell
> out what that liability should be, beyond "knowingly and materially
> aiding" an infringement"
>
> http://craphound.com/acta_digital_chapter-1.pdf
> --
> http://mail.python.org/mailman/listinfo/python-list
>



Even if this is "Off Topic" (which I think it really isn't in any open
source / free software-oriented mailing list), I want to agree with
Joan.

ACTA is a *real* problem that we must fend politically. Here is a blog
post I wrote about the problem with making ISPs liable for what their
users communicate:

http://translate.google.com/translate?js=y&prev=_t&hl=en&ie=UTF-8&layout=1&eotf=1&u=http%3A%2F%2Folofb.wordpress.com%2F&sl=sv&tl=en
(sorry for the bad quality google translation -- this is an important topic!)

Note the name of the important principle: "Mere conduit".



-- 
http://olofb.wordpress.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this secure?

2010-02-23 Thread Paul Rubin
mk  writes:
> I need to generate passwords and I think that pseudo-random generator
> is not good enough, frankly. So I wrote this function:...
> The question is: is this secure? That is, can the string generated
> this way be considered truly random? (I abstract from
> not-quite-perfect nature of /dev/urandom at the moment; I can always
> switch to /dev/random which is better)

urandom is fine and the entropy loss from the numeric conversions and
eliminating 'z' in that code before you get letters out is not too bad.
The code is pretty ugly.  The main problem is you end up with a password
that's usually 5 letters but sometimes just 4 or fewer.  Passwords that
short are vulnerable to dictionary attacks.  Longer passwords made from
random letters are difficult to remember.

I find it's most practical to use a few random words (chosen from a word
list like /usr/dict/words) rather than random letters.  Words are easier
to remember and type.

You might look at the site www.diceware.com for an approach to this,
which you can implement with a program.  The docs there are pretty
thoughtful and may help you understand the relevant issues.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: formatting a number as percentage

2010-02-23 Thread vsoler
On Feb 22, 8:32 pm, Hans Mulder  wrote:
> Günther Dietrich wrote:
> > vsoler  wrote:
>
> >> I'm trying to print .7 as 70%
> >> I've tried:
>
> >> print format(.7,'%%')
> >> .7.format('%%')
>
> >> but neither works. I don't know what the syntax is...
>
> > Did you try this:
>
>  print('%d%%' % (0.7 * 100))
> > 70%
>
> That method will always round down; TomF's method will round to
> the nearest whole number:
>
>  >>> print "%d%%" % (0.698 * 100)
> 69%
>  >>> print "{0:.0%}".format(.698)
> 70%
>
> Only the OP knows which one is more appropriate for his use case.
>
> Hope this helps,
>
> -- HansM

Great!!!

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


python dowload

2010-02-23 Thread monkeys paw

I used the following code to download a PDF file, but the
file was invalid after running the code, is there problem
with the write operation?

import urllib2
url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
a = open('adobe.pdf', 'w')
for line in urllib2.urlopen(url):
a.write(line)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is this secure?

2010-02-23 Thread mk
On Feb 23, 7:19 pm, Paul Rubin  wrote:

> The code is pretty ugly.  The main problem is you end up with a password
> that's usually 5 letters but sometimes just 4 or fewer.  

Well I didn't write the whole thing here, in actual use I'd write a
loop repeating the function until I have enough characters and then
I'd select a substring of specified length.

Anything else in the code that is ugly and I should correct?

> You might look at the sitewww.diceware.comfor an approach to this,
> which you can implement with a program.  The docs there are pretty
> thoughtful and may help you understand the relevant issues.

Thanks. But I would also be grateful for indicating what is wrong/ugly
in my code.

Regards,
mk


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


Re: Is this secure?

2010-02-23 Thread Robert Kern

On 2010-02-23 13:19 PM, Paul Rubin wrote:


I find it's most practical to use a few random words (chosen from a word
list like /usr/dict/words) rather than random letters.  Words are easier
to remember and type.

You might look at the site www.diceware.com for an approach to this,
which you can implement with a program.  The docs there are pretty
thoughtful and may help you understand the relevant issues.


I like RFC 1751 for this:

http://gitweb.pycrypto.org/?p=crypto/pycrypto-2.x.git;a=blob;f=lib/Crypto/Util/RFC1751.py;h=1c98a212c22066adabfee521b495eeb4f9d7232b;hb=HEAD

Shortened URL:

http://tr.im/Pv9B

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: python dowload

2010-02-23 Thread John Bokma
monkeys paw  writes:

> I used the following code to download a PDF file, but the
> file was invalid after running the code, is there problem
> with the write operation?
>
> import urllib2
> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
> a = open('adobe.pdf', 'w')
> for line in urllib2.urlopen(url):
> a.write(line)

pdf is /not/ text. You're processing it like it's a text file (and
storing it like it's text, which on Windows is most likely a no no).

import urllib2

url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
response = urllib2.urlopen(url)
fh = open('adobe.pdf', 'wb')
fh.write(response.read())
fh.close()
response.close()

-- 
John Bokma   j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fascism is coming to Internet

2010-02-23 Thread D'Arcy J.M. Cain
On Tue, 23 Feb 2010 20:30:03 +0100
Olof Bjarnason  wrote:
> Even if this is "Off Topic" (which I think it really isn't in any open
> source / free software-oriented mailing list), I want to agree with
> Joan.

It isn't about the Python programming language so it is off topic.  So
what if some members have an interest?  We have interest in a lot of
things.  We all have interest in the hardware that our programs run on
but questions about hardware are also off topic.

Perhaps you don't quite grasp the point of topical discussion groups.
They are a way of letting individuals decide for themselves what kind
of discussions they want to be involved in.  By spamming the group this
way you take away that freedom of choice.  It's ironic when it is done
in the name of freedom.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python dowload

2010-02-23 Thread Tim Chase

monkeys paw wrote:

I used the following code to download a PDF file, but the
file was invalid after running the code, is there problem
with the write operation?

import urllib2
url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
a = open('adobe.pdf', 'w')


Sure you don't need this to be 'wb' instead of 'w'?


for line in urllib2.urlopen(url):
 a.write(line)


I also don't know if this "for line...a.write(line)" loop is 
doing newline translation.  If it's a binary file, you should use 
.read() (perhaps with a modest-sized block-size, writing it in a 
loop if the file can end up being large.)


-tkc


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


Re: python dowload

2010-02-23 Thread Jerry Hill
On Tue, Feb 23, 2010 at 2:42 PM, monkeys paw  wrote:
> I used the following code to download a PDF file, but the
> file was invalid after running the code, is there problem
> with the write operation?
>
> import urllib2
> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
> a = open('adobe.pdf', 'w')
> for line in urllib2.urlopen(url):
>    a.write(line)

Two guesses:

First, you need to call a.close() when you're done writing to the file.

This will happen automatically when you have no more references to the
file, but I'm guessing that you're running this code in IDLE or some
other IDE, and a is still a valid reference to the file after you run
that snippet.

Second, you're treating the pdf file as text (you're assuming it has
lines, you're not writing the file in binary mode, etc.).  I don't
know if that's correct for a pdf file.  I would do something like this
instead:

Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit
(Intel)] on win32
IDLE 2.6.4

>>> import urllib2
>>> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
>>> a = open('C:/test.pdf', 'wb')
>>> data = urllib2.urlopen(url).read()
>>> a.write(data)
>>> a.close()

That seems to works for me, in that it downloads a 16 page pdf
document, and that document opens without error or any other obvious
problems.

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


Re: formatting a number as percentage

2010-02-23 Thread Günther Dietrich
Hans Mulder  wrote:

>> Did you try this:
>> 
> print('%d%%' % (0.7 * 100))
>> 70%
>
>That method will always round down; TomF's method will round to
>the nearest whole number:
>
> >>> print "%d%%" % (0.698 * 100)
>69%
> >>> print "{0:.0%}".format(.698)
>70%

It was intended as a hint to this way of formatting. He could also try:

>>> print('%.0f%%' % (0.698 * 100))
70%



Best regards,

Günther
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python dowload

2010-02-23 Thread David Robinow
On Tue, Feb 23, 2010 at 2:42 PM, monkeys paw  wrote:
> I used the following code to download a PDF file, but the
> file was invalid after running the code, is there problem
> with the write operation?
>
> import urllib2
> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
> a = open('adobe.pdf', 'w')
> for line in urllib2.urlopen(url):
>    a.write(line)

If you're running Windows, try
  a = open('adobe.pdf', 'wb')

[Works for me]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python dowload

2010-02-23 Thread sstein...@gmail.com

On Feb 23, 2010, at 2:42 PM, monkeys paw wrote:

> I used the following code to download a PDF file, but the
> file was invalid after running the code, is there problem
> with the write operation?
> 
> import urllib2
> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
> a = open('adobe.pdf', 'w')

Try 'wb', just in case.

S



> for line in urllib2.urlopen(url):
>a.write(line)
> -- 
> http://mail.python.org/mailman/listinfo/python-list

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


Re: python dowload

2010-02-23 Thread Shashwat Anand
PyPdf/pdfminer library will be of help

On Wed, Feb 24, 2010 at 1:47 AM, Tim Chase wrote:

> monkeys paw wrote:
>
>> I used the following code to download a PDF file, but the
>> file was invalid after running the code, is there problem
>> with the write operation?
>>
>> import urllib2
>> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
>> a = open('adobe.pdf', 'w')
>>
>
> Sure you don't need this to be 'wb' instead of 'w'?
>
>
>  for line in urllib2.urlopen(url):
>> a.write(line)
>>
>
> I also don't know if this "for line...a.write(line)" loop is doing newline
> translation.  If it's a binary file, you should use .read() (perhaps with a
> modest-sized block-size, writing it in a loop if the file can end up being
> large.)
>
> -tkc
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Signature-based Function Overloading in Python

2010-02-23 Thread Arnaud Delobelle
Michael Rudolf  writes:

> Just a quick question about what would be the most pythonic approach
> in this.
>
> In Java, Method Overloading is my best friend, but this won't work in
> Python:
>
 def a():
>   pass
 def a(x):
>   pass
 a()
> Traceback (most recent call last):
>   File "", line 1, in 
> a()
> TypeError: a() takes exactly 1 argument (0 given)
>
> So - What would be the most pythonic way to emulate this?
> Is there any better Idom than:
>
 def a(x=None):
>   if x is None:
>   pass
>   else:
>   pass
>

There are a number of frameworks for function overloading out there.  FWIW,
there is actually one in the Python sandbox (for Python 3):

http://svn.python.org/view/sandbox/trunk/Overload3K/

-- 
Arnaud

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


Re: What's Going on between Python and win7?

2010-02-23 Thread Michel Claveau - MVP
Hi!

> Symbolic links are available in NTFS starting with Windows Vista.

No.
Hardlink come with NTFS, and already exists in W2K (and NT with specifics 
utilities).

@-salutations
-- 
Michel Claveau 

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


Re: Is this secure?

2010-02-23 Thread Robert Kern

On 2010-02-23 13:59 PM, mk wrote:

On Feb 23, 7:19 pm, Paul Rubin  wrote:


The code is pretty ugly.  The main problem is you end up with a password
that's usually 5 letters but sometimes just 4 or fewer.


Well I didn't write the whole thing here, in actual use I'd write a
loop repeating the function until I have enough characters and then
I'd select a substring of specified length.

Anything else in the code that is ugly and I should correct?


I would recommend using random.SystemRandom.choice() on a sequence of acceptable 
characters. E.g. (untested)


import random
import string


characters = string.letters + string.digits + '~...@#$%^&*()-+=,;./\?><|'
# ... or whatever.

def gen_rand_string(length):
prng = random.SystemRandom()
chars = []
for i in range(length):
chars.append(prng.choice(characters))
return ''.join(chars)

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: SMTPServerDisconnected

2010-02-23 Thread Jonathan Gardner
On Tue, Feb 23, 2010 at 8:47 AM, Victor Subervi  wrote:
> Hi;
> I think the last main thing I have to do on my server is get a running email
> server up. Now that I've nuked sendmail and given up on postfix, I'm back to
> trying to get qmail up and running again. Of course, there are no active
> discussion lists for *any* email server, so I have to turn here for help.
> While running a script that worked perfectly well on another server to send
> an email, I get the following error:
> A problem occurred in a Python script. Here is the sequence of function
> calls leading up to the error, in the order they occurred.
> A problem occurred in a Python script. Here is the sequence of function
> calls leading up to the error, in the order they occurred.
>  /var/www/html/globalsolutionsgroup.vi/simplemail/mail2.py
>    52 
>    53 '''
>    54 my_mail()
>    55 print '''
>    56 
> my_mail = 
>  /var/www/html/globalsolutionsgroup.vi/simplemail/mail2.py in my_mail()
>    33       to_address = ourEmail1,
>    34       subject = subject,
>    35       message = message
>    36   ).send()
>    37   Email(
> message = 'Name: beno -\nMessage: test'
>  /var/www/html/globalsolutionsgroup.vi/simplemail/simplemail.py in
> send(self=)
>   344         smtp = smtplib.SMTP()
>   345         if self.smtp_server:
>   346             smtp.connect(self.smtp_server)
>   347         else:
>   348             smtp.connect()
> smtp = , smtp.connect =  >, self = , self.smtp_server
> = 'localhost'
>  /usr/lib64/python2.4/smtplib.py in connect(self=,
> host='localhost', port=25)
>   305         if not self.sock:
>   306             raise socket.error, msg
>   307         (code, msg) = self.getreply()
>   308         if self.debuglevel > 0: print>>stderr, "connect:", msg
>   309         return (code, msg)
> code undefined, msg = 'getaddrinfo returns an empty list', self =
> , self.getreply =  >
>  /usr/lib64/python2.4/smtplib.py in getreply(self=)
>   349             if line == '':
>   350                 self.close()
>   351                 raise SMTPServerDisconnected("Connection unexpectedly
> closed")
>   352             if self.debuglevel > 0: print>>stderr, 'reply:',
> repr(line)
>   353             resp.append(line[4:].strip())
> global SMTPServerDisconnected = 
> SMTPServerDisconnected: Connection unexpectedly closed
>       args = ('Connection unexpectedly closed',)
> I cannot find the qmail logs. I assumed they'd be in either
> /var/qmail/supervise/qmail-send
> or
> /var/qmail/supervise/qmail-smtpd
> but I find no logs there.
>
> [SSH] Protocol Version 2 (OpenSSH_4.3)
> [SSH] Cipher: aes128-cbc
> Logged in (password)
> Last login: Tue Feb 23 05:24:00 2010 from 66.248.168.67
> [b...@13gems ~]$ su
> Password:
> [r...@13gems beno]# man netstat
> [r...@13gems beno]# netstat
> Active Internet connections (w/o servers)
> Proto Recv-Q Send-Q Local Address               Foreign Address
> State
> getnameinfo failed
> tcp        0    268 nrelectric.com:ssh          [UNKNOWN]:61912
> ESTABLISHED
> Active UNIX domain sockets (w/o servers)
> Proto RefCnt Flags       Type       State         I-Node Path
> unix  7      [ ]         DGRAM                    10842  /dev/log
> unix  2      [ ]         DGRAM                    10370
>  @/org/kernel/udev/udevd
> unix  2      [ ]         DGRAM                    6077731
> unix  3      [ ]         STREAM     CONNECTED     6077679
> unix  3      [ ]         STREAM     CONNECTED     6077678
> unix  2      [ ]         DGRAM                    6077675
> unix  2      [ ]         DGRAM                    11556
> unix  2      [ ]         DGRAM                    11511
> unix  2      [ ]         DGRAM                    10990
> [r...@13gems beno]#
>
> How do I trouble-shoot this?

Try connecting to the port that is supposed to accept mail messages
via telnet and issue a few SMTP commands.

-- 
Jonathan Gardner
jgard...@jonathangardner.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Creating variables from dicts

2010-02-23 Thread vsoler
Hi,

I have two dicts

n={'a', 'm', 'p'}
v={1,3,7}

and I'd like to have

a=1
m=3
p=7

that is, creating some variables.

How can I do this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread W. eWatson

On 2/23/2010 11:14 AM, Gib Bogle wrote:

W. eWatson wrote:

On 2/23/2010 8:26 AM, Rick Dooling wrote:

No telling what Windows will do. :)

I am a mere hobbyist programmer, but I think real programmers will
tell you that it is a bad habit to use relative paths. Use absolute
paths instead and remove all doubt.

http://docs.python.org/library/os.path.html

RD

You may be right. The actual 300 line program just reads the folder
without specifying any path. I'm not that familiar with os path, but
have seen it used.


How do you invoke the program? Do you use a Command Prompt window?

IDLE, but I'm prett sure I tried it (300 lines) with Cprompt.
--
http://mail.python.org/mailman/listinfo/python-list


Milenko Kindl and America's Worst French Fries

2010-02-23 Thread Milenko Kindl
Milenko Kindl

In spite of the name, French fries are practically an American
birthright. They’re offered as the first choice side dish with nearly
every fast-food and sit-down chain meal available. But here’s the
catch: In a recent study of 7,318 New York City patrons leaving fast
food chains during the lunch hour, researchers learned that combo meals
—meaning meals with sides—averaged 1,100 calories each, which is over
half a day’s allotment. It goes to show: When your regular meals at
these restaurants are already pushing the nutritional envelope, adding
an extra 300 (or more!) empty calories can make for a dietary
disaster.

The authors of the best-selling weight-loss series Eat This, Not That!
and Cook This, Not That! have rounded up three of the worst orders of
fries available at chain restaurants across the country. We’ve also
offered up the surprising winner of the fast food French fry cook-off—
you’ll never believe which restaurant chain produces the healthiest
fried spuds!


Worst Curly Fries
Arby’s Curly Fries (Large)
640 calories
34 g fat (5 g saturated, 0 g trans)
1,460 mg sodium

Arby’s is famous for its curly fries—too bad they’re overloaded with
fat, calories and sodium. When one side dish accounts for nearly three-
quarters of your daily allotment of salt, you know there’s a problem.
As fun as these curli-Qs are, stick to the Homefry variety at Arby’s—
downsizing to a small Curly Fries will still leave you with a 410-
calorie side, which is more than many of Arby’s sandwiches!

Bonus tip: For full nutrition information for all of your favorite
chain restaurants and thousands of foods, download the bestselling Eat
This, Not That! iPhone app. It’s like having your own personal
nutritionist in your pocket at all times, and will help you avoid the
caloric calamities and guide you to the best ways to lose your belly
fast.

Eat This Instead!
Homestyle Fries (Small)
350 calories
15 g fat (2 g saturated)
720 mg sodium


Worst Wedge Fries
Jack in the Box Bacon Cheddar Wedges
715 calories
45 g fat (13 g saturated, 1 g trans)
905 mg sodium

It doesn’t take a nutritionist to identify the hazards of a grease-
soaked, cheese-slathered sack of deep-fried potatoes, but by
appearance alone, nobody could guess what’s really at stake when you
order this side from Jack’s. The American Heart Association recommends
that people cap their trans fat intake at 1 percent of total calories.
For people on a 2,000-calorie diet, that’s about 2 grams per day. See
the problem? Another issue, of course, is the overload in calories—
about one-third your daily allotment!

Bonus tip: Cheese fries are clearly an unhealthy choice. But sometimes
healthy-seeming options are just as dangerous as the obvious diet-
sinkers. For 30 jaw-dropping examples, check out The 30 Worst
Sandwiches in America.

Eat This Instead!
Grilled Chicken Strips (4) with Fire Roasted Salsa
185 calories
2 g fat (0.5 g saturated)
805 mg sodium


Worst Fries for Your Blood Pressure
Dairy Queen Chili Cheese Fries
1,240 calories
71 g fat (28 g saturated, 0.5 g trans)
2,550 milligrams sodium

This one’s a no-brainer: Chili, cheese, fried potatoes. But even a
savvy eater couldn’t possibly anticipate how bad these 3 ingredients
could be when combined by one heavy-handed fast-food company. There’s
as much sodium in this side dish as you’ll find in 15 strips of bacon.
Stick with classic ketchup and recapture nearly a day’s worth of
sodium and 930 calories.

Bonus tip: Save calories, time, and money with our free Eat This, Not
That! newsletter. Sign up today and you’ll get the Eat This, Not That!
guide to shopping once and eating for a week for free!

Eat This Instead!
French Fries (regular)
310 calories
13 g fat (2 g saturated)
640 mg sodium


Worst Regular Order of Fries
Five Guys Fries (large)
1,464 calories
71 g fat (14 g saturated)
213 mg sodium

Unfortunately, Five Guys doesn’t offer anything but fries in the side
department. Your safest bet, of course, is to skip the fries
altogether (you’d be better off adding a second patty to your burger),
but if you can’t bring yourself to eat a burger sans fries, then split
a regular order. That will still add 310 calories to your meal, but it
beats surrendering more than 75% of your day’s calories to a greasy
paper bag.

Bonus tip: Sides account for a third of our combo-meal calories—but
drinks account for a quarter of the total calories we consume each
day! Battle the liquid bulge: Avoid all drinks on this shocking list
of The Worst Drinks in the Supermarket.

Eat This Instead!
Regular Fries (1/2 serving)
310 calories
15 g fat (3 g saturated)
45 mg sodium


Worst Fries in America
Chili’s Texas Cheese Fries w/Jalapeno Ranch
1,920 calories
147 g fat (63 g saturated)
3,580 mg sodium

The only thing that comes close to redeeming this cheesy mound of lard
and grease is the fact that it’s ostensibly meant to be shared with a
few friends. Even so, you’ll collectively be taking in an entire day’s
worth of calories, three days’

Re: Creating variables from dicts

2010-02-23 Thread Arnaud Delobelle
vsoler  writes:

> Hi,
>
> I have two dicts
>
> n={'a', 'm', 'p'}
> v={1,3,7}

These are sets, not dicts.

> and I'd like to have
>
> a=1
> m=3
> p=7

As sets are unordered, you may as well have

   a = 3
   m = 7
   p = 1

or any other permutation.  You need some sequences instead.  E.g.

   n = ['a', 'm', 'p']
   v = (1, 3, 7)

Then you can do:

   for name, value in zip(n, v):
   globals()[name] = value

After this the names, 'a', 'm' and 'p' will be bound to the values you
want in the global namespace.  However, it is almost always a bad idea
to do this.  Can you explain why you need to do this?

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


Re: What's Going on between Python and win7?

2010-02-23 Thread buggsy2
"W. eWatson"  writes:

> I noted that this search box has
> some sort of filter associated with it. Possibly, in my early stages
> of learning to navigate in Win7, I accidentally set the filter.
>
> Comments?

FYI, the only truly reliable and powerful file search utility I've found
for Windows is Agent Ransack (http://download.mythicsoft.com/agentran.exe)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating variables from dicts

2010-02-23 Thread Hai Vu
On Feb 23, 12:53 pm, vsoler  wrote:
> Hi,
>
> I have two dicts
>
> n={'a', 'm', 'p'}
> v={1,3,7}
>
> and I'd like to have
>
> a=1
> m=3
> p=7
>
> that is, creating some variables.
>
> How can I do this?

I think you meant to use the square brackets [ ] instead of the curly
ones { } to define the list:

>>> n = ['a', 'b', 'c']
>>> v = [3, 5, 7]
>>> for x, y in zip(n, v):
...  exec '%s=%d' % (x, y)
...
>>> a
3
>>> b
5
>>> c
7

---
The key is the use of the exec statement, which executes the strings
"a=3", "b=5", ... as if they are python statements.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bay Area PUG Meeting [Speaker] Thursday in Mountain View, CA?

2010-02-23 Thread W. eWatson

On 2/23/2010 7:49 AM, W. eWatson wrote:

Anyone here going to the meeting,Subject? As far as I can tell, it meets
from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to
be an informal group dinner at 6 pm at some place yet unknown. Comments?


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


Re: Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Gib Bogle

W. eWatson wrote:

On 2/23/2010 11:14 AM, Gib Bogle wrote:

W. eWatson wrote:

On 2/23/2010 8:26 AM, Rick Dooling wrote:

No telling what Windows will do. :)

I am a mere hobbyist programmer, but I think real programmers will
tell you that it is a bad habit to use relative paths. Use absolute
paths instead and remove all doubt.

http://docs.python.org/library/os.path.html

RD

You may be right. The actual 300 line program just reads the folder
without specifying any path. I'm not that familiar with os path, but
have seen it used.


How do you invoke the program? Do you use a Command Prompt window?

IDLE, but I'm prett sure I tried it (300 lines) with Cprompt.


I don't know what you mean by "300 lines".  Have you opened a Command Prompt 
window, changed to the directory where you copied the files, and executed:

python your_prog.py
?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Creating variables from dicts

2010-02-23 Thread MRAB

vsoler wrote:

Hi,

I have two dicts

n={'a', 'm', 'p'}
v={1,3,7}


Those aren't dicts, they're sets.


and I'd like to have

a=1
m=3
p=7

that is, creating some variables.

How can I do this?


The real question is not how, but why?

Anyway, assuming you want them to be global variables:

globals().update(dict(zip(n, v)))

On my machine the variables didn't get the correct values because, as I
said, 'n' and 'v' are sets, so the order of the members is arbitrary.
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's Going on between Python and win7?

2010-02-23 Thread Benjamin Kaplan
On Tue, Feb 23, 2010 at 3:35 PM, Michel Claveau - MVP
 wrote:
> Hi!
>
>> Symbolic links are available in NTFS starting with Windows Vista.
>
> No.
> Hardlink come with NTFS, and already exists in W2K (and NT with specifics 
> utilities).
>
> @-salutations
> --
> Michel Claveau
>

And there's a difference between hard links and symbolic links.
Symbolic links were added to NTFS starting with Windows Vista.

http://msdn.microsoft.com/en-us/library/aa365680%28VS.85%29.aspx

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


Re: How to transmit a crash report ?

2010-02-23 Thread Stef Mientki

On 23-02-2010 15:21, Thomas wrote:

On Feb 22, 9:27 pm, MRAB  wrote:
   

Stef Mientki wrote:
 

hello,
   
 

in my python desktop applications,
I'ld like to implement a crash reporter.
By redirecting the sys.excepthook,
I can detect a crash and collect the necessary data.
Now I want that my users sends this information to me,
and I can't find a good way of doing this.
   
 

The following solutions came into my mind:
(most of my users are on Windows, and the programs are written in Python
2.6)
   
 

1. mailto:
doesn't work if the the user didn't install a default email client,
or if the user uses a portable email client (that isn't started yet)
Besides this limits the messages to small amounts of data.
   
 

2.other mail options: smtp
AFAIK such a solution needs smtp authorization, and therefor I've to put
my username and password in the desktop application.
   

Try reading the documentation for Python's smtplib module.

You don't need to provide any password.



 

3. http-post
Although post is also limited in size,
I could store information in cookies (don't know yet how), and cookies
are sent parallel to the post message.
On the server site I can use a small php script, that stores the
post-data, cookies and/or send's a (long) email.
   
 

are there better options ?- Hide quoted text -
   

- Show quoted text -- Hide quoted text -

- Show quoted text -
 

Try http://code.activestate.com/recipes/442459/
   


Apparently there's something terrible wrong on my system, because I do 
need username and password :-(


First, a script that works without username and password.
I guess it works, because the smtp_server is the smtp server of my 
provider, and I'm in that domain of my provider,

so it won't work for a random user of my program.
  if Test ( 4 ) :
import smtplib
from email.mime.text  import MIMEText
from email.mime.multipart import MIMEMultipart

body = 'test_body'
subject  = 'test_subject'
mail_to  = 's.mien...@ru.nl'
mail_from = 'stef.mien...@gmail.com'

msg = MIMEMultipart ( 'alternative' )
msg [ 'To'  ] = mail_to
msg [ 'From'] = mail_from
msg [ 'Subject' ] = subject

part1 = MIMEText ( body, 'plain' )
msg.attach ( part1 )

smtp_server = 'mail.upcmail.nl'
session = smtplib.SMTP ( smtp_server )
session.sendmail ( mail_from, [mail_to], msg.as_string() )


Using smtp on google , works only if I support username and password:
  if Test ( 5 ) :
import smtplib
from email.mime.text  import MIMEText
from email.mime.multipart import MIMEMultipart

body = 'test_body'
subject  = 'test_subject'
mail_to  = 's.mien...@ru.nl'
mail_from = 'stef.mien...@gmail.com'

msg = MIMEMultipart ( 'alternative' )
msg [ 'To'  ] = mail_to
msg [ 'From'] = mail_from
msg [ 'Subject' ] = subject

part1 = MIMEText ( body, 'plain' )
msg.attach ( part1 )

smtp_server = 'smtp.gmail.com'
session = smtplib.SMTP ( smtp_server, 587 )
session.ehlo ( mail_from )
session.starttls ()
session.ehlo ( mail_from )
session.login (username, password )
session.sendmail ( mail_from, [mail_to], msg.as_string() )


And her a number of different tries with localhost / mail :
  if Test ( 6 ) :
import smtplib
from email.mime.text  import MIMEText
from email.mime.multipart import MIMEMultipart

body = 'test_body'
subject  = 'test_subject'
mail_to  = 's.mien...@ru.nl'
mail_from = 'stef.mien...@gmail.com'

msg = MIMEMultipart ( 'alternative' )
msg [ 'To'  ] = mail_to
msg [ 'From'] = mail_from
msg [ 'Subject' ] = subject

part1 = MIMEText ( body, 'plain' )
msg.attach ( part1 )

session = smtplib.SMTP ( 'localhost' )
"""
Traceback (most recent call last):
  File "D:\Data_Python_25\support\mail_support.py", line 375, in 
session = smtplib.SMTP ( smtp_server )
  File "P:\Python26\lib\smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
  File "P:\Python26\lib\smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
  File "P:\Python26\lib\smtplib.py", line 273, in _get_socket
return socket.create_connection((port, host), timeout)
  File "P:\Python26\lib\socket.py", line 514, in create_connection
raise error, msg
error: [Errno 10061] No connection could be made because the target 
machine actively refused it

"""
#session = smtplib.SMTP ( 'localhost', 25 )
#session = smtplib.SMTP ( 'mail', 25 )
session = smtplib.SMTP ( 'mail', 1025 )
"""
Traceback (most recent call last):
  File "D:\Data_Python_25\support\mail_support.py", line 377, in 
session = smtplib.SMTP ( 'mail', 1025 )
  File "P:\Python26\lib\smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
  File "P:\Python26\lib\smtplib.py", line 295, in connect
self.sock = self._

Re: When will Python go mainstream like Java?

2010-02-23 Thread Ben Finney
Stefan Behnel  writes:

> Chris Rebert, 23.02.2010 06:45:
> > Indeed. Python is at position 7, just behind C#, in the TIOBE Index:
> > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
>
> That index is clearly flawed. A language like PHP (whatever that is
> supposed to be comparable with) can't possibly be on the rise, can it?

Why not? What do you think the TIOBE measures, and why would PHP not be
rising by that measure?

-- 
 \ “To save the world requires faith and courage: faith in reason, |
  `\and courage to proclaim what reason shows to be true.” |
_o__)—Bertrand Russell |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem creating executable, with PyQwt

2010-02-23 Thread David Boddie
On Tuesday 23 February 2010 05:32, Gib Bogle wrote:

> David Boddie wrote:
> 
>> I have previously referred people with py2exe/PyQt issues to this page on
>> the PyQt Wiki:
>> 
>>   http://www.py2exe.org/index.cgi/Py2exeAndPyQt
>> 
>> If you can somehow convince py2exe to include the QtSvg module (and
>> presumably the libQtSvg library as well) then perhaps that will solve
>> this problem.
>> 
>> David
> 
> Thanks David, that worked a treat.  :-)

If you could update the Wiki (or maybe the py2exe Wiki, if they have one)
to say what you did, that would be useful for others in the future. Then
they'll only be one search away from the answer. :-)

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


Re: Bay Area PUG Meeting Thursday in Mountain View, CA

2010-02-23 Thread Aahz
In article ,
W. eWatson  wrote:
>
>Anyone here going to the meeting,Subject? As far as I can tell, it meets 
>from 7:30 to 9 pm. Their site shows no speaker yet, and there seems to 
>be an informal group dinner at 6 pm at some place yet unknown. Comments?

Subscribe to http://mail.python.org/mailman/listinfo/baypiggies
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] Question for you

2010-02-23 Thread Daniel Fetchinson
>> Hello, Dave;
>>
>>My name is Craig Connor and I am a senior s/w developer at Northrop
>> Grumman.
>>
>> I have a question for you. I have installed* Boost* (via the
>> Installer), and stored it into my
>>
>> C Drive inside a dir called:
>>
>> * C:\boost_1_42*
>>
>> I also installed the* Boost Jam* into a directory called:
>>
>> * C:\boost-jam-3.1.17*
>>
>> I am using 2 separate compilers in my* Win OS XP (SP3)*
>>
>> and I would like to be able to use the Python module of Boost
>>
>> in order to embed Python.h into my C++ compiler.
>>
>> The C++ compilers that I have are:
>>
>> o* Dev-cpp*, and
>>
>> o* Visual C++.net*  (of* MS Visual Studio.Net 2008*).
>>
>> Problem:
>>
>>When I compile a simple program, I keep getting the error:
>> "*pyconfig.h: No such file or directory*".
>>
>> The program I am trying to start with is (below):
>>
>> *#include *
>>
>> *#include*
>>
>> *#include*
>>
>> *using namespace std;*
>>
>> *int main( )*
>>
>> *{*
>>
>> *  cout << "Hello, Boost World!!" << endl;*
>>
>> *  boost::any a(5);*
>>
>> *  a = 7.67;*
>>
>> *  std::cout<(a)<>
>> * *
>>
>> *  system( "PAUSE" );*
>>
>> *  return 0;*
>>
>> *}*
>>
>>
>> Also:
>>
>>   I did set up my environmental config to go to the Boost dir.
>>
>> Question:
>>
>>   Do you know what am I doing wrong?
>>
>> Regards,
>>
>>Craig Connor
>>
>>720.622.2209
>>
> Hello Connor,
>
> I think you have the wrong email address - this is Python-dev, an email
> list for the development *of* Python.
>
> All the best,
>
> Michael Foord

[redirecting to python-list from python-dev]

And the fact that you are a "senior s/w developer" at Northrop Grumman
surely doesn't sound like good advertisement for said firm.

Cheers,
Daniel



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


Re: Creating variables from dicts

2010-02-23 Thread Luis M . González
On Feb 23, 5:53 pm, vsoler  wrote:
> Hi,
>
> I have two dicts
>
> n={'a', 'm', 'p'}
> v={1,3,7}
>
> and I'd like to have
>
> a=1
> m=3
> p=7
>
> that is, creating some variables.
>
> How can I do this?

You are probably coming from another language and you're not used to
python's data structures.
If you want a list of items, you use tuples or lists. Examples:

('a', 'm', 'p') ---> this is a tuple, and it's made with
parenthesis ()
['a', 'm', 'p'] ---> this is a list, and it's made with brackets
[]

Check the documentation to see the difference between tuples and
lists.
For now, lets just use lists and forget about tuples...
Now if you want a sequence of items ordered a key + value pairs, use a
dictionary, as follows:

{'name': 'joe', 'surname': 'doe', 'age': 21} ---> this is a dict,
and it's made with curly braces {}.

Curly braces are also used to create sets, but you don't need them now
(check the documentation to learn more about sets).
So going back to your question, you should have two lists, as follows:

n = ['a', 'm', 'p']
v = [1,3,7] --> note that I used brackets [], not curly
braces {}.

And now you can build a dict formed by the keys in "n" and the values
in "v":

myDict = {}   --> this is an new empty dictionary
for k,v in zip(n,v):
myDict[k] = v

This results in this dictionary: {'a': 1, 'p': 7, 'm': 3}.

Hope this helps...
Luis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Signature-based Function Overloading in Python

2010-02-23 Thread Lie Ryan
On 02/24/10 05:25, Michael Rudolf wrote:
> Just a quick question about what would be the most pythonic approach in
> this.
> 
> In Java, Method Overloading is my best friend, but this won't work in
> Python:

> So - What would be the most pythonic way to emulate this?
> Is there any better Idom than:
> 
 def a(x=None):
> if x is None:
> pass
> else:
> pass

Python's idiom for this has always been to use "if arg is None:"; but
now with the (relatively) new decorator feature, though is not yet a
popular idiom, it is now possible to do something like this:

#!/usr/bin/env python

from functools import wraps

def overloaded(func):
@wraps(func)
def overloaded_func(*args, **kwargs):
for f in overloaded_func.overloads:
try:
return f(*args, **kwargs)
except TypeError:
pass
else:
# it will be nice if the error message prints a list of
# possible signatures here
raise TypeError("No compatible signatures")

def overload_with(func):
overloaded_func.overloads.append(func)
return overloaded_func

overloaded_func.overloads = [func]
overloaded_func.overload_with = overload_with
return overloaded_func

#

@overloaded
def a():
print 'a() without args'
pass

@a.overload_with
def _(n):
# note that, just like property(), the function's name in
# the "def _(n):" line can be arbitrary, the important
# name is in the "@overloads(a)" line
print 'a() with args'
pass

a()
a(4)
a(4, 5) # ERROR: no matching signature



PS: I posted the code to recipe book, for future reference:
http://code.activestate.com/recipes/577064-simple-function-overloading-with-decorator/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spam from gmail (Was: fascism)

2010-02-23 Thread Daniel Fetchinson
>> >> Is it just me or has the spew from gmail on this list radically
>> >> increased in the last week?  Anyone else considering blocking all gmail
>> >> posts to this list?
>> >
>> > I did that a long time ago for all of the Usenet groups I read
>> > and all but one of the mailing lists I read.
>>
>> Wait, I misread the posting.  I block everything from
>> google.groups, not everything from gmail.
>
> Yes, I did that a long time ago as well.  But now there seems to be
> more and more actual spam coming from gmail.com itself.  It may just be
> a minor blip on the spam graph but I'm keeping my eye on it.
>
> Most mailing lists that I am on are pretty good at filtering spam
> before it gets to the list.  The only spam I ever see on my NetBSD
> lists are the ones that I moderate and I block them before anyone else
> sees them.  A little more pain for me in return for a lot less pain for
> everyone else.  I guess that's not possible on a list that is gatewayed
> to UseNet like this one is.
>
> Hmm.  I wonder if all the spam is coming from the NG side.  I'll have
> to look at that.  One of the reasons that I stopped reading UseNet over
> ten years ago was because of the diminishinig S/N ratio.  I have always
> felt that it was a mistake to gateway this group.

And this has to do with python programming in what way?

You, sir, are incredibly funny :)

Just 5 minutes ago you declared in a nearby thread that

> It isn't about the Python programming language so it is off topic.  So
> what if some members have an interest?  We have interest in a lot of
> things.  We all have interest in the hardware that our programs run on
> but questions about hardware are also off topic.
>
> Perhaps you don't quite grasp the point of topical discussion groups.
> They are a way of letting individuals decide for themselves what kind
> of discussions they want to be involved in.  By spamming the group this
> way you take away that freedom of choice.  It's ironic when it is done
> in the name of freedom.

Touche!

Cheers,
Daniel


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


Re: python dowload

2010-02-23 Thread monkeys paw

On 2/23/2010 3:17 PM, Tim Chase wrote:

monkeys paw wrote:

I used the following code to download a PDF file, but the
file was invalid after running the code, is there problem
with the write operation?

import urllib2
url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
a = open('adobe.pdf', 'w')


Sure you don't need this to be 'wb' instead of 'w'?


'wb' does the trick. Thanks all!

Here is the final working code, i used an index(i)
to see how many reads took place, i have to assume there is
a default buffer size:

import urllib2
a = open('adobe.pdf', 'wb')
i = 0
for line in 
urllib2.urlopen('http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'):

i = i + 1
a.write(line)

print "Number of reads: %d" % i
a.close()


NEW QUESTION if y'all are still reading:

Is there an integer increment operation in Python? I tried
using i++ but had to revert to 'i = i + 1'




for line in urllib2.urlopen(url):
a.write(line)


I also don't know if this "for line...a.write(line)" loop is doing
newline translation. If it's a binary file, you should use .read()
(perhaps with a modest-sized block-size, writing it in a loop if the
file can end up being large.)

-tkc




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


Re: Writing an assembler in Python

2010-02-23 Thread Lawrence D'Oliveiro
In message , 
Anh Hai Trinh wrote:

> On Feb 23, 10:08 am, Lawrence D'Oliveiro  
> wrote:
>>
>> Let me suggest an alternative approach: use Python itself as the
>> assembler. Call routines in your library to output the code. That way you
>> have a language more powerful than any assembler.
>>
>> See  for an example.
> 
> SyntaxError: Non-matching "#end if" in crosscode8.py:345

What mismatch? Line 345 is the last line of this routine:

def org(self, addr) :
"""sets the origin for defining subsequent consecutive memory 
contents."""
self.curpsect.setorigin(self.follow(addr))
self.lastaddr = self.curpsect.origin
return self # for convenient chaining of calls
#end org

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


Re: python dowload

2010-02-23 Thread Wes James


>
>
> NEW QUESTION if y'all are still reading:
>
> Is there an integer increment operation in Python? I tried
> using i++ but had to revert to 'i = i + 1'

i+=1


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


Re: Is this secure?

2010-02-23 Thread Lawrence D'Oliveiro
In message , mk wrote:

> I need to generate passwords and I think that pseudo-random generator is
> not good enough, frankly. So I wrote this function:

Much simpler:

import subprocess

data, _ = subprocess.Popen \
  (
args = ("pwgen", "-nc"),
stdout = subprocess.PIPE
  ).communicate()
print data

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


  1   2   >