Hello everyone,
If you look at the following tutorial, you will find the great advantage of using 'set' as a data structure. http://docs.python.org/tut/node7.htm...00000000000000
But it seems I need to import something before using it, otherwise it'll not be recognised. Could anybody please tell me what I should import?
Thanks in advance!
2 1549
Hello everyone,
If you look at the following tutorial, you will find the great advantage of using 'set' as a data structure. http://docs.python.org/tut/node7.htm...00000000000000
But it seems I need to import something before using it, otherwise it'll not be recognised. Could anybody please tell me what I should import?
Thanks in advance!
If your Python version is less than 2.4: - import Set as set
-
# or (I think)
-
from Future import Set as set
Use the as modifier so that you code works with higher versions.
Otherwise, it's as simple as -
>>> set([1,1,3,4,5,5])
-
set([1, 3, 4, 5])
-
>>>
Note that sets are not mutable (just like tuples). I've been using sets lately for their cool ability to subtract from one another: -
>>> set([1,2,3,4,5,6]) - set([4,5,6])
-
set([1, 2, 3])
-
>>>
If your Python version is less than 2.4: - import Set as set
-
# or (I think)
-
from Future import Set as set
Use the as modifier so that you code works with higher versions.
Otherwise, it's as simple as -
>>> set([1,1,3,4,5,5])
-
set([1, 3, 4, 5])
-
>>>
Note that sets are not mutable (just like tuples). I've been using sets lately for their cool ability to subtract from one another: -
>>> set([1,2,3,4,5,6]) - set([4,5,6])
-
set([1, 2, 3])
-
>>>
cool! thanks a lot. the python version i used was 2.2.... that's why...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: kazack |
last post by:
Hi all it's me again with another question as I got further in my book. The
chapter I am in covers structres, abstract data and classes. I only read
through to the end of the coverage on...
|
by: Pete |
last post by:
Before I get started with the question, does anyone have a (single)
good book recommendation for database design? Not an Access-specific
book, but something geared toward helping me figure out...
|
by: Andrew Arace |
last post by:
I scoured the groups for some hands on code to perform the menial task
of exporting table data from an Access 2000 database to Oracle
database (in this case, it was oracle 8i but i'm assuming this...
|
by: Thomas Paul Diffenbach |
last post by:
Can anyone point me to an open source library of /statically
allocated/ data structures?
I'm writing some code that would benefit from trees, preferably self
balancing, but on an embedded system...
|
by: Hi5 |
last post by:
Hi,
I am new to access I usedto work in Oracle and Mysql.
I am after a way that enables me to populate a database I designed in
access with lots of data which can be sorted in excel sheets,
...
|
by: aurora |
last post by:
This is an entry I just added to ASPN. It is a somewhat novel technique I
have employed quite successfully in my code. I repost it here for more
explosure and discussions.
...
|
by: Sam Kong |
last post by:
Hi,
JavaScript hides its memory structure.
I know that numbers, booleans, null and undefined are value types
(value is directed saved in a variable).
I want to know:
- How JavaScript...
|
by: chrisben |
last post by:
Hi,
Here is the scenario. I have a list of IDs and there are multiple threads
trying to add/remove/read from this list. I can do in C#
1. create Hashtable hList = Hashtable.Synchronized(new...
|
by: william |
last post by:
When implementing Linked list, stack, or trees, we always use pointers
to 'link' the nodes.
And every node is always defined as:
struct node
{
type data; //data this node contains
...
node *...
|
by: Chad |
last post by:
#include <stdio.h>
enum Type {DAYS, HOURSMINUTES};
struct Days {
int num_days;
};
struct HoursMinutes {
int num_hours;
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |