Re: Extracting DB schema (newbie Q)

2012-05-17 Thread Steve Sawyer
Thanks, James, but John Gordon identified my usage error so I'm good to go now. On Mon, 14 May 2012 09:28:06 -0700 (PDT), james hedley wrote: >On Monday, 14 May 2012 17:01:49 UTC+1, Steve Sawyer wrote: >> Brand-new to Python (that's a warning, folks) >> >> Trying to write a routine to import a

Re: Extracting DB schema (newbie Q)

2012-05-14 Thread james hedley
On Monday, 14 May 2012 17:01:49 UTC+1, Steve Sawyer wrote: > Brand-new to Python (that's a warning, folks) > > Trying to write a routine to import a CSV file into a SQL Server > table. To ensure that I convert the data from the CSV appropriately, > I"m executing a query that gives me the schema (

Re: Extracting DB schema (newbie Q)

2012-05-14 Thread Chris Angelico
On Tue, May 15, 2012 at 5:09 AM, Steve Sawyer wrote: > Thanks - now, given my query that returns the table structure, this > works fine: > > table_dict = {} > table_specs = cursor.execute(query_string) > for row in table_specs: >        row_dict = {} >        row_dict['type'] = row.DataType >    

Re: Extracting DB schema (newbie Q)

2012-05-14 Thread Steve Sawyer
Thanks, John. >What are you trying that isn't working? Typical newbie trick - trying to make things more complicated than they are. I didn't realize that syntax would establish the key/value pairs of the dictionary - I thought that would only allow you to establish the value to correspond to a spe

Re: Extracting DB schema (newbie Q)

2012-05-14 Thread John Gordon
In Steve Sawyer writes: > What I think I want to do is to construct a dictionary using the > column names as the index value, and a list containing the various > attributes (data type, lenghth, precision). If you're using just the column name as the dictionary key, make sure there are no dupli

Re: Extracting DB schema (newbie Q)

2012-05-14 Thread Jean-Michel Pichavant
Steve Sawyer wrote: Brand-new to Python (that's a warning, folks) Trying to write a routine to import a CSV file into a SQL Server table. To ensure that I convert the data from the CSV appropriately, I"m executing a query that gives me the schema (data column names, data types and sizes) from th

Re: Extracting DB schema (newbie Q)

2012-05-14 Thread Chris Angelico
On Tue, May 15, 2012 at 2:01 AM, Steve Sawyer wrote: > Brand-new to Python (that's a warning, folks) It's one we're familiar with :) Welcome! > Trying to write a routine to import a CSV file into a SQL Server > table. To ensure that I convert the data from the CSV appropriately, > I"m executing

Extracting DB schema (newbie Q)

2012-05-14 Thread Steve Sawyer
Brand-new to Python (that's a warning, folks) Trying to write a routine to import a CSV file into a SQL Server table. To ensure that I convert the data from the CSV appropriately, I"m executing a query that gives me the schema (data column names, data types and sizes) from the target table. What

Re: Newbie Q about Turtle Gfx

2009-02-19 Thread Neil
Hi It turns out I should have used t=turtle.Pen() and not t=turtle.pen() My stupid mistake! "Neil" wrote in message news:jyydnb8xe8hpoghunz2dnuvz8juwn...@bt.com... > Thanks everyone! > > It appears the info in the book is wrong. Trying what you have all > suggested > has got it to work! >

Re: Newbie Q about Turtle Gfx

2009-02-18 Thread Neil
Thanks everyone! It appears the info in the book is wrong. Trying what you have all suggested has got it to work! Many thanks, and I am sure I will be back here again with other newbie problems! Neil "Neil" wrote in message news:ifidnr_gysdmfqhunz2dnekdnzzin...@bt.com... > Hello > > Sorry if

Re: Newbie Q about Turtle Gfx

2009-02-18 Thread Mensanator
On Feb 18, 4:16 pm, "Neil" wrote: > Hello > > Sorry if this is not an appropriate newsgroup for this problem. I am very > new to Python but not new to programming. > > I am hoping to use Python to teach a class and have been looking at the > online book 'Snake Wrangling for Kids'. > > I have follo

Re: Newbie Q about Turtle Gfx

2009-02-18 Thread Scott David Daniels
Neil wrote: Forgot to say, that after the error message the turtle window 'hangs' as unresponsive ... "Neil" wrote in message news:ifidnr_gysdmfqhunz2dnekdnzzin...@bt.com... Hello I am hoping to use Python to teach a class and have been looking at the online book 'Snake Wrangling for Kids'.

Re: Newbie Q about Turtle Gfx

2009-02-18 Thread Neil
Thanks for the very speedy reply! Not sure what your reply means but I have emailed the author with the problem! Cheers Neil "sjbrown" wrote in message news:9ba48cb7-d32b-40ef-a6a6-d22508863...@l33g2000pri.googlegroups.com... It looks like there may be a bug if you were expecting t to be som

Re: Newbie Q about Turtle Gfx

2009-02-18 Thread sjbrown
It looks like there may be a bug if you were expecting t to be some object other than a dict. You can apparently contact the authour here: http://www.briggs.net.nz/log/contact/ On Feb 18, 2:16 pm, "Neil" wrote: > Hello > > Sorry if this is not an appropriate newsgroup for this problem. I am ver

Re: Newbie Q about Turtle Gfx

2009-02-18 Thread Neil
Forgot to say, that after the error message the turtle window 'hangs' as unresponsive ... "Neil" wrote in message news:ifidnr_gysdmfqhunz2dnekdnzzin...@bt.com... > Hello > > Sorry if this is not an appropriate newsgroup for this problem. I am very > new to Python but not new to programming. >

Newbie Q about Turtle Gfx

2009-02-18 Thread Neil
Hello Sorry if this is not an appropriate newsgroup for this problem. I am very new to Python but not new to programming. I am hoping to use Python to teach a class and have been looking at the online book 'Snake Wrangling for Kids'. I have followed the example >>>import turtle >>>t=turtle.pe

Re: Komodo Edit newbie Q

2008-06-26 Thread Todd Whiteman
John Dann wrote: I'm learning Python using the Komodo Edit freeware code editor. One thing I'm finding a little confusing is that the code completion lists (what I would call Intellisense coming from a .Net background) are often very incomplete, especially with imported classes like wx. It's like

Komodo Edit newbie Q

2008-06-26 Thread John Dann
I'm learning Python using the Komodo Edit freeware code editor. One thing I'm finding a little confusing is that the code completion lists (what I would call Intellisense coming from a .Net background) are often very incomplete, especially with imported classes like wx. It's like KE can't look far

Re: Newbie Q: modifying SQL statements

2008-01-11 Thread Faber J. Fedor
On 12/01/08 00:23 +0100, Hrvoje Niksic wrote: > "Faber J. Fedor" <[EMAIL PROTECTED]> writes: > > Does this '("" if not where...' syntax actually work? > > http://docs.python.org/whatsnew/pep-308.html C'mon! I'm in Day Two of learning Python. You can't expect me to be reading "What's New" docs a

Re: Newbie Q: modifying SQL statements

2008-01-11 Thread Faber J. Fedor
On 11/01/08 18:29 -0500, Mike Meyer wrote: > It is a 2.5 feature, though. I was beginning to wonder of that was the case. > I converted all my clients to 2.5.1, > shortly after it was available, and haven't used anything older > since. Sorry 'bout that. No prob. -- Regards, Faber Fedor

Re: Newbie Q: modifying SQL statements

2008-01-11 Thread Hrvoje Niksic
"Faber J. Fedor" <[EMAIL PROTECTED]> writes: > On 10/01/08 22:53 -0500, Mike Meyer wrote: >> Personally, I think it would be more pythonic to not try and use two >> different APIs to walk the list of jobs (... One Way To Do it): >> >> def __call__(self, where=None): >> q = "select * from %s"

Re: Newbie Q: modifying SQL statements

2008-01-11 Thread Mike Meyer
On Fri, 11 Jan 2008 18:11:41 -0500 "Faber J. Fedor" <[EMAIL PROTECTED]> wrote: > On 10/01/08 22:53 -0500, Mike Meyer wrote: > > Personally, I think it would be more pythonic to not try and use two > > different APIs to walk the list of jobs (... One Way To Do it): > > > > def __call__(self, where

Re: Newbie Q: modifying SQL statements

2008-01-11 Thread Faber J. Fedor
On 10/01/08 22:53 -0500, Mike Meyer wrote: > Personally, I think it would be more pythonic to not try and use two > different APIs to walk the list of jobs (... One Way To Do it): > > def __call__(self, where=None): > q = "select * from %s" % (self.name,) + ("" if not where else (" where > %s

Re: Newbie Q: modifying SQL statements

2008-01-10 Thread Mike Meyer
On Thu, 10 Jan 2008 20:32:06 -0500 "Faber J. Fedor" <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm in the process of learning Python by writing a job queue program. > Nothing fancy, mind you, just read from a table, shell out to a program, > write back to the table. > > I'm working off of the tuto

Newbie Q: modifying SQL statements

2008-01-10 Thread Faber J. Fedor
Hi all, I'm in the process of learning Python by writing a job queue program. Nothing fancy, mind you, just read from a table, shell out to a program, write back to the table. I'm working off of the tutorial listed here (amongst many places): http://www.devx.com/dbzone/Article/22093 In my Jobs c

Re: newbie Q: sequence membership

2007-11-19 Thread Steven D'Aprano
On Mon, 19 Nov 2007 16:06:36 -0500, Sells, Fred wrote: >> >>> a, b = [], [] >> >>> a.append(b) >> >>> b.append(a) > did you perhaps mean a.append('b'); b.append('a'); otherwise this seems > pretty advanced for a newbie If you had bothered to read the rest of the post, you'd see that he meant exa

RE: newbie Q: sequence membership

2007-11-19 Thread Sells, Fred
> >>> a, b = [], [] > >>> a.append(b) > >>> b.append(a) did you perhaps mean a.append('b'); b.append('a'); otherwise this seems pretty advanced for a newbie > >>> b in a > True > >>> a in a > Traceback (most recent call last): > File "", line 1, in > RuntimeError: maximum recursion depth exce

Re: newbie Q: sequence membership

2007-11-19 Thread Gabriel Genellina
En Mon, 19 Nov 2007 03:32:12 -0300, saccade <[EMAIL PROTECTED]> escribió: > So if I am permitted to think of integers as immutable objects with > predefined labels (i.e. the integers used in the text of the program > code) that cannot de or re referenced then what a similar treatment of > characte

Re: newbie Q: sequence membership

2007-11-19 Thread John Machin
> > On Nov 17, 4:35 am, John Machin <[EMAIL PROTECTED]> wrote: >> Worse: Consider z = ['A1', 'Z9']. It's highly likely that when x == >> 'A1', "x is_in z" is True -- because an unguaranteed implementation- >> dependent caper caches or "interns" some values, so that x and z[0] >> are the same objec

Re: newbie Q: sequence membership

2007-11-18 Thread MonkeeSage
On Nov 19, 12:32 am, saccade <[EMAIL PROTECTED]> wrote: > I am not a programmer so I feel odd commenting about language design > decisions. When my Prof. introduced python the first question that > popped into mind was that since "x=9; y=9; print x is y and x == y" > prints "True" is there a way t

Re: newbie Q: sequence membership

2007-11-18 Thread saccade
On Nov 17, 3:40 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > You can write your own membership test based on identity ('is'): > Thank you for the practical (usable) advice and explanation of the '==' operator. On Nov 17, 4:35 am, John Machin <[EMAIL PROTECTED]> wrote: > > And that can

Re: newbie Q: sequence membership

2007-11-17 Thread John Machin
On Nov 17, 6:02 pm, saccade <[EMAIL PROTECTED]> wrote: > >>> a, b = [], [] > >>> a.append(b) > >>> b.append(a) > >>> b in a > True > >>> a in a > > Traceback (most recent call last): > File "", line 1, in > RuntimeError: maximum recursion depth exceeded in cmp > > >>> a is a[0] > False > >>> a =

Re: newbie Q: sequence membership

2007-11-17 Thread Gabriel Genellina
En Sat, 17 Nov 2007 04:02:12 -0300, saccade <[EMAIL PROTECTED]> escribió: a, b = [], [] a.append(b) b.append(a) b in a > True a in a > Traceback (most recent call last): > File "", line 1, in > RuntimeError: maximum recursion depth exceeded in cmp a is a[0] >

newbie Q: sequence membership

2007-11-16 Thread saccade
>>> a, b = [], [] >>> a.append(b) >>> b.append(a) >>> b in a True >>> a in a Traceback (most recent call last): File "", line 1, in RuntimeError: maximum recursion depth exceeded in cmp >>> >>> a is a[0] False >>> a == a[0] Traceback (most recent call last): File "", line 1, in RuntimeError:

Re: Newbie Q: Class Privacy (or lack of)

2006-08-02 Thread Antoon Pardon
On 2006-08-02, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >> I find that a strange purpose because when you are working on a class, >> you don't necessarily know if you will ever know many instance of that >> class. So should I use __slots__ in all my classes, just to be sure >> for when someone w

Re: Newbie Q: Class Privacy (or lack of)

2006-08-02 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Antoon Pardon wrote: > On 2006-07-28, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> This avoids the problem but you get others in return. And it's an >> abuse of `__slots__` which is meant as a way to save memory if you need >> really many objects of that type an

Re: Newbie Q: Class Privacy (or lack of)

2006-08-02 Thread Diez B. Roggisch
> I find that a strange purpose because when you are working on a class, > you don't necessarily know if you will ever know many instance of that > class. So should I use __slots__ in all my classes, just to be sure > for when someone wants many instances of one? I find that a strange reasoning b

Re: Newbie Q: Class Privacy (or lack of)

2006-08-02 Thread Antoon Pardon
On 2006-07-28, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> >> class MyClass(object): >> >> __slots__ = ('bar',) >> >> def func(self): >> return 123 >> >> x = MyClass() >> x.instance_var_not_defined_in_the_class = 456 >> ==> >> AttributeError: 'MyClass' object has no a

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Ray
Ben Sizer wrote: > Ray wrote: > But remember, at no point did they think to make that stuff > deliberately hard so that it would give you safety. It's hard because > the implementation is relatively complex. The flipside of that is > writing function objects in C++, which are an ugly hack to get a

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Ben Sizer
Ray wrote: > Yeah, I know... but the thing is that it's easy to "do it". Say in C++, > you can rebind the method of a class to another function if you want > to, you can muck around with the vtable and stuff, but you've gotta do > something different than, say, a normal assignment. But remember, a

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Ray
Bruno Desthuilliers wrote: > Ray wrote: > > Bruno Desthuilliers wrote: > > Actually Bruno, don't you think that the notion of flexibility in > > Python comes at the expense of "security" is simply due to the fact > > that the syntax of "screw up" is exactly the same as the syntax of "I > > mean it

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Timo wrote: > Steve Jobless kirjoitti: > >> Let's say the class is defined as: >> >> class MyClass: >> def __init__(self): >> pass >> def func(self): >> return 123 >> >> But from the outside of the class my interpreter let me do: >> >> x = MyClass()

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Bruno Desthuilliers
Ray wrote: > Bruno Desthuilliers wrote: >>> I'd rather let a machine to do that. Wasn't computer created for tasks >>> like this? (No, not really. But...) >> There's obviously a trade-off between 'security' and flexibility. As I >> said, I do make lots of typo too, but OTOH the edit/test cycle in P

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Bruno Desthuilliers
Steve Jobless wrote: > Bruno Desthuilliers wrote: >> Steve Jobless wrote: >>> Sybren Stuvel wrote: >>> Steve Jobless enlightened us with: > The first case can be just a typo, like: > > x.valeu = 5 > > I make typos all the time. Without a spell checker, this message >>

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Ben Sizer
Steve Jobless wrote: > Unfortunately, I don't see a way > to separate interface from implementation in Python. So, it may not make > much difference whether you subclass it or hack it from the outside. Documentation. (And name-mangling, underscore prepending, all the stuff the others said.) Whenev

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Timo
Steve Jobless kirjoitti: > Let's say the class is defined as: > > class MyClass: > def __init__(self): > pass > def func(self): > return 123 > > But from the outside of the class my interpreter let me do: > > x = MyClass() > x.instance_var_not_defined_in_the_class = 456 >

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Ray
Ben Sizer wrote: > Ray wrote: > > Actually Bruno, don't you think that the notion of flexibility in > > Python comes at the expense of "security" is simply due to the fact > > that the syntax of "screw up" is exactly the same as the syntax of "I > > mean it this way and I do want it"? > > > > Per

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Ben Sizer
Ray wrote: > Actually Bruno, don't you think that the notion of flexibility in > Python comes at the expense of "security" is simply due to the fact > that the syntax of "screw up" is exactly the same as the syntax of "I > mean it this way and I do want it"? > > Perhaps if we use a different synta

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Steve Jobless wrote: > Bruno Desthuilliers wrote: >> >> Steve Jobless wrote: >> > But what about adding a method to the class? Am I supposed to ask "Is >> > anyone using name xxx?" >> >> assert 'xxx' not in dir(SomeClassOrObject) >> >> > The class may be used by develop

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Ray
Bruno Desthuilliers wrote: > > I'd rather let a machine to do that. Wasn't computer created for tasks > > like this? (No, not really. But...) > > There's obviously a trade-off between 'security' and flexibility. As I > said, I do make lots of typo too, but OTOH the edit/test cycle in Python > is u

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Steve Jobless
Bruno Desthuilliers wrote: > > Steve Jobless wrote: > > Sybren Stuvel wrote: > > > >>Steve Jobless enlightened us with: > >> > >>>The first case can be just a typo, like: > >>> > >>> x.valeu = 5 > >>> > >>>I make typos all the time. Without a spell checker, this message > >>>would be unreadable :

Re: Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Ben Sizer
Steve Jobless wrote: > Sybren Stuvel wrote: > > > > Steve Jobless enlightened us with: > > > The first case can be just a typo, like: > > > > > > x.valeu = 5 > > > > > > I make typos all the time. Without a spell checker, this message > > > would be unreadable :). > > > > Then learn to read what

Re: Re:[OT] Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Ray
Bruno Desthuilliers wrote: > Ray wrote: > > Bruno Desthuilliers wrote: > > > >>Ray wrote: > >>Ray, please, don't top-post > > > > > > Um, top-post? I'm using Google News and it looks like it is placed > > correctly in the thread... or you're referring to a different thing? > > http://en.wikipedia.

Re:[OT] Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Bruno Desthuilliers
Ray wrote: > Bruno Desthuilliers wrote: > >>Ray wrote: >>Ray, please, don't top-post > > > Um, top-post? I'm using Google News and it looks like it is placed > correctly in the thread... or you're referring to a different thing? http://en.wikipedia.org/wiki/Top-posting -- bruno desthuilliers

Re: Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Ray
Bruno Desthuilliers wrote: > Ray wrote: > Ray, please, don't top-post Um, top-post? I'm using Google News and it looks like it is placed correctly in the thread... or you're referring to a different thing? Ray -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Ray
John Machin wrote: > Ray wrote: > > > The argument against this is that since development with Python is so > > rapid, you're supposed to always equip your code with extensive unit > > tests. I like Python but I've never really bought that argument--I > > guess I've been doing Java too long :) > >

Re: Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Ray
Sybren Stuvel wrote: > Ray enlightened us with: > > Huh? No. The compiler will always tell you. Have you ever tried Java > > before? > > I know what I'm talking about, I've got a degree in Computer Science > from the University of Amsterdam. Then how come you didn't know that the Java compiler wi

Re: Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Bruno Desthuilliers
Steve Jobless wrote: > Sybren Stuvel wrote: > >>Steve Jobless enlightened us with: >> >>>The first case can be just a typo, like: >>> >>> x.valeu = 5 >>> >>>I make typos all the time. Without a spell checker, this message >>>would be unreadable :). >> >>Then learn to read what you type, as you ty

Re: Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread John Machin
Ray wrote: > The argument against this is that since development with Python is so > rapid, you're supposed to always equip your code with extensive unit > tests. I like Python but I've never really bought that argument--I > guess I've been doing Java too long :) > In Java, if you don't always e

Re: Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Bruno Desthuilliers
Ray wrote: Ray, please, don't top-post (snip) > Also having to check whether a name has already existed can be a major > pain in the butt with Python. assert 'somename' not in dir(someObject) (snip) > Regarding the lack of privacy, s/privacy/language-inforced access restriction/ > --I guess

Re: Newbie Q: Class Privacy (or lack of)

2006-07-27 Thread Ray
Sybren Stuvel wrote: > Ray enlightened us with: > > Also having to check whether a name has already existed can be a > > major pain in the butt with Python. With Java you always know when a > > name has already existed, and what type is bound to the name. I > > consider this to be a Good Thing (tm

Re: Newbie Q: Class Privacy (or lack of)

2006-07-26 Thread Ray
Hey Steve, Yes, I agree with you. The lack of checking can get confusing fast. It's not about typing without errors. Regardless of how you train as long as you're human you WILL make typos. Also having to check whether a name has already existed can be a major pain in the butt with Python. With J

Re: Newbie Q: Class Privacy (or lack of)

2006-07-26 Thread Steve Jobless
Sybren Stuvel wrote: > > Steve Jobless enlightened us with: > > The first case can be just a typo, like: > > > > x.valeu = 5 > > > > I make typos all the time. Without a spell checker, this message > > would be unreadable :). > > Then learn to read what you type, as you type it. Typing without

Re: Newbie Q: Class Privacy (or lack of)

2006-07-26 Thread bearophileHUGS
Steve Jobless: > I'm hearing that "they are features, but don't use them." You can use them if you know why you are doing it. You can also take a look at PyChecker and PyLint, they may help you. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Q: Class Privacy (or lack of)

2006-07-26 Thread Simon Brunning
On 7/26/06, Steve Jobless <[EMAIL PROTECTED]> wrote: > If I was working on a large project with many engineers, I'd assume > someone will do things like this sooner or later. I've seen many > horrendous code in my life and I have no control over who I work with. If you work with cowboys, not P

Re: Newbie Q: Class Privacy (or lack of)

2006-07-25 Thread Steve Jobless
Steve Jobless wrote: > > Hi, > > I just started learning Python. I went through most of the tutorial at > python.org. But I noticed something weird. I'm not talking about the > __private hack. > > Let's say the class is defined as: > > class MyClass: > def __init__(self): > pass >

Re: Newbie Q: Class Privacy (or lack of)

2006-07-25 Thread Bruno Desthuilliers
Steve Jobless wrote: > Hi, > > I just started learning Python. I went through most of the tutorial at > python.org. But I noticed something weird. I'm not talking about the > __private hack. Actually this is __ultra_private. For normal privacy, _private is enough !-) > Let's say the class is def

Re: Newbie Q: Class Privacy (or lack of)

2006-07-24 Thread John Machin
Steve Jobless wrote: > Hi, > > I just started learning Python. I went through most of the tutorial at > python.org. But I noticed something weird. I'm not talking about the > __private hack. > > Let's say the class is defined as: > > class MyClass: > def __init__(self): > pass > def

Re: Newbie Q: Class Privacy (or lack of)

2006-07-24 Thread Kevin Watters
See: http://redhanded.hobix.com/inspect/monkeypytching.html Shouldn't be done unless you have a really cool reason for doing so. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Q: Class Privacy (or lack of)

2006-07-24 Thread Jean-Paul Calderone
On Tue, 25 Jul 2006 02:49:06 GMT, Steve Jobless <[EMAIL PROTECTED]> wrote: >Hi, > >I just started learning Python. I went through most of the tutorial at >python.org. But I noticed something weird. I'm not talking about the >__private hack. > >Let's say the class is defined as: > > class MyClass:

Newbie Q: Class Privacy (or lack of)

2006-07-24 Thread Steve Jobless
Hi, I just started learning Python. I went through most of the tutorial at python.org. But I noticed something weird. I'm not talking about the __private hack. Let's say the class is defined as: class MyClass: def __init__(self): pass def func(self): return 123 But from th

restarting multiple instances of apache - newbie Q

2006-06-03 Thread [EMAIL PROTECTED]
hi all, i am new to python programming, so thanks for your patience in advance. I have a small script that I am working on that i want to restart multiple instances of apaches on our developers servers. We have about 25 developers each with their own apache. import sys, os try: file = open(

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread BartlebyScrivener
Pretty tough to beat Alan Gauld, but the more examples the merrier for me, and the infogami has plenty of those. Thanks. http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm rpd -- http://mail.python.org/mailman/listinfo/python-list

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread Kent Johnson
John Salerno wrote: > Couldn't we also say that this issue of namespace scope is a little more > specific to Python than OOP in general? I could very easily be wrong, > but I wouldn't want the poster to think that this is how OOP works always. No, the confusion in the OP was between class attrib

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread John Salerno
[EMAIL PROTECTED] wrote: > Thanks guys, > > It is starting to make much more sense. Most documentation I find about > OO is very academic Couldn't we also say that this issue of namespace scope is a little more specific to Python than OOP in general? I could very easily be wrong, but I wouldn't

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > It is starting to make much more sense. Most documentation I find about > OO is very academic you may find Jay Parlar's new python class tutorial helpful: http://parlar.infogami.com/pytut_classes_copy (this is a proposed addition/replacement for the class chapter

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread mitsura
Thanks guys, It is starting to make much more sense. Most documentation I find about OO is very academic -- http://mail.python.org/mailman/listinfo/python-list

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread Wildemar Wildenburger
J Rice wrote: > Someone should correct me if I'm wrong but: > If > you want to change myVar for the whole class, you need to reference it > as self.myVar. > wrong: If you want to change myVar for the whole *class*, you need to reference it as Obj.myVar (prefix with classname). self.myVar will c

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread Ben C
On 2006-04-13, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > > I just started with Python and I am new to OO programming. > Here is a simple code: > " > class Obj: > myVar = 1 > > def __init__(self): > myVar = 2 > > # > > > myObj = Obj() > > print myObj.myVar > " >

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread J Rice
Someone should correct me if I'm wrong but: If you add "print myVar" to __init__, you will see that myVar is assigned to "2" in that function. It doesn't change the assignment of "1" in the class because myVar in __init__ is local to __init__. If you want to change myVar for the whole class, yo

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread Azolex
[EMAIL PROTECTED] wrote: > Hi, > > I just started with Python and I am new to OO programming. > Here is a simple code: > " > class Obj: > myVar = 1 > > def __init__(self): > myVar = 2 > > # > > > myObj = Obj() > > print myObj.myVar > " > > The output is of this scri

trying to grasp OO : newbie Q?

2006-04-13 Thread mitsura
Hi, I just started with Python and I am new to OO programming. Here is a simple code: " class Obj: myVar = 1 def __init__(self): myVar = 2 # myObj = Obj() print myObj.myVar " The output is of this script is '1'. I would except it to be '2'. I not understanding

Re: Newbie Q: dynamically assigning object attribute

2006-02-10 Thread Ben Wilson
Well, my Perl way of doing it would be to have all attributes in a dict (hash), then create the accessor vi a dynamic function. I knew Python would have a right way to do it for Python, but when I went looking I neglected to look at the core of the language. I suppose I'm just too accustomed to the

Re: Newbie Q: dynamically assigning object attribute

2006-02-10 Thread Sion Arrowsmith
Ben Wilson <[EMAIL PROTECTED]> wrote: >I would like to dynamically assign object attributes: > >dict = { > a : 1, > b : 2, >} > >for key,val in dict : > obj.key = val > >I've googled to no effect, or maybe I'm needing to be hit with the >appropriately sized clue-by-four. The conventional clue-by-

Re: Newbie Q: dynamically assigning object attribute

2006-02-09 Thread Dylan Moreland
No problem. There are, in fact, ugly class-based methods of doing this. You could assign to an instance's __dict__ dictionary, or -- if the class is a new-style class -- you can call the __setattr__(self, name, value) method. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Q: dynamically assigning object attribute

2006-02-09 Thread Ben Wilson
That's it. I should spend more time R-ingTFM. I kept looking for some class-based solution and there was a built in. Perfectly logical. Thanks, Ben -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Q: dynamically assigning object attribute

2006-02-09 Thread Dylan Moreland
Take a look at the built-in function setattr: http://ftp.python.org/doc/lib/built-in-funcs.html#l2h-64 -- http://mail.python.org/mailman/listinfo/python-list

Newbie Q: dynamically assigning object attribute

2006-02-09 Thread Ben Wilson
I would like to dynamically assign object attributes: dict = { a : 1, b : 2, } for key,val in dict : obj.key = val To get: print obj.a 1 I've googled to no effect, or maybe I'm needing to be hit with the appropriately sized clue-by-four. Any assistance would be appreciated. Regards, Ben

Re: newbie Q on sdtin word completion

2005-12-08 Thread Fischer
Thanks, exactly what I was looking for. I should go and buy you book ;-) Bernd Fredrik Lundh wrote: > "Bernd" wrote: > > >>I'm on a Linux env and try to get >>word completion form sdtin done, >>like Perl's >> $stdin = Complete( "\t: ", @choices ); >> >>What I have so far shows me the directory

Re: newbie Q on sdtin word completion

2005-12-08 Thread Fredrik Lundh
"Bernd" wrote: > I'm on a Linux env and try to get > word completion form sdtin done, > like Perl's > $stdin = Complete( "\t: ", @choices ); > > What I have so far shows me the directory listing > on the second hit on TAB and not the list of > choices on the first like I wanted to have. your com

newbie Q on sdtin word completion

2005-12-07 Thread Fischer
Hi, I'm on a Linux env and try to get word completion form sdtin done, like Perl's $stdin = Complete( "\t: ", @choices ); What I have so far shows me the directory listing on the second hit on TAB and not the list of choices on the first like I wanted to have. Any help appreciated, Ber

Re: newbie Q: mouse clicks don't seem to get trapped

2005-09-05 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Hi, > > I want to display a window containing an image and when I move the > mouse over the image and click on the left Mb, I want to get the > position of the mouse on the image. > I listed the code to view the image below (so far so good) but for some > reason the EVT_

newbie Q: mouse clicks don't seem to get trapped

2005-09-05 Thread mitsura
Hi, I want to display a window containing an image and when I move the mouse over the image and click on the left Mb, I want to get the position of the mouse on the image. I listed the code to view the image below (so far so good) but for some reason the EVT_LEFT_DOWN/UP does not work. Any idea w

newbie q: Visualizing py-classes in UML automatically

2005-08-11 Thread pyragine_sraige
Hi "Py's", is there anyone who has written a kind of converter (?) for visualizing python-classes with "poseidon for uml"? I couldn't find a plug-in-hint(?) on the HP; or am I looking wrong? A good hint to another free tool would be also nice. (I only want to see if I am totally wrong with self

Re: Dumb*ss newbie Q

2005-03-29 Thread Captain Dondo
On Mon, 28 Mar 2005 08:42:22 -0600, Larry Bates wrote: > Others have answered your specific question, I thought I > would add some suggestions (not tested): > > 1) You don't need a separate set_title method. You can > change the title attribute at any time by just saying > m.title="new title".

Re: Dumb*ss newbie Q

2005-03-28 Thread Larry Bates
Others have answered your specific question, I thought I would add some suggestions (not tested): 1) You don't need a separate set_title method. You can change the title attribute at any time by just saying m.title="new title". No method is required unless you need to do some pre/post processing

Use informative subject lines! (was Re: Dumb*ss newbie Q)

2005-03-27 Thread beliavsky
A subject line should say what the message is about, for example "Create HTML tag using objects (newbie Q)" and enable people who are not interested in or knowledgable about a topic to skip it, while grabbing the attention of people who are knowledgable/interested. -- http://mail.

Re: Dumb*ss newbie Q

2005-03-27 Thread Captain Dondo
On Mon, 28 Mar 2005 01:15:34 +, Jp Calderone wrote: > > Notice that you have a method named "url" as well as an attribute > named "url". You have the same problem for "thumb". These methods > and attributes are in collision with each other. When you try to > look up the

Re: Dumb*ss newbie Q

2005-03-27 Thread Jp Calderone
On Sun, 27 Mar 2005 17:06:05 -0800, Captain Dondo <[EMAIL PROTECTED]> wrote: > [snip] > > def url (self): > self.url = ... > > def thumb (self): > self.thumb = ... > > [snip] > > The problem is that m.html in the test section fails with > > TypeError: cannot concatenat

Dumb*ss newbie Q

2005-03-27 Thread Captain Dondo
OK, I know this is covered somewhere in Python 101, but for the life of me I cannot figure this out. I really need a basic intro to Python book I am trying to do something very simple - create an HTML tag using objects: class Movie: def __init__ (self, t="", a="", d=""): #

  1   2   >