473,289 Members | 2,155 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,289 software developers and data experts.

Conjunction List

http://codepad.org/MV3k10AU

I want to write like next one.

def conjunction(number=a[1],name=b[1],size=c[1]):
flag = a[0]==b[0]==c[0]
if flag:
for e in zip(number,name,size):
print e

conjunction(a,b,c)

-----------------------------------------------------------------------------------------------------
function args receive sequence element:

def somefunc(name=elm1[1], size=elm2[1], color=elm3[1]):
for e in zip(name, size, color):
print e,

conjunction(a,b,c)
-----------------------------------------------------------------------------------------------------

not like two case:
-----------------------------------------------------------------------------------------------------

def somefunc(elm1, elm2, elm3):
name = elm1[1]; size = elm1[1]; color = elm1[1] # best solution?
for e in zip(name, size, color):
print e,

conjunction(a,b,c)
-----------------------------------------------------------------------------------------------------

def somefunc(elm1, elm2, elm3, **attr):
for e in zip(attr['name'], attr['size'], attr['color']):
print e,

conjunction(a,b,c, name=a[1], size=b[1], color=c[1]) # many args...
-----------------------------------------------------------------------------------------------------

What's a good approach to get the conjunction nest-list-data?
Jun 1 '08 #1
1 2937
On May 31, 8:01 pm, ccy56...@gmail.com wrote:
http://codepad.org/MV3k10AU

I want to write like next one.

def conjunction(number=a[1],name=b[1],size=c[1]):
flag = a[0]==b[0]==c[0]
if flag:
for e in zip(number,name,size):
print e

conjunction(a,b,c)

-----------------------------------------------------------------------------------------------------
function args receive sequence element:

def somefunc(name=elm1[1], size=elm2[1], color=elm3[1]):
for e in zip(name, size, color):
print e,

conjunction(a,b,c)
-----------------------------------------------------------------------------------------------------

not like two case:
-----------------------------------------------------------------------------------------------------

def somefunc(elm1, elm2, elm3):
name = elm1[1]; size = elm1[1]; color = elm1[1] # best solution?
for e in zip(name, size, color):
print e,

conjunction(a,b,c)
-----------------------------------------------------------------------------------------------------

def somefunc(elm1, elm2, elm3, **attr):
for e in zip(attr['name'], attr['size'], attr['color']):
print e,

conjunction(a,b,c, name=a[1], size=b[1], color=c[1]) # many args...
-----------------------------------------------------------------------------------------------------

What's a good approach to get the conjunction nest-list-data?
The one you comment with "best solution?" is ok for this example. If
you dislike the repetitive part of setting the flag and getting the
second element of each argument, or especially if you want to
generalize it to more than three arguments, here's one way to do it:

def conjunction(*args):
if not args: return
first = args[0][0]
if all(arg[0]==first for arg in args):
for e in zip(*(arg[1] for arg in args)):
print e
>>conjuction(a,b,c)
('0', 'one', '0%')
('1', 'two', '50%')
('2', 'three', '100%')

HTH,
George
Jun 1 '08 #2

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

Similar topics

6
by: massimo | last post by:
Hey, I wrote this program which should take the numbers entered and sort them out. It doesnąt matter what order, if decreasing or increasing. I guess I'm confused in the sorting part. Anyone...
10
by: Kent | last post by:
Hi! I want to store data (of enemys in a game) as a linked list, each node will look something like the following: struct node { double x,y; // x and y position coordinates struct enemy...
24
by: Robin Cole | last post by:
I'd like a code review if anyone has the time. The code implements a basic skip list library for generic use. I use the following header for debug macros: /* public.h - Public declarations and...
4
by: JS | last post by:
I have a file called test.c. There I create a pointer to a pcb struct: struct pcb {   void *(*start_routine) (void *);   void *arg;   jmp_buf state;   int    stack; }; ...
3
by: chellappa | last post by:
hi this simple sorting , but it not running...please correect error for sorting using pointer or linked list sorting , i did value sorting in linkedlist please correct error #include<stdio.h>...
0
by: drewy2k12 | last post by:
Heres the story, I have to create a doubly linked list for class, and i have no clue on how to do it, i can barely create a single linked list. It has to have both a head and a tail pointer, and...
5
by: dkelly925 | last post by:
Is there a way to add an If Statement to the following code so if data in a field equals "x" it will launch one report and if it equals "y" it would open another report. Anyone know how to modify...
10
by: Rudolf Bargholz | last post by:
Perhaps some kind soul could help me out with an SQL I have been trying all day to get to work, where one colum is just not summing up the way I want it to. I have the following data GRP_SEQ ...
1
by: ccy56781 | last post by:
http://codepad.org/MV3k10AU I want to write like next one. def conjunction(number=a,name=b,size=c): flag = a==b==c if flag: for e in zip(number,name,size): print e
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
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...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
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)...

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.