Re: [Tutor] loading modules only when needed and PEP 008

2008-03-19 Thread Eric Walstad
Hey Timmie, Tim Michelsen wrote: >> When I do this sort of thing I like >> to move my imports into my functions/methods. > Would this then be compliant with the style recommendations? Hm, I'm not sure. I guess that if you consider that somewhere near the top of the style guide it says something a

Re: [Tutor] reading parts of a input string into different variables based on units.

2008-03-19 Thread Marc Tompkins
On Wed, Mar 19, 2008 at 3:56 PM, Tim Michelsen <[EMAIL PROTECTED]> wrote: > m = 0 > cm = 0 > mm = 0 > ## first list item > if first.endswith("m",-1): > m = first.strip("m") > elif first.endswith("cm",-2): > cm = first.strip("cm") > elif first.endswith("mm",-2): > mm = first.strip("mm")

Re: [Tutor] Python to C++

2008-03-19 Thread Michael Langford
Weave is probably what you really want to do, although it doesn't do what you said: http://wiki.python.org/moin/weave Pyrex actually does what you said: http://wiki.python.org/moin/Pyrex On Wed, Mar 19, 2008 at 7:52 PM, Dinesh B Vadhia <[EMAIL PROTECTED]> wrote: > > > Say because of performance, y

Re: [Tutor] Converter

2008-03-19 Thread bob gailer
[EMAIL PROTECTED] wrote: > print "Converter" > number = 2.5 > n = int(raw_input("Insert Feet Amount")) > while n > 0: > print n, "Feet is" > print n*12, "inches" > print n*30, "centimeters" > print > > Currently this is what I am working with. > 2 problems I am facing. > 1.

[Tutor] Converter

2008-03-19 Thread wackedd
print "Converter" number = 2.5 n = int(raw_input("Insert Feet Amount")) while n > 0: print n, "Feet is" print n*12, "inches" print n*30, "centimeters" print Currently this is what I am working with. 2 problems I am facing. 1. When I run the script and type in the amount of

Re: [Tutor] reading parts of a input string into different variables based on units.

2008-03-19 Thread Kent Johnson
Alan Gauld wrote: > For something like this I'd use regular expressions. > If your strings vary in length then I'd use a separate regular > expression per unit then use that to findall matching > substrings for each unit. > Of course you will have to work out the right regex but that > shouldn't

Re: [Tutor] reading parts of a input string into different variables based on units.

2008-03-19 Thread Tim Michelsen
Hello, thank you for the fast reply! > A regex would avoid that since it would detect an m > as being diffrent to a cm or mm. > > Of course you will have to work out the right regex but that > shouldn't be too difficult if you are sure you have a whitespace > separator and a number followed by th

Re: [Tutor] loading modules only when needed and PEP 008

2008-03-19 Thread Tim Michelsen
> When I do this sort of thing I like > to move my imports into my functions/methods. Would this then be compliant with the style recommendations? > The 'main' code then > conditionally calls the function/method. All the code in the > function safely assumes that the import has been done but co

[Tutor] Python to C++

2008-03-19 Thread Dinesh B Vadhia
Say because of performance, you might want to re-write/convert Python code to C++. What is the best way (or best practice) to do this wrt the tools available? Dinesh ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Using pyusb

2008-03-19 Thread Michael Langford
Btw, the win32 version of libusb is not maintained anymore, and bogus in my experience. I didn't really get to use libusb much on linux, but it seemed to get a descriptor at least. IIRC, they were upset with their interface and in the middle of vastly changing it. --Michael On Wed, Mar 19,

Re: [Tutor] Using pyusb

2008-03-19 Thread Michael Langford
I've never heard of the type of cable you're using. Can you send a link to one to the list? You're missing most of the USB ideas more than the python ideas. USB is very very complicated. The USB spec (of which you care about chapter 9) is nothing like how most people actually use USB. Most people

Re: [Tutor] reading parts of a input string into different variables based on units.

2008-03-19 Thread Alan Gauld
"Tim Michelsen" <[EMAIL PROTECTED]> wrote > I would like to read several parts of a string into different > variables > based on the (physical) units of the quantities. > > Here's my testing code: > ### > mystring = '2m 4cm 3mm' # can also be '1pound 30pence', ... > mylist = mystring.

Re: [Tutor] loading modules only when needed and PEP 008

2008-03-19 Thread Eric Walstad
Hi Tim, Tim Michelsen wrote: > Hello fellow Pythonistas, > I have a question concerning import statements. ... > it takes a lot > of time for a TKinter-GUI to start up. And this start-up time is even > longer when matplotlib is imported > a optimized version would be: > import sys > > plot_

[Tutor] reading parts of a input string into different variables based on units.

2008-03-19 Thread Tim Michelsen
Hello, I would like to read several parts of a string into different variables based on the (physical) units of the quantities. Here's my testing code: ### mystring = '2m 4cm 3mm' # can also be '1pound 30pence', ... mylist = mystring.split(" ") print mylist first = mylist[0] second =

[Tutor] loading modules only when needed and PEP 008

2008-03-19 Thread Tim Michelsen
Hello fellow Pythonistas, I have a question concerning import statements. My code uses matplotlib to plot the results of my calculations. Since I want to make this plotting functionality a optional feature I would like to import matplotlib only when needed because it takes a lot of time for a T

Re: [Tutor] Should config file parser be in module's __init__.py

2008-03-19 Thread Kent Johnson
Shrutarshi Basu wrote: > Ok, I'm starting to understand how things work. Just one last > question: suppose my package has a config.py (which contains a config > dict) which another module in the package imports by "import config". > If the user of my package has a config.py in the directory from wh

Re: [Tutor] Should config file parser be in module's __init__.py

2008-03-19 Thread Shrutarshi Basu
Ok, I'm starting to understand how things work. Just one last question: suppose my package has a config.py (which contains a config dict) which another module in the package imports by "import config". If the user of my package has a config.py in the directory from where they run their program (whi

Re: [Tutor] Using pyusb

2008-03-19 Thread Alan Gauld
"Mike Holloway" <[EMAIL PROTECTED]> wrote > I have a Prolific Technologies bridged usb cable that I wish to talk > to > using pyusb and libusb, Sorry I can't help but thanks for pointing these out. I've been intending to write a USB module for over a year, now I don't need to! :-) -- Alan Gau

[Tutor] Using pyusb

2008-03-19 Thread Mike Holloway
Hi all, I'm very new to this list, so hello all! I'm just starting out using python, my background is lamp. I have a Prolific Technologies bridged usb cable that I wish to talk to using pyusb and libusb, I've tried following examples and compiling my own code but I'm really struggling getting i

Re: [Tutor] Calling super classs __init__?

2008-03-19 Thread Allen Fowler
> Nowadays the best practice for invoking a method from all superclasses > (yes, multiple inheritance) is this: > > class SubClass(BaseClass): > def __init__(self, t, *args, **kw): > super(SubClass, self).__init__(*args, **kw) > # do something with t > > That way you let Pyth

Re: [Tutor] Converter

2008-03-19 Thread Alan Gauld
"Jack Lucas" <[EMAIL PROTECTED]> wrote >I am trying to make a converter for Python on my Mac. > I know I can find one online, but this is more satisfying. Have you looked at the Cocoa tutorial on using Python on MacOS? It is just such a convertor(for currency). Using that as a template it should

Re: [Tutor] Converter

2008-03-19 Thread Timmie
> start, as I want to be able to input any Unit to Convert (will keep it simple for now, feet, inches etc. and add Maybe you want to get inspired by a Gnome deskbar handler: http://www.kryogenix.org/days/2006/09/06/converter-deskbar ___ Tutor maillist -

Re: [Tutor] Should config file parser be in module's __init__.py

2008-03-19 Thread Kent Johnson
Shrutarshi Basu wrote: > Thanks for that, i think that creating a configuration submodule and > importing it into the modules that need it will be the most elegant > solution for me. I was wondering whether the following solution would > work / be good practice? > 1. have the parser system in __ini

[Tutor] Converter

2008-03-19 Thread Jack Lucas
I am trying to make a converter for Python on my Mac. I know I can find one online, but this is more satisfying. I am not sure exactly where to start. I want to be able to input a "Unit to Convert" a "Unit to Convert to" and an "Amount of Unit to Convert" For example Unit to Convert: centimeters,

Re: [Tutor] how to search a directory from a Tkinter program

2008-03-19 Thread Alan Gauld
"brindly sujith" <[EMAIL PROTECTED]> wrote > i am developing an application in tkinter > > i want to know whether we have any option to search a directory from > tkinter > program I'm not sure what you mean. You can use the standard Python modules to search a directory, or indeed an entire dire

Re: [Tutor] c++::return

2008-03-19 Thread Luke Paireepinart
elis aeris wrote: > I actually said "ending" to avoid problems with different terminology > between different languages - but i guess a return is still a return > in python. Return does not exit a program. A return statement denotes a point in a function when the function will stop executing an

[Tutor] how to search a directory from a Tkinter program

2008-03-19 Thread brindly sujith
hi i am developing an application in tkinter i want to know whether we have any option to search a directory from tkinter program please answer me thank you ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor