Re: [Tutor] Global Variables

2009-11-20 Thread Luke Paireepinart
On Fri, Nov 20, 2009 at 4:44 PM, Joseph Fennell wrote: > My apologies yes these are in seperate files, > -- > main.py > --- > cHandler.execute("SELECT * FROM table") > > #sets results from above to nl > > nl = cHandler.fetchall() > > dn = raw_input("User input: ") > > nl2

Re: [Tutor] Global Variables

2009-11-20 Thread Alan Gauld
"Joseph Fennell" wrote I assume that it's because the variable is considered local and the imported functions are not technically local to that document. global in Python means "in the same module" not global across all modules You are best to pass data into functions as arguments and to pa

Re: [Tutor] (no subject)

2009-11-20 Thread Alan Gauld
"mark guinder" wrote ok, all i know is that i have python installed on my computer(mac), and i know how to open up "IDLE", how do i write my first program, what do i use , how do i open that, and how to i save it as a prograam? That's slightly more than I assume for beginners in my tuto

Re: [Tutor] Readable date arithmetic

2009-11-20 Thread bob gailer
Stephen Nelson-Smith wrote: I have the following method: def get_log_dates(the_date_we_want_data_for): t = time.strptime(the_date_we_want_data_for, '%Y%m%d') t2 = datetime.datetime(*t[:-2]) extra_day = datetime.timedelta(days=1) t3 = t2 + extra_day next_log_date = t3.strftime('%Y%m%d')

Re: [Tutor] how to access deep classes

2009-11-20 Thread John
On Friday 20 November 2009 09:48:38 am Alan Gauld wrote: > "John" wrote > > > class A (wx.Panel); > > def__init__(...) > > > > class B(wx.PyPanel): > > > > def __init__(..): > > self.pages = A(...) > > > > class C (B) > > def __init__(...) > > > > I can't change the code in either class A

Re: [Tutor] Querying a packages modules?

2009-11-20 Thread Eric Pavey
On Fri, Nov 20, 2009 at 12:28 PM, Kent Johnson wrote: > On Fri, Nov 20, 2009 at 3:05 PM, Dave Angel wrote: > > Eric Pavey wrote: > > >> lol, in usual fashion, after I hack through it, while in the docs, I > find > >> the 'fancy' solution: > >> > >> import pkgutil > >> import myPackage > >> modul

Re: [Tutor] Global Variables

2009-11-20 Thread Luke Paireepinart
On Fri, Nov 20, 2009 at 2:51 PM, Joseph Fennell wrote: > Quick introduction, I'm Joseph Fennell, and I've been playing with python > for the past 6 years (primarily in the interpreter) and have finally gotten > started on a full project and I've run into a small problem. I have defined > some m

Re: [Tutor] (no subject)

2009-11-20 Thread Wayne Werner
On Fri, Nov 20, 2009 at 1:42 PM, mark guinder wrote: > ok, all i know is that i have python installed on my computer(mac), and i > know how to open up "IDLE", how do i write my first program, what do i use , > how do i open that, and how to i save it as a prograam? Try taking a look at http://d

[Tutor] Global Variables

2009-11-20 Thread Joseph Fennell
Quick introduction, I'm Joseph Fennell, and I've been playing with python for the past 6 years (primarily in the interpreter) and have finally gotten started on a full project and I've run into a small problem. I have defined some modules, and when I import them into the page I want to use them o

Re: [Tutor] Querying a packages modules?

2009-11-20 Thread Kent Johnson
On Fri, Nov 20, 2009 at 3:05 PM, Dave Angel wrote: > Eric Pavey wrote: >> lol, in usual fashion, after I hack through it, while in the docs, I find >> the 'fancy' solution: >> >> import pkgutil >> import myPackage >> modules = pkgutil.iter_modules(myPackage.__path__) >> for p in modules: >>    pr

[Tutor] (no subject)

2009-11-20 Thread mark guinder
ok, all i know is that i have python installed on my computer(mac), and i know how to open up "IDLE", how do i write my first program, what do i use , how do i open that, and how to i save it as a prograam? ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Querying a packages modules?

2009-11-20 Thread Dave Angel
Eric Pavey wrote: On Fri, Nov 20, 2009 at 11:14 AM, Eric Pavey wrote: On Fri, Nov 20, 2009 at 10:58 AM, Eric Pavey wrote: On Fri, Nov 20, 2009 at 10:40 AM, Dave Angel wrote: lol, in usual fashion, after I hack through it, while in the docs, I find the 'fancy' solution: i

Re: [Tutor] Querying a packages modules?

2009-11-20 Thread Eric Pavey
On Fri, Nov 20, 2009 at 10:58 AM, Eric Pavey wrote: > On Fri, Nov 20, 2009 at 10:40 AM, Dave Angel wrote: > >> Eric Pavey wrote: >> >>> On Fri, Nov 20, 2009 at 4:09 AM, Kent Johnson wrote: >>> >>> >>> On Thu, Nov 19, 2009 at 9:31 PM, Eric Pavey wrote: > Say I have this packa

Re: [Tutor] Querying a packages modules?

2009-11-20 Thread Eric Pavey
On Fri, Nov 20, 2009 at 10:40 AM, Dave Angel wrote: > Eric Pavey wrote: > >> On Fri, Nov 20, 2009 at 4:09 AM, Kent Johnson wrote: >> >> >> >>> On Thu, Nov 19, 2009 at 9:31 PM, Eric Pavey wrote: >>> >>> Say I have this package layout \myPackage __init__.py moduleA.p

Re: [Tutor] Querying a packages modules?

2009-11-20 Thread Dave Angel
Eric Pavey wrote: On Fri, Nov 20, 2009 at 4:09 AM, Kent Johnson wrote: On Thu, Nov 19, 2009 at 9:31 PM, Eric Pavey wrote: Say I have this package layout \myPackage __init__.py moduleA.py moduleB.py Is there a way (and I'm sure there is...) to query, for a given package level, whic

Re: [Tutor] Can a method be added to dictionary?

2009-11-20 Thread Luke Paireepinart
Does the partial just do a lambda in the background? It's a neat example, thanks! I've never seen this used before. Sorry if reply is top-posted or otherwise weird, posting from mobile. On 11/20/09, Lie Ryan wrote: > lau...@protopc.com wrote: >> John, >> >> Thank you so much for your help! -- Pro

Re: [Tutor] Breaking out of loop...

2009-11-20 Thread Albert-Jan Roskam
Hi! Slightly different (extented) than your original question, but here's how I'd do this (although the program doesn't really do very much): import time, random def is_valid_date():     while True:     prompt = 'Enter the date in ISO format (-MM-DD), or 0 to exit: '     date = raw

Re: [Tutor] Breaking out of loop...

2009-11-20 Thread Ken G.
Alan Gauld wrote: "Ken G." wrote I am trying to break out of a loop posted below. When asked for monthdate, it should break out if I entered the number zero and it does not. GRRR. Been working on this for almost an hour. monthdate = 999 while monthdate <> 0: You are comparing

Re: [Tutor] how to access deep classes

2009-11-20 Thread Alan Gauld
"John" wrote class A (wx.Panel); def__init__(...) class B(wx.PyPanel): def __init__(..): self.pages = A(...) class C (B) def __init__(...) I can't change the code in either class A or class B. But I want to add a property to class A in class C. Is that possible? You need to d

Re: [Tutor] Breaking out of loop...

2009-11-20 Thread Alan Gauld
"Ken G." wrote I am trying to break out of a loop posted below. When asked for monthdate, it should break out if I entered the number zero and it does not. GRRR. Been working on this for almost an hour. monthdate = 999 while monthdate <> 0: You are comparing monthdate with a num

[Tutor] Breaking out of loop...

2009-11-20 Thread Ken G.
I am trying to break out of a loop posted below. When asked for monthdate, it should break out if I entered the number zero and it does not. GRRR. Been working on this for almost an hour. monthdate = 999 while monthdate <> 0: monthdate = raw_input('Enter the month and date in t

Re: [Tutor] Tutor Digest, Vol 69, Issue 96

2009-11-20 Thread rick
On Fri, 2009-11-20 at 16:40 +0100, tutor-requ...@python.org wrote: > That is a surprise! I was so use to using lprint as in Basic. Oh > well. I will have to study up on fmt and/or groff. > > Would those two commands (fmt, groff) send data to lpr from shell? > Is > lpr the same hookup for USB

Re: [Tutor] Querying a packages modules?

2009-11-20 Thread Eric Pavey
On Fri, Nov 20, 2009 at 4:09 AM, Kent Johnson wrote: > On Thu, Nov 19, 2009 at 9:31 PM, Eric Pavey wrote: > > Say I have this package layout > > > > \myPackage > > > > __init__.py > > moduleA.py > > moduleB.py > > > > Is there a way (and I'm sure there is...) to query, for a given package > > le

Re: [Tutor] Replace try: except: finally:

2009-11-20 Thread Kent Johnson
On Fri, Nov 20, 2009 at 8:08 AM, Stephen Nelson-Smith wrote: > I need to make some code Python 2.4 compliant... the only thing I see > is use of try: except: finally: > > To make this valid, I think I need to do a try: finally: and next try: > except: inside.  Is this correct? Yes, the backwards-

Re: [Tutor] Handling missing positional arguments

2009-11-20 Thread Geoff Dutton
On Fri, Nov 20, 2009 at 5:03 AM, Kent Johnson wrote: > On Thu, Nov 19, 2009 at 5:47 PM, Geoff Dutton > wrote: > > Do you have recommendations for handling missing positional arguments? > I'm > > a huge fan of OptionParser module and use it in several programs to > handle > > options, but there m

Re: [Tutor] Outputting Data to Printer

2009-11-20 Thread Ken G.
ALAN GAULD wrote: > > There is no universal easy way to print stuff unfortunately. > > In console mode on Unix its not too bad, you can send data > > to lpr, just as you would from the shell. > That is a surprise! I was so use to using lprint as in Basic. BASIC ran on a predefined platform

Re: [Tutor] Outputting Data to Printer

2009-11-20 Thread ALAN GAULD
> > There is no universal easy way to print stuff unfortunately. > > In console mode on Unix its not too bad, you can send data > > to lpr, just as you would from the shell. > That is a surprise! I was so use to using lprint as in Basic. BASIC ran on a predefined platform so could be sure w

Re: [Tutor] Outputting Data to Printer

2009-11-20 Thread Ken G.
Alan Gauld wrote: "Ken G." wrote Is there a Python command to send data to printer? I have a Canon MX300 hooked up by USB. I can print from Firefox and Thunderbird. I am using Ubuntu 9.04 and Python 2.6.2. There is no universal easy way to print stuff unfortunately. In console mode on Un

Re: [Tutor] how to access deep classes

2009-11-20 Thread John
On Friday 20 November 2009 04:48:59 am Lie Ryan wrote: > Is this what you want? > > class C(B): >     �...@property >      def wxpanelFontSize(self): >          return self.pages.wxpanelFontSize >     �...@wxpanelfontsize.setter >      def wxpanelFontSize(self, value): >          self.pages.wxpanel

[Tutor] Replace try: except: finally:

2009-11-20 Thread Stephen Nelson-Smith
I need to make some code Python 2.4 compliant... the only thing I see is use of try: except: finally: To make this valid, I think I need to do a try: finally: and next try: except: inside. Is this correct? The code has; try: ... ... ... except SystemExit: raise except KeyboardInte

Re: [Tutor] how to access deep classes

2009-11-20 Thread Lie Ryan
John wrote: Hi, I'm not to sure I can explain myself. But I need to ask because I do not understand how it works or what is possible. class A (wx.Panel); def__init__(...) class B(wx.PyPanel): def __init__(..): self.pages = A(...) class C (B) def __init__(...) I can't change t

Re: [Tutor] Can a method be added to dictionary?

2009-11-20 Thread Lie Ryan
lau...@protopc.com wrote: John, Thank you so much for your help! -- Problem SOLVED!!! -- Your explanation and example was extremely helpful. I am very grateful. Lauren :-) if you want to pass an argument, you can "curry" the function with functools.partial() # currying the function, don't

[Tutor] how to access deep classes

2009-11-20 Thread John
Hi, I'm not to sure I can explain myself. But I need to ask because I do not understand how it works or what is possible. class A (wx.Panel); def__init__(...) class B(wx.PyPanel): def __init__(..): self.pages = A(...) class C (B) def __init__(...) I can't change the code in eith

Re: [Tutor] copy zip file from source folder to destination and unzip all files within destination

2009-11-20 Thread Kent Johnson
On Fri, Nov 20, 2009 at 1:54 AM, MARCUS NG wrote: > Hey all, > I have been searching online for ways to copy a zip file to a destination > and extract the zip file with python. > Currently nothing works due to my limited understanding. > I am wondering if my syntax is wrong or am I missing anythin

Re: [Tutor] Querying a packages modules?

2009-11-20 Thread Kent Johnson
On Thu, Nov 19, 2009 at 9:31 PM, Eric Pavey wrote: > Say I have this package layout > > \myPackage > > __init__.py > moduleA.py > moduleB.py > > Is there a way (and I'm sure there is...) to query, for a given package > level, which modules live under it? > I thought I could do it like so: > > impo

Re: [Tutor] Handling missing positional arguments

2009-11-20 Thread Kent Johnson
On Thu, Nov 19, 2009 at 5:47 PM, Geoff Dutton wrote: > Do you have recommendations for handling missing positional arguments?  I'm > a huge fan of OptionParser module and use it in several programs to handle > options, but there must be an eligant way of handling missing arguments and > alerting t

Re: [Tutor] copy zip file from source folder to destination and unzip all files within destination

2009-11-20 Thread Lie Ryan
MARCUS NG wrote: Hey all, I have been searching online for ways to copy a zip file to a destination and extract the zip file with python. Currently nothing works due to my limited understanding. I am wondering if my syntax is wrong or am I missing anything? the code is as such. also if there is

Re: [Tutor] copy zip file from source folder to destination and unzipall files within destination

2009-11-20 Thread Alan Gauld
"MARCUS NG" wrote Currently nothing works due to my limited understanding. That's a pretty vague description of the problem. What exactly happens? Does the file get copied? Do you get error messages? If so what? I am wondering if my syntax is wrong or am I missing anything? If the syntax

Re: [Tutor] Outputting Data to Printer

2009-11-20 Thread Alan Gauld
"Ken G." wrote Is there a Python command to send data to printer? I have a Canon MX300 hooked up by USB. I can print from Firefox and Thunderbird. I am using Ubuntu 9.04 and Python 2.6.2. There is no universal easy way to print stuff unfortunately. In console mode on Unix its not too bad