473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Going crazy...

Hello all,

I'm 100% sure that I saw an example which looked something like this
recently:
a=(1, 2, 3, 4, 5, 6)
b=(2, 3, 6)
a - b

(1, 4, 5)

The only new language I have been involved in lately is Python. Is my
memory failing me, or have I seen such an Python-example somewhere? If
so: Where; or more importantly: How does it work?

I just tried typing the above in Python, and it - obviously - doesn't
work, so it must be some other syntax.
Jul 19 '05 #1
5 1048
Jan Danielsson wrote:
Hello all,

I'm 100% sure that I saw an example which looked something like this
recently:
a=(1, 2, 3, 4, 5, 6)
b=(2, 3, 6)
a - b

(1, 4, 5)

The only new language I have been involved in lately is Python. Is my
memory failing me, or have I seen such an Python-example somewhere? If
so: Where; or more importantly: How does it work?

I just tried typing the above in Python, and it - obviously - doesn't
work, so it must be some other syntax.

Not with tuples, lists or dictionaries. However a more recent addition
to the language is Sets, and they support set differences:
from sets import Set
Set([1,2,3,4,5,6]) - Set([2,3,6])

Set([1, 4, 5])
Gary Herron

Jul 19 '05 #2
Jan Danielsson wrote:
Hello all,

I'm 100% sure that I saw an example which looked something like this
recently:

a=(1, 2, 3, 4, 5, 6)
b=(2, 3, 6)
a - b
(1, 4, 5)

The only new language I have been involved in lately is Python. Is my
memory failing me, or have I seen such an Python-example somewhere? If
so: Where; or more importantly: How does it work?

I just tried typing the above in Python, and it - obviously - doesn't
work, so it must be some other syntax.


Try sets:
a=set([1,2,3,4,5,6])
b=set([2,3,6])
a-b set([1, 4, 5])


--Irmen
Jul 19 '05 #3
On Mon, 13 Jun 2005 20:52:43 -0400, Gary Herron wrote
(in article <42**************@islandtraining.com>):
Jan Danielsson wrote:
Hello all,

I'm 100% sure that I saw an example which looked something like this
recently:
> a=(1, 2, 3, 4, 5, 6)
> b=(2, 3, 6)
> a - b
>
>

(1, 4, 5)

The only new language I have been involved in lately is Python. Is my
memory failing me, or have I seen such an Python-example somewhere? If
so: Where; or more importantly: How does it work?

I just tried typing the above in Python, and it - obviously - doesn't
work, so it must be some other syntax.

Not with tuples, lists or dictionaries. However a more recent addition
to the language is Sets, and they support set differences:
>>> from sets import Set
>>> Set([1,2,3,4,5,6]) - Set([2,3,6])

Set([1, 4, 5])
Gary Herron


Looks like something that might be part of an example of class operator
overloading??? But I'm not far enough along to quickly show a sample if such
is possible.

Lee C
Jul 19 '05 #4
Gary Herron wrote:
[---]
I just tried typing the above in Python, and it - obviously - doesn't
work, so it must be some other syntax.

Not with tuples, lists or dictionaries. However a more recent addition
to the language is Sets, and they support set differences:
from sets import Set
Set([1,2,3,4,5,6]) - Set([2,3,6])

Set([1, 4, 5])


That's it! Thanks; I knew I had seen it. That's a pretty cool
feature; which I have use for in a library I'm writing.
Jul 19 '05 #5
Jan Danielsson wrote:
Gary Herron wrote:
... a more recent addition to the language is Sets, ...
>from sets import Set
>Set([1,2,3,4,5,6]) - Set([2,3,6])


Set([1, 4, 5])


If you are using 2.4 or later, you can simply use "set" without
importing anything.

set(['apple', 'orange', 5]) - set([5])

--Scott David Daniels
Sc***********@Acm.Org
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Richard | last post by:
I need help. I have a smarty based program that I am modifying. I have a smarty template file that consists of smarty and HTML. I need to integrate some PHP database calls into it. My problem...
6
by: Fresh Air Rider | last post by:
Hi I understand that ASP.net 2.0 (Whidbey) is going to reduce coding by 70%. Surely this is going to de-skill or dumb down the developers task and open up the task to less qualified and...
5
by: spoilsport | last post by:
Ive got to write a multi-function program and I'm plugging in the functions but I keep getting this error from line 40. Im new to this and cant find an answer anywhere. Sam #include...
3
by: Larry Tate | last post by:
I have had a monstrous time getting any good debugging info out of the .net platform. Using ... ..NET Framework 1.1 Windows 2K Server VB.NET <- is this the problem? error handling in the...
7
by: Miguel Dias Moura | last post by:
Hello, In an ASP.Net / VB web page I want to display an image which filename depends of a parameter on the URL. I have this:
1
by: Zack | last post by:
I am writing an app using FileSystemWatcher and just went a little class crazy. I have the following classes Server MasterServer inherits server SlaveServer inherits server SiblingServer...
6
by: thomas.luce | last post by:
Okay, I have been programming for a long time, and am getting back into C after about a 4 year break from it. Below is some code that won't compile for the life of me, and it is driving me crazy!...
15
by: manstey | last post by:
Hi, I have a text file called a.txt: # comments I read it using this:
3
by: squash | last post by:
I have spent two hours trying to make sense of this script, called crazy.php. The output should be nothing because $cookie_password is nowhere defined in this script, correct? But it actually...
3
by: Johnny Jörgensen | last post by:
I've got a serious problem. I've got Visual Studio 2005 installed, and of course I'm using the Pretty Listing formatting function. When I start up VS, everything is fine, but after a while (which...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.