John wrote:
I know a code example might help, so I try to show it here (my code
I'm afraid is too complex and ugly at the moment). You can see the it
fails because MyTools doesn't have 'this' attribute...
Then give it one.
class MyTools:
Add an initialisation method:
def __init__(self
Prasad, Ramit wrote:
I don't know what they are from but they are both the same value,
one in hex and one in octal.
0xC9 == 0311
As for the encoding mechanisms I'm afraid I can't help there!
Nice catch! Yeah, I am stuck on the encoding mechanism as well. I
know how to encode/decode...but not
On 25 August 2011 23:54, Bspymaster wrote:
> How do I make it so that when you open the program, it starts the code (so
> anyone can use it, not just those who have idle and know ow to program
> python)?
>
To add to what Ramit's said: On Linux/Ubuntu it's customary to add as the
top line of a s
>I don't know what they are from but they are both the same value, one in
>hex and one in octal.
>
>0xC9 == 0311
>
>As for the encoding mechanisms I'm afraid I can't help there!
Nice catch! Yeah, I am stuck on the encoding mechanism as well. I know how to
encode/decode...but not what encoding to
From: tutor-bounces+ramit.prasad=jpmorgan@python.org
[mailto:tutor-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of
Bspymaster
Sent: Thursday, August 25, 2011 5:54 PM
To: tutor@python.org
Subject: [Tutor] finalizing code
Hello! I recently started programming in python (I use IDLE w
Hello! I recently started programming in python (I use IDLE with python 2.7
on ubuntu 11.04, by the way) and recently made a program (no interface) that
launches other programs. The problem I'm having is that when I gave my
friend the code, he had to get an editor to use the code. How do I make it
Hello! I recently started programming in python (I use IDLE with python 2.7
on ubuntu 11.04, by the way) and recently made a program (no interface) that
launches other programs. The problem I'm having is that when I gave my
friend the code, he had to get an editor to use the code. How do I make it
Robert,
The lists were created using MS Notepad, and I forgot about the newlines -
so you were absolutely right! So, is it possible to use strip() immediately
when reading a file into a list to avoid confusion down the road, and is
this common?
Thank you everyone who contributed to this thread :
> shantanoo, Andre, and Robert:
>
> All of your solutions seem to work (and thank you for the tips!), however,
> with each solution there seems to be 2 MACs that should not be in the
> results.
>
> 00:1C:14:BA:D9:E9 and
> 00:16:3E:EB:04:D9
>
> should not be be turning up in the results because they
shantanoo, Andre, and Robert:
All of your solutions seem to work (and thank you for the tips!), however,
with each solution there seems to be 2 MACs that should not be in the
results.
00:1C:14:BA:D9:E9 and
00:16:3E:EB:04:D9
should not be be turning up in the results because they are in the
'veri
> Scenario: I have a list of MAC addresses that are known and good, and am
> comparing it to a list of MACs found in a scan. I want to weed out the
> those which are unknown. I am using IDLE (Python 2.7) on Windows, and all
> files are in the same directory.
>
> Code:
>
> scanResults = open('scan
On Thu, Aug 25, 2011 at 9:08 PM, Justin Wendl wrote:
> Hi John,
>
> Thanks for the quick response. Unfortunately it is returning the same
> result..
>
>
This is caused by the
else:
break
part of the the code. Break breaks out of the loop, thus you skip all
following elements if you go throu
Giovanni,
scanResults.txt:
00:16:3E:D0:26:25
00:16:3E:43:7D:24
00:16:3E:2D:6D:F8
00:16:3E:EB:04:D9
00:16:3E:FD:85:0B
00:1C:14:AF:04:39
00:1C:14:E3:D6:CA
00:1C:14:15:B2:C8
00:1C:14:47:5A:A0
00:1C:14:BA:D9:E9
verifiedList:
00:1C:14:BA:D9:E9
00:16:3E:D0:26:25
00:1C:14:AF:04:39
00:16:3E:EB:04:D9
- J
On Thu, Aug 25, 2011 at 4:08 PM, Justin Wendl wrote:
> Hi John,
>
> Thanks for the quick response. Unfortunately it is returning the same
> result..
Please send a small example of the contents in each file.
--
Giovanni Tirloni
sysdroid.com
___
Tutor
You may try using set instead of list.
>>> verifiedList = {[1,2,3}
>>> scanResults = {1,2,3,4,5}
>>> badMacs = scanResults - verifiedList
>>> badMacs
set([4, 5])
>>> verifiedList = {1,2,3,7,8,9}
>>> badMacs = scanResults - verifiedList
>>> badMacs
set([4, 5])
--
shantanoo
On 26-Aug-2011, at 12:2
On Thu, Aug 25, 2011 at 1:51 PM, John wrote:
> Hello, I am writing a module that will have two classes ('runners') I
> am calling them, as they will ultimately use subprocess to run a
> command line program, so they are basically option parsers, etc...
>
> As I wrote the second 'runner', I realiz
Ha! Inheritance!
On Thu, Aug 25, 2011 at 7:51 PM, John wrote:
> Hello, I am writing a module that will have two classes ('runners') I
> am calling them, as they will ultimately use subprocess to run a
> command line program, so they are basically option parsers, etc...
>
> As I wrote the second '
Hi John,
Thanks for the quick response. Unfortunately it is returning the same
result..
- Justin
On Thu, Aug 25, 2011 at 2:59 PM, John wrote:
> Not entirely sure, but I think it is as simple as:
>
> scanResults = open('scanResults.txt', 'r').readlines()
> verifiedList = open('verifiedList.tx
Not entirely sure, but I think it is as simple as:
scanResults = open('scanResults.txt', 'r').readlines()
verifiedList = open('verifiedList.txt', 'r').readlines()
Now both are lists. I assume each mac address is on it's own line?
-john
On Thu, Aug 25, 2011 at 8:56 PM, Justin Wendl wrote:
> He
Hello,
Bare with me, as I am new to Python and a beginner programmer.
I am trying to compare two lists (not of the same length), and create a new
list of items that are -not- found in both lists.
Scenario: I have a list of MAC addresses that are known and good, and am
comparing it to a list of MA
Hello, I am writing a module that will have two classes ('runners') I
am calling them, as they will ultimately use subprocess to run a
command line program, so they are basically option parsers, etc...
As I wrote the second 'runner', I realized many of the methods are
going to be the same as the f
On Thursday 25 August 2011 15:17:04 Alan Gauld wrote:
> On 25/08/11 10:46, Lisi wrote:
> > I copied and ran the following script:
> >
> > multiplier = 12
> >
> > for j in range(1,13):
> > print "%d x %d = %d" %(j, multiplier, j*multiplier)
> >
> > That ran perfectly and gave me the 12 times ta
On Thu, Aug 25, 2011 at 6:49 PM, surya k wrote:
> Hi,
> I'm doing a puzzle where it asked me to find the largest palindrome number
> formed by the product of two three-digit numbers. They mentioned an example
> saying that 9009 is the largest palindrome number formed by two two-digit
> numbers (99
On 25/08/11 15:36, Prasad, Ramit wrote:
I have a string question for Python2. Basically I have two strings with
> non-ASCII characters and I would like to have a better understanding
> of what the escapes are from
' M\xc9XICO' and ' M\311XICO'
I don't know what they are from but they are bot
Hi,
I'm doing a puzzle where it asked me to find the largest palindrome number
formed by the product of two three-digit numbers. They mentioned an example
saying that 9009 is the largest palindrome number formed by two two-digit
numbers (99 * 91).
I've written my code this way.. and I tested it w
It wasn't on the repo.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Looks good, although I would add one or two things.
> #assuming target number 15
>
Put that in a variable for the target number
> roll = (result, initial_mins, initial_max)
> if roll[0] > 15:
>if roll[1] >= 2:
You could even put all the constants in variables
>
print("Success")
>
I have a string question for Python2. Basically I have two strings with
non-ASCII characters and I would like to have a better understanding of what
the escapes are from and how to possibly remove/convert/encode the string to
something else. If the description of my intended action is vague it i
On 25/08/11 10:46, Lisi wrote:
I copied and ran the following script:
multiplier = 12
for j in range(1,13):
print "%d x %d = %d" %(j, multiplier, j*multiplier)
That ran perfectly and gave me the 12 times table.
I then decided that it would be fun to branch out and make teh
script "univer
Steven D'Aprano wrote:
if some_condition:
flag = True
else:
flag = False
is better written as:
flag = some_condition
Actually, that's a slight over-simplification.
some_condition may not actually be a bool. If you don't mind flag also
being a non-bool, that's fine, but if you want
Lisi wrote:
I copied and ran the following script:
[...]
What extra should I have done because the variable value came from the
keyboard, and why is it different from the first example?
You can investigate this yourself:
>>> a = 12
>>> a = raw_input("please type 12")
please type 12 12
>>> a
John wrote:
Thanks for the feedback. I wasn't aware about the assert usage not
being intended for production code.
That's not quite true. There is nothing wrong with using asserts in
production code. The important thing is to use them *properly*. Asserts
are for checking your internal program
Christian Witts wrote:
if child.exitstatus and child.exitstatus == 0:
success = True
else:
success = False
There is never any need to write Python code that looks like that. (Or
in any other language I'm familiar with either.) Anything of the form:
if some_conditio
On 08/25/2011 05:46 AM, Lisi wrote:
I copied and ran the following script:
multiplier = 12
for j in range(1,13):
print "%d x %d = %d" %(j, multiplier, j*multiplier)
That ran perfectly and gave me the 12 times table.
I then decided that it would be fun to branch out and make teh
script "u
I copied and ran the following script:
multiplier = 12
for j in range(1,13):
print "%d x %d = %d" %(j, multiplier, j*multiplier)
That ran perfectly and gave me the 12 times table.
I then decided that it would be fun to branch out and make teh
script "universal", so I wrote and ran:
print
On 25-Aug-11 01:37, Christian Witts wrote:
Good catch, it should be `if child.exitstatus != None and
child.exitstatus == 0:`
It's better form to say
if child.exitstatus is not None
instead of comparing for equality to None with the != operator.
--
Steve Willoughby / st...@alchemy.com
>> #assuming target number 15
>> roll = (result, initial_mins, initial_max)
> I'd forget the tuple and just use the names,
> it is more readable that way...
>if result > 15:
>if initial_mins >= 2:...
>elif initial_max >=2:...
> But otherwise it seems to reflect the rules as you've writte
On 25/08/11 09:27, John wrote:
Just a quick question,
is it wrong to use the *args and **kwargs ( the latter in particular)
when DEFINING a function?
No, in fact it's essential if you don't know in advance what arguments
are going to be passed to the function. This is very common if you are
On 25/08/11 08:51, Robert Sjoblom wrote:
If I roll two sixes (on the initial roll) and below the target number
(in total), it's a failure.
If I roll two sixes (on the initial roll) and above the target number
(in total), it's a critical failure.
If I roll two ones (on the initial roll) and abov
Thanks for the feedback. I wasn't aware about the assert usage not
being intended for production code.
On Wed, Aug 24, 2011 at 11:37 PM, Alan Gauld wrote:
> On 24/08/11 21:03, Prasad, Ramit wrote:
>>
>> I was under the impression that asserts are more for testing
>
>> than for production code
>
>
On 2011/08/25 10:19 AM, Alan Gauld wrote:
On 25/08/11 07:25, Christian Witts wrote:
Once you call child.close() the exit and signal status will be stored in
.exitstatus and .signalstatus, for a normal exit of the program
.exitstatus will store the return code from SCP as per [1] [2] [3] and
.si
Just a quick question,
is it wrong to use the *args and **kwargs ( the latter in particular)
when DEFINING a function?
def fest(**kwargs):
""" a function test """
keys = sorted(kwargs.keys())
print("You provided {0} keywords::\n".format(len(keys)))
for kw in keys:
print("
On 25/08/11 07:25, Christian Witts wrote:
Once you call child.close() the exit and signal status will be stored in
.exitstatus and .signalstatus, for a normal exit of the program
.exitstatus will store the return code from SCP as per [1] [2] [3] and
.signalstatus will be None. If SCP was termin
I've written a function that rolls (standard) dice. There are a few
special cases though:
Any sixes rolled are removed and 2*number of sixes new dice are rolled
in their place.
Initial roll is important to keep track of.
I've solved it with the following function:
from random import randint
def
44 matches
Mail list logo