Re: Looking for Advanced Python Tutorials

2008-04-04 Thread 3c273
Thanks for this.
Louis

"Ravi Kotecha" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Apr 4, 12:58 pm, [EMAIL PROTECTED] wrote:
> > I was wondering if anyone knew of some online (free if possible)
> > advanced tutorials, especially ones that provides tasks and ideas for
> > small projects. The issue for myself is I want to improve my python
> > programming level, and my ability to program in general, but come up
> > blank thinking of a possible task or project to undertake. So with
> > that in mind I thought I'd ask the community if they knew of sites or
> > books to read up on and use as a starting block. Of course project
> > ideas would be great as well!
> >
> > Thanks for any help you can provide.
> >
> > Coko
>
> Project Euler is a site where you work through mathematical problems
> using any programming language you like.
>
> Once you solve a problem you can see everyone elses solutions and
> Python is quite popular on that site so you'll see some very clever
> uses of Python there.
>
> I like it a lot for when I haven't got anything better to code:
> http://projecteuler.net/
>
> - Ravi


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Removing the Close, Min, Maximize and frame with ANY gui toolkit

2008-02-05 Thread 3c273
Google for overrideredirect().
Louis

"Daniel Folkes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I was wondering if anyone knew how to remove the Minimize, Maximize
> and Close from the frame around a gui.
> Removing everything would work even better.
>
> I would prefer instructions for tkinter, but any GUI would
> suffice(glade, gtk, wx, Qt).  I really would like to make a widget
> like object instead of a window.
>
> Thanks,
> Daniel Folkes
> http://danfolkes.com


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Comparing bitmap images for differences?

2007-05-01 Thread 3c273
> Those are my ideas so far but I thought it would be worth asking here
> first in case there are some known-good algorithms for doing this kind
> of thing rather than me trying to re-invent a wheel that ends up
> triangular...
>
> Thanks!
>   Matthew.
>
This might get you started.
http://tinyurl.com/7qexl
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to upload a file

2006-12-12 Thread 3c273
"Lad" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Users needs to upload big files upto 100MB.So I think that FTP protocol
> would be a solution, but how can I allow users to select the right file
> ,on their  local disk, via a file dialog ?
>
> Thank you for your ideas
> L.
>
import tkFileDialog
help(tkFileDialog)
Hope this helps.

Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WMI Help

2006-07-13 Thread 3c273
"Tim Golden" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 3c273 wrote:
> > Hello,
> > When I run the following at an interactive interpreter on Windows XP, I
get
> > the expected results. But if I save it to a file and run it, it
generates
> > the following error. (And it generates the same error either way on
Windows
> > 2000)
> >
> > import wmi
> > c=wmi.WMI()
> > for item in c.win32_PhysicalMedia():
> > print item
>
> A couple of things:
>
> + As someone else has pointed out, Win32_PhysicalMedia
> appears to be new to XP/2k3. (This happens quite a lot
> with WMI classes; you need to check the small-print).
> So that explains why it won't work on  your Win2K box
> nor on mine.
>
> + In addition, the bit after the "c." (here, Win32_PhysicalMedia)
> is case-sensitive. So you have to put c.Win32_PhysicalMedia
> (notice the capital "W"). I'm not actually sure why this should
> be, and when I get a moment I'll take a look at the code to
> see, but it's true nonetheless.
>
> Under the covers, the module is doing exactly what
> Michel showed you in his second post (WMIS = GetObject etc.)
>
>  > Strange that this does not return the serial number
>  > reported by other hardware utilities (SIW for one) and on both of my
>  > machines this number ends with 202020202020202020202020???
>
> Strange indeed. Unfortunately, what you see is what you get
> with WMI. I don't have access to an XP machine to test, but
> let me know if this code doesn't work:
>
> 
> import wmi
> c = wmi.WMI ()
> for item in c.Win32_PhysicalMedia ():
>print item
>
> 
>
> Good luck with WMI
>
> TJG

Thanks for your input. Strangely enough, it now works whether the Win32 is
captalized or not??? I must have had a typo in there somewhere. Thanks
again.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WMI Help

2006-07-13 Thread 3c273
"Michel Claveau" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Re!
>
> This script run on my XP :
>
>
> import win32com.client
> WMIS = win32com.client.GetObject(r"winmgmts:root\cimv2")
> objs = WMIS.ExecQuery("select * from Win32_PhysicalMedia")
> for obj in objs:
> print obj.SerialNumber
> print obj.Tag
> print
>
Thank you for the input. Strange that this does not return the serial number
reported by other hardware utilities (SIW for one) and on both of my
machines this number ends with 202020202020202020202020??? Thanks again.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


WMI Help

2006-07-13 Thread 3c273
Hello,
When I run the following at an interactive interpreter on Windows XP, I get
the expected results. But if I save it to a file and run it, it generates
the following error. (And it generates the same error either way on Windows
2000)

import wmi
c=wmi.WMI()
for item in c.win32_PhysicalMedia():
print item


Traceback (most recent call last):
  File "", line 1, in ?
for item in c.win32_PhysicalMedia():
  File "wmi.py", line 850, in __getattr__
return getattr (self._namespace, attribute)
  File "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line 489,
in __getattr__
raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError:
winmgmts:{impersonationLevel=impersonate,authenticationLevel=default}//./roo
t/cimv2.win32_PhysicalMedia

Any help is appreciated.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: timeit module for comparing the performance of two scripts

2006-07-11 Thread 3c273

"John Machin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> You appear to know what a switch is. I'm therefore surprised that you
> appear not to
> know that the convention is that any program that uses
> command-line switches should do something informative when run with a -h
> switch.
>
Doh! Me thinks Windows at work "python /?" (No good!), Linux at home
"python -h" (Ah ha!). I still think it should be in the docs somewhere.
Thanks.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: timeit module for comparing the performance of two scripts

2006-07-11 Thread 3c273

"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> $ python -m timeit -s "import pyConfig" "pyConfig.pyConfig()"
> $ python -m timeit -s "import pyConparse" "pyConparse.pyConParse()"
>
> note that timeit runs the benchmarked function multiple times, so you may
want
> to remove the print statements.

Hello,
Could you tell me what the "-m" switch does or even better, where to find
information on all switches in the documentation? Thanks.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess.Popen on Windows

2006-06-23 Thread 3c273
"madpython" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> playing with subprocess.Popen on Windows I stumbled into the following
> problem:
> Python 2.4.3 (#69, Mar 29 2006, 17:35:34)
>
> IDLE 1.1.3
>
> >>> import subprocess
> >>> p1=subprocess.Popen("c:\\asd.bat") #works OK
> >>> p2=subprocess.Popen("c:\\asd.bat",stdout=subprocess.PIPE)
>
> Traceback (most recent call last):
>   File "", line 1, in -toplevel-
> p2=subprocess.Popen("c:\\asd.bat",stdout=subprocess.PIPE)
>   File "C:\Python24\lib\subprocess.py", line 533, in __init__
> (p2cread, p2cwrite,
>   File "C:\Python24\lib\subprocess.py", line 593, in _get_handles
> p2cread = self._make_inheritable(p2cread)
>   File "C:\Python24\lib\subprocess.py", line 634, in _make_inheritable
> DUPLICATE_SAME_ACCESS)
> TypeError: an integer is required
> >>>
> What do I do wrongly?
>
I get the same thing. This only happens when using IDLE. From a command
prompt, everthing works as expected. Hopefully somebody else will know why.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OS specific command in Python

2006-06-21 Thread 3c273
"Avell Diroll" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 3c273 wrote:
> > I was just trying to learn how to use .communicate() and all of the
examples
> > I see have [0] after .communicate(). What is the significance of the
[0]?
>
>
>  From the Python Library Reference
> (http://docs.python.org/lib/node239.html), you learn that the method
> communicate() from the subprocess.Popen() class returns a tuple
> containing the standard output as first item and the standard error of
> the child process as second item. So the [0] in the example is for
> selecting the first item of the tuple ...

Thank you for taking the time to make that clear for me. I did read the
docs, I just didn't really understand what communicate() did, but I do now.
Thanks again.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OS specific command in Python

2006-06-21 Thread 3c273
"Avell Diroll" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> ##Python Script :
> from subprocess import Popen
> p1 = Popen(["dmesg"], stdout=PIPE)
> p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
> output = p2.communicate()[0]

I was just trying to learn how to use .communicate() and all of the examples
I see have [0] after .communicate(). What is the significance of the [0]?
Thanks for your help.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Customized Boot Manager in Python

2006-06-13 Thread 3c273
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Now, I have to create a visual interface for such kind of small
> program.
>
> I have 2 questions
> (i) How can we use operating system specific commands like ssh within
> the python program (ii) Which grphics library (wxPython or any other)
> would be the fastest with least learning curve to get this thing done.
>
> Thanks

(i)Check out the subprocess module.
(ii)If you are just looking to put a couple of buttons on a gui, I learned
to do this pretty quickly using Tkinter and one of the online tutorials.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Instead of saving text files i need as html

2006-06-08 Thread 3c273
"3c273" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Or is this what you mean?
> -begin-
> import urllib
> urlfile = open('c:\\temp\\url.txt', 'r')
> newurlfile = open('c:\\temp\\newurls.html', 'w')
> newurlfile.write(' \n\n')
> for lines in urlfile:
> try:
> if lines == '\n':
> pass
> else:
> lines = ''\
>  + lines.strip() + '' + '\n'
> newurlfile.write(lines)
> except:
> pass
> newurlfile.write(' \n')
> urlfile.close()
> newurlfile.close()
> -end-
> Louis
>
Oops, I guess we don't need "import urllib" anymore.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Instead of saving text files i need as html

2006-06-08 Thread 3c273
"Shani" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have the following code which takes a list of urls
> "http://google.com";, without the quotes ofcourse, and then saves there
> source code as a text file. I wan to alter the code so that for the
> list of URLs an html file is saved.
>
> -begin-
> import urllib
> urlfile = open(r'c:\temp\url.txt', 'r')
> for lines in urlfile:
> try:
> outfilename = lines.replace('/', '-')
> urllib.urlretrieve(lines.strip('/n'), 'c:\\temp\\' \
> + outfilename.strip('\n')[7:] + '.txt')
> except:
> pass
> -end-
>
Or is this what you mean?
-begin-
import urllib
urlfile = open('c:\\temp\\url.txt', 'r')
newurlfile = open('c:\\temp\\newurls.html', 'w')
newurlfile.write(' \n\n')
for lines in urlfile:
try:
if lines == '\n':
pass
else:
lines = ''\
 + lines.strip() + '' + '\n'
newurlfile.write(lines)
except:
pass
newurlfile.write(' \n')
urlfile.close()
newurlfile.close()
-end-
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Instead of saving text files i need as html

2006-06-08 Thread 3c273
"Shani" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have the following code which takes a list of urls
> "http://google.com";, without the quotes ofcourse, and then saves there
> source code as a text file. I wan to alter the code so that for the
> list of URLs an html file is saved.
>
> -begin-
> import urllib
> urlfile = open(r'c:\temp\url.txt', 'r')
> for lines in urlfile:
> try:
> outfilename = lines.replace('/', '-')
> urllib.urlretrieve(lines.strip('/n'), 'c:\\temp\\' \
> + outfilename.strip('\n')[7:] + '.txt')
> except:
> pass
> -end-
>

Is this what you mean?

-begin-
import urllib
urlfile = open(r'c:\temp\url.txt', 'r')
for lines in urlfile:
try:
outfilename = lines.replace('/', '-')
urllib.urlretrieve(lines.strip('/n'), 'c:\\temp\\' \
+ outfilename.strip('\n')[7:] + '.html')
except:
pass
-end-
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does the _winreg module start with an underscore

2006-05-19 Thread 3c273

"Erik Max Francis" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 3c273 wrote:
>
> > Does it signify something? Just curious.
>
> Dear quasar,
>
> Typically an identifier starting with an underscore signifies something
> that is not intended to be exposed as part of a public API.  In other
> words, it's an implementation detail in whatever you're using and as
> such you probably shouldn't use it or rely on it, unless you know the
> internal details very well.  An identifier starting with _two_
> underscores is automatically mangled in a way that makes it more
> difficult (but not impossible) for external clients to accidentally use
> them.
>
Thanks for the explanation. (Fellow astronomer?)
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Why does the _winreg module start with an underscore

2006-05-19 Thread 3c273
Does it signify something? Just curious.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: timeit.py examples in docs generate error

2006-03-09 Thread 3c273
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Window's command processor doesn't recognise single quote marks as
> meaning anything special, so your command is passing 4 separate arguments
> to timeit.py instead of the 1 argument that a unix shell would be passing.
>
> Try using double quotes around everything instead:
>
> timeit.py "if hasattr(int, '__nonzero__'): pass"
That did the trick. Thanks!
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


timeit.py examples in docs generate error

2006-03-09 Thread 3c273
Hello,
I was reading the thread on try/except overhead and decided to try Alex's
examples but they kept generating exceptions. So I went to the docs and
tried the examples there (copied and pasted) with the same results (Win2k,
Python 2.4). Any help is appreciated. The output follows:
#1
C:\Python24\Lib>timeit.py 'if hasattr(int, "__nonzero__"): pass'
Traceback (most recent call last):
  File "C:\Python24\Lib\timeit.py", line 285, in ?
sys.exit(main())
  File "C:\Python24\Lib\timeit.py", line 249, in main
t = Timer(stmt, setup, timer)
  File "C:\Python24\Lib\timeit.py", line 116, in __init__
code = compile(src, dummy_src_name, "exec")
  File "", line 6
'if
  ^
SyntaxError: EOL while scanning single-quoted string

#2
C:\Python24\Lib>timeit.py 'try:' '  str.__nonzero__' 'except
AttributeError:' '
 pass'
Traceback (most recent call last):
  File "C:\Python24\Lib\timeit.py", line 285, in ?
sys.exit(main())
  File "C:\Python24\Lib\timeit.py", line 249, in main
t = Timer(stmt, setup, timer)
  File "C:\Python24\Lib\timeit.py", line 116, in __init__
code = compile(src, dummy_src_name, "exec")
  File "", line 7
'
^
SyntaxError: EOL while scanning single-quoted string

Thanks again,
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Opening files without closing them

2006-03-08 Thread 3c273

"Bryan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> if i really want to handle the exception, then i handle it at a
conceptually
> "higher" level by wrapping it in an exception which is basically what some
> higher-level routine would do anyways.
>
>
> try:
>  f = open('file)
>  try:
>  # do something
>  finally:
>  f.close()
> except IOError:
>  # handle exceptions
>
I like this idea also. Thanks to all who helped me understand..
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Opening files without closing them

2006-03-08 Thread 3c273
"Peter Hansen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> So this is better, though probably excessive in small scripts:
>
> try:
>  f = open('file')
> except IOError:
>  # do something else
> else:
>  try:
>  content = f.read()
>  finally:
>  f.close()
>
> This takes advantage of "else" on try statements, which executes only if
> the except statement is not executed.
>
Thank you for your reply. I had forgotten that you could use 'else' in a
'try' statement. I like this solution. Thanks again.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Opening files without closing them

2006-03-07 Thread 3c273
"Robert Kern" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Paul Rubin wrote:
> > Say that the open is inside the try block.  If the file can't be
> > opened, then 'open' raises an exception, 'f' doesn't get set, and then
> > the 'finally' clause tries to close f.  f might have been previously
> > bound to some other file (which still has other handles alive) and so
> > the wrong file gets closed.
>
> And even if 'f' wasn't bound to anything, you will get a NameError instead
of
> the exception that you're really interested in seeing.

Thanks to both of you. So in order to be thorough, should I be doing:
try:
f=open('file')
except: IOError:
print 'doesn't exist'
so_something_else_instead()

try:
contents = f.read()
finally:
f.close()

Thanks again.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Opening files without closing them

2006-03-06 Thread 3c273
"Erik Max Francis" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Note quite.  The assignment of the resources to its variable needs to be
> done before the try:
>
> f = open(file)
> try:
> contents = f.read()
> finally:
> f.close()
>
Pardon the newbie question, but could you explain why? I have been doing it
the same way as the OP and would like to know the difference. Thank you.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple System Tray Icon

2006-03-02 Thread 3c273
quoted
This is untested, 'cos I'm on a Mac these days, but what you want
should look something like:

from SysTrayIcon import SysTrayIcon
icon = SysTrayIcon('parh/to/icon.ico', "Hover text", {})

How simple do you want?

/quoted

I guess I still don't get it. The code you supplied creates an icon and then
hangs.

from SysTrayIcon import SysTrayIcon
icon = SysTrayIcon('PathToMyIcon', "My Application",())
while 1:
DoStuff()

DoStuff doesn't do happen until I choose 'QUIT' from the icon menu. Any
help? I feel like I'm missing something really fundamental here. Thanks
again.

Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple System Tray Icon

2006-03-02 Thread 3c273

"Simon Brunning" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

This is untested, 'cos I'm on a Mac these days, but what you want
should look something like:

from SysTrayIcon import SysTrayIcon
icon = SysTrayIcon('parh/to/icon.ico', "Hover text", {})

How simple do you want?


That's what I wanted. I just couldn't figure out how to use it. Thanks a
bunch.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple System Tray Icon

2006-03-02 Thread 3c273

"Thomas Heller" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 3c273 wrote:
> > Can someone point me to a simple example that just shows an icon? I
don't
> > need it to anything but show up. Any help is appreciated.
> > Louis
> >
> >
> Simon Bruning has made something that should you get started.
>
> http://www.brunningonline.net/simon/blog/archives/001835.html
>
> Thomas

I guess I should have capitalized the word 'simple' in my request :-) Thanks
for your reply. I had already found this and it made the wx example look
like a one-liner. I didn't realize that this was such a chore. Thanks again,
I will keep trying.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple System Tray Icon

2006-03-02 Thread 3c273

"Michele Petrazzo" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> wxTaskBarIcon is very, very simple!
> Into the demo, inside 80 line, you can find all the taskbar work, the
> menu connected with the rclick and its image change...
> Where do you find this complex?

I guess since it is in a class and I am not very familiar with OOP. I was
hoping there was a simple procedural way to do something like:

myIcon=wx.TaskBarIcon('path to my icon file')
myIcon.ShowIcon()

but I guess it's not that simple. Thanks for your reply, I will keep trying.

> Try to make the windows taskbar with the win32 api ... :)

I saw an example of that. No thanks!

Thanks again.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Simple System Tray Icon

2006-03-02 Thread 3c273
Hello,
I have a short looping script that runs in the background (Windows 2000) and
I want to have a tray icon so I know that it is running. I have looked at
wxTaskBarIcon and the examples on the web and in the demo, but it seems
pretty complex and I haven't had any success even getting one to show up.
Can someone point me to a simple example that just shows an icon? I don't
need it to anything but show up. Any help is appreciated.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing python on a server?

2006-02-10 Thread 3c273
"Renato" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
-snip-
> On systems with package management (pretty much all of them, except
> Slack) install is a matter of a few commands. And you can automate it,
> obviously.

Slackware has package management, (pkgtool, installpkg, removepkg,
upgradepkg), it just doesn't do dependency checking.
http://www.slackbook.org/html/package-management.html
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: winsound.MessageBeep

2006-01-30 Thread 3c273
"Larry Bates" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> You need to call winsound.MessageBeep(winsound.MB_OK)
>
> (e.g. MB_OK isn't automatically bound to anything).
>
Thanks so much
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


winsound.MessageBeep

2006-01-30 Thread 3c273
Hello,
I was trying to use the MessageBeep fuction to play different system sounds,
but using the syntax in the docs, all I can get is the default sound.. While
I finally got my sounds to play using PlaySound, I am curious as to what I
was doing wrong with MessageBeep. (Win2000 & XP)

>From the docs

  MessageBeep( [type=MB_OK])

...The type argument specifies which sound to play; possible values are -1,
MB_ICONASTERISK, MB_ICONEXCLAMATION, MB_ICONHAND, MB_ICONQUESTION, and
MB_OK, all described below

Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import winsound
>>> winsound.MessageBeep(-1)
(This works)

>>> winsound.MessageBeep(MB_OK)
Traceback (most recent call last):
  File "", line 1, in ?
NameError: name 'MB_OK' is not defined

(OK I'm kind of new to this so maybe it needs quotes:-)

>>> winsound.MessageBeep('MB_OK')
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: an integer is required

So what do I need to do to play the other sounds listed in the docs (using
MessageBeep). Thanks.

Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decimal ROUND_HALF_EVEN Default

2006-01-17 Thread 3c273
Thanks to all! Interesting reading.

Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Decimal ROUND_HALF_EVEN Default

2006-01-16 Thread 3c273
Hello,

I'm just curious as to why the default rounding in the decimal module is
ROUND_HALF_EVEN instead of ROUND_HALF_UP. All of the decimal arithmetic I do
is rounded half up and I can't think of why one might use round half even. I
googled a bit and didn't really find a good answer. Any insight is
appreciated.

Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Insert database rows from CSV file

2005-04-05 Thread 3c273

"Steve Holden" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Dennis Lee Bieber wrote:
> > On Mon, 4 Apr 2005 15:54:37 -0700, "3c273" <[EMAIL PROTECTED]> declaimed
> > the following in comp.lang.python:
> >
> >
> >>Thanks for the link, but this is the step I am trying to save (for
someone
> >>else). Every time he goes to run a report, he must stop and import any
new
> >>csv files. Since the files are generated by a Python script, I thought I
> >
> >
> > That information wasn't supplied in the original message. Your
> > original post implied that the data source /was/ the CSV file...
> >
> > Show us the code segment that is writing the CSV file, and we
> > can probably show you the DB-API equivalent for "writing" a new record
> > to the table.
> >
> > For short however:
> >
> > aCustomer = "Customer1"
> > theWidget = "Widget1"
> > aQuantity = 1000
> >
> > # I'm presuming the table only has the three columns, since you didn't
> > list fields
> > cursor.execute(""" INSERT INTO "Table1" Values (%s, %s, %s) """,
> > (aCustomer, theWidget, aQuantity))
>
> Beware, however, that the parameter markers ("%s" in the example above)
> will depend on which database module you use - some modules will expect
> "?", for example. This depends on the module's "paramstyle".
>
> Also, don't forget to commit the changes!
>
> regards
>   Steve

Thanks for the heads-up. I think I'm well on my way now.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Insert database rows from CSV file

2005-04-05 Thread 3c273

"Dennis Lee Bieber" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Mon, 4 Apr 2005 15:54:37 -0700, "3c273" <[EMAIL PROTECTED]> declaimed
> the following in comp.lang.python:
>
> > Thanks for the link, but this is the step I am trying to save (for
someone
> > else). Every time he goes to run a report, he must stop and import any
new
> > csv files. Since the files are generated by a Python script, I thought I
>
> That information wasn't supplied in the original message. Your
> original post implied that the data source /was/ the CSV file...
>
> Show us the code segment that is writing the CSV file, and we
> can probably show you the DB-API equivalent for "writing" a new record
> to the table.
>
> For short however:
>
> aCustomer = "Customer1"
> theWidget = "Widget1"
> aQuantity = 1000
>
> # I'm presuming the table only has the three columns, since you didn't
> list fields
> cursor.execute(""" INSERT INTO "Table1" Values (%s, %s, %s) """,
> (aCustomer, theWidget, aQuantity))

Ah.. Many thanks. This is what I was looking for.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Insert database rows from CSV file

2005-04-04 Thread 3c273
Thanks for the link, but this is the step I am trying to save (for someone
else). Every time he goes to run a report, he must stop and import any new
csv files. Since the files are generated by a Python script, I thought I
could just insert them into his table and save him some steps. I'm also just
trying to learn the basics Python and SQL . Thanks again.
Louis

"Larry Bates" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> You may want to take a look at this link.  It should
> be much faster than any programmatic technique.
>
> http://www.its.niu.edu/its/CSupport/tipoftheweek/tip_080502.shtml
>
> If you still want to do it programmatically, you will need to
> look at csv module to parse the lines.
>
> Larry Bates
>
>
>
> 3c273 wrote:
> > Hello,
> > I have a really simple Access database table with a format similar to
this:
> > CustomerName - ProductOrdered - QtyOrdered
> >
> > I have a CSV file with the appropriate values as follows:
> > Customer1, Widget1, 1000
> > Customer2, Widget2, 3000
> > etc
> >
> > I have figured out how to insert the data manually from the interactive
> > prompt:
> > cursor.execute(""" INSERT INTO "Table1" Values ('Customer1', "Widget1',
> > '1000') """)
> >
> > What I would like to do is iterate over the CSV file like this:
> > for lines in file:
> > cursor.execute(""" INSERT INTO "Table1" lines """)
> >
> > I have googled and found some examples that use string formatting, but
> > without documentation I can't seem to find the right formula. I don't
have
> > any problem with the iteration part, I just can't seem to figure out how
to
> > use a variable to insert an entire row with the INSERT statement. Can
anyone
> > get me going in the right direction? I'm using odbc from win32all,
> > Python2.3, and Access2000 if it matters. Thanks.
> > Louis
> >
> >


-- 
http://mail.python.org/mailman/listinfo/python-list


Insert database rows from CSV file

2005-04-04 Thread 3c273
Hello,
I have a really simple Access database table with a format similar to this:
CustomerName - ProductOrdered - QtyOrdered

I have a CSV file with the appropriate values as follows:
Customer1, Widget1, 1000
Customer2, Widget2, 3000
etc

I have figured out how to insert the data manually from the interactive
prompt:
cursor.execute(""" INSERT INTO "Table1" Values ('Customer1', "Widget1',
'1000') """)

What I would like to do is iterate over the CSV file like this:
for lines in file:
cursor.execute(""" INSERT INTO "Table1" lines """)

I have googled and found some examples that use string formatting, but
without documentation I can't seem to find the right formula. I don't have
any problem with the iteration part, I just can't seem to figure out how to
use a variable to insert an entire row with the INSERT statement. Can anyone
get me going in the right direction? I'm using odbc from win32all,
Python2.3, and Access2000 if it matters. Thanks.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter (OOP?) help

2005-01-03 Thread 3c273

"Mike Meyer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> Every time you call newwindow, you rebind self.new to the window just
> created. So any close button that works will close the last window opened.
>
> You need to create a separate class for new windows, each with it's
> own self.new (or self.window) that it's self.closeme will call destroy
> on.
>
> http://mail.python.org/mailman/listinfo/python-list


Tkinter (OOP?) help

2004-12-30 Thread 3c273
Hello,
I am trying to expand on a tutorial I am working through and I am not
understanding something. In the following example if you click on the "New
window" button, a new window appears with a "Close me" button in it and if
you click on it's "Close me" button, it works. But, if you click the
original "New window" button two or more times, the "Close me" button only
works on one of the new windows. Furthermore, if you click "Close me" on the
first new window, it closes the last window to open, not the one that you
clicked on. How do I bind a "closeme2" function to each new window? Any help
is appreciated.

Louis

--begin code--
from Tkinter import *

class MyApp:
def __init__(self, parent):
self.myparent = parent
self.frame1 = Frame(parent)
self.frame1.pack()

self.btn1 = Button(self.frame1, text='Do nothing', bg='green')
self.btn1.pack(side=LEFT)

self.btn2 = Button(self.frame1, text='Close me', fg='white',
bg='red')
self.btn2.pack(side=LEFT)
self.btn2.bind('', self.closeme)

self.btn3 = Button(self.frame1, text='New window?', bg='grey')
self.btn3.pack(side=LEFT)
self.btn3.bind('', self.newwindow)

def closeme(self, event):
self.myparent.destroy()

def newwindow(self, event):
self.new = Toplevel(self.myparent)
self.frame2 = Frame(self.new)
self.frame2.pack()

self.btn4 = Button(self.frame2, text='Close me', fg='white',
bg='red')
self.btn4.pack()
self.btn4.bind('', self.closeme2)

def closeme2(self, event):
self.new.destroy()

root = Tk()
root.title('Tk Test Program')
myapp = MyApp(root)
root.mainloop()


-- 
http://mail.python.org/mailman/listinfo/python-list