Re: How to open a remote file using python.

2009-02-22 Thread Chris Rebert
On Sun, Feb 22, 2009 at 9:02 PM, venutaurus...@gmail.com venutaurus...@gmail.com wrote: On Feb 23, 9:25 am, MRAB goo...@mrabarnett.plus.com wrote: venutaurus...@gmail.com wrote: Hello all, I am writing an application where I need to open a shared file on a remote machine using

Re: different errors, return outside function and others

2009-02-22 Thread Chris Rebert
On Sun, Feb 22, 2009 at 10:51 PM, Tony sternbrightbl...@gmail.com wrote: Hi, I am trying to write a small program for my final for school, everytime i run my program it gives me a return outside function error (after i fixed all the indentation errors it throws at me), i am not very good at

Re: different errors, return outside function and others

2009-02-23 Thread Chris Rebert
Ok, that's not a standard Python error report (I'm guessing you're using an IDE of some sort). Also, something's not right because your excerpt doesn't match the source you posted. In your previous post, the 'while' line in question was given as: while introselection 1 or introselection 2 Note

Re: confusing UnboundLocalError behaive

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 12:06 AM, neoedmund neoedm...@gmail.com wrote: see the 3 small piece of code, i cannot understand why it result as this. 1. def test(): abc=111 def m1(): print(abc) m1() test() Output: 111 2. def test(): abc=111

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

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 5:51 AM, venutaurus...@gmail.com venutaurus...@gmail.com 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

Re: Peculiar swap behavior

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 10:43 AM, Tim Chase python.l...@tim.thechases.com wrote: snip # 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

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 s.selvams...@gmail.com 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

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 woody...@sky.com 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',

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 labm...@gmail.com 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

Re: more on unescaping escapes

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 4:26 PM, bvdp b...@mellowood.ca 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

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 dhananjay.c.jo...@gmail.com 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,

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 woody...@sky.com 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

Re: Accessing callers context from callee method

2009-02-24 Thread Chris Rebert
On Tue, Feb 24, 2009 at 10:53 AM, mobiledream...@gmail.com 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

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

2009-02-24 Thread Chris Rebert
On Tue, Feb 24, 2009 at 11:05 AM, zaheer.ag...@gmail.com 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

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 madhav@gmail.com 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

Re: Convert PySerial to python 3.0

2009-02-24 Thread Chris Rebert
On Tue, Feb 24, 2009 at 7:46 PM, Seth king.s...@gmail.com 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

Re: variable length tuple assignment

2009-02-25 Thread Chris Rebert
On Wed, Feb 25, 2009 at 1:16 AM, Helmut Jarausch jarau...@igpm.rwth-aachen.de 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,list of remaining items) = S.split(',') In

Re: coding style - try, except

2009-02-25 Thread Chris Rebert
On Wed, Feb 25, 2009 at 9:36 AM, RGK bl...@empty.blank 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

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 chela...@gmail.com 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

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 visc...@gmail.com 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

Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 3:05 AM, Clarendon jine...@hotmail.com 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

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 cosmo_gene...@yahoo.com 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

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 jessealdri...@gmail.com 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

Re: PythonWin -vs- Idle

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 2:23 PM, Gary Schells gsche...@hotmail.com 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

Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam pe...@www.pjb.com.au wrote: On 2009-02-26, Clarendon jine...@hotmail.com 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',

Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 4:37 PM, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Thu, 26 Feb 2009 22:18:18 -0200, Chris Rebert c...@rebertia.com escribió: On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam pe...@www.pjb.com.au wrote: On 2009-02-26, Clarendon jine...@hotmail.com wrote: Hi

Re: Using xreadlines

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 4:32 PM, Brett Hedges lilhedge...@yahoo.com 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

Re: Multiple conditional expression

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 7:11 PM, Anjanesh Lekshminarayanan m...@anjanesh.net 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

Re: Multiple conditional expression

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 8:39 PM, Anjanesh Lekshminarayanan m...@anjanesh.net 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') ?

Re: removing duplication from a huge list.

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 8:49 PM, Benjamin Peterson benja...@python.org wrote: Shanmuga Rajan m.shanmugarajan at 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

Re: Delete all items in the list

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 10:26 PM, odeits ode...@gmail.com wrote: On Feb 26, 3:05 am, Clarendon jine...@hotmail.com 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',

Re: decimal to string conv

2009-02-27 Thread Chris Rebert
On Fri, Feb 27, 2009 at 1:45 AM, Aj aru...@gmail.com 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

Re: Delete all items in the list

2009-02-27 Thread Chris Rebert
On Fri, Feb 27, 2009 at 5:10 AM, Steve Holden st...@holdenweb.com wrote: Chris Rebert wrote: On Thu, Feb 26, 2009 at 10:26 PM, odeits ode...@gmail.com wrote: [...] while 'a' in L:   L.remove('a') not the most efficient but it works Not the most efficient; it's terribly inefficient! It's 2

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 ra.ravi@gmail.com 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

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 charly.fou...@gmail.com 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'  

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 gagsl-...@yahoo.com.ar wrote: En Sun, 01 Mar 2009 13:20:28 -0200, John O'Hagan resea...@johnohagan.com escribió: Inspired by some recent threads here about using classes to extend the behaviour of iterators, I'm trying to replace some some

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 david.christ...@gmail.com 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.

Re: Can CleintForm work with webbrowser?

2009-03-01 Thread Chris Rebert
On Sun, Mar 1, 2009 at 9:36 PM, Muddy Coder cosmo_gene...@yahoo.com 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.

Re: os module

2009-03-02 Thread Chris Rebert
On Mon, Mar 2, 2009 at 12:26 AM, M Kumar tomanis...@gmail.com 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

Re: os module

2009-03-02 Thread Chris Rebert
On Mon, Mar 2, 2009 at 1:59 PM, Chris Rebert c...@rebertia.com wrote: On Mon, Mar 2, 2009 at 12:26 AM, M Kumar tomanis...@gmail.com 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

Re: os module

2009-03-02 Thread Chris Rebert
On Mon, Mar 2, 2009 at 2:17 PM, Chris Rebert c...@rebertia.com wrote: On Mon, Mar 2, 2009 at 1:59 PM, Chris Rebert c...@rebertia.com wrote: On Mon, Mar 2, 2009 at 12:26 AM, M Kumar tomanis...@gmail.com wrote: Hi, I am writing a server side program, clients can be any machine

Re: os module

2009-03-02 Thread Chris Rebert
On Mon, Mar 2, 2009 at 2:31 PM, Chris Rebert c...@rebertia.com wrote: On Mon, Mar 2, 2009 at 2:17 PM, Chris Rebert c...@rebertia.com wrote: On Mon, Mar 2, 2009 at 1:59 PM, Chris Rebert c...@rebertia.com wrote: On Mon, Mar 2, 2009 at 12:26 AM, M Kumar tomanis...@gmail.com wrote

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

2009-03-02 Thread Chris Rebert
On Mon, Mar 2, 2009 at 4:56 PM, Nick Mellor nick.mellor.gro...@pobox.com 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

Re: Pickle Problem

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 1:52 AM, Fab86 fabien.h...@gmail.com 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)

Re: Get bound method by name

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 3:12 AM, Johannes Bauer dfnsonfsdu...@gmx.de 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

Re: Indentifying types?

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 9:03 AM, Mike Driscoll kyoso...@gmail.com wrote: - Show quoted text - On Mar 3, 10:57 am, Oltmans rolf.oltm...@gmail.com 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

Re: Perl-python regex-performance comparison

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 9:05 AM, Ivan i...@invalid.net 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

Re: Get bound method by name

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 12:54 PM, Steve Holden st...@holdenweb.com 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() y =

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 amich...@gmail.com 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

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 amich...@gmail.com wrote: On Mar 3, 10:05 pm, Chris Rebert c...@rebertia.com wrote: On Tue, Mar 3, 2009 at 6:59 PM, Amir Michail amich...@gmail.com wrote: Hi, Is it the case that the random module will always give the same results if given

Re: How to create Standalone PYC File

2009-03-04 Thread Chris Rebert
On Wed, Mar 4, 2009 at 11:38 AM, Rohan Hole rohanhol...@gmail.com 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

Re: Question about binary file reading

2009-03-04 Thread Chris Rebert
On Wed, Mar 4, 2009 at 2:58 PM, vibgyorbits bka...@gmail.com 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

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 mrw...@gmail.com 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

Re: PyPI editing

2009-03-05 Thread Chris Rebert
On Wed, Mar 4, 2009 at 11:42 PM, andrew cooke and...@acooke.org 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,

Re: While loop

2009-03-05 Thread Chris Rebert
On Thu, Mar 5, 2009 at 9:49 AM, Fab86 fabien.h...@gmail.com wrote: On Mar 5, 5:23 pm, Marco Mariani ma...@sferacarta.com 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? snip using

Re: alias method definitions / syntactic sugar suggestion

2009-03-05 Thread Chris Rebert
On Thu, Mar 5, 2009 at 6:17 PM, Tennessee Leeuwenburg tleeuwenb...@gmail.com 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

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 st...@pearwood.info 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() ...    

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 tribulati...@paralleles.invalid 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

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 ger...@gmail.com 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,

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 ger...@gmail.com 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:        

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 ger...@gmail.com wrote: Il Fri, 06 Mar 2009 03:43:22 -0800, Chris Rebert ha scritto: On Fri, Mar 6, 2009 at 3:07 AM, mattia ger...@gmail.com wrote: Great, the for statement has not to deal with fap anymore, but with another sequence, like this: def

Re: datetime question

2009-03-06 Thread Chris Rebert
On Fri, Mar 6, 2009 at 7:24 AM, jyoun...@kc.rr.com 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’s

Re: help with printing to stdout...

2009-03-08 Thread Chris Rebert
On Sun, Mar 8, 2009 at 1:37 AM, Daniel Dalton d.dal...@iinet.net.au 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

Re: How to extract some text?

2009-03-08 Thread Chris Rebert
On Sun, Mar 8, 2009 at 2:18 PM, Oltmans rolf.oltm...@gmail.com 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

Re: NEWB: dividing numbers

2009-03-08 Thread Chris Rebert
On Sun, Mar 8, 2009 at 3:08 PM, Lo gr...@congstar.de 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

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 sjmac...@lexicon.net wrote: On Mar 9, 3:15 pm, Jack Steven a...@hotmail.com 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

Re: Implementing chain of responsibility

2009-03-09 Thread Chris Rebert
On Sun, Mar 8, 2009 at 11:53 PM, koranthala koranth...@gmail.com 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

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 pablo.ang...@uam.es 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

Re: Ban Xah Lee

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 4:12 AM, Larry Gates la...@example.invalid 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.

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 ze...@op.pl 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

Re: Implementing chain of responsibility

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 3:54 AM, koranthala koranth...@gmail.com wrote: On Mar 9, 12:16 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Mar 8, 2009 at 11:53 PM, koranthala koranth...@gmail.com wrote: Hi,    I want to implement chain of responsibility pattern in Python (for a Django

Re: Read from .csv file

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 1:56 PM, Karnama Ahmad (KTH) ahmad.karn...@partners.fortum.com 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 --

Re: Concurrent tasklets in Stackless Python

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 3:05 PM, Minesh Patel min...@gmail.com 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

Re: docstring reference to another docstring

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 3:23 PM, bdb112 boyd.blackw...@gmail.com 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

Re: docstring reference to another docstring

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 4:17 PM, bdb112 boyd.blackw...@gmail.com 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

Re: Concurrent tasklets in Stackless Python

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

Re: searching strings

2009-03-09 Thread Chris Rebert
On Mon, Mar 9, 2009 at 6:18 PM, Daniel Dalton d.dal...@iinet.net.au 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

Re: Number Sequencing, Grouping and Filtering

2009-03-10 Thread Chris Rebert
On Tue, Mar 10, 2009 at 2:54 AM, flebber flebber.c...@gmail.com 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

Re: Number Sequencing, Grouping and Filtering

2009-03-10 Thread Chris Rebert
On Tue, Mar 10, 2009 at 3:00 AM, flebber flebber.c...@gmail.com wrote: On Mar 10, 8:54 pm, flebber flebber.c...@gmail.com 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

Re: urllib2.URLError: urlopen error unknown url type: http

2009-03-11 Thread Chris Rebert
On Tue, Mar 10, 2009 at 11:34 PM, Coonay fla...@gmail.com 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

Re: calling class methods from class methods, help?

2009-03-11 Thread Chris Rebert
On Wed, Mar 11, 2009 at 10:08 AM, Oltmans rolf.oltm...@gmail.com 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

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 sc...@invalid.gmail.com 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

Re: unbiased benchmark

2009-03-12 Thread Chris Rebert
On Thu, Mar 12, 2009 at 1:07 PM, Sam Ettessoc sami...@gmail.com 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

Re: converting a string to a function parameter

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 12:52 AM, koranthala koranth...@gmail.com 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

Re: Python package for .ics (iCalendar) files

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 3:05 PM, tinn...@isbd.co.uk 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

Re: How to interface with C# without IronPython

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 3:51 PM, Mudcat mnati...@gmail.com 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

Re: Parameter sublists [was: An ordering question]

2009-03-13 Thread Chris Rebert
On Fri, Mar 13, 2009 at 5:30 PM, Peter Pearson ppear...@nowhere.invalid wrote: On Fri, 13 Mar 2009 18:56:30 +0100, Hrvoje Niksic hnik...@xemacs.org 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

Re: python book for a C programmer

2009-03-14 Thread Chris Rebert
On Fri, Mar 13, 2009 at 10:29 PM, Paul Rubin http wrote: Saurabh nirkh...@gmail.com 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

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, tinn...@isbd.co.uk 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 =

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, tinn...@isbd.co.uk wrote: Roy Smith r...@panix.com wrote: In article 49bd3ab8$0$510$bed64...@news.gradwell.net, tinn...@isbd.co.uk 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

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 r...@panix.com wrote: In article mailman.1910.1237139217.11746.python-l...@python.org,  Chris Rebert c...@rebertia.com wrote: Which makes some sense considering a month can range from 28-31 days, which would make the delta oddly fuzzy. BTW, what

Re: Set overlapping

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 1:41 PM, mattia ger...@gmail.com 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, Dec] this are the

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 st...@holdenweb.com wrote: Roy Smith wrote: In article 49bd3ab8$0$510$bed64...@news.gradwell.net, tinn...@isbd.co.uk 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

Re: Correct URL encoding

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:21 PM, mattia ger...@gmail.com 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 way

Re: Correct URL encoding

2009-03-15 Thread Chris Rebert
On Sun, Mar 15, 2009 at 4:54 PM, gervaz ger...@gmail.com wrote: On Mar 16, 12:38 am, Graham Breed x3...@cnntp.org 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(|,

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, venutaurus...@gmail.com venutaurus...@gmail.com 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 =

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 aaron.lee.garr...@gmail.com 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):    

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 robertsong.li...@gmail.com 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.

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 da...@druid.net wrote: On Tue, 17 Mar 2009 11:10:36 -0700 Chris Rebert c...@rebertia.com 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 sh (1

  1   2   3   4   5   6   7   8   9   10   >