473,388 Members | 1,526 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,388 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 2940
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
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.