Re: Sending username password to a webpage

2008-11-20 Thread Chris Rebert
On Thu, Nov 20, 2008 at 7:52 PM, KDawg44 <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a way to essentially simulate populating a text box and > calling a submit button on a webpage? I want to write an app that > gets a users information from a website and then uses that to get > information from

Re: Optional parameter object re-used when instantiating multiple objects

2008-11-20 Thread Chris Rebert
On Thu, Nov 20, 2008 at 9:26 PM, alex23 <[EMAIL PROTECTED]> wrote: > On Nov 21, 10:07 am, Aaron Brady <[EMAIL PROTECTED]> wrote: >> Why, I would expect the interpreter to define the functions when it >> first hits the def, that is, at the point of definition. > > Then why are you arguing that the p

Re: initialization in argument definitions

2008-11-21 Thread Chris Rebert
On Fri, Nov 21, 2008 at 1:25 PM, Brentt <[EMAIL PROTECTED]> wrote: > Hi, I know this is a terribly simple question, but the docs seem to be > designed for people who probably find a the answer to this question > terribly obvious. But its not at all obvious to me. > > I can't figure out why when I d

Re: opening files with names in non-english characters.

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 5:51 AM, [email protected] wrote: > Hi all, > I am trying to find the attributes of afile whose name has > non english characters one like given below. When I try to run my > python scirpt, it fails giving out an error filename must be in string > or UNICODE.

Re: Peculiar swap behavior

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 10:43 AM, Tim Chase wrote: > # swap list contents...not so much... m,n = [1,2,3],[4,5,6] m[:],n[:] = n,m m,n > ([4, 5, 6], [4, 5, 6]) Pseudo-C-Python expansion: #evaluate RHS. simply *take pointers* since the RHS is just plain variables ptr_n = &n ptr_m = &

Re: Need to store dictionary in file

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 12:38 PM, S.Selvam Siva wrote: > Hi all, > > I have a dictionary in which each key is associated with a list as value. > > eg: dic={'a':['aa','ant','all']} > > The dictionary contains 1.5 lakh keys. Tip: You might not want to use the "lakh" in international media such as i

Re: Can someone tell me why i get None at the end please this has me stuck for ages

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 11:22 AM, Gary Wood wrote: > '''exercise to complete and test this function''' > import string > def joinStrings(items): > '''Join all the strings in stringList into one string, > and return the result. For example: > >>> print joinStrings(['very', 'hot', 'day']

Re: intermediate python csv reader/writer question from a beginner

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 1:33 PM, Learning Python wrote: > anything related to csv, I usually use VB within excel to manipulate > the data, nonetheless, i finally got the courage to take a dive into > python. i have viewed a lot of googled csv tutorials, but none of > them address everything i nee

Re: more on unescaping escapes

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there any particular reason you can't just internally use regular forward-slashes for the paths? They work in Windows from Python in nearly all cases and you can easily interconvert using os.

Re: Problem in accessing files with unicode fonts.

2009-02-23 Thread Chris Rebert
A. Your reason for emailing us off-list makes no sense. The list would garner you more and about as quick responses, not to mention the value it adds through public archiving. CC-ing us /might/ have made slight sense. B. This is your problem: v = unicode(full_path,errors='skip') I'd advise you

Re: How to read columns in python

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 10:41 PM, Dhananjay wrote: > I am bit new to python and programming and this might be a basic question: > > I have a file containing 3 columns. Your question is much too vague to answer. What defines a "column" for you? Tab-separated, comma-separated, or something else alt

Re: Newby - is this what they are looking for ?? and is their a better a way

2009-02-24 Thread Chris Rebert
On Tue, Feb 24, 2009 at 4:54 AM, Gary Wood wrote: > ''' program. > 1.What type of data will the input be? What type of data will the output be? > 2.Get the phrase from the user. > 3.Convert to upper case. > 4.Divide the phrase into words. > 5.Initialize a new empty list, letters. > 6.Get the first

Re: Accessing callers context from callee method

2009-02-24 Thread Chris Rebert
On Tue, Feb 24, 2009 at 10:53 AM, wrote: > when i call a method foo from another method func. can i access func context > variables or locals() from foo > so > def func(): >   i=10 >   foo() > > in foo, can i access func's local variables on in this case i You can, but it's an evil hack that I w

Re: Is there any equivalent feature available in Python..?

2009-02-24 Thread Chris Rebert
On Tue, Feb 24, 2009 at 11:05 AM, wrote: > Hi, > > Is there any Python equivalent of java jar,can I include all my > sources,properties file etc into a single file.Is there anyway in > Python that I can run like the following > > java  -jar Mytest.jar --startwebserver > > How to so something like

Re: Run a linux system command as a superuser, using a python script

2009-02-24 Thread Chris Rebert
On Tue, Feb 24, 2009 at 11:38 AM, madhav wrote: > I have got postfix installed on my machine and I am updating on of its > configuration files programmatically(using python)(on some action). > Since any change in the configuration needs a reload, I need to reload > postfix to reflect the latest ch

Re: Convert PySerial to python 3.0

2009-02-24 Thread Chris Rebert
On Tue, Feb 24, 2009 at 7:46 PM, Seth wrote: > I am just messing around trying to get pyserial to work with 3.0. > > I am stuck on this line: > > if type(port) in [type(''), type(u'')] > > > how can I convert this to 3.0? I tried changing the u to a d that did > not do anything. Looks like it's d

Re: variable length tuple assignment

2009-02-25 Thread Chris Rebert
On Wed, Feb 25, 2009 at 1:16 AM, Helmut Jarausch wrote: > Sorry if this is too simple but I couldn't find. > > I vaguely remember there is a means to assign a variable length tuple > and catch the 'rest'  like > > S="a,b,c,d" > > (A,B,) = S.split(',') In Python 3.0 (IIRC): A, B, *rest = S.split(

Re: coding style - try, except

2009-02-25 Thread Chris Rebert
On Wed, Feb 25, 2009 at 9:36 AM, RGK wrote: > > I'm still learning, so eager to see if there is some community wisdom about > use of the try/except structures in this situation. > > I find myself with some potentially risky stuff and wrap it in a try/except > structure with good functional results

Re: i have problem with glob.glob() in remotely directory

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 1:05 AM, lameck kassana wrote: > hey i want to count number of files in remote computer > > example of my code is > > import glob > import os > import time > from datetime import date > today=date.today() > dir_count, file_count=0, 0 > > for files in glob.glob('\\192.168.0.

Re: subprocess module: execution of standard binaries without shell?

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 2:41 AM, Visco Shaun wrote: > hi all > > while getting used to with subprocess module i failed in executuing a) > but succeeded in running b). Can anyone explain me why as i am providing > absolute path? Is this has to do anything with shared library.. which > must be acces

Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 3:05 AM, Clarendon wrote: > Hi. This must be a simple command but I just can't find it in the > Phthon manual. How do I delete all items with a certain condition from > a list? For instance: > > L=['a', 'b', 'c', 'a'] > > I want to delete all 'a's from the list. > But if L.

Re: How to parse form in client side?

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 12:19 PM, Muddy Coder wrote: > Hi Folks, > > cgi module can easily acquire the all fields of data input from client > side, through a form. Then, a simple line of code: > > form_dict = cgi.FieldStorage() > > grabs all data into a dictionary form_dict. The rest becomes a pie

Re: Can someone explain this behavior to me?

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 1:48 PM, Jesse Aldridge wrote: > I have one module called foo.py > - > class Foo: >    foo = None > > def get_foo(): >    return Foo.foo > > if __name__ == "__main__": >    import bar >    Foo.foo = "foo" >    bar.go() > - > And anoth

Re: PythonWin -vs- Idle

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 2:23 PM, Gary Schells wrote: > > Hello, > Python newbie here.  I am working with Python and geoprocessing in ArcGIS. > I'm taking a training course online and the exercise I'm working on makes > mention of using PythonWin instead of Idle. > > I am using version 2.5 and have

Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam wrote: > On 2009-02-26, Clarendon wrote: >> Hi. This must be a simple command but I just can't find it in the >> Phthon manual. How do I delete all items with a certain condition from >> a list? For instance: > L=['a', 'b', 'c', 'a'] >> I want to dele

Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 4:37 PM, Gabriel Genellina wrote: > En Thu, 26 Feb 2009 22:18:18 -0200, Chris Rebert > escribió: >> >> On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam >> wrote: >>> >>> On 2009-02-26, Clarendon wrote: >>>> >>>

Re: Using xreadlines

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 4:32 PM, Brett Hedges wrote: > > Hi, > > I am using both xreadlines and files iterators for a script that I need to > finish. I am iterating over the entire file but stopping to use xreadlines to > grab certain lines as strings to process them. > > My question is how do I

Re: Multiple conditional expression

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 7:11 PM, Anjanesh Lekshminarayanan wrote: > How do I achieve something like this using python ? > spaces = (form.has_key('spaces') ? form.getvalue('spaces') == 1 ? True > : False : False) > > spaces = True if form.getvalue('spaces') == 1 if > form.has_key('spaces') else Fal

Re: Multiple conditional expression

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 8:39 PM, Anjanesh Lekshminarayanan wrote: >> How do we know that from the what the OP posted? > Its CGI alright. > spaces = form.has_key('spaces') and form.getvalue('spaces') == '1' > > But I just dont see how > spaces = (form.has_key('spaces') ? form.getvalue('spaces') ==

Re: removing duplication from a huge list.

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 8:49 PM, Benjamin Peterson wrote: > Shanmuga Rajan gmail.com> writes: > >> f any one suggests better solution then i will be very happy.Advance thanks > for any help.Shan > > Use a set. To expand on that a bit: counted_recs = set(rec[0] for rec in some_fun()) #or in Pyth

Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 10:26 PM, odeits wrote: > On Feb 26, 3:05 am, Clarendon wrote: >> Hi. This must be a simple command but I just can't find it in the >> Phthon manual. How do I delete all items with a certain condition from >> a list? For instance: >> >> L=['a', 'b', 'c', 'a'] >> >> I want

Re: decimal to string conv

2009-02-27 Thread Chris Rebert
On Fri, Feb 27, 2009 at 1:45 AM, Aj wrote: > Hi all, > > I am trying to convert a list to string. > example [80, 89,84,72,79,78,0] is my input. I could make it to just > [0x50,0x59,0x54,0x48,0x4F,0x4E,0x00]. > but I wanted it to be like "PYTHON". > I couldnt even convert 0x50 to 'P'. Is there any

Re: Delete all items in the list

2009-02-27 Thread Chris Rebert
On Fri, Feb 27, 2009 at 5:10 AM, Steve Holden wrote: > Chris Rebert wrote: >> On Thu, Feb 26, 2009 at 10:26 PM, odeits wrote: > [...] >>> while 'a' in L: >>>   L.remove('a') >>> >>> not the most efficient but it works >>

Re: Make a python property with the same name as the class member name

2009-02-27 Thread Chris Rebert
On Fri, Feb 27, 2009 at 5:59 AM, Ravi wrote: > Is it possible in python to create a property with the same name as > the member variable name of the class. e.g. No, because accessing the property and the instance variable are *syntactically identical* (it's the raison detre of properties) so ther

Re: cannot execute binary file (Python 3.0.1)

2009-03-01 Thread Chris Rebert
On Sun, Mar 1, 2009 at 12:04 AM, cf29 wrote: > Greetings, > On Mac OS 10.5.6, I updated Python to version 3.0.1. > When I want to run a py file, I get an error: > xxx:~ xxx$ cd '/Users/xxx/Documents/programmingPractice/' && '/usr/ > local/bin/python'  '/Users/xxx/Documents/programmingPractice/ > p

Re: Iterator class to allow self-restarting generator expressions?

2009-03-01 Thread Chris Rebert
On Sun, Mar 1, 2009 at 8:54 AM, Gabriel Genellina wrote: > En Sun, 01 Mar 2009 13:20:28 -0200, John O'Hagan > escribió: > >> Inspired by some recent threads here about using classes to extend the >> behaviour of iterators, I'm trying to replace some some top-level >> functions >> aimed at doing s

Re: Reason why co_filename is no longer interned?

2009-03-01 Thread Chris Rebert
On Sun, Mar 1, 2009 at 5:03 PM, David Christian wrote: > In 2005, when the ast branch was merged to head, compile.c > > when setting the filename for the code object, > PyString_InternFromString was replaced with PyString_FromString. > > http://svn.python.org/view?view=rev&revision=39758 > > This

Re: Can CleintForm work with webbrowser?

2009-03-01 Thread Chris Rebert
On Sun, Mar 1, 2009 at 9:36 PM, Muddy Coder wrote: > Hi Folks, > > ClientForm is cool at grabbing and parsing stuff from server, I like > it. After the stuff parsed, and even filled values for the Controls, I > popped up an idea of displaying what I had done with webbrowser. Look > at the code: >

Re: os module

2009-03-02 Thread Chris Rebert
On Mon, Mar 2, 2009 at 12:26 AM, M Kumar wrote: > > Hi, > > I am writing a server side program, clients can be any machine but the > server machine is Linux. In program I want to use the OS module based on the > client's operating system. But when I do "import os" m only able to get the > module w

Re: os module

2009-03-02 Thread Chris Rebert
> On Mon, Mar 2, 2009 at 1:59 PM, Chris Rebert wrote: >> >> On Mon, Mar 2, 2009 at 12:26 AM, M Kumar wrote: >> > >> > Hi, >> > >> > I am writing a server side program, clients can be any machine but the >> > server machine is Lin

Re: os module

2009-03-02 Thread Chris Rebert
> On Mon, Mar 2, 2009 at 2:17 PM, Chris Rebert wrote: >> >> > On Mon, Mar 2, 2009 at 1:59 PM, Chris Rebert wrote: >> >> >> >> On Mon, Mar 2, 2009 at 12:26 AM, M Kumar wrote: >> >> > >> >> > Hi, >> >> >

Re: os module

2009-03-02 Thread Chris Rebert
> On Mon, Mar 2, 2009 at 2:31 PM, Chris Rebert wrote: >> > On Mon, Mar 2, 2009 at 2:17 PM, Chris Rebert wrote: >> >> > On Mon, Mar 2, 2009 at 1:59 PM, Chris Rebert >> >> > wrote: >> >> >> On Mon, Mar 2, 2009 at 12:26 AM, M Kumar >&

Re: Attribute error-- but I'm innocent(?)

2009-03-02 Thread Chris Rebert
On Mon, Mar 2, 2009 at 4:56 PM, Nick Mellor wrote: > Hi all, > > I'm pretty sure I'm following all the Python rules: I've put "self" > before "forename" to make sure it's treated as a data attribute > (instance variable.) And from within a class, I'm told, you need to > prefix the var with self to

Re: Pickle Problem

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 1:52 AM, Fab86 wrote: > Hello, > > I am new to using Python and am looking at exporting some of my code > into a seperate document. > > The code I am using for the pickle is: > > file = open('testdoc.txt', 'w') > > pickle.dump(res1.total_results_available,file) > pickle.dump

Re: Get bound method by name

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 3:12 AM, Johannes Bauer wrote: > Hello group, > > I'm looking for a Python function but have forgotten it's name. > Essentially what I want is: > > class Foo(): >        def bar(self): >                pass > > x = Foo() > y = x.MAGIC("bar") getattr() is the function you se

Re: Indentifying types?

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 9:03 AM, Mike Driscoll wrote: > - Show quoted text - > On Mar 3, 10:57 am, Oltmans wrote: >> I'm reading from a file that contains text like >> >> >> 5 >> google_company >> apple_fruit >> pencil_object >> 4 >> test_one >> tst_two >> >> >> When I read the integer 5

Re: Perl-python regex-performance comparison

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 9:05 AM, Ivan wrote: > Hello everyone, > > I know this is not a direct python question, forgive me for that, but > maybe some of you will still be able to help me. I've been told that > for my application it would be best to learn a scripting language, so > I looked around a

Re: Get bound method by name

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 12:54 PM, Steve Holden wrote: > Graham Breed wrote: >> Johannes Bauer wrote: >>> Hello group, >>> >>> I'm looking for a Python function but have forgotten it's name. >>> Essentially what I want is: >>> >>> class Foo(): >>>     def bar(self): >>>         pass >>> >>> x = Foo(

Re: random module gives same results across all configurations?

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 6:59 PM, Amir Michail wrote: > Hi, > > Is it the case that the random module will always give the same > results if given the same seed across all configurations (e.g., > architectures, compilers, etc.)? Your question is vague. Define what you mean by "same results" in this

Re: random module gives same results across all configurations?

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 7:11 PM, Amir Michail wrote: > On Mar 3, 10:05 pm, Chris Rebert wrote: >> On Tue, Mar 3, 2009 at 6:59 PM, Amir Michail wrote: >> > Hi, >> >> > Is it the case that the random module will always give the same >> > results if giv

Re: How to create Standalone PYC File

2009-03-04 Thread Chris Rebert
On Wed, Mar 4, 2009 at 11:38 AM, Rohan Hole wrote: > I have .py file which uses some third party modules like egg files, like > simplejson and python-twitter , > > - start of file  - > > import ConfigParser > import getopt > import os > import sys > import twitter > > > when i compile this

Re: Question about binary file reading

2009-03-04 Thread Chris Rebert
On Wed, Mar 4, 2009 at 2:58 PM, vibgyorbits wrote: > I'm writing a tool to do some binary file comparisons. > I'm opening the file using > > fd=open(filename,'rb') > > # Need to seek to 0x80 (hex 80th) location > > fd.seek(0x80) > > # Need to read just 8 bytes and get the result back in hex format

Re: why python doesn't have a writeline() method like c# ?

2009-03-04 Thread Chris Rebert
On Wed, Mar 4, 2009 at 4:46 PM, ww wrote: > just curious, it would make writing to a file  a bit easier? Because we have print(), which adds the newline, and most other cases either involve lists of stuff (so '\n'.join() is used), or the string comes back from a library and already has newlines,

Re: PyPI editing

2009-03-05 Thread Chris Rebert
On Wed, Mar 4, 2009 at 11:42 PM, andrew cooke wrote: > > Not sure where to ask this, but how do I edit my PyPI page? > > http://pypi.python.org/pypi/LEPL/2.0 doesn't have any text compared to > http://pypi.python.org/pypi/pypp/0.0.2 (selected at random).  How do I the > "Benefits", "Drawbacks" etc

Re: While loop

2009-03-05 Thread Chris Rebert
On Thu, Mar 5, 2009 at 9:49 AM, Fab86 wrote: > On Mar 5, 5:23 pm, Marco Mariani wrote: >> Fab86 wrote: >> > Is it possible to get the program to catch the exception, wait 10 >> > seconds, then carry of from where it was rather than starting again? > using sleep and then continue just makes the s

Re: alias method definitions / syntactic sugar suggestion

2009-03-05 Thread Chris Rebert
On Thu, Mar 5, 2009 at 6:17 PM, Tennessee Leeuwenburg wrote: > I'm not sure if this problem I face affects many other people, but I'll just > describe it and see what kind of feedback I get. > > I have a suggestion for a new piece of Python syntax when defining methods. > I have seen the following

Re: Modify an exception before re-raising it

2009-03-05 Thread Chris Rebert
On Thu, Mar 5, 2009 at 10:29 PM, Steven D'Aprano wrote: > I wish to catch an exception, modify the error message, and re-raise it. > There are two ways I know of to do this, with subtly different effects: > def raise_example1(): > ...     try: > ...             None() > ...     except TypeErr

Re: how to prevent python import from looking into the current directory

2009-03-06 Thread Chris Rebert
On Fri, Mar 6, 2009 at 1:33 AM, TP wrote: > Hi everybody, > > I would like to prevent the loading of modules in the current directory. > For example, if I have a personal module in the current directory > named "os", when I do "import os", I would like Python to import os > standard module, not my

Re: Is there a better way of doing this?

2009-03-06 Thread Chris Rebert
On Fri, Mar 6, 2009 at 2:19 AM, mattia wrote: > Hi, I'm new to python, and as the title says, can I improve this snippet > (readability, speed, tricks): > > def get_fitness_and_population(fitness, population): >    return [(fitness(x), x) for x in population] > > def selection(fitness, population)

Re: Is there a better way of doing this?

2009-03-06 Thread Chris Rebert
On Fri, Mar 6, 2009 at 3:07 AM, mattia wrote: > Great, the for statement has not to deal with fap anymore, but with > another sequence, like this: > > def get_roulette_wheel(weight_value_pairs): >    roulette_wheel = [] >    for weight, value in weight_value_pairs: >        roulette_wheel += [valu

Re: Is there a better way of doing this?

2009-03-06 Thread Chris Rebert
On Fri, Mar 6, 2009 at 3:52 AM, mattia wrote: > Il Fri, 06 Mar 2009 03:43:22 -0800, Chris Rebert ha scritto: > >> On Fri, Mar 6, 2009 at 3:07 AM, mattia wrote: >>> Great, the for statement has not to deal with fap anymore, but with >>> another sequence, like this:

Re: datetime question

2009-03-06 Thread Chris Rebert
On Fri, Mar 6, 2009 at 7:24 AM, wrote: > Just curious if this is the best way to get the first 3 letters of the > current month? > import datetime d = datetime.date.today() m = d.strftime("%B")[:3].upper() m > 'MAR' I believe you want the lowercase version, "%b" (Locale

Re: help with printing to stdout...

2009-03-08 Thread Chris Rebert
On Sun, Mar 8, 2009 at 1:37 AM, Daniel Dalton wrote: > Hi, > > I've got a program here that prints out a percentage of it's > completion. Currently with my implimentation it prints like this: > 0% > 1% > 2% > 3% > 4% > > etc taking up lots and lots of lines of output... So, how can I make it > wri

Re: How to extract some text?

2009-03-08 Thread Chris Rebert
On Sun, Mar 8, 2009 at 2:18 PM, Oltmans wrote: > I'm at a loss to figure out how to extract some text from a string. > Here is a string: > > setTimeout("location.href='http://youtube.example.com/login.aspx'", > 5000); > > and I want to only retrieve the URL from above i.e I only want this > http:/

Re: NEWB: dividing numbers

2009-03-08 Thread Chris Rebert
On Sun, Mar 8, 2009 at 3:08 PM, Lo wrote: > I just tried python first time. > > 2/3 > > the result is zero > > I want the result to be .333... > > How do I get this? Add the following to the top of your program: from __future__ import division That tells Python to use the proper kind of divisio

Re: str.Template 4 times slower than calling replace multiple times

2009-03-08 Thread Chris Rebert
On Sun, Mar 8, 2009 at 10:23 PM, John Machin wrote: > On Mar 9, 3:15 pm, Jack Steven wrote: >> Isn't string.Template suppose to be faster than calling replace multiple >> times? That's what I thought until I benchmarked this code, where >> string.Template ended up being 4 times slower. >> >> This

Re: Implementing chain of responsibility

2009-03-09 Thread Chris Rebert
On Sun, Mar 8, 2009 at 11:53 PM, koranthala wrote: > Hi, >    I want to implement chain of responsibility pattern in Python (for > a Django project) >    The problem that I see is a rather odd one - how to link the > subclasses with the super class. Grabbing out my copy of Head First Design Patte

Re: a potential pep to extend the syntax of for loops

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 2:15 AM, pang wrote: >  Hello, >  This is an idea about something I'd like to see implemented in > python. > I understand that's the purpose of PEPs, so I'll write it as a PEP, > but > send it here to receive your valuable feedback. > > Abstract > > This is a proposal to inc

Re: Ban Xah Lee

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 4:12 AM, Larry Gates wrote: > On Sun, 08 Mar 2009 04:09:52 +, Dirk Bruere at NeoPax wrote: > >> Dirk Bruere at NeoPax wrote: > >>> Well, don't worry - nobody is going to ban you from Usenet (except >>> possibly the Chinese govt). >>> OTOH, nobody here much cares. >>> So,

Re: Is python worth learning as a second language?

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 3:43 AM, ZikO wrote: > Hi > > I hope I won't sound trivial with asking my question. > > I am a C++ programmer and I am thinking of learning something else because I > know second language might be very helpful somehow. I have heard a few > positive things about Python but I

Re: Implementing chain of responsibility

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 3:54 AM, koranthala wrote: > On Mar 9, 12:16 pm, Chris Rebert wrote: >> On Sun, Mar 8, 2009 at 11:53 PM, koranthala wrote: >> > Hi, >> >    I want to implement chain of responsibility pattern in Python (for >> > a Django project) >&g

Re: Read from .csv file

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 1:56 PM, Karnama Ahmad (KTH) wrote: > > Dear all, > > I would be thankfukl if you answer to the following easy question: > > How can I read from a .csv file in Python and save the data in a array > or dictionary. Use the `csv` module -- http://docs.python.org/library/csv.ht

Re: Concurrent tasklets in Stackless Python

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 3:05 PM, Minesh Patel wrote: > Is there a way for multiple tasklets to run in parallel? Seems doubtful (though I'm not an expert). From the Wikipedia article: "Stackless microthreads are managed by the language interpreter itself, not the operating system kernel—context sw

Re: docstring reference to another docstring

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 3:23 PM, bdb112 wrote: > A function of the class ClusterSet uses a similar function of the > class Cluster to do most of its work.  Its docstring could have so > much in common with that in Cluster that it could be just a line or > two in addition to that of Cluster. > > Is

Re: docstring reference to another docstring

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 4:17 PM, bdb112 wrote: > Thanks for the quick reply - I expanded it to a working program, > it seems to do the job and works in my actual code (always good).  As > you said, it assumes the called function's class is already defined. > Is there a way around this? (The mo

Re: Concurrent tasklets in Stackless Python

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 4:47 PM, Minesh Patel wrote: > On Mon, Mar 9, 2009 at 3:17 PM, Chris Rebert wrote: >> On Mon, Mar 9, 2009 at 3:05 PM, Minesh Patel wrote: >>> Is there a way for multiple tasklets to run in parallel? >> >> Seems doubtful (though I'm not a

Re: searching strings

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 6:18 PM, Daniel Dalton wrote: > Hi, > > I'm writing a program where I search a variable (path), and see if it > contains the whole string of variable name > so: > if name in path: >   > else: >   > > One question about this, how can I make it do exactly what it's doi

Re: Number Sequencing, Grouping and Filtering

2009-03-10 Thread Chris Rebert
On Tue, Mar 10, 2009 at 2:54 AM, flebber wrote: > Hi > > I was hoping someone would be able to point me in the direction of > some good documentation regarding sequencing, grouping and filtering > and in which order they should be done. > > As a small example it is easy to create the range of numb

Re: Number Sequencing, Grouping and Filtering

2009-03-10 Thread Chris Rebert
On Tue, Mar 10, 2009 at 3:00 AM, flebber wrote: > On Mar 10, 8:54 pm, flebber wrote: >> Hi >> >> I was hoping someone would be able to point me in the direction of >> some good documentation regarding sequencing, grouping and filtering >> and in which order they should be done. >> >> As a small e

Re: urllib2.URLError:

2009-03-11 Thread Chris Rebert
On Tue, Mar 10, 2009 at 11:34 PM, Coonay wrote: > i use python2.6 > > > File "C:\PROGRA~1\Python26\lib\urllib2.py", line 383, in open >    response = self._open(req, data) >  File "C:\PROGRA~1\Python26\lib\urllib2.py", line 401, in _open >    '_open', req) >  File "C:\PROGRA~1\Python26\lib\urllib2

Re: calling class methods from class methods, help?

2009-03-11 Thread Chris Rebert
On Wed, Mar 11, 2009 at 10:08 AM, Oltmans wrote: > I've a multithreaded program in which I've to call class methods from > class methods. Um, those are instance methods, not class methods. Class methods take the class itself as an argument (the parameter is typically named "cls" instead of "self"

Re: Can python (CPython) and IPython coexist normally on the same computer ?

2009-03-11 Thread Chris Rebert
On Wed, Mar 11, 2009 at 4:17 PM, scoop wrote: > I know I could just try to install it and see, but I've got my > configuration just right, so I don't want to mess it up (maybe) with > IPython. > > Also, can someone please point me to some page where I can find > differences between C and I Python.

Re: unbiased benchmark

2009-03-12 Thread Chris Rebert
On Thu, Mar 12, 2009 at 1:07 PM, Sam Ettessoc wrote: > I would like to share a benchmark I did. The computer used was a > 2160MHz Intel Core Duo w/ 2000MB of 667MHz DDR2 SDRAM running MAC OS > 10.5.6 and a lots of software running (a typical developer > workstation). > > Python benchmark: > HAMBUR

Re: converting a string to a function parameter

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 12:52 AM, koranthala wrote: > Hi, >    Is it possible to convert a string to a function parameter? > Ex: > str = 'True, type=rect, sizes=[3, 4]' > and I should be able to use it as: > test(convert(str)) and the behaviour should be same as calling test > with those values :

Re: Python package for .ics (iCalendar) files

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 3:05 PM, wrote: > Is there an 'offical' Python package for handling .ics files or is the > follwing the best there is:- > >    http://codespeak.net/icalendar/ > > It seems rather old but Google didn't pop anything else up. Well, the iCalendar standard doesn't really chang

Re: How to interface with C# without IronPython

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 3:51 PM, Mudcat wrote: > All the topics I seem to find on this topic lead me in the direction > of IronPython, but I'm not interested right now in a reimplementation > of Python in .Net environment. There are wrappers and methods > available for integrating with Java, C, an

Re: Parameter sublists [was: An ordering question]

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 5:30 PM, Peter Pearson wrote: > On Fri, 13 Mar 2009 18:56:30 +0100, Hrvoje Niksic wrote: > [snip] >> a.sort(key=lambda (x, y): b[y - 1], reverse=True) > > Huh?  I had no idea one could do this: > def g( ( ( x, y ), z ) ): > ...   return y > ... g( ((1,2),3) ) > 2

Re: python book for a C programmer

2009-03-14 Thread Chris Rebert
On Fri, Mar 13, 2009 at 10:29 PM, Paul Rubin wrote: > Saurabh writes: >> Hi all, >> I am an experienced C programmer, I have done some perl code as well. >> But while thinking about large programs,I find perl syntax a >> hinderance. > > I would say read the online tutorial, then "Python in a Nuts

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 10:28 AM, wrote: > I have a date in the form of a datetime object and I want to add (for > example) three months to it.  At the moment I can't see any very > obvious way of doing this.  I need something like:- > >    myDate = datetime.date.today() >    inc = datetime.timed

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 11:00 AM, wrote: > Roy Smith wrote: >> In article <[email protected]>, [email protected] >> wrote: >> >> > I have a date in the form of a datetime object and I want to add (for >> > example) three months to it.  At the moment I can't see any very

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 1:30 PM, Roy Smith wrote: > In article , >  Chris Rebert wrote: > >> Which makes some sense considering a month can range from 28-31 days, >> which would make the delta oddly fuzzy. > > BTW, what date is "One month after August 10, 1752&quo

Re: Set overlapping

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 1:41 PM, mattia wrote: > How can I determine the common values found in two differents sets and > then assign this values? > E.g. > dayset = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] > monthset = ["Jan", "Feb", "Apr", "May", "Jun", "Jul", "Aug", "Sep", > "Oct", "Nov

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:17 PM, Steve Holden wrote: > Roy Smith wrote: >> In article <[email protected]>, [email protected] >> wrote: >> >>> I have a date in the form of a datetime object and I want to add (for >>> example) three months to it.  At the moment I can't see a

Re: Correct URL encoding

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:21 PM, mattia wrote: > I'm using urlopen in order to download some web pages. I've always to > replace some characters that are in the url, so I've come up with: > url.replace("|", "%7C").replace("/", "%2F").replace(" ", "+").replace > (":", "%3A") > There isn't a better

Re: Correct URL encoding

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:54 PM, gervaz wrote: > On Mar 16, 12:38 am, Graham Breed wrote: >> mattia wrote: >> > I'm using urlopen in order to download some web pages. I've always to >> > replace some characters that are in the url, so I've come up with: >> > url.replace("|", "%7C").replace("/", "

Re: Problem while copying a file from a remote filer

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 10:24 PM, [email protected] wrote: > Hi all, >      I have to write an application which does a move and copy of a > file from a remote machine to the local machine. I tried something > like: > > file = ur"venuwin2008\\C\\4Folders\\Folder02\\Folder002\ > \TextFile

Re: Newbie question: How do I add elements to **kwargs in a function?

2009-03-16 Thread Chris Rebert
On Mon, Mar 16, 2009 at 7:48 PM, Aaron Garrett wrote: > I have spent quite a bit of time trying to find the answer on this > group, but I've been unsuccessful. Here is what I'd like to be able to > do: > > def A(**kwargs): >    kwargs['eggs'] = 1 > > def B(**kwargs): >    print(kwargs) > > def C(*

Re: Can python quickly display results like bash?

2009-03-17 Thread Chris Rebert
On Mon, Mar 16, 2009 at 6:05 PM, robert song wrote: > Hello, everyone. > python can be debugged with pdb, but if there anyway to get a quick > view of the python execution. > Just like sh -x of bash command. > I didn't find that there is an option of python that can do it. I've read the manpage f

Re: Can python quickly display results like bash?

2009-03-17 Thread Chris Rebert
On Tue, Mar 17, 2009 at 11:13 AM, D'Arcy J.M. Cain wrote: > On Tue, 17 Mar 2009 11:10:36 -0700 > Chris Rebert wrote: >> I've read the manpage for bash and can find no such -x option listed. > > It's an option from sh(1) that bash copies.  Check the man page for s

Re: Can python quickly display results like bash?

2009-03-17 Thread Chris Rebert
On Tue, Mar 17, 2009 at 12:15 PM, Hrvoje Niksic wrote: > Chris Rebert writes: > >> Ah, I should've thought to google for the sh manpage. Locally, man >> sh just gives me the bash manpage again which doesn't list -x :-( > > Are you sure?  On my system the OPTI

<    5   6   7   8   9   10   11   12   13   14   >