Programming :: Popping Off More Than One Item At A Time In A List?

Jul 14, 2010

I was reading some code the other day and thought that I saw they were using the list.pop method to pop of more than one item at a time. Something like this.

Code:

l = [ 'a', 'b', 'c', 'd', 'e' ]
l.pop(0:3)
['a','b','c']
l
['d','e']

But of course when I looked at invoking the method, it only works for one item at a time. I'm working on a data structure where I'm parcing weather data that is 15 items long that are return in as data in a list that has 3,000 + items. I was wanting to pop off a lists of the 1st 15 items breaking them into chuncks (still trying to figure out how I'm going to store the associations as each day has 2-4 readings an hour for the past 72 hours, so I was wanting to group the days together but have each data point for each time).

I know I can just write a function (with some additional tweaking needed for neg starts to work on the right end):

Code:

def longpop (seq, length=1, start=0):
slice = seq[start:start+length]
del seq[start:start+length]
return slice

But with increasing data sizes, I was wondering if there was a faster built-in way of doing this (perhaps implemented under the hood written originally in C as an extention, for example).

View 6 Replies


ADVERTISEMENT

Programming :: Append Item To A List ( C Macro )?

Apr 13, 2010

I have my own declared types and I have to operate with lists of items. I wish to write a one macro, instead of using a function for each type. It's intended to be like this: Code: #define ____append_to_list(head,

item, type)
type* ptr;
for ( ptr = head; ptr->next != NULL; ptr = ptr->next )

[code].....

View 9 Replies View Related

OpenSUSE :: Recently Installed Items Are Not Showing At Add To Panel Item List

Nov 27, 2010

Recently I have installed DockbarX and Cardapio. After installation they are supposed to be found in the Add to Panel items, but both of them are not there.I can run them directly without any problem. Is there anything else I should do manually? I have tried pkill gnome-panel to restart the panel as well.

View 9 Replies View Related

General :: Fortran Runtime Error: Bad Real Number In Item 1 Of List Input

Feb 9, 2011

I am using the package Quantum espresso to get electron phonon coefficients for monolayer graphene. While applying one of the executables, I got the error: "At line 356 of file q2r.f90 (Unit 51 "a2Fq2r.51") Traceback not availabel: compile with -ftrace=frame or -ftrace=full. Fortran Runtime error: bad real number in item 1 of list input

View 3 Replies View Related

Programming :: Bash Array - More Than One Value Per Item?

Nov 28, 2010

Is it possible to have an array in Bash that can hold more than one value per item?

For example I would like an array like this:

Entry 1: apple, green
Entry 2: banana, yellow

And be able to call the fruit names and their colour in a list. Something like:

for fruit in "${array[@]}"
do
echo a $fruit is $colour
done

If that is possible, is there a limit to values per item? For example some entries in an array could be:

Entry 1: apple, green, round, pips, tree
Entry 2: banana, yellow, long, skin, tree

And I would like to pick out the values such as #3 being "round" and "long".

View 3 Replies View Related

Programming :: Adding An Item To A Java Swing Jlist?

May 4, 2011

I need to make a quick gui to interface with another application. I'm using Java swing to produce it, however have no experience with JAVA. I have used net bean to produce the gui. At one part I have a jList private javax.swing.JList jSymbolList1;

I want on a button press to add or change members of the list from a text field. I thought I could so this simply by using the addelement eg jSymbolList1.addElement("hello world"); However this produces an error. Can anyone tell me how to add a string or how to change a string at a set position?

View 4 Replies View Related

Programming :: List 4 Names From Users List And Output Them To Fbusers In Numbered Ascending Order?

Feb 2, 2010

How would I list 4 users ID numbered 10, 11, 12 and 13 from my users list and output them to a file busers where their names are numbered by ascending order? How would I accomplish that on a one line command?

View 4 Replies View Related

Programming :: Downloading A List Of Files From A Remote Server Using A List?

Feb 10, 2009

I am trying to get this script to work. The purpose is to download a list of modules from the slax.org the list consist of a list of module numbers. What I am trying to do is Download the file or the file name corresponding to the number in the list.the list is comma delimited. this is what I have done so far and I am a stand still.

#!/bin/sh
# Wget script to retrieve modules from slax.org modules
#
# ----Begin of user defined values -----
# Path to wget

[code].....

View 7 Replies View Related

Programming :: Function Handler Is Called One Time Only Instead 2 Times If The 2 Timers Expires At A Time

Mar 2, 2011

I am using Debian linux. I have 100 timers running. If a timer expired which will generate a signal and it was mapped to a same function handler. All the timers are mapped to one function handler. The problem is if the timer expires one at a time, the function handler called at a time. But if the 2 timers expires at a time, the function handler is called one time only instead 2 times. Is it possible to invoke the function handler as many times based on timer expirary happens simultaneoulsy?

View 14 Replies View Related

Programming :: Get The Current Time As Provided From NTP (not The Currently Set Time On The Server)?

Jun 9, 2010

Is there a way to get the current time as provided from NTP (not the currently set time on the server)?

View 4 Replies View Related

Programming :: Set Time Using Settimeofday But It Sets Local Time?

Jan 12, 2010

I am trying to set time using settimeofday in linux. But it sets local time. i.e works like SetLocalTime in windows. But I want to set system time(like SetSystemTime in windows). I could'nt find no other api in linux. What should i do? I had tried with mktime/gmtime apis

View 3 Replies View Related

General :: List All Jobs And Their Pids From A Certain Time Frame?

May 10, 2011

Is it possible to list all jobs and their pids from a certain time frame? For instance if I needed to see all completed jobs from yesterday how would I do this? I've tried jobs -n but that was messed up because I had typed jobs right before that.

View 1 Replies View Related

General :: Command - List Only Access Time And File Name?

Mar 19, 2010

How do I list only access time and file name? For example if I do ls -l --sort=time then

[Code]...

View 5 Replies View Related

General :: Descending List Ordered By File Modification Time

Feb 28, 2011

How can I generate a list of files in a directory [e.g.: "/mnt/hdd/PUB/"] ordered by the files modification time? [in descending order, the oldest modified file is at the lists end]
ls -A -lRt would be great:[URL]
But if a file is changed in a directory it lists the full directory...so the pastebined link isn't good [i don't want a list ordered by "directories", I need a "per file" ordered list]
OS: openwrt..[no perl -> not enough space for it :( + no "stat", or "file" command]

View 3 Replies View Related

Programming :: Active Forum / Mailing List For C Programming?

Apr 19, 2010

Just i want to ask doubts in c programming. I dont know whether this is the right place to ask doubts in c. If this is not a correct place, may i know where can i get help for c programming?is there any active forum or mailing list for c programming?

View 6 Replies View Related

Fedora :: Sound Crackling & Popping With F12

Feb 13, 2010

I have a Creative Labs SB X-Fi sound card and I am getting a lot of crackling & popping with it. Plus I have to kill and restart pulseaudio a lot. Does anyone know of anything that can be done to help this out? I have the latest F12 kernel and rpms installed.

View 2 Replies View Related

Ubuntu :: Get Rid Of The Keying Nonsense That Keeps Popping Up?

Jan 1, 2010

I'm starting to use SuperUbuntu, and am trying to set up Evolution email prog. This is on a USB stick. Anyone know how to get rid of the keyring nonsense that keeps popping up? Google searches reveal that others are highly annoyed too, but can't cure it easily. Is it easy to put Thunderbird on and remove Evolution? And before anyone starts to preach security to me - I don't want to hear it. No offence meant. All I'm looking for is a correction.

View 3 Replies View Related

Ubuntu :: Get Rid Of Nepomuk - Keeps Popping Up On Startup?

May 30, 2010

I don't know what program Nepomuk came with. I thought I got rid of it but this keeps popping up on startup [picture attached].

View 4 Replies View Related

Ubuntu :: Applications Popping Up Automatically?

Oct 5, 2010

i m using ubuntu 10.04 Lucidi m reposting this thread.few days back when i setup evolution client i m facing this problem since then.when i open my system i always find three applications opening automatically.1. Evolution2. A open office Word Processor (untitled3. Documents folder window.

View 2 Replies View Related

Ubuntu :: Launcher Bar Gets Stuck After Popping Out?

Jun 18, 2011

This is an annoying problem I've been having with Unity. I'll be moving the mouse around and sometimes hit the right or left mouse clicker and the launcher bar pops out and stays stuck out. I can't get it to auto hide unless the browser is closed. Then I have to reopen the browser and start all over again. What makes this very annoying is there may be several tabs open in the browser that have to be all reloaded again.How do you get the launcher bar to auto hide again after it is stuck popped out?

View 9 Replies View Related

Ubuntu :: How To Fix Popping Sound In 11.04 Natty

Jun 22, 2011

Since I installed Natty recently, I had this "popping" sound from the speakers when the laptop was running on battery. Turns out this popping has to do with a power-saving feature for "hda-intel" sound-chips.

Open terminal and do:
Code:
gksudo gedit /usr/lib/pm-utils/power.d/intel-audio-powersave
Find this line:
INTEL_AUDIO_POWERSAVE=${INTEL_AUDIO_POWERSAVE:-true}

And comment it out by putting a "#" in front of it like this:
# INTEL_AUDIO_POWERSAVE=${INTEL_AUDIO_POWERSAVE:-true}

Just below this line you make a new line, like this:
INTEL_AUDIO_POWERSAVE=false

So now you will have:
# INTEL_AUDIO_POWERSAVE=${INTEL_AUDIO_POWERSAVE:-true}
INTEL_AUDIO_POWERSAVE=false
Save the file (File > Save) and exit.
Reboot the computer.
The popping sound will be gone.

If you for some reason need to undo the setting, just open the file again and remove the "#" from:
INTEL_AUDIO_POWERSAVE=${INTEL_AUDIO_POWERSAVE:-true}

And delete this line:
INTEL_AUDIO_POWERSAVE=false
Save the file.
Reboot.

View 4 Replies View Related

Ubuntu :: Screen Popping Up Whenever Start?

Jul 14, 2011

I just got Ubuntu a few days ago and recently updated it. I now have a screen popping up whenever I start Ubuntu that says I have less than a gig of space left on my hard drive. I dont want windows xp on my computer anymore but have no idea how to get rid of it.

View 3 Replies View Related

CentOS 5 :: Firefox Popping Window Instead Of Tab / Fix It?

Apr 23, 2009

I loaded CentOS from a USB net install as I am trying to get an eeeBox to run CentOS 5.3 as a low power usage firewall. As you might know this box doesn't have an optical drive so everything has to be loaded from something USB. After the net install I ran a yum update and then went to some websites that I use and Firefox would pop a small window which looked like a vertical blue bar with a white dot at the bottom. I could grab it with the mouse and expand it and it would open as a normal window but inside there would be nothing. Usually in other CentOS installations Firefox would put the new window in another tab. When I go to the Edit/Preferences area and click on the tab icon nothing appears on the page...only the mail and security icons work. I unloaded Firefox using yum remove and reloaded it using yum install and now when I start Firefox it pops three windows and every site I go to pops another window with nothing in it. Am I losing my mind, or is there something wrong with my hardware, or is this a bug?

View 3 Replies View Related

OpenSUSE :: Media Folder Popping Up In Nautilus?

Jul 15, 2010

I close Nautilus and it pops open again and always to the folder "media". The only thing I had in the media was a CDROM, which I unmounted and that made no difference. I then removed the CD from the CDROM drive and that made no difference. Any ideas why opensuse 11.2 would insist on keeping a Nautilus window open all the time -- defaulting the "/media" folder on initial opening?

View 5 Replies View Related

General :: Nautilus Popping Up After Inserting USB Stick In KDE?

Aug 28, 2011

I am using Debian testing with KDE 4.6.5. However, when I insert my ubs stick, on top of the expected kde response I get a Nautilus window popping up (which is the Gnome file manager). How can I disable this?

View 1 Replies View Related

Ubuntu :: Stop Folder Popping Up When Connecting HDD?

Jan 25, 2010

I have an external hard drive that i keep my media on for use with XBMC. The problem is that when media centre is on and i attach the hard drive, Ubuntu's file browser pops up with the contents of my drive and this is over XBMC. When using a remote i am left stuck as i can't alt+tab out of the file browser. How do i disable this?

View 6 Replies View Related

Ubuntu :: Broadcast Accounts Popping Up (Lucid)?

Apr 23, 2010

I installed the Lucid Release Candidate today, and for some reason Broadcast Accounts keeps opening itself, even after I've added all the accounts I'm going to. Is this happening with anyone else, and how can I make it stop?

View 9 Replies View Related

Ubuntu Multimedia :: Popping And Distorted Sound On 10.04?

Jul 6, 2010

I did a clean install to 10.04. Not too many issues except any sound I play sounds like it's underwater and pops while playing. I have tried to do the Pulse Audio install, but every time I loaded pauvcontrol (I think was the title), it would pop up "Connection Failure: Connection Refused." I tried to follow other guides, but they'd all fail because I'd be missing half of the files it changed. I have a Creative Labs X-Fi Fatality card that has given me troubles in the past, but usually, it works. I tried to install Creative's open driver, but again, I had an error when I attempted to Make the directory.

View 6 Replies View Related

Ubuntu :: Appearance Window Popping Up On Start Up?

Nov 3, 2010

every time i start up my laptop, "appearance preferances" window pops up with no reason whatsoever..

View 2 Replies View Related

Ubuntu Multimedia :: Banshee Won't Close - Keeps Popping Back?

Aug 11, 2010

I seem to be having a problem with Banshee. When I boot up, it automatically starts up, which seems innocent enough. However, I opened up Exaile (because Banshee had this problem of not recognizing spaces in some of my songs' filenames, replacing them with '%20'), and closed Banshee from its notifications icon. It closed, but about 3-5 seconds later its window pops up again. I used Ctrl+Q to quit, but it still came back after a few seconds. I've tried opening up a terminal and typing "killall banshee-1", but still, Banshee keeps coming back. Even though I restart and not open Exaile, Banshee still keeps coming back when I try to kill it.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved