Re: setting Referer for urllib.urlretrieve

2009-09-04 Thread E
On Aug 10, 10:21 am, samwyse wrote: > On Aug 9, 9:41 am, Steven D'Aprano > cybersource.com.au> wrote: > > On Sun, 09 Aug 2009 06:13:38 -0700,samwysewrote: > > > Here's what I have so far: > > > > import urllib > > > > class AppURLopener(urllib.FancyURLopener): > > >     version = "App/1.7" > > >

Re: How to download directly to a file?

2009-09-04 Thread kj
In <[email protected]> "Diez B. Roggisch" writes: >kj schrieb: >> I want to send a POST request and have the returned content put >> directly into a file. Is there a way to do this easily in Python? >> I've been looking at the documentation for urllib2, but I can't >> see a dire

global variable not working inside function. Increment

2009-09-04 Thread Helvin
Hi, This increment thing is driving me nearly to the nuts-stage. > < I have a function that allows me to pick points. I want to count the number of times I have picked points. global no_picked no_picked = 0 def picked(object, event): no_picked += 1 print no_picke

Re: global variable not working inside function. Increment

2009-09-04 Thread Rami Chowdhury
global no_picked no_picked = 0 def picked(object, event): no_picked += 1 print no_picked In order to be able to affect variables in the global scope, you need to declare them global inside the function, and not at the global scope. So your code should read:

Re: global variable not working inside function. Increment

2009-09-04 Thread Helvin Lui
Wow!!! Thanks a million!! It worked! = DThanks for the fast reply too! Helvin On Sat, Sep 5, 2009 at 11:52 AM, Rami Chowdhury wrote: >global no_picked >>no_picked = 0 >> >>def picked(object, event): >> no_picked += 1 >> print no_picked >> > > In order to be able t

Re: Annoying octal notation

2009-09-04 Thread NevilleDNZ
On Sep 3, 2:57 pm, James Harris wrote: > On 3 Sep, 14:26, Albert van der Horst > wrote: > > > In article > > <[email protected]>, > > James Harris   wrote: > > > > > >So you are saying that Smalltalk has r where > > >r is presumably for radix? That

Re: The future of Python immutability

2009-09-04 Thread sturlamolden
On 4 Sep, 06:20, John Nagle wrote: > > In the current CPython implementation, every object has a reference > > count, even immutable ones. This must be a writable field - and here you > > have your race condition, even for immutable objects. > >     That's an implementation problem with CPython.

Two schools in Argentina provide model for Jewish education

2009-09-04 Thread bilawal samoon
BUENOS AIRES, Argentina (JTA) -- The old Citroen on the campus of one of ORT’s two schools in Buenos Aires sits stripped to a skeleton, its doors removed, dangling wires spilling out of the dashboard. For more details www.technicaledu.blogspot.com -- http://mail.python.org/mailman/listinfo/python-

Re: The future of Python immutability

2009-09-04 Thread sturlamolden
On 3 Sep, 20:03, John Nagle wrote: >      Python doesn't have immutable objects as a general concept, but > it may be headed in that direction.  There was some fooling around > with an "immmutability API" associated with NumPy back in 2007, but > that was removed.  As more immutable types are add

Re: pexpect and unicode strings

2009-09-04 Thread Sean DiZazzo
On Sep 4, 7:11 pm, Mathew Oakes wrote: > Is there anything that can be done to make pexpect spawns send unicode lines? > > In this example they are just middot characters, but this process > needs to be able to handle languages in other character sets. > > >>> spokentext = u'Nation . Search the FO

pexpect and unicode strings

2009-09-04 Thread Mathew Oakes
Is there anything that can be done to make pexpect spawns send unicode lines? In this example they are just middot characters, but this process needs to be able to handle languages in other character sets. >>> spokentext = u'Nation . Search the FOX Nation . czars \xb7 Health care >>> \xb7 t

SEI Job Opening

2009-09-04 Thread bilawal samoon
SEI is seeking a FT, YR Photovoltaic Technical Manager. If you are a team player with a minimum of 4 years PV installation, curriculum and education development, management experience, the ability to multitask, strong verbal and written communication skills, and a sense of humor, SEI invites you to

Re: The future of Python immutability

2009-09-04 Thread Steven D'Aprano
On Fri, 04 Sep 2009 19:23:06 -0700, sturlamolden wrote: > I one did a test of NumPy's mutable arrays against Matlab's immutable > arrays on D4 wavelet transforms. On an array of 64 MB of double > precision floats, the Python/NumPy version was faster by an order of > magnitude. Is the difference b

Re: What python can NOT do?

2009-09-04 Thread Steven D'Aprano
On Fri, 04 Sep 2009 08:21:15 -0700, Mike Coleman wrote: > It is true, though, that Python > cannot be used to write arbitrarily complex one-liners, though. Incorrect. >>> exec "x=1\0while x < 5:\0 x+=1\0print x".replace('\0','\n') 5 Take (almost) any arbitrary piece of Python code. Replace all

Re: How to download directly to a file?

2009-09-04 Thread Chris Rebert
On Fri, Sep 4, 2009 at 4:35 PM, kj wrote: > In <[email protected]> "Diez B. Roggisch" > writes: > >>kj schrieb: >>> I want to send a POST request and have the returned content put >>> directly into a file.  Is there a way to do this easily in Python? >>> I've been looking at the d

Re: What python can NOT do?

2009-09-04 Thread Grant Edwards
On 2009-09-05, Steven D'Aprano wrote: > On Fri, 04 Sep 2009 08:21:15 -0700, Mike Coleman wrote: > >> It is true, though, that Python >> cannot be used to write arbitrarily complex one-liners, though. > > Incorrect. > exec "x=1\0while x < 5:\0 x+=1\0print x".replace('\0','\n') > 5 > > Take (a

Re: The future of Python immutability

2009-09-04 Thread sturlamolden
On 5 Sep, 05:12, Steven D'Aprano wrote: > Is the difference because of mutability versus immutability, or because > of C code in Numpy versus Matlab code? Are you comparing bananas and > pears? It consisted of something like this import numpy def D4_Transform(x, s1=None, d1=None, d2=None):

Re: The future of Python immutability

2009-09-04 Thread Steven D'Aprano
On Fri, 04 Sep 2009 06:36:59 -0700, Adam Skutt wrote: > Nope, preventing mutation of the objects themselves is not enough. You > also have to forbid variables from being rebound (pointed at another > object). Consider this simple example: > > -- Thread 1 -- | -- Thread 2

Re: recursive decorator

2009-09-04 Thread Michele Simionato
On Sep 4, 7:03 pm, Ethan Furman wrote: > Just to verify, using the decorator module is portable, yes? Yes, it is portable. BTW, here is what you want to do (requires decorator-3.1.2): from decorator import FunctionMaker def bindfunc(f): name = f.__name__ signature = ', '.join(FunctionM

Re: Usage of main()

2009-09-04 Thread alex23
Carl Banks wrote: > Sorry, alex, unfortunately you are wrong, although it's understandable > that you've missed this. > [...] > The speedup comes because local lookups are much faster.  Accessing a > local is a simple index operation, and a nonlocal is a pointer deref > or two, then an indexing.  

Re: possible attribute-oriented class

2009-09-04 Thread Steven D'Aprano
On Fri, 04 Sep 2009 22:37:15 +0200, Jan Kaliszewski wrote: > Named tuples (which indeed are really very nice) are read-only, but the > approach they represent could (and IMHO should) be extended to some kind > of mutable objects. What do you mean "read-only"? Do you mean immutable? What sort of

Re: What python can NOT do?

2009-09-04 Thread Steven D'Aprano
On Fri, 04 Sep 2009 22:27:39 -0500, Grant Edwards wrote: >> Take (almost) any arbitrary piece of Python code. Replace all newlines >> by nulls. Escape any quotation marks. Wrap the whole thing in quotes, >> and pass it to exec as above, and you have an arbitrarily complex >> one-liner. > > I don'

Re: recursive decorator

2009-09-04 Thread sturlamolden
On 4 Sep, 14:50, Michele Simionato wrote: > # requires byteplay by Noam Raphael > # seehttp://byteplay.googlecode.com/svn/trunk/byteplay.py > from byteplay import Code, LOAD_GLOBAL, STORE_FAST, LOAD_FAST Incrediby cool :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: The future of Python immutability

2009-09-04 Thread Steven D'Aprano
On Fri, 04 Sep 2009 20:48:13 -0700, sturlamolden wrote: > > Is the difference because of mutability versus immutability, or > > because of C code in Numpy versus Matlab code? Are you comparing > > bananas and pears? > > It consisted of something like this Your code does a lot of unnecessary wor

expy 0.1.2 released!

2009-09-04 Thread Yingjie Lan
Hi, This is to announce the release of expy 0.1.2 What's new? -- 1. allow both keywords and positional arguments to functions/methods. 2. allow wrapping up your returned value by yourself. (example is provided in tutorial) What is expy? -- expy is an expressway to exte

Re: Application-global "switches"?

2009-09-04 Thread Ethan Furman
kj wrote: I'm looking for the "best-practice" way to define application-global read-only switches, settable from the command line. The best example I can think of of such global switch is the built-in variable __debug__. This variable is visible everywhere in a program, and broadly affects it

Re: The future of Python immutability

2009-09-04 Thread sturlamolden
On 5 Sep, 07:04, Steven D'Aprano wrote: > Your code does a lot of unnecessary work if you're just trying to > demonstrate immutability is faster or slower than mutability. No ... I was trying to compute D4 wavelet transforms. I wanted to see how NumPy compared with Matlab. > How does Matlab sp

Re: The future of Python immutability

2009-09-04 Thread sturlamolden
On 5 Sep, 07:04, Steven D'Aprano wrote: > How does Matlab speed compare to Python in general? Speed-wise Matlab is slower, but it is not the interpreter limiting the speed here. -- http://mail.python.org/mailman/listinfo/python-list

Re: possible attribute-oriented class

2009-09-04 Thread Ken Newton
On Fri, Sep 4, 2009 at 9:49 PM, Steven D'Aprano wrote: ... > >> The old discussion, the above link points to, shows that such a >> dot-accessible dict-like class is something that many people need and >> repeatedly implemet it (more or less perfectly) for themselves. > > I think it's something whic

print() a list

2009-09-04 Thread DarkBlue
I am trying to get used to the new print() syntax prior to installing python 3.1: test=[["VG", "Virgin Islands, British"],["VI", "Virgin Islands, U.S."], ["WF", "Wallis and Futuna"],["EH", "Western Sahara"],["YE", "Yemen"], ["ZM", "Zambia"],["ZW", "Zimbabwe"],] #old print for z in test: if z[0

Re: print() a list

2009-09-04 Thread Mark Tolonen
"DarkBlue" wrote in message news:[email protected]... I am trying to get used to the new print() syntax prior to installing python 3.1: test=[["VG", "Virgin Islands, British"],["VI", "Virgin Islands, U.S."], ["WF", "Wallis and Futuna"],["EH", "We

Re: print() a list

2009-09-04 Thread Mark Tolonen
"DarkBlue" wrote in message news:[email protected]... I am trying to get used to the new print() syntax prior to installing python 3.1: test=[["VG", "Virgin Islands, British"],["VI", "Virgin Islands, U.S."], ["WF", "Wallis and Futuna"],["EH", "We

Re: File Handling Problem

2009-09-04 Thread SUBHABRATA BANERJEE
Dear Sir, Thank you for your kind reply. I would surely check your code. Meanwhile, I solved it using readlines() but not in your way. I will definitely have a look in your code. My solution came so smart that I felt I should not have posted this question. But I would like to know about, i) File

Re: File Handling Problem

2009-09-04 Thread Chris Rebert
On Fri, Sep 4, 2009 at 11:39 PM, SUBHABRATA BANERJEE wrote: > And one small question does Python has any increment operator like ++ in C. No. We do x += 1 instead. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list

Re: The future of Python immutability

2009-09-04 Thread Steven D'Aprano
On Fri, 04 Sep 2009 22:30:44 -0700, sturlamolden wrote: > On 5 Sep, 07:04, Steven D'Aprano > wrote: > >> How does Matlab speed compare to Python in general? > > Speed-wise Matlab is slower, but it is not the interpreter limiting the > speed here. How do you know? -- Steven -- http://mail.p

Re: print() a list

2009-09-04 Thread Dero
On Sep 5, 2:35 pm, "Mark Tolonen" wrote: > "DarkBlue" wrote in message > > news:[email protected]... > > > > >I am trying to get used to the new print() syntax prior to installing > > python 3.1: > > > test=[["VG", "Virgin Islands, British"],["VI", "

<    1   2