Python newbie data structures question

2009-10-28 Thread codingJoe
Hi all! I am trying to choose the right data structure to do a value lookup with multiple keys. I want to lookup data by: key, key,{ values } My final product should be able to reference this datastructure from within a django template. Because my lookup needs only 80 values and will never c

WSE 3 with Python (Newbie)

2009-03-11 Thread Shane Bignell
Hi, I am trying to post a python HTTP request to a web service that implements using Web Service Enhancements 3.0. I have WSE3.0 installed on the client and the server and I have looked over a few examples of how the SOAP header should look like for WSE authentication, I have included the follo

Re: book recommendation for Python newbie?

2008-10-11 Thread nage
I would have a look on Amazon at Python Programming: An Introduction to Computer Science (Paperback) -- nage nage's Profile: http://nettechguide.com/forums/member.php?u=268 View this thread: http://nettechguide.com/forums/

Re: book recommendation for Python newbie?

2008-10-10 Thread Abah Joseph
Core Python Programming" written by Wesley J. Chun, second edition, Prentice Hall, ISBN 0-13-226993-7, go for it. I`m only a PHP programmer and this book have helped me a lot from basic to advance level. though i`m still reading... On 10/10/08, slais-www <[EMAIL PROTECTED]> wrote: > > Mike Drisc

Re: book recommendation for Python newbie?

2008-10-10 Thread slais-www
Mike Driscoll wrote: A lot of people recommend Lutz's "Learning Python". While I haven't read it, I have read his follow-up "Programming Python" and it was I found Learning Python good for learning, and a useful reference sometimes, but it can seem very slow paced if you already know some oth

Re: book recommendation for Python newbie?

2008-10-10 Thread Gabriel Rossetti
Joe Strout wrote: I'm trying to (gently) convince my business partner that we should be adding Python to our core toolset. He's never used it before, apart from poking around in the tutorial a bit at my urging. But he's got a birthday coming up, and I'd like to get him a book that will help h

Re: book recommendation for Python newbie?

2008-10-09 Thread Mike Driscoll
On Oct 9, 3:00 pm, Joe Strout <[EMAIL PROTECTED]> wrote: > I'm trying to (gently) convince my business partner that we should be   > adding Python to our core toolset.  He's never used it before, apart   > from poking around in the tutorial a bit at my urging.  But he's got a   > birthday coming up

book recommendation for Python newbie?

2008-10-09 Thread Joe Strout
I'm trying to (gently) convince my business partner that we should be adding Python to our core toolset. He's never used it before, apart from poking around in the tutorial a bit at my urging. But he's got a birthday coming up, and I'd like to get him a book that will help him make the tr

Re: Python newbie question re Strings and integers

2008-09-22 Thread Bruno Desthuilliers
rmac a écrit : Ah! Arghh!!! You are so correct on the usage of the ':' Python syntax is a little different from what I am used to. I don't know what you're used to, but chances are that more than the syntax differs !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python newbie question re Strings and integers

2008-09-20 Thread Bruno Desthuilliers
rmac a écrit : the following code attempts to extract a symbol name from a string: extensionStart = int(filename.rfind('.')) rfind returns an int, so passing it to the int type constructor is useless. filenameStart = int(filename.rfind('/')) idem #print 'Extension Start - ' +

Re: Python newbie

2008-09-19 Thread bearophileHUGS
Mladen Gogala: Welcome to Python, you will need only one or few weeks to be able to write useful Python programs. But even with the help of a good book (that I suggest you to read) you may need several months or one year to master it :-) > 2) Why is it illegal to pass a built-in function "print"

Re: Python newbie

2008-09-19 Thread Peter Pearson
On 19 Sep 2008 08:13:05 GMT, Steven D'Aprano wrote: > On Fri, 19 Sep 2008 09:13:48 +0200, Mladen Gogala wrote: [snip] >> perl -e '@a=(1,2,3); map { $_*=2 } @a; map { print "$_\n"; } @a;' >> >> The equivalent in Python looks like this: > > Actually, no it doesn't. The equivalent looks more like th

Re: Python newbie

2008-09-19 Thread Grant Edwards
On 2008-09-19, Mladen Gogala <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > >> No. Python implicitly dereferences all names when using them >> to compute values, and only uses them as references on the >> left-hand side of an assignment. >> >> Please note the above statement is contentious, an

Re: Python newbie

2008-09-19 Thread kaer
On 19 sep, 10:13, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 19 Sep 2008 09:13:48 +0200, Mladen Gogala wrote: > > I am a Python newbie who decided to see what that Python fuss is all > > about. Quite frankly, I am a bit perplexed., here is what perplexes me: &g

Re: Python newbie

2008-09-19 Thread Tim Golden
Mladen Gogala wrote: Steve Holden wrote: No. Python implicitly dereferences all names when using them to compute values, and only uses them as references on the left-hand side of an assignment. Please note the above statement is contentious, and will likely bring a horde of screaming fanatics

Re: Python newbie

2008-09-19 Thread Mladen Gogala
Steve Holden wrote: > No. Python implicitly dereferences all names when using them to compute > values, and only uses them as references on the left-hand side of an > assignment. > > Please note the above statement is contentious, and will likely bring a > horde of screaming fanatics of various f

Re: Python newbie

2008-09-19 Thread Steven D'Aprano
On Fri, 19 Sep 2008 03:34:50 -0400, Steve Holden wrote: > Please note the above statement is contentious, and will likely bring a > horde of screaming fanatics of various flavors down on my head for > terminological inexactitude. A pox on you and your descendants onto the tenth generation! *win

Re: Python newbie

2008-09-19 Thread Steven D'Aprano
On Fri, 19 Sep 2008 09:13:48 +0200, Mladen Gogala wrote: > I am a Python newbie who decided to see what that Python fuss is all > about. Quite frankly, I am a bit perplexed. Naturally you will be perplexed if you assume that Python is just Perl with a more verbose syntax. It isn't

Re: Python newbie

2008-09-19 Thread Marc 'BlackJack' Rintsch
On Fri, 19 Sep 2008 09:13:48 +0200, Mladen Gogala wrote: > There are several questions: > > 1) Why is the array "a" unchanged after undergoing a transformation with >map? Because `map()` creates a new list and doesn't change the elements in `a`. > 2) Why is it illegal to pass a built-in fun

Re: Python newbie

2008-09-19 Thread Steve Holden
Mladen Gogala wrote: > I am a Python newbie who decided to see what that Python fuss is all about. > Quite frankly, I am a bit perplexed. After having had few months of > experience with Perl (started in 1994 with Perl v4, and doing it ever > since) , here is what perplexes me: >

Re: Python newbie

2008-09-19 Thread Tino Wildenhain
Hi, Mladen Gogala wrote: I am a Python newbie who decided to see what that Python fuss is all about. Quite frankly, I am a bit perplexed. After having had few months of experience with Perl (started in 1994 with Perl v4, and doing it ever since) , here is what perplexes me: perl -e '@a=(

Python newbie

2008-09-19 Thread Mladen Gogala
I am a Python newbie who decided to see what that Python fuss is all about. Quite frankly, I am a bit perplexed. After having had few months of experience with Perl (started in 1994 with Perl v4, and doing it ever since) , here is what perplexes me: perl -e '@a=(1,2,3); map { $_*=2 } @a

Re: Python newbie question re Strings and integers

2008-09-18 Thread rmac
Ah! Arghh!!! You are so correct on the usage of the ':' Python syntax is a little different from what I am used to. Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python newbie question re Strings and integers

2008-09-18 Thread Miki
>     currentSymbol=filename[int(filenameStart),int(extensionStart)] Should be currentSymbol=filename[int(filenameStart):int(extensionStart)] (change , to :) You don't need to convert to int all the time, rfind will return an integer. Also you can use os.path for this from os.path import

Re: Python newbie question re Strings and integers

2008-09-18 Thread Christian Heimes
rmac wrote: the following code attempts to extract a symbol name from a string: extensionStart = int(filename.rfind('.')) filenameStart = int(filename.rfind('/')) #print 'Extension Start - ' + str(extensionStart) #print 'FileName Start - ' + str(filenameStart) currentSymbol=f

Python newbie question re Strings and integers

2008-09-18 Thread rmac
the following code attempts to extract a symbol name from a string: extensionStart = int(filename.rfind('.')) filenameStart = int(filename.rfind('/')) #print 'Extension Start - ' + str(extensionStart) #print 'FileName Start - ' + str(filenameStart) currentSymbol=filename[int(f

Re: Advice for a python newbie on parsing whois records?

2008-06-11 Thread Phillip B Oldham
On Jun 10, 8:21 pm, Miki <[EMAIL PROTECTED]> wrote: > Hello, > > > Hi. I'm stretching my boundaries in programming with a little python > > shell-script which is going to loop through a list of domain names, > > grab the whois record, parse it, and put the results into a csv. > > > I've got the res

Re: Advice for a python newbie on parsing whois records?

2008-06-10 Thread Miki
Hello, > Hi. I'm stretching my boundaries in programming with a little python > shell-script which is going to loop through a list of domain names, > grab the whois record, parse it, and put the results into a csv. > > I've got the results coming back fine, but since I have *no* > experience with

Re: Advice for a python newbie on parsing whois records?

2008-06-10 Thread Lie
On Jun 10, 9:47 pm, Phillip B Oldham <[EMAIL PROTECTED]> wrote: > Hi. I'm stretching my boundaries in programming with a little python > shell-script which is going to loop through a list of domain names, > grab the whois record, parse it, and put the results into a csv. > > I've got the results co

Advice for a python newbie on parsing whois records?

2008-06-10 Thread Phillip B Oldham
Hi. I'm stretching my boundaries in programming with a little python shell-script which is going to loop through a list of domain names, grab the whois record, parse it, and put the results into a csv. I've got the results coming back fine, but since I have *no* experience with python I'm wonderin

Re: python newbie: some surprises

2008-05-18 Thread Lie
On May 8, 2:06 pm, v4vijayakumar <[EMAIL PROTECTED]> wrote: > When I started coding in python, these two things surprised me. > > 1. my code is inconsistently indented with the combination of tabs and > spaces. Even lines looked intended, but it is not. The problem is in tab not Python, there is n

Re: python newbie: some surprises

2008-05-15 Thread tinnews
Kees Bakker <[EMAIL PROTECTED]> wrote: > > So far, I have seen only one editor that understands the difference between > TABs and indentation, and that is Emacs. Most vi clones (and the original vi) do too! :-) E.g. in the clone I use (vile) there are independent settings for tabstop and shiftw

Re: python newbie: some surprises

2008-05-15 Thread Marco Mariani
Kees Bakker wrote: So far, I have seen only one editor that understands the difference between TABs and indentation, and that is Emacs. Oh, well... in .vimrc: autocmd FileType python set tabstop=8 autocmd FileType python set softtabstop=4 autocmd FileType python set expandtab --

Re: python newbie: some surprises

2008-05-15 Thread Kees Bakker
Gabriel Genellina wrote: > En Fri, 09 May 2008 10:37:30 -0300, v4vijayakumar <[EMAIL PROTECTED]> > escribió: > >> On May 9, 1:48 pm, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote: >>> v4vijayakumar a écrit : >>> >>> > When I started coding in python, these two things surprised me. >>> >>> > 1.

Re: python newbie: some surprises

2008-05-10 Thread Gabriel Genellina
En Fri, 09 May 2008 10:37:30 -0300, v4vijayakumar <[EMAIL PROTECTED]> escribió: > On May 9, 1:48 pm, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> v4vijayakumar a écrit : >> >> > When I started coding in python, these two things surprised me. >> >> > 1. my code is inconsistently indented with

Re: python newbie: some surprises

2008-05-09 Thread J. Cliff Dyer
On Fri, 2008-05-09 at 15:08 +, Yves Dorfsman wrote: > Gabriel Genellina wrote: > > >> I see the point of the OP. Couldn't the new-line be used as an > >> equivalent of ':', for example, do you find this difficult to read: > >> > >> if a == 3 > >>do_something() > >> > >> > >> if a == 3:

Re: python newbie: some surprises

2008-05-09 Thread Yves Dorfsman
Gabriel Genellina wrote: I see the point of the OP. Couldn't the new-line be used as an equivalent of ':', for example, do you find this difficult to read: if a == 3 do_something() if a == 3: do_something() Yes, it could be done, there are no technical reasons to always force to use

Re: python newbie: some surprises

2008-05-09 Thread v4vijayakumar
On May 9, 1:48 pm, Bruno Desthuilliers wrote: > v4vijayakumar a écrit : > > > When I started coding in python, these two things surprised me. > > > 1. my code is inconsistently indented with the combination of tabs and > > spaces. Even lines looked intended, but it is not. > > Then you have a prob

Re: python newbie: some surprises

2008-05-09 Thread Bruno Desthuilliers
Yves Dorfsman a écrit : (snip) I see the point of the OP. Couldn't the new-line be used as an equivalent of ':', Technically, yes. OTHO, the ':' helps editors doing proper indentation. -- http://mail.python.org/mailman/listinfo/python-list

Re: python newbie: some surprises

2008-05-09 Thread Bruno Desthuilliers
Yves Dorfsman a écrit : Mensanator wrote: 2. python requires to pass "self" to all instance methods Who uses methods? Is this a joke ? Very probably. What are the alternatives ? Err... functions ?-) -- http://mail.python.org/mailman/listinfo/python-list

Re: python newbie: some surprises

2008-05-09 Thread Bruno Desthuilliers
v4vijayakumar a écrit : When I started coding in python, these two things surprised me. 1. my code is inconsistently indented with the combination of tabs and spaces. Even lines looked intended, but it is not. Then you have a problem with your code editor - not with Python. 2. python require

Re: python newbie: some surprises

2008-05-08 Thread Gabriel Genellina
En Fri, 09 May 2008 01:47:49 -0300, Yves Dorfsman <[EMAIL PROTECTED]> escribió: I see the point of the OP. Couldn't the new-line be used as an equivalent of ':', for example, do you find this difficult to read: if a == 3 do_something() if a == 3: do_something() And surely, it shoul

Re: python newbie: some surprises

2008-05-08 Thread Mensanator
On May 8, 11:47�pm, Yves Dorfsman <[EMAIL PROTECTED]> wrote: > Mensanator wrote: > >> 2. python requires to pass "self" to all instance methods > > > Who uses methods? > > Is this a joke ? Yes. > What are the alternatives ? > > > > >> and I missed ":" often. :) > > > Try using something like Seed

Re: python newbie: some surprises

2008-05-08 Thread Yves Dorfsman
Mensanator wrote: 2. python requires to pass "self" to all instance methods Who uses methods? Is this a joke ? What are the alternatives ? and I missed ":" often. :) Try using something like Seed7, where you have to use "then" with "if" and "do" with "while" and "end" in every block. M

Re: python newbie: some surprises

2008-05-08 Thread Mensanator
On May 8, 2:06 am, v4vijayakumar <[EMAIL PROTECTED]> wrote: > When I started coding in python, these two things surprised me. > > 1. my code is inconsistently indented with the combination of tabs and > spaces. Even lines looked intended, but it is not. You must type inconsistently. I never had s

Re: python newbie: some surprises

2008-05-08 Thread Martin P. Hellwig
v4vijayakumar wrote: When I started coding in python, these two things surprised me. 1. my code is inconsistently indented with the combination of tabs and spaces. Even lines looked intended, but it is not. Even the standard editor Idle tries to guess the intendation, so this was never a probl

python newbie: some surprises

2008-05-08 Thread v4vijayakumar
When I started coding in python, these two things surprised me. 1. my code is inconsistently indented with the combination of tabs and spaces. Even lines looked intended, but it is not. 2. python requires to pass "self" to all instance methods and I missed ":" often. :) -- http://mail.python.org

Python newbie

2008-03-02 Thread t3chn0n3rd
i am a python newbie. My studies have me in many directions -- http://mail.python.org/mailman/listinfo/python-list

Re: Question from a python newbie

2007-12-13 Thread Russell
I suspected it was a ternary type of operator, but was unable to confirm it. And I didn't realize it was new to 2.5. Perfectly clear now. :) Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Question from a python newbie

2007-12-13 Thread J. Clifford Dyer
On Thu, Dec 13, 2007 at 04:57:04PM +0100, Remco Gerlich wrote regarding Re: Question from a python newbie: > >On Dec 13, 2007 4:39 PM, Russell <[EMAIL PROTECTED]> wrote: > > I've been learning Python slowly for a few months, coming from a > C/C+ >

Re: Question from a python newbie

2007-12-13 Thread Remco Gerlich
On Dec 13, 2007 4:39 PM, Russell <[EMAIL PROTECTED]> wrote: > I've been learning Python slowly for a few months, coming from a C/C+ > +, C#, Java, PHP background. I ran across a code fragment I'm having > trouble wrapping my brain around. I've searched the Language > Reference and was not able t

Re: Question from a python newbie

2007-12-13 Thread Duncan Booth
Russell <[EMAIL PROTECTED]> wrote: > I've searched the Language > Reference and was not able to find any info regarding the structure of > this code fragment: > > int(text) if text.isdigit() else text http://docs.python.org/whatsnew/pep-308.html -- http://mail.python.org/mailman/listinfo/pytho

Question from a python newbie

2007-12-13 Thread Russell
I've been learning Python slowly for a few months, coming from a C/C+ +, C#, Java, PHP background. I ran across a code fragment I'm having trouble wrapping my brain around. I've searched the Language Reference and was not able to find any info regarding the structure of this code fragment: int(t

Re: python newbie - question about lexical scoping

2007-12-02 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : (snip) > class Foo(object): > bar = {'baz':'bing'} > def __init__(self): > self.bar = self.bar Hem... Should re-read before posting :( It's of course: def __init__(self): self.bar = self.bar.copy() -- http://mail.python.org/mailman/listinfo/pyt

Re: python newbie - question about lexical scoping

2007-12-02 Thread hdante
On Dec 1, 11:31 pm, "Matt Barnicle" <[EMAIL PROTECTED]> wrote: > >> On Dec 1, 4:47 pm, Matt Barnicle <[EMAIL PROTECTED]> wrote: > > aye yaye aye... thanks for the pointers in the right direction.. i > > fiddled around with the code for a while and now i've reduced it to the > > *real* issue... i

Re: python newbie - question about lexical scoping

2007-12-02 Thread Bruno Desthuilliers
Matt Barnicle a écrit : >>>On Dec 1, 4:47 pm, Matt Barnicle <[EMAIL PROTECTED]> wrote: >> >>aye yaye aye... thanks for the pointers in the right direction.. i >>fiddled around with the code for a while and now i've reduced it to the >>*real* issue... i have a class dict variable that apparently

Re: python newbie - question about lexical scoping

2007-12-02 Thread Hrvoje Niksic
"Matt Barnicle" <[EMAIL PROTECTED]> writes: >> i have a class dict variable that apparently holds its value across >> instantiations of new objects.. [...] > ok, i see... python has a concept i'm not accustomed to I don't doubt that Python managed to confuse you here, but in this case there is n

Re: python newbie - question about lexical scoping

2007-12-01 Thread Matt Barnicle
>> On Dec 1, 4:47 pm, Matt Barnicle <[EMAIL PROTECTED]> wrote: > aye yaye aye... thanks for the pointers in the right direction.. i > fiddled around with the code for a while and now i've reduced it to the > *real* issue... i have a class dict variable that apparently holds its > value across in

Re: python newbie - question about lexical scoping

2007-12-01 Thread Matt Barnicle
>> On Dec 1, 4:47 pm, Matt Barnicle <[EMAIL PROTECTED]> wrote: > aye yaye aye... thanks for the pointers in the right direction.. i > fiddled around with the code for a while and now i've reduced it to the > *real* issue... i have a class dict variable that apparently holds its > value across in

Re: python newbie - question about lexical scoping

2007-12-01 Thread Tim Roberts
Matt Barnicle <[EMAIL PROTECTED]> wrote: >hi everyone.. i've been chugging along learning python for a few months >now and getting answers to all needed questions on my own, but this one >i can't figure out nor can i find information on the internet about it, >possibly because i don't understa

Re: python newbie - question about lexical scoping

2007-12-01 Thread Matt Barnicle
> On Dec 1, 4:47 pm, Matt Barnicle <[EMAIL PROTECTED]> wrote: >> hi everyone.. i've been chugging along learning python for a few months >> now and getting answers to all needed questions on my own, but this one >> i can't figure out nor can i find information on the internet about it, >> possibly

Re: python newbie - question about lexical scoping

2007-12-01 Thread Matt Barnicle
> On Dec 1, 4:47 pm, Matt Barnicle <[EMAIL PROTECTED]> wrote: >> hi everyone.. i've been chugging along learning python for a few months >> now and getting answers to all needed questions on my own, but this one >> i can't figure out nor can i find information on the internet about it, >> possibly

Re: python newbie - question about lexical scoping

2007-11-30 Thread John Machin
On Dec 1, 4:47 pm, Matt Barnicle <[EMAIL PROTECTED]> wrote: > hi everyone.. i've been chugging along learning python for a few months > now and getting answers to all needed questions on my own, but this one > i can't figure out nor can i find information on the internet about it, > possibly becau

python newbie - question about lexical scoping

2007-11-30 Thread Matt Barnicle
hi everyone.. i've been chugging along learning python for a few months now and getting answers to all needed questions on my own, but this one i can't figure out nor can i find information on the internet about it, possibly because i don't understand the right words to type into google.. i ha

Re: python newbie

2007-11-05 Thread Duncan Booth
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > As far as I know, all it would take to allow modules to be callable > would be a single change to the module type, the equivalent of: > > def __call__(self, *args, **kwargs): > try: > # Special methods are retrieved from the class, not >

Re: python newbie

2007-11-04 Thread Steven D'Aprano
On Sun, 04 Nov 2007 12:05:35 -0800, Paul Rubin wrote: > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: >> > from random import random >> > x = random() >> > y = random.choice((1,2,3)) # oops >> >> from random import random, choice >> >> x = random() >> y = choice((1, 2, 3)) > > Really,

Re: python newbie

2007-11-04 Thread Paul Rubin
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > > from random import random > > x = random() > > y = random.choice((1,2,3)) # oops > > from random import random, choice > > x = random() > y = choice((1, 2, 3)) Really, a lot of these modules exist primarily to export a single class or f

Re: python newbie

2007-11-04 Thread Bruno Desthuilliers
Paul Rubin a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > >>What's wrong with: >> >>from StringIO import StringIO >>buf = StringIO('hello') > > > The other functions in the module aren't available then. E.g. > > from random import random > x = random() > y = random.choice(

Re: python newbie

2007-11-04 Thread Paul Rubin
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > What's wrong with: > > from StringIO import StringIO > buf = StringIO('hello') The other functions in the module aren't available then. E.g. from random import random x = random() y = random.choice((1,2,3)) # oops -- http://mail.python.

Re: python newbie

2007-11-04 Thread Bruno Desthuilliers
Bjoern Schliessmann a écrit : > Hendrik van Rooyen wrote: > > >>So what's the difference ? Why can't bar be called a method >>of foo, or is it merely a convention that classes have >>methods and modules have functions? > > > In depends on which terminology you use. As Steven told, Python > met

Re: python newbie

2007-11-04 Thread Bruno Desthuilliers
Paul Rubin a écrit : > Paul Hankin <[EMAIL PROTECTED]> writes: > >>I'm intrigued - when would you want a callable module? > > > I think it would be nice to be able to say > >import StringIO >buf = StringIO('hello') > > instead of > > import StringIO > buf = StringIO.StringIO('hell

Re: python newbie

2007-11-04 Thread Bruno Desthuilliers
Hendrik van Rooyen a écrit : > "Bruno Desthuilliers" wrote: > > >>functions are *not* methods of their module. > > > Now I am confused - if I write: > > result = foo.bar(param) > > Then if foo is a class, we probably all agree that bar is > a method of foo. We probably agree that it's an att

Re: python newbie

2007-11-04 Thread Bruno Desthuilliers
Bjoern Schliessmann a écrit : > Bruno Desthuilliers wrote: > >>Bjoern Schliessmann a écrit : > > >>>You can't just declare in Python, you always define objects (and >>>bind a name to them). >> >>def toto(): >> global p >> p = 42 >> >>Here I declared 'x' as global without defining it. > > >

Re: python newbie

2007-11-03 Thread Paul Rubin
Paul Hankin <[EMAIL PROTECTED]> writes: > I'm intrigued - when would you want a callable module? I think it would be nice to be able to say import StringIO buf = StringIO('hello') instead of import StringIO buf = StringIO.StringIO('hello') -- http://mail.python.org/mailman/listinfo/p

Re: python newbie

2007-11-03 Thread Paul Hankin
On Nov 3, 8:35 pm, Paul Rubin wrote: > Duncan Booth <[EMAIL PROTECTED]> writes: > > This isn't perfect (global variables have to be set before hooking the > > module) but it sort of works: > > - callable.py --- > > """How to define a callable module"""

Re: python newbie

2007-11-03 Thread Paul Rubin
Duncan Booth <[EMAIL PROTECTED]> writes: > This isn't perfect (global variables have to be set before hooking the > module) but it sort of works: > - callable.py --- > """How to define a callable module""" ... Oh neat, thanks, I'll have to file that one away, and use it now

Re: python newbie

2007-11-03 Thread Duncan Booth
Paul Rubin wrote: > Duncan Booth <[EMAIL PROTECTED]> writes: >> modules are not special in any way, except that you cannot subclass >> them. Oops, sorry I got that wrong. Modules are not special in any >> way, they can have methods as well as functions: > > I've felt fo

Re: python newbie

2007-11-03 Thread Gabriel Genellina
En Sat, 03 Nov 2007 09:55:38 -0300, Paul Rubin <"http://phr.cx"@NOSPAM.invalid> escribió: > Duncan Booth <[EMAIL PROTECTED]> writes: >> modules are not special in any way, except that you cannot subclass >> them. >> Oops, sorry I got that wrong. Modules are not special in any way, they >> ca

Re: python newbie

2007-11-03 Thread Paul Rubin
Duncan Booth <[EMAIL PROTECTED]> writes: > modules are not special in any way, except that you cannot subclass them. > Oops, sorry I got that wrong. Modules are not special in any way, they can > have methods as well as functions: I've felt for a long time that you should be able to define __cal

Re: python newbie

2007-11-03 Thread Duncan Booth
Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> Then if foo is a class, we probably all agree that bar is a method of >> foo. > > There are funny edge cases (e.g. bar might be an attribute with a > __call__ method) but in general, yes, bar would be a method of foo. > But that 'funny edge case' is

Re: python newbie

2007-11-03 Thread Bjoern Schliessmann
Hendrik van Rooyen wrote: > So what's the difference ? Why can't bar be called a method > of foo, or is it merely a convention that classes have > methods and modules have functions? In depends on which terminology you use. As Steven told, Python methods are special functions. In contrast, the t

Re: python newbie

2007-11-02 Thread Steven D'Aprano
On Sat, 03 Nov 2007 08:36:24 +0200, Hendrik van Rooyen wrote: > "Bruno Desthuilliers" wrote: > >>functions are *not* methods of their module. > > Now I am confused - if I write: > > result = foo.bar(param) > > Then if foo is a class, we probably all agree that bar is a method of > foo. There

Re: python newbie

2007-11-02 Thread Hendrik van Rooyen
"Bruno Desthuilliers" wrote: >functions are *not* methods of their module. Now I am confused - if I write: result = foo.bar(param) Then if foo is a class, we probably all agree that bar is a method of foo. But the same syntax would work if I had imported some module as foo. So what's the dif

Re: python newbie

2007-11-02 Thread Bjoern Schliessmann
Jim Hendricks wrote: > This sounds like an issue of terminology. I understand that I > don't declare variables like I would in C or Java, but that they > are implicitly declared via the first assignment. I think yes, it's an issue of terminology. As mentioned I used the terms I know from C/C++,

Re: python newbie

2007-11-02 Thread Bjoern Schliessmann
Bruno Desthuilliers wrote: > Bjoern Schliessmann a écrit : >> You can't just declare in Python, you always define objects (and >> bind a name to them). > > def toto(): >global p >p = 42 > > Here I declared 'x' as global without defining it. Ah well, someone had to notice it ... BTW, wh

Re: python newbie

2007-11-02 Thread Bjoern Schliessmann
Duncan Booth wrote: > Why not try it out for yourself (both of you). Globals do not need > to be defined in the global scope so long as the first 'access' is > to bind a value to the variable: Well, I did. I (mis)understood the OP to mean "read" by "access". I didn't consider rebinding another obj

Re: python newbie

2007-11-02 Thread tasjaevan
On Nov 2, 3:35 pm, Jim Hendricks <[EMAIL PROTECTED]> wrote: > > This sounds like an issue of terminology. I understand that I don't > declare variables like I would in C or Java, but that they are > implicitly declared via the first assignment. And the define objects > and bind a name to them mak

Re: python newbie

2007-11-02 Thread Bruno Desthuilliers
Bjoern Schliessmann a écrit : > Jim Hendricks wrote: (snip) >> I see the global keyword that allows access to global vars in a >> function, what I'm not clear on is does that global need to be >> declared in the global scope, > > You can't just declare in Python, you always define objects (and > b

Re: python newbie

2007-11-02 Thread Bruno Desthuilliers
Jim Hendricks a écrit : > New to python, programming in 15 or so langs for 24 years. > > Couple of questions the tuts I've looked at don't explain: > > 1) global vars - python sets scope to the block a var is declared (1st > set), I see the global keyword that allows access to global vars in a

Re: python newbie

2007-11-02 Thread Jim Hendricks
J. Clifford Dyer wrote: >> before calling my_function, x does not exist in my program. So, my >> question is in my_function, the combination of using the global >> statement, then implicitly creating x via assignment to the result of >> the open function, is x created in the global namespace? >

Re: python newbie

2007-11-02 Thread BartlebyScrivener
On Nov 2, 10:13 am, Jim Hendricks <[EMAIL PROTECTED]> wrote: > Here's an example of what I am asking: Try this example from Beazley (pg 82) a = 42 def foo(): a = 13 foo() print a 42 By contrast: a = 42 b = 13 def foo(): global a, b a = 13 b = 0 foo() print a 13 print b 0 -- h

Re: python newbie

2007-11-02 Thread J. Clifford Dyer
On Fri, Nov 02, 2007 at 11:13:00AM -0400, Jim Hendricks wrote regarding Re: python newbie: > > BartlebyScrivener wrote: > > On Nov 2, 8:51 am, Jim Hendricks <[EMAIL PROTECTED]> wrote: > >> New to python, programming in 15 or so langs for 24 years. > >> &g

Re: python newbie

2007-11-02 Thread Jim Hendricks
Bjoern Schliessmann wrote: > Please use a more informative subject next time. > > Jim Hendricks wrote: >> 1) global vars - python sets scope to the block a var is declared >> (1st set), > > http://docs.python.org/ref/global.html > > I'm afraid not. Python only interprets the listed name(s) as >

Re: python newbie

2007-11-02 Thread Duncan Booth
Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: > Jim Hendricks wrote: >> I see the global keyword that allows access to global vars in a >> function, what I'm not clear on is does that global need to be >> declared in the global scope, > > You can't just declare in Python, you always define obje

Re: python newbie

2007-11-02 Thread Jim Hendricks
BartlebyScrivener wrote: > On Nov 2, 8:51 am, Jim Hendricks <[EMAIL PROTECTED]> wrote: >> New to python, programming in 15 or so langs for 24 years. >> >> Couple of questions the tuts I've looked at don't explain: > > Did you look at THE tut? You would seem to be the perfect reader for > it, beca

Re: python newbie

2007-11-02 Thread Neil Cerutti
On 2007-11-02, Jim Hendricks <[EMAIL PROTECTED]> wrote: > New to python, programming in 15 or so langs for 24 years. > > Couple of questions the tuts I've looked at don't explain: > > 1) global vars - python sets scope to the block a var is > declared (1st set), I see the global keyword that allows

Re: python newbie

2007-11-02 Thread Bjoern Schliessmann
Please use a more informative subject next time. Jim Hendricks wrote: > 1) global vars - python sets scope to the block a var is declared > (1st set), http://docs.python.org/ref/global.html I'm afraid not. Python only interprets the listed name(s) as globals. > I see the global keyword that al

Re: python newbie

2007-11-02 Thread BartlebyScrivener
On Nov 2, 8:51 am, Jim Hendricks <[EMAIL PROTECTED]> wrote: > New to python, programming in 15 or so langs for 24 years. > > Couple of questions the tuts I've looked at don't explain: Did you look at THE tut? You would seem to be the perfect reader for it, because you are already a programmer. h

python newbie

2007-11-02 Thread Jim Hendricks
New to python, programming in 15 or so langs for 24 years. Couple of questions the tuts I've looked at don't explain: 1) global vars - python sets scope to the block a var is declared (1st set), I see the global keyword that allows access to global vars in a function, what I'm not clear on is d

Re: handling tabular data in python--newbie question

2007-08-29 Thread hyena
Thanks Bruno and Steve for the quick answer! >What make you think such a thing ? I am also using R and java from time to time, and think it is very covinient that in R tables are handled as matrixs or data frames. Thus I expect python has something similiar. :) And I went for Steve's first sugg

<    1   2   3   4   5   >