Debian Programming :: How To Find Total Size Of A List Object In Byte
Jan 11, 2013
Assuming there are two list objects a1, a2.
a1 = ['
']
a2 =['hi
']
len() built-in function gives total number of elements in the list object.
len(a1) gives 1. len(a2) gives 1 also.
Code: Select all$ python
Python 2.7.3 (default, Sep 9 2012, 17:41:34)
[GCC 4.7.1] on linux2
[Code]......
I thought there exists a built-in function that gives total size of a list object in byte. So using the function produces 1 for a1, 3 for a2. I haven't found such function or module yet.
View 3 Replies
ADVERTISEMENT
Jul 6, 2011
I got across a peculiar problem with memcpy.History:writing a code which do flash/Read functionality for SPI Parts.
Implementation:
1.memory map the Flash chip registers to userspace. - fine
2.Issue block read command
3.Just print the data I got, using the memory mapped address - fine I got the correct data.
4.Copy the data to a local buffer from memory mapped address using memcpy - FAIL
UPDATE:
on SUSE 11.3 -32 bit the above code worked perfectly, but on SUSE 11.4 - 64bit , Ubantu, Fedora it failed.
I am using gcc compiler obviously. I am using i386/x86_64 OS. Processor: Intel core 2 duo, SNB after step 4 , when I dump the data from local buffer every thing is FF.But step 4, if i implement byte by byte copy using assignment operator, it worked.is there any known bug with memcpy? am I missing anything?
View 7 Replies
View Related
Mar 1, 2010
Only ones I can think of seem overly complex, and I'm sure there is a simple solution I am overlooking. I have a class, it has a member who is an object. This object needs to be able to represent an object of different types.
[code]...
Where "surface" could be several different types, which will be set during execution. Hope this is clear enough. I have tried using templates but am getting "data member cannot be a member template". Either I have incorrect syntax, or am not implementing it right. another solution would have one class containing definitions of all possible shapes, But this would take up extra memory. Other solutions I thought of seem too round-about, and seems there is a simpler solution that I have overlooked.
View 8 Replies
View Related
Mar 10, 2009
i am trying to find the size of an array, not by using the array as a parameter to "sizeof", but by using a pointer -pointing to the array- as a parameter. How do i do this?I use a 32-bit PC.Here's:
Code:
#include <string>
#include <iostream>
[code]...
View 2 Replies
View Related
May 24, 2010
I'm looking for a standalone backup manager with the following properties:
1) Easy scheduling.
2) Automatic encryption of backups
3) Ability to remove old backups based on total size, not just backup age. (to avoid overfilling backup media)
4) Since this is going onto a business-critical machine used by a techno-peasant, it needs to have a snazzy, graphical interface for easy monitoring and configuration.
I am sure I *could* write this myself, but I find it hard to believe that there isn't one out there already, and I am lazy. Unfortunately, there are also a very large number of backup programs out there with less than complete descriptions and I am getting tired of installing each in turn to see what it does.Has anyone stumbled across something like what I just described?
View 2 Replies
View Related
Jul 22, 2011
how to find total size of all files whose names starting with a
OS: SunOS
du -h a* is giving individual file sizes.
View 6 Replies
View Related
Aug 3, 2010
I'm trying to determine the total disk space used by some files with certain type.I'm trying this with find, but maybe there's another solution?The fact is that I don't know what should I give to the pipe next to find (or whatever command) so that I can determine the total disk space used by that files.
View 2 Replies
View Related
Oct 30, 2010
With file command we can get the file type. File returns a unique answer for each file type. I want to get the total list that file can return for linux & solaris. For example, I have a partial list of file's return output. Unfortunately I can't see the total list from manual page.
ASCII C program text
ASCII C++ program text
ASCII C program text, with CRLF
ASCII C program text, with very
ASCII English text
ASCII English text, with CRLF line
[Code]...
View 1 Replies
View Related
Nov 24, 2010
I'm learning C and trying to write a program to convert gigabyte into byte. It will take 50% of the value given and then convert that value into byte. But the problem is the output goes into minus / negative value. Like, if I enter 22, I get output: -2147483648.
Code:
#include <stdio.h>
#include <math.h>
main (int argc, char* argv[])
{
[Code]....
View 5 Replies
View Related
Jul 10, 2011
As 2.17
I want to code this:
and byte[45],03
In words, AND the byte at memory location 45 with immediate value 03. As reports "Ambiguous operand size for and". How could I code the instruction such that as understands my intention?
john: .byte 45
and byte[john],03
gives the same error.
View 8 Replies
View Related
Jun 11, 2010
E.g. 98 is represented as 1100010 (number of valid bits is 7)
What is the formula to calculate the number of valid bits in a byte ?
View 14 Replies
View Related
Aug 12, 2010
I'm trying to write an extension to PHP which means coding in C. I'm really really rusty at C coding and was never very good at it.
Can anyone propose an efficient, safe, and [hopefully] future-proof way of reversing a double? Keep in mind that it should work on as many systems as possible and on 32- and 64-bit systems (and on ???-bit systems in the future?). Will the size of a 'double' ever change or will it always be 8 bytes?
I've tried this and it doesn't work...the compiler complains about "invalid operands to binary" because I'm trying bitwise shiftw on a non-integer.
Code:
x = (x>>56) |
((x<<40) & 0x00FF000000000000) |
((x<<24) & 0x0000FF0000000000) |
((x<<8) & 0x000000FF00000000) |
[Code]....
View 3 Replies
View Related
Oct 26, 2010
I need to convert an integer to a byte array of size 2 and vice versa. The code shown below works well for positive values but not for negative values. Also, using an array of size four makes the conversion works. However, I am limited to an array of size 2.
View 5 Replies
View Related
Jun 16, 2010
I am trying to learn assembly using nasm as assembler. I did not found example related to string operation. I had following example code,
global asm_strlen
section .data
section .bss
section .text
[code].....
my problem is at highlighted line, I am not getting how to copy a byte into 4 byte reg. rather what is syntax of mov instruction to mov byte to WORD DWORD etc.
View 3 Replies
View Related
Dec 13, 2009
I wrote a serial port communication program to access a equipment.
int main(void)
{
int fd = 0;
int nread = 0,i = 0,nwrite = 0, tmpread = 0, m = 0, n = 0 ;
[code]....
View 2 Replies
View Related
Sep 22, 2010
I wrote a program that multiplies 2 matrices using multi-threads and another one using multiple processes and shared memory. Both in C.I need to find the total memory usage of these programs. I know of the top command, but when my matrices are relatively small they don't even show up on top because they complete so fast, how can I find the memory usage for these instances?Also, how can I find the total turnaround time of my programs?
View 3 Replies
View Related
Sep 12, 2010
Top only show the memory usage for individual processes. Apache often runs hundreds of processes, each of which may use only a small amount of memory, however the total memory consumed by all apache processes can be fairly large.Is there a way to see the total memory usage for all apache processes?
View 7 Replies
View Related
Dec 21, 2010
i'd like to know the total filesize of all files found with the find command, so
Code:
find -iname '*.mpg' | xargs -I {} du -sh {}
but this gives me the filesize of each file, since each line is passed to "du".
how can I pass the whole list through the pipe?
View 6 Replies
View Related
Mar 7, 2010
Groovy is an object-oriented programming language for the Java platform. I do not have experience in Java, only perl and shell scripts. Recently I have been asked to maintain a software written in groovy (also to make enhancements). So can I learn groovy without knowing java language. or isit I have to learn java before venturing into groovy.
View 1 Replies
View Related
Jan 6, 2010
How can I get the total arguments in perl.To be more specific if I try to execute the command
Code:
perl -w myperl.pl ash ok kumar
I should be able to get all the command line arguments.
I know that @ARGV will store only the arguments passed but not the entire arguments.
View 14 Replies
View Related
May 26, 2010
I get the following error after installing a package. I believe this occurred because zypper attempted to update libxml2 to meet package dependencies.
Code:
Is there any way to manually update the package database to solve this problem?
View 3 Replies
View Related
May 24, 2011
When I start evolution from the terminal I get this: (evolution:3265): GLib-GObject-CRITICAL **: Object class EMFolderTree doesn't implement property 'paste-target-list' from interface 'ESelectable' The program still starts though. I am fairly new to Ubuntu.
View 2 Replies
View Related
Nov 22, 2010
I am writing a php script and I need to find the total diskspace of a directory. I have used space already. I have a couple of different users with quotas
Code:
$path = "/home/" . ($_SERVER['PHP_AUTH_USER']);
$used = exec("du -c -a $path");
echo $used;
Will give me the disk space used. But I need total quota for that user.
View 4 Replies
View Related
Jan 25, 2010
I'm having problems adding up column totals using arrays. I've got it to add up the row totals and display at the end of the row. Here is my code so far
Code:
#include <stdio.h>
#include <string.h>
const int maxrows=10;
[code]...
What i need it to do is, add up the columns and display it at the bottom of each column similar to how the row totals display
View 2 Replies
View Related
Aug 25, 2010
Is there an easy way in C to get the total amount of allocated SHM memory on a machine?
View 7 Replies
View Related
Oct 14, 2013
I'm trying to search for several strings, which I have in a .txt file line by line, on another file.
So the idea is, take input.txt and search for each line in that file in another file, let's call it rules.txt.
So far, I've been able to do this, to search for individual strings:
Code: Select allimport re
shakes = open("output.csv", "r")
for line in shakes:
if re.match("STRING", line):
print line,
How can I change this to input the strings to be searched from another file?
So far I haven't been able to.
View 3 Replies
View Related
Jan 29, 2014
I going through the Python course on Codeacademy. I have some trouble understanding what I'm doing wrong. This is my code below:
Code: Select alldef count(sequence, item):
total = 0
for x in sequence:
return x
if x in sequence:
total += 1
return total
print count([1,2,1,1], 1 )
The code gives me an error: "Oops, try again. Your function fails on count([1],7). It returns 1 when it should return 0."
It should be outputting 3 because 1 occurs 3 times in the list.
View 7 Replies
View Related
Jun 5, 2010
I have a Canoscan LiDE 30 scanner which works fine in Linux. I haven't used it in months, and never since moving from Jaunty x86_64 to Fedora 11 x86_64. This evening I suddenly need to scan two pages to send to someone via e-mail, and the recipient is desperate to receive them. Naturally, Xsane has decided this is the moment to screw me.
The problem: I cannot figure out how to tell Xsane that the page size is 8.5 11. It insists on scanning only the left side, 3.99 x 11. I cannot find a page size anywhere in any of the buttons.
In Preview I once got it to scan the entire page, but could not figure out how to save the image to file. Subsequently I have not been able to figure out how I did it. In any event, scanning from the small main window always scans 3.99 x 11. Adjusting the scan area manually in the Preview window allows me to change the size area in the small main window to 8.5 x 11, but when I then scan from the small main window it reverts to 3.99 x 11.
I have scanned the document a hundred times at least, each time trying different buttons, but nothing has succeeded in getting the full page.
View 5 Replies
View Related
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
Apr 4, 2011
I am trying to write a script to calculate the total amount of installed memory to use during an anaconda kickscript, so the swap file is created at 2 x the installed memory. I so far have the amount of installed RAM DIMMS but need a way to total them up and produce a varible I can use in the pre section of the install.
Code:
dmidecode -t 17 | grep Size | awk ' { print $2 }'
Output:
2048
2048
Note: on some servers there could be from 1 DIMM up to 16 DIMMS installed so the script needs to be able to handle this. I also can not use bc as it does not exist during the install stage. I am guessing I need a while loop to do this and use expr but do not know where to start for this logic.
View 3 Replies
View Related