[Tutor] grammer

2008-03-20 Thread Eric Walker
Hello, I have been reading about python grammers for processing text files. Does anyone have any simple examples? Thanks Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs

Re: [Tutor] Calling super classs __init__?

2008-03-20 Thread tiger12506
Woah. Either you're leaving out essential info, or python got a lot more complicated. Firstly, super returns all base classes. How? Does it return a tuple of them, or a container object, or is this something horribly worse such as syntactic sugar? It doesn't make sense for it to return a tuple

Re: [Tutor] CSV file processing...

2008-03-20 Thread bob gailer
On Thu, Mar 20, 2008 at 03:16:05PM -0600, Spencer Parker wrote: I've interspersed a bunch of comments to show you how hard it has been to read and understand your problem description. After going thru it I think I understand the question. Please in the future try to express the question more

Re: [Tutor] Help this newbie

2008-03-20 Thread tiger12506
This is Windows I presume? Try: cd\python25 python C:\Elliot\filename.py But for windows you shouldn't have to. You can just double-click the file. On the other hand, if you mean 'import' as it means in the context of the actual python language, then you would put the line "import filename" at

Re: [Tutor] Calling super classs __init__?

2008-03-20 Thread Andreas Kostyrka
Am Freitag, den 21.03.2008, 21:48 -0500 schrieb tiger12506: Actually, super returns all base classes, all in it's own time. Basically, every class has a member __mro__, that contains a consistently ordered list of classes. super needs the class from where it is being called to locate the right

[Tutor] Help this newbie

2008-03-20 Thread Elliot Silvers
I am as new as you can get to Python. I have just learned how to save my work (very simple work of course). I created a folder on C:\ (in this case C:\Elliot) for my work. I am able to use the cmd prompt to run it (cd \Elliot -> C:\Elliot 'filename.py') however I cannot figure out how to import

Re: [Tutor] Calling super classs __init__?

2008-03-20 Thread tiger12506
>> class SubClass(BaseClass): >> def __init__(self, t, *args, **kw): >> super(SubClass, self).__init__(*args, **kw) >> # do something with t > Is there a proper way to handle the case when SubClass() is called using > positional arguments, and you do not desire "t" to be at th

Re: [Tutor] question concerning Boolean operators

2008-03-20 Thread Alan Gauld
"Guba" <[EMAIL PROTECTED]> wrote > >>> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance' > >>> non_null = string1 or string2 or string3 > >>> non_null > 'Trondheim' > > How does this work?? How does Python know that we are looking for > non_null? After all, we don't provide this informa

Re: [Tutor] CSV file processing...

2008-03-20 Thread Dave Kuhlman
On Thu, Mar 20, 2008 at 03:16:05PM -0600, Spencer Parker wrote: > I am trying to read a CSV file and the get that information into a MySQL > database. I am able to do this, but I have a small problem. I have a piece > of software that runs and each iteration is one like. It only runs once > righ

Re: [Tutor] question concerning Boolean operators

2008-03-20 Thread Steve Willoughby
On Thu, Mar 20, 2008 at 04:55:17PM -0700, jim stockford wrote: > >>> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance' > >>> jackson = string1 or string2 or string3 > >>> jackson > 'Trondheim' The key here is the "or" operator which, in an expression like a or b will return a if

Re: [Tutor] question concerning Boolean operators

2008-03-20 Thread jim stockford
i'm guessing assignment, which actually associates a reference, will skip referencing an identifier to a null and will make the association (assignment) to the first non-null value in the expression, which is string2 in this case. that the identifier is non_null is immaterial; you could write

Re: [Tutor] CSV file processing...

2008-03-20 Thread Eric Walstad
Hi Spencer Spencer Parker wrote: > I have a > piece of software that runs and each iteration is one like. I don't understand what this means. > It only > runs once right now; there is only one line + the headers. I use the > csv module to kill the headers and import the one line. Does 'kill

Re: [Tutor] CSV file processing...

2008-03-20 Thread Kent Johnson
Spencer Parker wrote: > I am trying to read a CSV file and the get that information into a MySQL > database. I am able to do this, but I have a small problem. I have a > piece of software that runs and each iteration is one like. It only > runs once right now; there is only one line + the hea

[Tutor] question concerning Boolean operators

2008-03-20 Thread Guba
Dear list, from Guido's tutorial: It is possible to assign the result of a comparison or other Boolean expression to a variable. For example, >>> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance' >>> non_null = string1 or string2 or string3 >>> non_null

[Tutor] CSV file processing...

2008-03-20 Thread Spencer Parker
I am trying to read a CSV file and the get that information into a MySQL database. I am able to do this, but I have a small problem. I have a piece of software that runs and each iteration is one like. It only runs once right now; there is only one line + the headers. I use the csv module to ki

Re: [Tutor] Python to C++

2008-03-20 Thread Chris Fuller
On Wednesday 19 March 2008 18:52, Dinesh B Vadhia wrote: > 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 You also might want to use some profiling tools, or skip that st

Re: [Tutor] Using pyusb

2008-03-20 Thread Michael Holloway
I hope I'm using this system correctly by just hitting reply-all in my email client :s Thanks very much Michael, I've been a bit thin on the other details I see. My platform is Mac Os 10.4, I'm using USB snooper to get the data I need, I'll post it at the end of this message. Forgive me, I've b

Re: [Tutor] Python to C++

2008-03-20 Thread Alan Gauld
"Dinesh B Vadhia" <[EMAIL PROTECTED]> wrote > 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? It may be obvious but its worth noting that optimised Python may be faster than a ba

Re: [Tutor] Python to C++

2008-03-20 Thread Andreas Kostyrka
If you need to rewrite Python code for performance, I'd recommend using Pyrex/Cython. (www.cython.org). It let's you get away with small changes to your code as a starter (Cython is relative compatible syntax-wise with Python), and you can add "C type annotations" as needed. (And no, C++ is not co

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

2008-03-20 Thread Kent Johnson
Kent Johnson wrote: > One regex can split apart a numeric part and a non-numeric unit: A little explanation: > In [22]: import re > In [23]: splitter = re.compile(r'(\d+)(\S+)') The regex finds one or more digits \d+ followed by one or more non-whitespace characters \S+. The parentheses define

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

2008-03-20 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote > One regex can split apart a numeric part and a non-numeric unit: > In [24]: splitter.findall('2m 4cm 3mm') > Out[24]: [('2', 'm'), ('4', 'cm'), ('3', 'mm')] As ever Kent, a neat solution. Much more efficient than my 3 way search and relatively easy to

Re: [Tutor] Converter

2008-03-20 Thread Alan Gauld
<[EMAIL PROTECTED]> wrote > Currently this is what I am working with. Thanks for posting that it gives us a much better idea of what stage you are at and lets us target our answers. Forget the Cocoa suggestion I made earlier, your basic Python skills need improving before you get to that. >