Re: How cai i encode url

2011-08-25 Thread Peter Otten
John Smithury wrote: > Hi pythons. > > following is my code > > # -*- coding: utf8 -*- > import urllib2 > import urllib > > url = "http://a.shanting.mobi/百家讲坛/大国医/list"; > print url > p1=u"百家讲坛".encode('utf8') > p2=u"大国医".encode('utf8') > encodeurl = "http://a.shanting.mobi/"+p1+"/"+p2+"/"+"lis

Re: is there any principle when writing python function

2011-08-25 Thread ting
On Aug 23, 7:59 am, smith jack wrote: > i have heard that function invocation in python is expensive, but make > lots of functions are a good design habit in many other languages, so > is there any principle when writing python function? > for example, how many lines should form a function? My su

How cai i encode url

2011-08-25 Thread John Smithury
Hi pythons. following is my code # -*- coding: utf8 -*- import urllib2 import urllib url = "http://a.shanting.mobi/百家讲坛/大国医/list"; print url p1=u"百家讲坛".encode('utf8') p2=u"大国医".encode('utf8') encodeurl = "http://a.shanting.mobi/"+p1+"/"+p2+"/"+"list"; print encodeurl mp3file = urllib2.urlopen(en

Re: Learning python reading software source code

2011-08-25 Thread Michael Hunter
On Thu, Aug 25, 2011 at 8:31 PM, Chetan Harjani wrote: [read book, picked miro to read through] > So I am looking for suggestions on how one can understand the code better. > Any specific references I should look in as I stumble upon libraries n > functions while reading or just the python officia

Learning python reading software source code

2011-08-25 Thread Chetan Harjani
Hello friends, I have learned the basic syntax of python through the book HOW TO THINK LIKE A COMPUTER SCIENTIST n by reading first 10-11 chapters of Apress-BEGINNING PROGRAMMING FROM NOVICE TO PROFESSIONAL. (btw it was really very boring) I am looking forward to learn further by understanding so

Re: [OT-ish] Design principles: no bool arguments

2011-08-25 Thread Roy Smith
In article <4e55f604$0$29973$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > [1] This is the Internet. There's *always* a certain amount of disagreement. No there's not. -- http://mail.python.org/mailman/listinfo/python-list

Re: Design principles: no bool arguments

2011-08-25 Thread Ian Kelly
On Thu, Aug 25, 2011 at 3:29 AM, Thomas 'PointedEars' Lahn wrote: > Both variants work (even in Py3) if you only define > > class Data(object): >  def merge_with(self, bar, overwrite_duplicates): >    pass > > data1 = Data() > data2 = Data() > > You have to define > > class Data(object): >  def me

Re: Run time default arguments

2011-08-25 Thread Chris Angelico
On Fri, Aug 26, 2011 at 6:54 AM, wrote: > def doSomething(debug=None): >  debug = coalesce(debug,defaults['debug']) >  # blah blah blah > It won't work with a True/False flag, but if you can guarantee that all real options will evaluate as True, you can use a simpler notation: def doSomething(o

Re: Run time default arguments

2011-08-25 Thread ting
On Aug 25, 10:35 am, Arnaud Delobelle wrote: > You're close to the usual idiom: > > def doSomething(debug=None): >     if debug is None: >         debug = defaults['debug'] >     ... > > Note the use of 'is' rather than '==' > HTH Hmm, from what you are saying, it seems like there's no elegant wa

Re: Adding a ranking based on two fields

2011-08-25 Thread Chris Rebert
On Thu, Aug 25, 2011 at 1:38 PM, noydb wrote: > Hello All, > > Looking for some advice/ideas on how to implement a ranking to a > 'scores' field I have.  So this scores field has values ranging from > 1.00-4.  There is also a count field.  I want to add a rank field such > that all the records hav

Adding a ranking based on two fields

2011-08-25 Thread noydb
Hello All, Looking for some advice/ideas on how to implement a ranking to a 'scores' field I have. So this scores field has values ranging from 1.00-4. There is also a count field. I want to add a rank field such that all the records have a unique ranking, 1 through the number of records (thous

Re: Disable pop up menu that triggers upon pressing tab,

2011-08-25 Thread Chris Rebert
On Thu, Aug 25, 2011 at 11:43 AM, Emory Watts wrote: > Hello, I tried to find out how to do this on my own, but searching around > turned up no results. And this is the only way I saw to get a question > answered. I would like know how to disable the pop up predictions menu that > appears when I p

Re: Design principles: no bool arguments

2011-08-25 Thread Thomas 'PointedEars' Lahn
Stefan Behnel wrote: > Thomas 'PointedEars' Lahn, 25.08.2011 11:29: >> Stefan Behnel wrote: >>> It's totally unreadable to find this in the code: >>> >>> data1.merge_with(data2, true); >>> >>> Requires you to either a) know the underlying signature by heart, or b) >>> look it up before under

Python-URL! - weekly Python news and links (Aug 25)

2011-08-25 Thread Cameron Laird
[Original draft by Gabriel Genellina.] QOTW: "Python is a programming language, not an ice cream shop." - Steven D'Aprano, 2011-08-10, on providing the language with just "more choices" Comparing the relative speed of `i += 1` and `i = i + 1` http://groups.google.com/group/comp.lang.

Disable pop up menu that triggers upon pressing tab,

2011-08-25 Thread Emory Watts
Hello, I tried to find out how to do this on my own, but searching around turned up no results. And this is the only way I saw to get a question answered. I would like know how to disable the pop up predictions menu that appears when I press tab. I would much rather just be able to tab over, and I

Re: Design principles: no bool arguments

2011-08-25 Thread Stefan Behnel
Thomas 'PointedEars' Lahn, 25.08.2011 11:29: Stefan Behnel wrote: It's totally unreadable to find this in the code: data1.merge_with(data2, true); Requires you to either a) know the underlying signature by heart, or b) look it up before understanding the code. It's a lot harder to argue

Re: Getting a module's code object

2011-08-25 Thread Arnaud Delobelle
On 25 August 2011 16:07, Peter Otten <__pete...@web.de> wrote: > Arnaud Delobelle wrote: > >> In Python 3, a function f's code object can be accessed via f.__code__. >> >> I'm interested in getting a module's code object, [...] > > Taken from pkgutil.py: > > def read_code(stream): >    # This helpe

Re: Getting a module's code object

2011-08-25 Thread Peter Otten
Arnaud Delobelle wrote: > In Python 3, a function f's code object can be accessed via f.__code__. > > I'm interested in getting a module's code object, i.e. the code that > is executed when the module is run. I don't think it's accessible via > the module object itself (although I would be glad

Re: [OT-ish] Design principles: no bool arguments

2011-08-25 Thread Terry Reedy
On 8/25/2011 3:13 AM, Steven D'Aprano wrote: One design principle often mentioned here (with a certain degree of disagreement[1]) is the idea that as a general rule, you shouldn't write functions that take a bool argument to switch between two slightly different behaviours. This is a principle o

Re: Immediate Requirement for a Data Warehouse Developer

2011-08-25 Thread Philip Semanchuk
On Aug 25, 2011, at 9:24 AM, Sirisha wrote: > Position Profile – Senior Data Warehouse Developer As was mentioned on the list less than 24 hours ago, please don't post job listings to this mailing list. Use the Python jobs board instead: http://www.python.org/community/jobs/ -- http://mail.p

Re: Run time default arguments

2011-08-25 Thread MRAB
On 25/08/2011 15:30, t...@thsu.org wrote: What is the most common way to handle default function arguments that are set at run time, rather than at compile time? The snippet below is the current technique that I've been using, but it seems inelegant. defaults = { 'debug' : false } def doSomethin

Re: Run time default arguments

2011-08-25 Thread Arnaud Delobelle
On Aug 25, 3:30 pm, t...@thsu.org wrote: > What is the most common way to handle default function arguments that > are set at run time, rather than at compile time? The snippet below is > the current technique that I've been using, but it seems inelegant. > > defaults = { 'debug' : false } > def do

Run time default arguments

2011-08-25 Thread ting
What is the most common way to handle default function arguments that are set at run time, rather than at compile time? The snippet below is the current technique that I've been using, but it seems inelegant. defaults = { 'debug' : false } def doSomething (debug = None): debug = debug if debug

Getting a module's code object

2011-08-25 Thread Arnaud Delobelle
Hi all, In Python 3, a function f's code object can be accessed via f.__code__. I'm interested in getting a module's code object, i.e. the code that is executed when the module is run. I don't think it's accessible via the module object itself (although I would be glad if somebody proved me wron

Re: How to run a setup command with 'pip install'?

2011-08-25 Thread Andrei
'pip install pyrex' solved the problem (credit to @jezdez) -- http://mail.python.org/mailman/listinfo/python-list

Immediate Requirement for a Data Warehouse Developer

2011-08-25 Thread Sirisha
Position Profile – Senior Data Warehouse Developer Location: Detroit, MI Contact: Please send resumes to resu...@rg-llc.com or call 313.254.4631 Purpose  Assist with analysis, design, development and implementation of projects for the corporate data warehouse  Partner with the DBA t

How to run a setup command with 'pip install'?

2011-08-25 Thread Andrei
Hello, I have a trouble installing the DMSL package with pip. The package doesn't have *.c files, which must be produced with Cython by 'pyhton setup.py build_ext' command. How do I run it with 'pip install'? Please see http://stackoverflow.com/questions/7189336/ for details. Regards, Andrei -

Re: PUT with proxy-support

2011-08-25 Thread Max Countryman
Check out the python Requests module: http://docs.python-requests.org/en/latest/index.html Sent from my iPhone On Aug 25, 2011, at 7:07, Shashwat Anand wrote: > I want to make a PUT request. > I need some headers of my own ( certificates etc ) and I need to mandatorily > use a proxy. > Also t

Re: PUT with proxy-support

2011-08-25 Thread Shashwat Anand
On Thu, Aug 25, 2011 at 5:22 PM, Laszlo Nagy wrote: > ** > > I tried httplib, httplib2, urllib2 with no avail. > I managed to do this via command line curl: > > $ curl http:/xyz.com/testing/shashwat/test.txt -T test.txt -H > "sw-version: 1.0" -H > "CA-Cert-Auth:v=1;a=yxyz.prod;h=10.10.0.1;t=131

Re: PUT with proxy-support

2011-08-25 Thread Laszlo Nagy
I tried httplib, httplib2, urllib2 with no avail. I managed to do this via command line curl: $ curl http:/xyz.com/testing/shashwat/test.txt -T test.txt -H "sw-version: 1.0" -H "CA-Cert-Auth:v=1;a=yxyz.prod;h=10.10.0.1;t=1316594650;s=.AeEYJMMfElN74f

Re: PUT with proxy-support

2011-08-25 Thread Shashwat Anand
On Thu, Aug 25, 2011 at 4:48 PM, Max Countryman wrote: > Check out the python Requests module: > http://docs.python-requests.org/en/latest/index.html > > Python request module is not documented very well IMHO. I tried to figure how to make PUT calls, how to add proxy, how to add certificates in h

Re: PUT with proxy-support

2011-08-25 Thread Shashwat Anand
On Thu, Aug 25, 2011 at 4:48 PM, Thomas Jollans wrote: > On 25/08/11 13:07, Shashwat Anand wrote: > > I want to make a PUT request. > > I need some headers of my own ( certificates etc ) and I need to > > mandatorily use a proxy. > > Also the url is of the form http://www.xyz.com/abc and I don't

Re: PUT with proxy-support

2011-08-25 Thread Thomas Jollans
On 25/08/11 13:07, Shashwat Anand wrote: > I want to make a PUT request. > I need some headers of my own ( certificates etc ) and I need to > mandatorily use a proxy. > Also the url is of the form http://www.xyz.com/abc and I don't have > permission to put data > on http://www.xyz.com while I do ha

PUT with proxy-support

2011-08-25 Thread Shashwat Anand
I want to make a PUT request. I need some headers of my own ( certificates etc ) and I need to mandatorily use a proxy. Also the url is of the form http://www.xyz.com/abc and I don't have permission to put data on http://www.xyz.com while I do have permission to put data on http://www.xyz.com/abc

Re: Design principles: no bool arguments

2011-08-25 Thread Thomas 'PointedEars' Lahn
Stefan Behnel wrote: > Maarten, 25.08.2011 09:52: >> On Aug 25, 9:13 am, Steven D'Aprano wrote: >>> One design principle often mentioned here (with a certain degree of >>> disagreement[1]) is the idea that as a general rule, you shouldn't write >>> functions that take a bool argument to switch bet

Re: bash command, get stdErr

2011-08-25 Thread Chris Rebert
On Thu, Aug 25, 2011 at 1:25 AM, Tracubik wrote: > Hi all! > i'ld like to execute via Python this simple bash command: > > sudo las > > las is intended to be a typo for "ls" > > the point is that i want to see in the terminal the stderr message (that > is "sorry, try again" if i insert the wrong p

bash command, get stdErr

2011-08-25 Thread Tracubik
Hi all! i'ld like to execute via Python this simple bash command: sudo las las is intended to be a typo for "ls" the point is that i want to see in the terminal the stderr message (that is "sorry, try again" if i insert the wrong password or "sudo: las: command not found" otherwise) i can sim

Re: Design principles: no bool arguments

2011-08-25 Thread Stefan Behnel
Maarten, 25.08.2011 09:52: On Aug 25, 9:13 am, Steven D'Aprano wrote: One design principle often mentioned here (with a certain degree of disagreement[1]) is the idea that as a general rule, you shouldn't write functions that take a bool argument to switch between two slightly different behaviou

Re: Design principles: no bool arguments

2011-08-25 Thread Maarten
On Aug 25, 9:13 am, Steven D'Aprano wrote: > One design principle often mentioned here (with a certain degree of > disagreement[1]) is the idea that as a general rule, you shouldn't write > functions that take a bool argument to switch between two slightly > different behaviours. > > This is a pri

[OT-ish] Design principles: no bool arguments

2011-08-25 Thread Steven D'Aprano
One design principle often mentioned here (with a certain degree of disagreement[1]) is the idea that as a general rule, you shouldn't write functions that take a bool argument to switch between two slightly different behaviours. This is a principle often championed by the BDFL, Guido van Rossum.