473,385 Members | 1,347 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,385 software developers and data experts.

Quene

I am trying to write a function that holds a variable-length quene. The
quene has 2 bits of information. At some point, I would like to remove
bits of this quene, when they are completed. Is there a way to do this
with something as follows?

quene=[]
quene.append((4,2))
quene.append((3,6))
if(4 in quene): #Shows false, what's the correct syntax to
show true?
remove 4 from quene #(Not python code, not sure how to do this...)
So, how can I make this work? Thanks!

Nov 30 '05 #1
2 1360
On 30 Nov 2005 09:38:44 -0800 in comp.lang.python, "Tuvas"
<tu*****@gmail.com> wrote:
I am trying to write a function that holds a variable-length quene. The
quene has 2 bits of information. At some point, I would like to remove
bits of this quene, when they are completed. Is there a way to do this
with something as follows?

the following might work...
quene=[]
quene.append((4,2))
quene.append((3,6))
if(4 in quene): #Shows false, what's the correct syntax to
show true?
found = [t for t in queue if t[0] == 4]
if found:
remove 4 from quene #(Not python code, not sure how to do this...)

queue.remove(found[0])

HTH,
-=Dave

--
Change is inevitable, progress is not.
Nov 30 '05 #2
Tuvas wrote:
I am trying to write a function that holds a variable-length quene. The
quene has 2 bits of information. At some point, I would like to remove
bits of this quene, when they are completed. Is there a way to do this
with something as follows?

quene=[]
quene.append((4,2))
Here you are not adding two items (a 4 and a 2) but only a single item
(a tuple, containing within it a 4 and a 2). What did you really want
to do?
quene.append((3,6))
if(4 in quene): #Shows false, what's the correct syntax to
show true?
Since you don't have a 4 in your list, there is no correct syntax. If
you did have a 4, that would be the correct syntax, or you could use
queue.index(4) instead if you cared *where* it was in the list.
remove 4 from quene #(Not python code, not sure how to do this...)


queue.pop(0) will pop an item off the front of the list, which is the
end opposite where .append() puts them.

-Peter

Nov 30 '05 #3

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

Similar topics

2
by: Kay | last post by:
This function is used to display the context of a queue. I input an integer comparing with the queue cuisine number, if cuisine number is same as the input, it shows the context. However, it cannot...
3
by: Ron Vecchi | last post by:
Hi all, Can someone point me in the direction on this one, resources or examples. I am writing a Windows Service to monitor a folder. When I file is modified within the folder or any subfolders...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.