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. 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
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
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
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.
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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:
|
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...
|
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!...
|
by: manstey |
last post by:
Hi,
I have a text file called a.txt:
# comments
I read it using this:
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |