Kent Johnson wrote:
> cedric briner wrote:
>> Hello,
>>
>> I do not understand the behaviour of this:
>>
>> import re
>> re.search('(a)*','aaa').groups()
>> ('a',)
>>
>> I was thinking that the ``*'' will operate on the group delimited by the
>> parenthesis. And so, I was expecting this result:
>>
Python has no way to force the OS to schedule a process on a given processor
(therefore you're safe). If you use multiple processes, you can get true
concurrency. This is one of the reasons process based concurrency is
superior to threads (*ducks from items thrown by threadophiles*).
Then again, y
James wrote:
> Thanks for the quick reply.
>
> Interesting. I'm a little overwhelmed with the different terminology
> (fork, spawn, thread, etc.). I'm under the impression that I'm
> supposed to use os.fork() or os.spawn() for something like what I'm
> trying to do (start multiple instances
Thanks for the quick reply.
Interesting. I'm a little overwhelmed with the different terminology
(fork, spawn, thread, etc.). I'm under the impression that I'm
supposed to use os.fork() or os.spawn() for something like what I'm
trying to do (start multiple instances of the I/O utility from
James wrote:
> Hi. :)
>
> I have a question regarding threading in Python. I'm trying to write
> a wrapper script in Python that will spin off multiple (lots!) of
> instances of an I/O benchmark/testing utility. I'm very interested
> in doing this in Python, but am unsure if this is a goo
Hi. :)
I have a question regarding threading in Python. I'm trying to write
a wrapper script in Python that will spin off multiple (lots!) of
instances of an I/O benchmark/testing utility. I'm very interested
in doing this in Python, but am unsure if this is a good idea. I
thought I re
On 9/19/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
> bhaaluu wrote:
>
> > def popNum(num):
> > if num == stackA[-1]:
> > stackA.pop()
>
> What happens here if stackA is empty?
>
> Kent
This was how I was looking for the number.
It seems to me that if the list was EMPTY
or didn't have
bhaaluu wrote:
> def popNum(num):
> if num == stackA[-1]:
> stackA.pop()
What happens here if stackA is empty?
Kent
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
You should check if the stack is empty before you access it:
def popNum(num):
if len(stackA) > 0 and num == stackA[-1]:
stackA.pop()
#etc
--Michael
--
Michael Langford
Phone: 404-386-0495
Consulting: http://www.TierOneDesign.com/
Entertaining: http://www.ThisIsYourCruiseDirec
Greetings,
I'm working with Python 2.4.3 on the GNU/Linux platform.
I'm currently playing with functions and stacks, and am
using the "Towers of Hanoi" as a test game to play with.
Note: This game is not a recursive programming exercise,
it is meant to be solved by the player, manually.
The
On 9/19/07, Ulrich Holtzhausen <[EMAIL PROTECTED]> wrote:
>
>
>
> I can't seem to figure out how to fix it, also, if there's a shorter way
> of doing this effectively, please help :) .
>
>
>
Instead of a keys in a dict, you should think about making a financeRecord
class to hold the data. Don't wor
On Thursday 20 September 2007 01:00, Ulrich Holtzhausen wrote:
> Non-working program: http://pastebin.com/f4da62e57
There seems to be a closing bracket ')' missing at the end of line 17.
In line 18 there is a bracket missing too, in the code at pastebin,
but nut in the error message. So this see
--- Begin Message ---
Hi there,
I started out with Python about two days ago, it's my very first shot at
programming and I find it quite interesting. Anyway I'll get to the point:
I made a simple script that works, albeit not the shortest way I think
but it works, however I would like to ma
Hi there,
I started out with Python about two days ago, it's my very first shot at
programming and I find it quite interesting. Anyway I'll get to the point:
I made a simple script that works, albeit not the shortest way I think
but it works, however I would like to make it a bit more "fancy" t
Your links aren't working for me.
On 9/20/07, Ulrich Holtzhausen <[EMAIL PROTECTED]> wrote:
>
> Hi there,
>
> I started out with Python about two days ago, it's my very first shot at
> programming and I find it quite interesting. Anyway I'll get to the point:
>
> I made a simple script that works,
"Boykie Mackay" <[EMAIL PROTECTED]> wrote
> Is there any simple way of getting parameter input from the user?
>
> What I want to do is to type in two (or more) values on the command
> prompt and have a function do some work on them and return a result.
Take a look at sys.argv.
And then take a l
Hi there,
I started out with Python about two days ago, it's my very first shot at
programming and I find it quite interesting. Anyway I'll get to the point:
I made a simple script that works, albeit not the shortest way I think
but it works, however I would like to make it a bit more "fancy" t
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on
wi
32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = raw_input("Who's yo daddy?: ")
Who's yo daddy?: Bubby June
>>> print a
Bubby June
>>>
See how the variable "a" now has the whole sentenc
Premature optimization is the devil. Care not which method is faster. Only
optimize when the whole program is too slow and then find which area is the
biggest culprit and optimize that.
Computers are very very fast these days. Even embedded systems are so fast
you don't understand how fast they ar
Hi again,
I have racked my brains and tried googling but to no avail.
Is there any simple way of getting parameter input from the user?
What I want to do is to type in two (or more) values on the command
prompt and have a function do some work on them and return a result.For
example say I had a
>>> t = timeit.Timer( '1000%2')
>>> t.timeit(100)
0.25893402099609375
>>> t = timeit.Timer( '1000&1')
>>> t.timeit(100)
0.2567589282989502
It's almost insignificantly faster.
However as a programmer and a mathematician, I disagree with your
position that the bitwise operation is mo
On Wed, 19 Sep 2007, Boykie Mackay wrote:
> if not n&1:
> return false
>
> The above should return false for all even numbers,numbers being
> represented by n.I have tried to wrap my head around the 'not n&1' but
> I'm failing to understand what's going on.Could someone please explain
> the s
Kent Johnson wrote:
> Noufal Ibrahim wrote:
>> My question is whether this is a valid use for a decorator and whether
>> this kind of usage is pythonic. If not, are there any better ways to
>> do this?
>
> It seems like a bit of a hack to me. I guess you change the way you call
> run_command to
Noufal Ibrahim wrote:
> My question is whether this is a valid use for a decorator and whether
> this kind of usage is pythonic. If not, are there any better ways to do
> this?
It seems like a bit of a hack to me. I guess you change the way you call
run_command to include desc?
You could add a
Thanks.That's solved!
On Wed, 2007-09-19 at 13:01 -0400,
[EMAIL PROTECTED] wrote:
>
>
> [EMAIL PROTECTED] wrote on 09/19/2007 12:38:49 PM:
>
> > Sorry about that.
> >
> > I have posted the code below:
> >
> > #!/usr/bin/env python
> >
> > '''A program to generate prime numbers when given 2 n
[EMAIL PROTECTED] wrote on 09/19/2007 12:38:49 PM:
> Sorry about that.
>
> I have posted the code below:
>
> #!/usr/bin/env python
>
> '''A program to generate prime numbers when given 2 numbers'''
>
> def isPrime(number):
> number=abs(int(number))
> #1 is not considered a prime number
Hello everyone,
I have a question regarding the use of some decorators.
In my program, I have functions like this
def process_command_line(...):
...
def run_command(...):
...
def update_db(...):
...
These functions are for various stages of the program. Now, I need
to
Sorry about that.
I have posted the code below:
#!/usr/bin/env python
'''A program to generate prime numbers when given 2 numbers'''
def isPrime(number):
number=abs(int(number))
#1 is not considered a prime number
if number<2:
return False
#2 is the only even prime numbe
Attachments are a bad thing to send to open mailing lists in general.
In your case, the list appears to have filtered off the code. Please paste
it in inline.
--Michael
On 9/19/07, Boykie Mackay <[EMAIL PROTECTED]> wrote:
>
> Hi Guys,
>
> Could you please look over my code 'attached' t
The problem was pointed out by Kent
"""
I think you want
s.arrayEnv = arrayEnv
Not s,arrayEnv (comma instead of period)
"""
Maybe I should put time limits on myself when I am programming...
After a few hours my mind starts going fruity.
Maybe I should be wearing the dunce cap. Hopefully, I can p
Hi Guys,
Could you please look over my code 'attached' to find and print out
prime numbers between to given values.When run it it is showing
inaccuracies i.e printing out '49' and '95' as prime numbers.
I have been through the code but can't seem to find where I may have
gone wrong.I am sure it h
Carnell, James E wrote:
> s,arrayEnv = arrayEnv### THIS MIGHT BE MY PROBLEM Is it just
> copying a pointer?###
I think you want
s.arrayEnv = arrayEnv
note the period where you have a comma.
and yes, assignment just makes a new reference to the same object, it
does not make a c
>
> > The above snippet is taking advantage of a similar property of binary
> > numbers, which are base 2. What the above snippet is doing is checking
> to
> > see if that last digit is a 0 or not (asking "not n&1" is equivalent to
> > asking "n&0", since that digit can only be a 0 or 1).
>
> Not q
Dear sacha,
>>can anyone point me in the direction of any python docs or tutorials
>>of interacting with the windows WMI interface ?
Scriptomatic 2.0 from Microsoft seems to be good for pythonists.
https://www.microsoft.com/downloads/details.aspx?FamilyID=09dfc342-648b-4119-b7eb-783b0f7d1178&Di
Any help would greatly appreciated.
Question: I am getting the following error from the validMove function:
ValueError: too many values to unpack
This program (currently) consists of a 2dArray and objects (represented
by integers)
in that array that can be moved.
I am guessing that it has to d
Thanks.
The analogy to the decimal system was a big help in getting me to
understand the principle.
On Wed, 2007-09-19 at 09:47 -0400, taserian wrote:
> On 9/19/07, Boykie Mackay <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I have come across a bit of code to find if a group
sacha rook wrote:
> Hi all
>
> can anyone point me in the direction of any python docs or tutorials of
> interacting with the windows WMI interface ?
See Tim Golden's WMI page:
http://tgolden.sc.sabren.com/python/wmi.html
Kent
___
Tutor maillist -
> > Which Book is better for python parsing and reading Xml files from
> > local
> > machine and remote machine and also through http...
>
> Python Network Programming has more on the networking
> side(surprise!) via http.
You mean, this one. http://www.complete.org/publications/pynet/ ?
>
>
Hi Boyks,
Boykie Mackay wrote:
> Hi guys,
>
> I have come across a bit of code to find if a group of numbers is odd or
> even.The code snippet is shown below:
>
> if not n&1:
> return false
>
> The above should return false for all even numbers,numbers being
> represented by n.I have tried
On 9/19/07, Boykie Mackay <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I have come across a bit of code to find if a group of numbers is odd or
> even.The code snippet is shown below:
>
> if not n&1:
> return false
>
> The above should return false for all even numbers,numbers being
> represented
Hi all
can anyone point me in the direction of any python docs or tutorials of
interacting with the windows WMI interface ?
I am not trying to do anything specific as yet just try to build up a bit of
knowledge see what the possibilities are!
Thanks in advance for you help :0-)
S
On 9/19/07, Boykie Mackay <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> I have come across a bit of code to find if a group of numbers is odd or
> even.The code snippet is shown below:
>
> if not n&1:
>return false
>
> The above should return false for all even numbers,numbers being
> represented
Hi guys,
I have come across a bit of code to find if a group of numbers is odd or
even.The code snippet is shown below:
if not n&1:
return false
The above should return false for all even numbers,numbers being
represented by n.I have tried to wrap my head around the 'not n&1' but
I'm failing
On 9/19/07, cedric briner <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I do not understand the behaviour of this:
>
> import re
> re.search('(a)*','aaa').groups()
> ('a',)
>
> I was thinking that the ``*'' will operate on the group delimited by the
> parenthesis. And so, I was expecting this result:
> (
cedric briner wrote:
> Hello,
>
> I do not understand the behaviour of this:
>
> import re
> re.search('(a)*','aaa').groups()
> ('a',)
>
> I was thinking that the ``*'' will operate on the group delimited by the
> parenthesis. And so, I was expecting this result:
> ('a', 'a', 'a')
>
> Is there
Ian Witham wrote:
> As Michael points out, you need to explicitly use the round function, as
> the float formatting merely truncates anything after the second decimal
> place.
No. I don't know what algorithm it uses for rounding, but it does round:
In [3]: '%.2f' % 6.
Out[3]: '6.67'
In [4]:
Alan Gauld wrote:
> What I was referring to was the lack of any kind of class
> structure at all, a purely prototype driven OOP style.
> (Somewhat like JavaScript OOP except that it's very easy
> to fake classes in JavaScript)
Wikipedia has an article about prototype-based programming:
http://
On 9/19/07, Michael Langford <[EMAIL PROTECTED]> wrote:
> I do think this is a good question for getting a sense of where a
> person's understanding is. I wonder how much this understanding is a
> pre-requistite for being a good developer... not too much I hope!
>
> A good developer is a very load
Hello,
I do not understand the behaviour of this:
import re
re.search('(a)*','aaa').groups()
('a',)
I was thinking that the ``*'' will operate on the group delimited by the
parenthesis. And so, I was expecting this result:
('a', 'a', 'a')
Is there something I'am missing ?
Ced.
--
Cedric BR
Dear Tutors,
I made an OO style triangulation based on an old C progam I made about 10
years ago.
The sample is working finally.
First time I made the triangulation with recursion, but I reached the
recursion limit very shortly.
So I changed the recursion to a queue.
I am interested about your
-Original Message-
From: Ian Witham <[EMAIL PROTECTED]>
Sent: Sep 18, 2007 11:39 PM
To: Christopher Spears <[EMAIL PROTECTED]>
Cc: tutor@python.org
Subject: Re: [Tutor] sales tax
As Michael points out, you need to explicitly use the round function, as the float formatting merely truncates
"Michael Langford" <[EMAIL PROTECTED]> wrote
> OOP without classes is quite common still. This is how a
> good portion of the Linux kernel is written
True, but as I understand it the Linux approach is to use C
structs to mimic some class type behaviour. Essentially
binding data and functions
I do think this is a good question for getting a sense of where a
person's understanding is. I wonder how much this understanding is a
pre-requistite for being a good developer... not too much I hope!
A good developer is a very loaded term. :o)
There are a lot of good programmers who are bad dev
"Michael Langford" <[EMAIL PROTECTED]> wrote
> PS: The function you're looking for is called round. Its first param
> is the
> number to round, the seconds is how many digits past the radix point
> to
> keep.
Caveat:
Note that round will perform math style rounding - sometimes
rounding up, some
"Christopher Spears" <[EMAIL PROTECTED]> wrote
> def calculate_price(price, percent_tax):
>sales_tax = price * percent_tax
>new_price = price + sales_tax
>return new_price
>
> price = float(raw_input("Enter a price: "))
> percent_tax = float(raw_input("Enter a sales tax: "))
> print "
"Stephen Nelson-Smith" <[EMAIL PROTECTED]> wrote
> I do think this is a good question for getting a sense of where a
> person's understanding is. I wonder how much this understanding is
> a
> pre-requistite for being a good developer... not too much I hope!
To use classes/objects yuou don;t ne
(*)BTW Its also possible to do OOP without classes! This is not
often seen nowadays but there were several OOP languages in
the 70's and 80's that explored that route. Scheme is probably
the best known. Its a very different kind of OOP of course but the
basic concepts are all there.
OOP without cl
"Michael Langford" <[EMAIL PROTECTED]> wrote
Good stuff on inheritance and polymorphism snipped...
> Encapsulation: The process of taking what shouldn't matter to
> the external world, and locking it behind an interface.
Actually I'd call that Abstraction.
Encapsulation literally means taking
"Ricardo Aráoz" <[EMAIL PROTECTED]> wrote>
> Encapsulation comes with OO - you get it for free.
>
> Encapsulation does not come with OO. It is something you must code
> in
> your classes.
This depends on your definition of encapsulation.
Many modern texts use a definition of encapsulation that r
"Stephen Nelson-Smith" <[EMAIL PROTECTED]> wrote
> "Place the following three in order: Inheritance, Polymorphism,
> Encapsulation."
Interesting exercise!
> Encapsulation comes with OO - you get it for free.
It comes with OO but not for free. It is a fundamental property of
OOP languages, but
60 matches
Mail list logo