Re: Function arguments

2009-01-26 Thread Chris Rebert
On Mon, Jan 26, 2009 at 1:03 AM, brasse wrote: > Hello! > > Is there any way that I can get at all the arguments passed to a > function as a map without using keyword arguments? > > def foo(a, b, c): ># Can I access all the arguments in a collection somewhere? You can use positional arguments

Re: Function arguments

2009-01-26 Thread Chris Rebert
On Mon, Jan 26, 2009 at 1:34 AM, brasse wrote: > On Jan 26, 10:11 am, Chris Rebert wrote: >> On Mon, Jan 26, 2009 at 1:03 AM, brasse wrote: >> > Hello! >> >> > Is there any way that I can get at all the arguments passed to a >> > function as a map wi

Re: Web services

2009-01-26 Thread Chris Rebert
On Mon, Jan 26, 2009 at 8:11 AM, loial wrote: > I am trying to learn about web services and how to interface with a > 3rd party web service from python. > > Can anyone point me at an idiots guide/tutorial for someone who is new > to web services? The XML-RPC client module in the std lib (xmlrpcli

Re: Exec woes

2009-01-27 Thread Chris Rebert
On Tue, Jan 27, 2009 at 9:34 AM, Christian Heimes wrote: > Hendrik van Rooyen schrieb: >> It starts with the conspiracy of silence at the interactive prompt: >> >> Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on >> win32 >> Type "copyright", "credits" or "license()" for m

Re: self-aware list of objects able to sense constituent member alterations?

2009-01-27 Thread Chris Rebert
On Tue, Jan 27, 2009 at 1:16 PM, Reckoner wrote: > I'm not sure this is possible, but I would like to have > a list of objects > > A=[a,b,c,d,...,z] > > where, in the midst of a lot of processing I might do something like, > > A[0].do_something_which_changes_the_properties() > > which alter the

Re: Python-list Digest, Vol 64, Issue 644

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 1:08 AM, M Kumar wrote: > is python a pure objected oriented language? Firstly: (A) Replying to Digests rather than individual posts is very discouraged. (B) The proper way to start a new thread by emailing python-list@python.org (as it says in the very header of the diges

Re: is python Object oriented??

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 2:01 AM, M Kumar wrote: > Object oriented languages doesn't allow execution of the code without class > objects, what is actually happening when we execute some piece of code, is > it bound to any class? That's not really the standard definition of object-oriented (c.f.

Re: slicings: 3 questions

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 10:01 AM, Alan G Isaac wrote: > 1. I seem not to understand something obvious at > http://docs.python.org/3.0/reference/expressions.html#slicings > (I assume I'm just not reading this right.) > What is an example of a slicing using a "slice_list"? There's nothing in the st

Re: Can't understand what python wants from me

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 1:50 PM, Oleksiy Khilkevich wrote: > Hello, everyone, > This may be a totally noob question, but since I am one, so here is it. > > I have the following code (not something much of): > http://paste.debian.net/27204 > The current code runs well, but the problem is with input

Re: is python Object oriented??

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 7:31 PM, Steven D'Aprano wrote: > On Thu, 29 Jan 2009 02:25:57 -0800, Chris Rebert wrote: > >> In addition to methods, Python has functions, which are not associated >> with a class > > Yes they are. > >>>> (lambda: None).__c

Re: is python Object oriented??

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 9:56 PM, Hung Vo wrote: > I'm new to Python and also wondering about OOP in Python. > > I want to justify the above question (is Python Object-Oriented?). > Does Python follow the concepts/practices of Encapsulation, > Polymorphism and Interface, which are quite familiar t

Re: is python Object oriented??

2009-01-29 Thread Chris Rebert
On Thu, Jan 29, 2009 at 10:25 PM, alex23 wrote: > On Jan 30, 4:15 pm, Chris Rebert wrote: >> - Python does not support interfaces in the Java sense (although there >> are a few third-party libraries that add such support); neither does >> Smalltalk. Instead, both Smalltal

Re: Want to write a script to do the batch conversion from domain name to IP.

2009-01-30 Thread Chris Rebert
On Fri, Jan 30, 2009 at 4:27 AM, Hongyi Zhao wrote: > Hi all, > > Suppose I've the entries like the following in my file: > > -- > 116.52.155.237:80 > ip-72-55-191-6.static.privatedns.com:3128 > 222.124.135.40:80 > 217.151.231.34:3128 > 202.106.121.134:80 > 211.161.197.182:80 > hpc

Re: import reassignment different at module and function scope

2009-01-30 Thread Chris Rebert
On Fri, Jan 30, 2009 at 11:31 PM, Brendan Miller wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > If I: > > import sys > > sys = sys.version > > This executes find but: > > import sys > > def f(): >sys = sys.version > > This gives an error indicating that the sys on the right hand

Re: What is wrong in my list comprehension?

2009-02-01 Thread Chris Rebert
On Sun, Feb 1, 2009 at 3:22 AM, Hussein B wrote: > Hey, > I have a log file that doesn't contain the word "Haskell" at all, I'm > just trying to do a little performance comparison: > ++ > from datetime import time, timedelta, datetime > start = datetime.now() > print start > lines = [l

Re: is python Object oriented??

2009-02-01 Thread Chris Rebert
On Sat, Jan 31, 2009 at 9:08 AM, wrote: > On Jan 30, 12:15 am, Chris Rebert wrote: >> - Python supports encapsulation. Prefixing an attribute/method with an >> underscore indicates that other programmers should treat it as >> 'private'. However, unlike B&D la

Re: database wrapper ?

2009-02-01 Thread Chris Rebert
On Sun, Feb 1, 2009 at 2:56 PM, Stef Mientki wrote: > hello, > > Until now I used a simple wrapper around pysqlite and pyodbc to manage my > databases. > Now I'm looking for a better solution, > because I've to support a (for this moment) unknown database, > and I'm not the one who will choose the

Re: question about Z=[[x for y in range(1, 2) if AList[x]==y] for x in range(0,5)]

2009-02-01 Thread Chris Rebert
On Fri, Jan 30, 2009 at 5:33 PM, Vincent Davis wrote: > Z=[[x for y in range(1,2) if AList[x]==y] for x in range(0,5)] > I am not sure how to ask this but which "for" is looped first? I could > test but was wondering if there was a nice explanation I could apply > to future situations. The outer

Re: AssertionError not caught?

2009-02-01 Thread Chris Rebert
On Sun, Feb 1, 2009 at 6:31 PM, LX wrote: > This one has me mystified good! > > This works (print statement is executed as the Exception is caught) as > advertised: >try: >raise AssertionError >except AssertionError: >print "caught AssertionError" > > > But this one does no

Re: call other program

2009-02-01 Thread Chris Rebert
On Sun, Feb 1, 2009 at 7:35 PM, JuanPablo wrote: > hi, > I have a newbie question. > In bash is posible call other program, send and recieve message with this. > > example: > $ python > output << EOF >> print "hello world" >> EOF > $ cat output > hello world > > in python exist some similar ?

Re: Combining several text files

2009-02-02 Thread Chris Rebert
On Mon, Feb 2, 2009 at 9:48 AM, Eric wrote: > This is my first post, so please advise if I'm not using proper > etiquette. I've actually searched around a bit and while I think I can > do this, I can't think of a clean elegant way. I'm pretty new to > Python, but from what I've learned so far is t

Re: how to create data to dump into yaml file

2009-02-02 Thread Chris Rebert
On Sun, Feb 1, 2009 at 11:41 PM, wrote: > hi >I have to create a yaml file using my list of objects.shall i need to > create a string using my objects and then load and dump that string or > is there any other way to create the yaml file. > > i want a yaml file to be created from [Text, Autho

Re: Exception error when accessing the class variable at the termination of the program

2009-02-02 Thread Chris Rebert
On Sun, Feb 1, 2009 at 11:52 PM, wrote: > Hi All, > > Here is a sample piece of code with which I am having a problem, with > Python version 2.4.4 > > class Person: >Count = 0 # This represents the count of objects of this class > >def __init__(self, name): >self.name = name

Re: importing module-performance

2009-02-02 Thread Chris Rebert
On Mon, Feb 2, 2009 at 1:29 AM, S.Selvam Siva wrote: > Hi all, > I have a small query, > Consider there is a task A which i want to perform. > > To perform it ,i have two option. > 1)Writing a small piece of code(approx. 50 lines) as efficient as possible. > 2)import a suitable module to perform t

Re: global variable confusion

2009-02-02 Thread Chris Rebert
On Mon, Feb 2, 2009 at 10:25 PM, Robert D.M. Smith wrote: > I have a question on global variables and how to use them. I have 2 files; > a.py & b.py > > # a.py - > > myvar = { 'test' : '123' } > > # --- > # b.py - > > from a import myvar > > def test(): > a.myvar = { 'blah' : '45

Re: Varibles -- copies and references

2009-02-02 Thread Chris Rebert
On Mon, Feb 2, 2009 at 10:02 PM, Ferdinand Sousa wrote: > Hi > > Some weeks back I had been following the thread "Why can't assign to > function call". Today, I saw the "function scope" thread, and decided I > should ask about the behaviour below: >

Re: subprocess.Popen - file like object from stdout=PIPE

2009-02-04 Thread Chris Rebert
On Wed, Feb 4, 2009 at 1:22 AM, Helmut Jarausch wrote: > Hi, > > using e.g. > import subprocess > Package='app-arch/lzma-utils' > EQ=subprocess.Popen(['/usr/bin/equery','depends',Package],stdout=subprocess.PIPE) > EQ_output= EQ.communicate()[0] > > EQ_output is a string containing multiple lines.

Re: Using while loop and if statement to tell if a binary has an odd or even number of 1's.

2009-02-04 Thread Chris Rebert
On Wed, Feb 4, 2009 at 5:02 PM, todp...@hotmail.com wrote: > Using while loop and if statement, I'm trying to get Python to tell me > whether there are even or odd number of 1's in a binary representation. > For example, if I give Python a 0111, then I want it to say that the > binary represen

Re: How to trigger a smart link?

2009-02-04 Thread Chris Rebert
On Wed, Feb 4, 2009 at 5:16 PM, Muddy Coder wrote: > Hi All, > > Using urllib2 can trigger CGI script in server side. However, I > encountered a problem of the so-called smart link. When a fairly large > site, the server needs to track the identifier of each request from > client, so it generated

Re: Using while loop and if statement to tell if a binary has an odd or even number of 1's.

2009-02-04 Thread Chris Rebert
A "byte" is *not* a Python type. My question was what *Python type* (i.e. bytes (which is distinctly different from the abstract notion of a byte), str/unicode, int, etc...) you were using for you "binary representation", which you still haven't answered. Also, please don't reply by top-posting (ht

Re: Comparing two book chapters (text files)

2009-02-04 Thread Chris Rebert
On Wed, Feb 4, 2009 at 5:20 PM, Nick Matzke wrote: > Hi all, > > So I have an interesting challenge. I want to compare two book chapters, > which I have in plain text format, and find out (a) percentage similarity > and (b) what has changed. > > Some features make this problem different than what

Re: global name 'sqrt' is not defined

2009-02-05 Thread Chris Rebert
On Thu, Feb 5, 2009 at 1:08 AM, Nick Matzke wrote: > Hi all, > > So, I can run this in the ipython shell just fine: > > === > a = ["12", "15", "16", "38.2"] > dim = int(sqrt(size(a))) sqrt() is not a builtin function, it's located in the 'math' module. You must have imported it at some po

Re: string replace for back slash

2009-02-05 Thread Chris Rebert
On Thu, Feb 5, 2009 at 3:40 AM, S.Selvam Siva wrote: > Hi all, > > I tried to do a string replace as follows, > s="hi & people" s.replace("&","\&") > 'hi \\& people' > > but i was expecting 'hi \& people'.I dont know ,what is something different > here with escape sequence. The Pyt

Re: Should "open(sys.stdin)" and "open(file, 'r')" be equivalent?

2009-02-05 Thread Chris Rebert
On Thu, Feb 5, 2009 at 2:58 AM, Simon Mullis wrote: > Hi All > > I've written a simple python script that accepts both stdin and a glob (or > at least, that is the plan). > Unfortunately, the glob part seems to hang when it's looped through to the > end of the filehandle. > > And I have no idea wh

Re: os.system issues

2009-02-05 Thread Chris Rebert
On Thu, Feb 5, 2009 at 6:00 AM, Youri Lammers wrote: > Ok, > > I want to run a program called 'muscle' with my python script, > muscle uses the following command: > 'muscle.exe -in filename -out filename' > so far I got: > > import os > args = ['-in filename', '-out filename'] As Christian indire

Re: return multiple objects

2009-02-05 Thread Chris Rebert
On Thu, Feb 5, 2009 at 7:03 PM, Vincent Davis wrote: > Is it correct that if I want to return multiple objects from a function I > need to in some way combine them? > def test1(): > a = [1,3,5,7] > b = [2,4,6,8] > c=[a,b] >return a, b # this does not work? >return [a, b] # does

Re: What is difference between ADO and RDO

2009-02-05 Thread Chris Rebert
On Thu, Feb 5, 2009 at 9:52 PM, agile wrote: > Explain ADO and RDO Take 5 seconds to Google them and find their Wikipedia pages: http://en.wikipedia.org/wiki/Remote_Data_Objects http://en.wikipedia.org/wiki/ActiveX_Data_Objects Apparently they're 2 Microsoft technology acronyms -- and they're **

Re: Changing return of type(obj)

2009-02-06 Thread Chris Rebert
On Fri, Feb 6, 2009 at 3:03 AM, Ken Elkabany wrote: > Hello, > > I am attempting to fully-simulate an 'int' object with a custom object type. > It is part of a library I am creating for python futures and promises. Is > there anyway such that type(my_object) can return ? Or for that > matter, any

Re: Question on Strings

2009-02-06 Thread Chris Rebert
On Fri, Feb 6, 2009 at 1:49 AM, Kalyankumar Ramaseshan wrote: > > Hi, > > Excuse me if this is a repeat question! > > I just wanted to know how are strings represented in python? > > I need to know in terms of: > > a) Strings are stored as UTF-16 (LE/BE) or UTF-32 characters? IIRC, Depends on wha

Re: Returning a variable number of things...

2009-02-06 Thread Chris Rebert
On Fri, Feb 6, 2009 at 10:50 AM, r0g wrote: > Hi There, > > I have a function that uses *args to accept a variable number of > parameters and I would like it to return a variable number of objects. > > I could return a list but I would like to take advantage of tuple > unpacking with the return va

Re: Lists implemented as integer-hashed Dictionaries?

2009-02-06 Thread Chris Rebert
On Fri, Feb 6, 2009 at 7:18 PM, er wrote: > Somebody much more intelligent than I said today that someone told him that > Python lists are just dictionaries with lists hashed by integers. Since he > said that someone else told him this, I piped up and said that I thought > that wasn't true. I lo

Re: Lists implemented as integer-hashed Dictionaries?

2009-02-06 Thread Chris Rebert
> On Fri, Feb 6, 2009 at 10:25 PM, Chris Rebert wrote: >> On Fri, Feb 6, 2009 at 7:18 PM, er wrote: >> > Somebody much more intelligent than I said today that someone told him >> > that >> > Python lists are just dictionaries with lists hashed by integers.

Re: WebError documentation?

2009-02-06 Thread Chris Rebert
On Thu, Feb 5, 2009 at 12:52 PM, Ron Garret wrote: > Is there any? Where is it? Extensive Googling has proven fruitless. It's not a standard Python exception. A third-party library you're using must be raising it. Check the exception traceback. Cheers, Chris -- Follow the path of the Iguana.

Re: The fastest way to convert a long list of date

2009-02-08 Thread Chris Rebert
On Sun, Feb 8, 2009 at 4:46 AM, wrote: > If I want to convert a single date format I can do: > > import datetime, dateutil.parser > d = dateutil.parser.parse('2008-09-26) > print d.strftime('%A %d, %b %y' ) > > but if I want convert a long list of time how can do it in the fastest > way? > for ex

Re: Python Module: nift

2009-02-08 Thread Chris Rebert
On Sun, Feb 8, 2009 at 10:42 AM, J wrote: > What are your thoughts on this module I created? * You should probably use individual docstrings for each function rather than one giant module docstring * Don't use 'list' as a variable name; it shadows the name of the builtin list type * You can use t

Re: Python Module: nift

2009-02-08 Thread Chris Rebert
On Sun, Feb 8, 2009 at 12:57 PM, Paul McGuire wrote: > On Feb 8, 12:42 pm, J wrote: >> What are your thoughts on this module I created? >> > Here are a few steps to illustrate some good basic Python idioms worth > learning: > > Step 1: Replace many-branched if-elif with dict > > While translating

Re: Python Module: nift

2009-02-08 Thread Chris Rebert
On Sun, Feb 8, 2009 at 2:45 PM, J wrote: > Thanks for your answers, especially Chris Rebert and Paul McGuire's. I > have a question: > How far does Python go in the Game Development field? (Using Python > only, no extensions) You pretty much need to integrate with some C(++) l

Re: Variable + String Format

2009-02-09 Thread Chris Rebert
On Tue, Feb 10, 2009 at 2:03 AM, Joel Ross wrote: > Hi all, > > I have this piece of code: > # > > wordList = "/tmp/Wordlist" > file = open(wordList, 'r+b') Why are you opening the file in binary mode? It's content is text!

Re: Help needed to retrieve text from a text-file using RegEx

2009-02-09 Thread Chris Rebert
On Mon, Feb 9, 2009 at 9:22 AM, Oltmans wrote: > Here is the scenario: > > It's a command line program. I ask user for a input string. Based on > that input string I retrieve text from a text file. My text file looks > like following > > Text-file: > - > AbcManager=C:\source\code\Modul

Re: "Super()" confusion

2009-02-09 Thread Chris Rebert
On Mon, Feb 9, 2009 at 4:18 PM, Lionel wrote: > On Feb 9, 4:04 pm, Jean-Paul Calderone wrote: >> On Mon, 9 Feb 2009 15:20:05 -0800 (PST), Lionel >> wrote: >> >Hello. I've been scouring the web looking for something to clear up a >> >little confusion about the use of "super()" but haven't found

Re: can multi-core improve single funciton?

2009-02-09 Thread Chris Rebert
On Mon, Feb 9, 2009 at 10:28 PM, oyster wrote: > I mean this > [code] > def fib(n): >if n<=1: >return 1 >return fib(n-1)+fib(n-2) > > useCore(1) > timeit(fib(500)) #this show 20 seconds > > useCore(2) > timeit(fib(500)) #this show 10 seconds > [/code] > > Is it possible? > > and mo

Re: What's wrong with my python? I can't use string

2009-02-09 Thread Chris Rebert
On Mon, Feb 9, 2009 at 11:13 PM, Frank Potter wrote: > I have a xxx.py which has code as below: > > import string > > print dir(string) > print string.printable > > > when I run it, I got the strange error: > > "\n" > "\n" > "##result##\n" > "##msg##\n" > "##pass_no##\n" > "##pot_num##\n" > "##pot

Re: can multi-core improve single funciton?

2009-02-10 Thread Chris Rebert
On Tue, Feb 10, 2009 at 12:45 AM, Steven D'Aprano wrote: > On Tue, 10 Feb 2009 18:18:23 +1000, Gerhard Weis wrote: > >> Once I have seen Haskell code, that ran fibonacci on a 4 core system. >> >> The algorithm itself basically used an extra granularity paramet until >> which new threads will be sp

Re: bool evaluations of generators vs lists

2009-02-10 Thread Chris Rebert
On Tue, Feb 10, 2009 at 11:15 AM, Josh Dukes wrote: > quite simply...what??? > > In [108]: bool([ x for x in range(10) if False ]) > Out[108]: False This evaluates the list comprehension and creates an empty list, which is considered boolean False by Python. > In [109]: bool( x for x in range(10

Re: Tricky question about native extension packaging

2009-02-10 Thread Chris Rebert
On Tue, Feb 10, 2009 at 8:42 AM, wrote: > let's assume I (almost) have and extension available as a C file and > the setup.py and I want to generate from this single c file 2 .so > files using > > cc -DOPTION1 x.c to produce x_1.so > cc -DOPTION2 x.c to produce x_2.so > > and at runtime depending

Re: How to get a return from Button?

2009-02-10 Thread Chris Rebert
On Tue, Feb 10, 2009 at 12:21 PM, Muddy Coder wrote: > Hi Folks, > > I want to use a Button to trigger askopenfilename() dialog, then I can > select a file. My short code is below: > > > def select_file(): >filenam = askopenfilename(title='Get the file:') > return filenam > > root =

Re: bool evaluations of generators vs lists

2009-02-10 Thread Chris Rebert
On Tue, Feb 10, 2009 at 1:57 PM, Steven D'Aprano wrote: > On Tue, 10 Feb 2009 12:50:02 -0800, Josh Dukes wrote: > >> The thing I don't understand is why a generator that has no iterable >> values is different from an empty list. > > How do you know it has no iterable values until you call next() o

Re: read Zipfile

2009-11-02 Thread Chris Rebert
> On Mon, Nov 2, 2009 at 5:02 PM, Tim Chase > wrote: I would like to open the csv file with folowwing command, file=archive.open("CHAVI_MACS_SC_A__AUG_25_08_FinalReport_090812.csv","r") But it turned out error, Traceback (most recent call last):  File "", line 1,

Re: how to remove the punctuation and no need words from paragraphs

2009-11-03 Thread Chris Rebert
On Tue, Nov 3, 2009 at 1:44 PM, kylin wrote: > I want to remove all the punctuation and no need words form a string > datasets for experiment. > > I am new to python, please give me some clue and direction to write > this code. The `replace` method of strings should get you pretty far (just repla

Re: How to print zero-padded floating point numbers in python 2.6.1

2009-11-04 Thread Chris Rebert
On Wed, Nov 4, 2009 at 12:04 AM, Lorenzo Di Gregorio wrote: > Hello, > > I thought that I could zero-pad a floating point number in 'print' by > inserting a zero after '%', but this does not work. > > I get: > > print '%2.2F' % 3.5 > 3.50 > print '%02.2F' % 3.5 > 3.50 > > How can I get print (in a

Re: python compare and process a csv file

2009-11-04 Thread Chris Rebert
On Tue, Nov 3, 2009 at 7:43 AM, Siva Subramanian wrote: > Hello all, > > I am new on this list and computer programming > > I have two distinct statistical files (both csv) > > 1.   Report_2_5 – this is a report dump containing over a 10 million > records and is different every day > > 2.

Re: a is b

2009-11-04 Thread Chris Rebert
On Wed, Nov 4, 2009 at 10:37 AM, Sebastian wrote: > I have a question from the pyar  list that may have been discussed on this > list, but i didn't catch it. > Have some common objects been somewhat hardcoded into python, like some > integers as shown in the examples below? What other object have

Re: Is there a function that can test if a path is in a directory or one of its sub-directory (recursively)?

2009-11-05 Thread Chris Rebert
On Thu, Nov 5, 2009 at 7:41 PM, Peng Yu wrote: > I looked though the os.path manual. I don't find a function that can > test if a path is in a directory or its sub-directory (recursively). > > For example, /a/b/c/d is in /a its sub-directory (recursively). Could > somebody let me know if such func

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-05 Thread Chris Rebert
On Thu, Nov 5, 2009 at 8:19 PM, Peng Yu wrote: > Suppose I have a list of strings, A. I want to compute the list (call > it B) of strings that are elements of A but doesn't match a regex. I > could use a for loop to do so. In a functional language, there is way > to do so without using the for loo

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-05 Thread Chris Rebert
On Thu, Nov 5, 2009 at 9:23 PM, Peng Yu wrote: > On Thu, Nov 5, 2009 at 10:25 PM, Chris Rebert wrote: >> On Thu, Nov 5, 2009 at 8:19 PM, Peng Yu wrote: >>> Suppose I have a list of strings, A. I want to compute the list (call >>> it B) of strings that are elements of

Re: Is there a function that can test if a path is in a directory or one of its sub-directory (recursively)?

2009-11-06 Thread Chris Rebert
On Thu, Nov 5, 2009 at 10:49 PM, Gabriel Genellina wrote: > En Fri, 06 Nov 2009 00:53:14 -0300, Chris Rebert > escribió: >> On Thu, Nov 5, 2009 at 7:41 PM, Peng Yu wrote: >>> I looked though the os.path manual. I don't find a function that can >>> test if

Re: why does "help(import)" not work?

2009-11-06 Thread Chris Rebert
On Fri, Nov 6, 2009 at 1:56 AM, Robert P. J. Day wrote: >  i'm sure there's a painfully obvious answer to this, but is there a > reason i can't do: > help(import) >  File "", line 1 >    help(import) >              ^ > SyntaxError: invalid syntax > >  on the other hand, i can certainly g

Re: Commenting and uncommenting from the shell

2009-11-08 Thread Chris Rebert
On Sun, Nov 8, 2009 at 3:13 PM, Ray Holt wrote: > Can you comment and uncomment code from the shell. I know that the format > meny only shows in the edit window. I tried crtl + 3, which is what it said > in the configuration window to use, and nothing happens. I'm assuming by "the shell" you mean

Re: [PYTHON] How to set the range for x-axis

2009-11-09 Thread Chris Rebert
On Mon, Nov 9, 2009 at 7:45 AM, Moses wrote: > I have written a script in python to plot a graph. However, the > range for the x-axis starts from 0.5 to 1.0. However, I would like > to start from 0 to 1. Any pointer to this shall be appreciated. Some /very/ basic information such as what plotting

Re: Knob label justification

2009-11-11 Thread Chris Rebert
On Wed, Nov 11, 2009 at 3:25 AM, Hugo Léveillé wrote: > By default, a boolean knob has the text label on the right. How can I make > it on the left? We're not mind readers. We'll need to know which GUI toolkit you're using. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mai

Re: Unexpected python exception

2009-11-11 Thread Chris Rebert
On Wed, Nov 11, 2009 at 8:49 AM, Eduardo Lenz wrote: > Em Qua 11 Nov 2009, às 03:21:55, Diez B. Roggisch escreveu: >> Richard Purdie schrieb: >> > I've been having problems with an unexpected exception from python which >> > I can summarise with the following testcase: >> > >> > def A(): >> >    

Re: Basic list/dictionary question

2009-11-11 Thread Chris Rebert
On Wed, Nov 11, 2009 at 4:16 AM, Daniel Jowett wrote: > Greetings, > > I'm trying to categorize items in a list, by copying them into a > dictionary... > A simple example with strings doesn't seem to work how I'd expect: > basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']

Re: installing lxml ?

2009-11-11 Thread Chris Rebert
On Wed, Nov 11, 2009 at 4:49 AM, 7stud wrote: > I'm trying to install lxml, but I can't figure out the installation > instructions.  Here: > > http://codespeak.net/lxml/installation.html > > it says: > > 1) Get the easy_install tool. > My os is mac os x 10.4.11. I would recommend installing fink

Re: Unexpected python exception

2009-11-11 Thread Chris Rebert
On Wed, Nov 11, 2009 at 4:37 AM, Richard Purdie wrote: > Is there a way to make the "global x" apply to all functions without > adding it to each one? Thankfully, no. > What I'm trying to do is to avoid having "import X" statements > everywhere by changing __builtin__. It seems my approach does

Re: query regarding file handling.

2009-11-12 Thread Chris Rebert
On Thu, Nov 12, 2009 at 1:59 AM, ankita dutta wrote: > hi all, > > i have a file of 3x3 matrix of decimal numbers(tab separated). like this : > > 0.02    0.38    0.01 > 0.04    0.32    0.00 > 0.03    0.40    0.02 > > now i want to read 1 row and get the sum of a particular row. but when i am > try

Re: Why Error is derived from EnvironmentError in shutil.py?

2009-11-12 Thread Chris Rebert
On Thu, Nov 12, 2009 at 7:10 AM, Peng Yu wrote: > On Thu, Nov 12, 2009 at 12:00 AM, alex23 wrote: >> On Nov 12, 2:46 pm, Peng Yu wrote: >>> I see Error is derived from EnvironmentError in shutil.py. >>> >>> class Error(EnvironmentError): >>>     pass >>> >>> I'm wondering why EnvironmentError ca

Re: object serialization as python scripts

2009-11-13 Thread Chris Rebert
On Fri, Nov 13, 2009 at 10:26 AM, King wrote: >> Why is it easier than the above mentioned - they are *there* (except the >> custom xml), and just can be used. What don't they do you want to do? >> >> Other than that, and even security issues put aside, I don't see much >> difference between pickl

Re: Run a external program.

2009-11-14 Thread Chris Rebert
> Quoting MRAB : >> Yasser Almeida Hernández wrote: >>> >>> Hi all!! >>> >>> I'm writing a script where i call a external program which receive  some >>> arguments. >>> One of this arguments is stored in a variable, that is passed as >>>  argument as well: >>> >>> import os >>> ... >>> f = open(fil

Re: Simple object reference

2009-11-14 Thread Chris Rebert
On Sat, Nov 14, 2009 at 3:25 PM, AON LAZIO wrote: > Hi, I have some problem with object reference > Say I have this code > > a = b = c = None > slist = [a,b,c] Values are stored in the list, not references to names. Modifying the list does not change what values the names a, b, and c have. There

Re: Simple object reference

2009-11-14 Thread Chris Rebert
On Sat, Nov 14, 2009 at 6:53 PM, Terry Reedy wrote: > Chris Rebert wrote: >> On Sat, Nov 14, 2009 at 3:25 PM, AON LAZIO wrote: >>> Hi, I have some problem with object reference >>> Say I have this code >>> >>> a = b = c = None >>> sl

Re: How to know if a file is a text file

2009-11-15 Thread Chris Rebert
On Sun, Nov 15, 2009 at 4:06 AM, Nobody wrote: > On Sat, 14 Nov 2009 17:02:29 +0100, Luca Fabbri wrote: > >> I'm looking for a way to be able to load a generic file from the >> system and understand if he is plain text. >> The mimetype module has some nice methods, but for example it's not >> work

Re: import subprocess in python

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 4:50 AM, Kuhl wrote: > found in my system, so I have to use python instead. However, "import > subprocess" still failed, see below. > > # which python > /usr/bin/python > # which ipython > ipython: Command not found. > # python > Python 2.2.3 (#1, Feb  2 2005, 12:22:48) >

Re: Newsgroup for beginners

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 6:01 AM, mrholtsr wrote: > Is there a Python newsgroup for those who are strictly beginners at > programming and python? python-tutor: http://mail.python.org/mailman/listinfo/tutor Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/pytho

Re: Logic operators with "in" statement

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 6:02 AM, Mr.SpOOn wrote: > Hi, > I'm trying to use logical operators (or, and) with the "in" statement, > but I'm having some problems to understand their behavior. > > In [1]: l = ['3', 'no3', 'b3'] > > In [2]: '3' in l > Out[2]: True > > In [3]: '3' and '4' in l > Out[3]:

Re: Logic operators with "in" statement

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 6:08 AM, Mr.SpOOn wrote: > Sorry for replying to myself, but I think I understood why I was wrong. > > The correct statement should be something like this: > > In [13]: ('b3' and '5') in l or ('3' and 'b3') in l > Out[13]: True No, you've just run into another misunderstan

Re: Logic operators with "in" statement

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 6:23 AM, Xavier Ho wrote: '3' in l and 'no3' in l > True > > AND operator has a higher precedence, so you don't need any brackets here, I > think. But anyway, you have to use it like that. So that's something you'll > have to fix first. Er, you mean lower precedence.

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 8:54 AM, Steve Ferg wrote: > This is a question for the language mavens that I know hang out here. > It is not Python related, except that recent comparisons of Python to > Google's new Go language brought it to mind. > > NOTE that this is *not* a suggestion to change Pytho

Re: Web servers

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 11:17 AM, Virgil Stokes wrote: > Any suggestions on using Python to connect to Web servers (e.g. to access > financial time series data)? In what format? Using what protocol? (*Insert other basic questions that need answering in order to answer your question here*) Cheers

Re: Changing the current directory (full post)

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 11:36 AM, vsoler wrote: > On Nov 16, 2:35 am, "Gabriel Genellina" > wrote: >> En Sun, 15 Nov 2009 09:04:06 -0300, vsoler >> escribió: >> >> > Ever since I installed my Python 2.6 interpreter (I use IDLE), I've >> > been saving my >> > *.py files in the C:\Program Files\Py

Re: Changing the current directory (full post)

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 11:56 AM, vsoler wrote: > On Nov 16, 8:45 pm, Chris Rebert wrote: >> On Mon, Nov 16, 2009 at 11:36 AM, vsoler wrote: >> > On Nov 16, 2:35 am, "Gabriel Genellina" >> > wrote: >> >> En Sun, 15 Nov 2009 09:04:06 -0300

Re: faster than list.extend()

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 2:30 PM, Hyunchul Kim wrote: > Hi, all. > > I want to improve speed of following simple function. > Any suggestion? > > ** > def triple(inputlist): >   results = [] >   for x in inputlist: >     results.extend([x,x,x]) >   return results > ** You'd probably

Re: Get attribute this way

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 10:04 PM, King wrote: > Python's getattr, setattr and __getattribute__ commands works fine > with python types. > For example: > print o.__getattribute__("name") > print getattr(o, "name") > This is the easiest way to get an attribute using a string. > > In my case the "Nod

Re: Get attribute this way

2009-11-16 Thread Chris Rebert
On Mon, Nov 16, 2009 at 10:53 PM, King wrote: > Writing/Reading data to xml is not a problem. The problem is when I > have to write to attributes in xml, where a connections has been > established. > XML: > destattribute="node2.gradient.colors[1][2]"/> You did not include an example like this in

Re: Accessing a Web server --- how?

2009-11-17 Thread Chris Rebert
On Mon, Nov 16, 2009 at 2:14 AM, Virgil Stokes wrote: > If one goes to the following URL: > http://www.nordea.se/Privat/Spara%2boch%2bplacera/Strukturerade%2bprodukter/Aktieobligation%2bNr%2b99%2bEuropa%2bAlfa/973822.html > > it contains a link (click on "Current courses NBD AT99 3113A") to: > htt

Re: TODO and FIXME tags

2009-11-17 Thread Chris Rebert
2009/11/16 Yasser Almeida Hernández : > Hi all.. > Sorry if this question sound elemental. > How is the sintaxis for set the TODO and FIXME tags...? There is no special syntax for those. Some people use them in comments, but it's just a convention. Cheers, Chris -- http://blog.rebertia.com -- ht

Re: Code for finding the 1000th prime

2009-11-17 Thread Chris Rebert
On Tue, Nov 17, 2009 at 9:27 AM, Diez B. Roggisch wrote: > Stefan Behnel wrote: >> Robert P. J. Day, 15.11.2009 15:44: >> Now, all that's left to do is write a prime number generator (a random >> number generator will do, too, but writing a good one isn't easy), run it >> repeatedly in a loop, and

Re: python simply not scaleable enough for google?

2009-11-17 Thread Chris Rebert
On Tue, Nov 17, 2009 at 8:41 AM, Rustom Mody wrote: > "Language L is (in)efficient. No! Only implementations are (in)efficient" > > I am reminded of a personal anecdote.  It happened about 20 years ago > but is still fresh and this thread reminds me of it. > > I was attending some workshop on theo

Re: TypeError: unsupported operand types for +: 'NoneType' and 'str'

2009-11-17 Thread Chris Rebert
On Tue, Nov 17, 2009 at 7:25 PM, wrote: > The error I get; > > File "myscript.py", Line 18, in ? > projectpath = ourHome+"/etc/TEMPLATE" > TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' > > Python 2.4.3 > > I've read were when passing a string to exec may need to end with a '

Re: WindowsError is not available on linux?

2009-11-17 Thread Chris Rebert
On Tue, Nov 17, 2009 at 7:37 PM, Peng Yu wrote: > On Tue, Nov 17, 2009 at 9:18 PM, alex23 wrote: >> Peng Yu wrote: >>> But the document doesn't say shutil need to be imported in order to >>> use WindowsError. Shall the document or the code be corrected? >> >> Neither, it's your understanding tha

Re: Running a python script from interactive mode

2009-11-17 Thread Chris Rebert
On Tue, Nov 17, 2009 at 8:56 PM, ashwini yal wrote: > Hi, > > I am trying to run a python script from interactive mode ,but i am not able > to know how to run it? Is it possible? if yes please let me how to run the > script? execfile("/path/to/the/script.py") or if it's on your sys.path and does

<    1   2   3   4   5   6   7   8   9   10   >