761 Posted Topics

Member Avatar for sss33

For example, given a file full of numbers "file.num"[CODE]values = [] with open("file.num") as f: for line in f: for value in line.split(): values.append(int(value)) print(values)[/CODE]Of course this is not production quality since it doesn't handle files that have badly formatted integers. For that, you probably want a try block around …

Member Avatar for griswolf
0
102
Member Avatar for Shaswat

Guiding you step by step on your project is not the function of DaniWeb. However here is a very broad step by step process that you can use for any project: [LIST=1] [*]Decide what it is that you are doing. (chat page for logged in users) [*]Refine your decision into …

Member Avatar for justiceigwe
-1
144
Member Avatar for pruthvikumar

First, you should show us some idea of what you think would work for your database schema, and only then will we be able to give some help. Second, this is not really the right forum for talking about a web crawler. Once you have the crawler working well enough …

Member Avatar for pruthvikumar
0
122
Member Avatar for kerimabdullah

I think that you want to loop through all the items in mylist, discarding any of them that are all spaces and keeping any that have length. You do not need to do it in place as your code tries to do but you do need to understand a little …

Member Avatar for TrustyTony
0
126
Member Avatar for Enders_Game

You want to look at the [URL="http://docs.python.org/library/struct.html"]struct[/URL] module which allows you to parse arbitrary sequence of binary types. You need to be aware of big-endian versus little-endian binary layout in the file.

Member Avatar for griswolf
0
358
Member Avatar for AnnetteM

You can do this with the [URL="http://docs.python.org/library/struct.html"]struct[/URL] package. For instance, you can read four of your short integers with this snippet (derived from code I saw here: [url]http://pyfaq.infogami.com/how-do-i-read-or-write-binary-data):[/url][CODE]import struct f = open(filename, "rb") s = f.read(8) w, x, y, z = struct.unpack(">hhhh", s) [/CODE]

Member Avatar for woooee
0
4K
Member Avatar for ihatehippies

I think you may be over-thinking. This works as expected:[CODE]def fun_a(): return "I am function a" def fun_b(): return "I'm b" s = { 'a': fun_a, 'b': fun_b} print("s['a'](): %s"%s['a']()) print("s['b'](): %s"%s['b']()) keep_fun = fun_a fun_a = fun_b print("After fun_a = fun_b") print("s['a'](): %s"%s['a']()) print("s['b'](): %s"%s['b']()) print("call fun_a() direct: %s"%fun_a()) …

Member Avatar for ihatehippies
0
169
Member Avatar for CalPolyGrad

You can do it with either technique you mention, but it may be better over the long term (in maintenance) to have company_contact separate from customer_contact. This will start to matter when you start to care about something that matters for customers but not in house contacts (date of the …

Member Avatar for griswolf
0
109
Member Avatar for emorjon2

A key in a dictionary must be immutable (the error message does state that requirement, but so subtly that you did not notice: Mutable types should not be hashed), and lists are mutable. You can use your list as a key if you cast it to a tuple first.

Member Avatar for griswolf
0
136
Member Avatar for KrazyKitsune

Please re-post your problem code along with the entire (error) output. When I fixed the int casts and the top level dispatch (1,2,3), the code ran as expected for me. At the top level, you can add this, to help diagnose trouble:[CODE]else: print("Missed the expected options with value %s of …

Member Avatar for Stefano Mtangoo
0
622
Member Avatar for RehabReda

First, you should show some effort. The best form of effort to show is some of your own code, best if it actually works to do something (maybe not the right thing); or if you cannot get it to compile then show the code and the errors you get from …

Member Avatar for swinefish
0
177
Member Avatar for a007s

I don't speak tkinter, but look at lines 18 and 25. Could be you need to scope the call back funcction? [iCODE]... , command = [B]Application.[/B]helloCallBack[/iCODE]

Member Avatar for a007s
0
3K
Member Avatar for gunneronaspooky

That looks like it works. Let me point out a few places it could be better, simpler: [LIST] [*]At line (approximately 2) put [icode]totalNumber = 100[/icode]so that if you ever want to change the count of numbers to ask for, you can do it in one place. [*]For similar reasons, …

Member Avatar for gunneronaspooky
0
133
Member Avatar for guif

For example, each city is in exactly one country, and each country has zero or more cities. Since this is always a one-to-many relationship, each smaller unit can have a column specifying the unique key of its next-larger unit. Similarly, each country is in exactly one sub-region, each sub-region in …

Member Avatar for swenning
0
132
Member Avatar for UaBoy

First two meta-issues: Please use [[I][/I]CODE] and [/[I][/I]CODE] tags around your code. The result gives line numbers, saves indentation, highlights keywords and is generally a good thing (and DaniWeb wants you to do it too). The easy way is to press the [C[I][/I]ODE] button on at the top of the …

Member Avatar for UaBoy
0
126
Member Avatar for LRNPHP

[CODE]shell> mysqlimport [options] db_name textfile1 [textfile2 ...][/CODE] See [url]http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html[/url] and particularly, search for a comment about csv files on Windows (which you will want to alter to your specific platform)

Member Avatar for LRNPHP
0
284
Member Avatar for lewashby

You should have command line tools that you can use to examine the database. Look in the [iCODE]bin[/iCODE] directory of the PostgreSQL installation location. There is also a [icode]doc[/icode] directory there.

Member Avatar for griswolf
0
76
Member Avatar for raafs

A virtual machine is "as if" a real machine, but running as a program on some other machine. This is useful in a variety of ways. Two of them are: [LIST=1] [*]You can run several virtual machines (even different OSs) at the same time on one piece of hardware. [*]You …

Member Avatar for griswolf
0
263
Member Avatar for dalacib

I would not want to write that in (bash), though I suppose it might be possible if you are allowed to use tools such as wget, curl, etc.

Member Avatar for griswolf
0
35
Member Avatar for aminit

One of the things people do best is design and invent things, including programming languages. Also, consider that we've been doing programming for about 50 years now more or less. Compare that to, say mechanical engineering which we've been doing since the Great Wall of China... or earlier... and there …

Member Avatar for leo002000
0
112
Member Avatar for ceeandcee

Try this?( no guarantee) [iCODE]echo "<img src='/images/bar_".{$row['teamA']}.".jpg'>";[/iCODE]

Member Avatar for ceeandcee
0
136
Member Avatar for vinod.narapuram
Member Avatar for James0l9l

So... what you want is another loop nested inside the first loop. I'll say it in English: loop over the x value, and for each x value, loop over the y value.

Member Avatar for griswolf
0
261
Member Avatar for Kadafiz

A trigger cannot directly do what you want. The documentation says: [URL="http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html"]A trigger is a named database object that is associated with a table, and that activates when a particular event occurs for the table. The trigger becomes associated with the table which must be a permanent table. CREATE TRIGGER …

Member Avatar for griswolf
0
100
Member Avatar for gsureshbabu

In the purple band at the top of the page is a search box. Type into that search box [I]compare two directories[/I] and press the [search] button. This problem has already been answered more than a few times on DaniWeb

Member Avatar for garryamin
0
89
Member Avatar for koveras vehcna

Line 10 is a problem: How do you ever quit? It should probably look something like[iCODE]while split_str:[/iCODE] (Or: What [B]is[/B] your halt condition?) line 33 is also a problem: Your while loop starts [B]after[/B] split_str is created the first time, so you need to add line 34:[iCODE]split_str = sstr.split()[/iCODE] I …

Member Avatar for koveras vehcna
0
186
Member Avatar for teenybopper

It seems a bit odd to try to do this [B]in[/B] your shell. [B]From[/B] your shell, sure. Look here: [url]http://www.thefreecountry.com/security/encryption.shtml[/url]

Member Avatar for griswolf
0
38
Member Avatar for acejhon

Modulus operator is the right thing to use. Why not? However, here's another way:[CODE]def divisibleBy3theHardWay(anInt): while anInt > 10: sum = 0 for c in str(anInt): sum += int(c) # I'm assuming anInt is indeed an int anInt = sum return anInt in (0,3,6,9)[/CODE]This method is also known as 'striking …

Member Avatar for woooee
0
82
Member Avatar for lewashby

Another DaniWeb poster has strongly recommended [URL="http://www.sybase.com/SQLAnywhere11DatabaseManagement?cmpid=cpc_us_q409_gg_sqla_sqladm0210&mc=google"]Sybase SQL Anywhere[/URL] which I can neither confirm nor deny from my own experience. Postgreql is also good and free.

Member Avatar for teedoff
0
100
Member Avatar for inddeveloper

If this is class work, please at least sketch out a plan of attack, better with some code (be sure to use [noparse][CODE][/noparse][I]your code goes here[/I][/CODE] tags around your code). If this is work related, please consider getting a serious commercial quality backup program (there are free ones available: I …

Member Avatar for inddeveloper
0
339
Member Avatar for gidireich

The size of a heap is smaller than the size of a tree: Heaps can be implemented on an array with effectively no overhead for storage whereas trees need extra storage to refer to each node's two subtrees[B](*[/B]). Intuitively (I haven't really thought about it hard), it seems to me …

Member Avatar for griswolf
0
84
Member Avatar for aman rathi

Oracle has a very good reputation. You may also want to look at MySql and Postgresql which are free and quite robust, but may not have such "nice" tools. In my career, I have found it very good to use more than one (programming language, or compiler, or DBMS) when …

Member Avatar for tesuji
0
294
Member Avatar for bhavithra

Read some papers on cryptography. What is interesting or important in what you learned? Can you think of some other way to do something that was discussed? Think outside the boundaries: Would steganography work better than or be better in conjunction with other techniques? What's wrong with sending messages by …

Member Avatar for griswolf
-1
86
Member Avatar for koveras vehcna

First a meta message: You misunderstood the instructions about how to post code (easy to do). The easiest way to post code is to press the (CODE) button at the top of the message box, then paste your code between the `your code here` tags that it places for you. …

Member Avatar for griswolf
0
256
Member Avatar for ausrasul

This is just a guess. Try [icode](yafc [url]ftp://test:test@192.168.1.225:21[/url]) < commands[/icode]. The parens make the enclosed command(s) run in a sub process together which may work as you wish.

Member Avatar for ausrasul
0
409
Member Avatar for rehber344

Please imagine that a stranger walked up to you and said: [I]for exapmle cam sees people.and ıt should detect dıstance between people how can we calculate ıt does anyone any ıdea about ıt? ı couldnt fıgure out the algorıthm[/I] Would you understand what that stranger wanted? Would you feel the …

Member Avatar for griswolf
0
109
Member Avatar for acrocephalus

Have a look here: [url]http://bytes.com/topic/python/answers/591081-connections-py[/url] (and note my signature ;)

Member Avatar for griswolf
0
211
Member Avatar for oracleruiz

You do [B]not[/B] need a authorized certificate, though you may use it if you prefer. What the Certificate Authority does is "guarantee" that you are who you say you are. That guarantee can be via a public key associated with your certificate. [I]Where do people get the public key?[/I] You …

Member Avatar for Rashakil Fol
0
142
Member Avatar for umandajayo

"Cloud" is a buzz word referring to the (cloud of) computational resources that are available "on the web". [URL="http://www.google.com/url?sa=t&source=web&cd=1&ved=0CDIQFjAA&url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FCloud_computing&ei=kBZvTMTdOIKCsQOEkrShCw&usg=AFQjCNHiF-WwWAL5XvVJY_JoQCkrwdCi3w"]Cloud computing[/URL] uses those resources to do work.

Member Avatar for griswolf
0
171
Member Avatar for gidireich

Use your Intel connections to find something at or near an Intel site near LA (Jeez. LA? Ick). Failing the Intel route, drop back to your University connections and use their resources to find another graduate who works near your target area. I think you see the pattern: Unless you …

Member Avatar for MindSter
0
173
Member Avatar for vukman

From the command line chant [iCODE]which bsh[/iCODE]and see what happens. My guess: It will print nothing (which means it can't find bsh on your $PATH). Could you be having a bad editorial day and missing the 'a' in bash? (a few minutes later): OK, I see that on some systems …

Member Avatar for griswolf
0
84
Member Avatar for challarao

It is much easier to understand the program if you use CODE tags around your source code: It makes your code much easier to understand, gives syntax highlighting, protects indentation, gives line numbers and is a generally great idea. The way to understand a program is to break it into …

Member Avatar for challarao
0
2K
Member Avatar for Axelro

I think you are either talking about a [I]type[/I] (float in Python) or a [I]representation[/I] which you can do with string formatting. [I]Type[/I] [CODE]integerValue = 484 floatValue = float(integerValue)[/CODE] [I]Representation[/I][CODE]print("%e"%integerValue)[/CODE]If neither of these is what you want, then you must ask your question more precisely.

Member Avatar for Axelro
0
279
Member Avatar for Ultralisk

One way: Instead of directly printing the '*', save them into a string, then at the end [iCODE]print("%[I]<width>[/I]s"%theAsteriskString)[/iCODE] Another way: Instead of printing the asterisk, append it to an array. Kind of like this (but using your code instead of my for loop), then convert and print the array:[CODE]blanks = …

Member Avatar for griswolf
0
109
Member Avatar for pythonbegin

I think you are working too hard. How about this code?[CODE]with open('file1.txt') as f1: # 42 K lines with open('file2.txt') as f2: # 18 lines with open('file3.txt','w') as fout: matches = set() for line in f2: matches.add(line.strip()) for line in f1: c0,c1,c2,rest = line.split(None,3) if c0 in matches or c2 …

Member Avatar for griswolf
0
139
Member Avatar for WHchaz1027

I'm confused. What label? Which database? Is this the right forum for this question?

Member Avatar for tmcpolin
0
122
Member Avatar for suhailansari

MySql and Postgresql are the usual choices for web service databases: They are good quality, freely available, have a large user base which means reasonably good support. Oracle also has a freely available version: [url]http://www.oracle.com/technetwork/database/express-edition/overview/index.html[/url] You may also want to look at Berkeley DB: [url]http://www.oracle.com/technetwork/database/berkeleydb/overview/index.html[/url] (also owned by Oracle). Microsoft …

Member Avatar for griswolf
0
273
Member Avatar for muppet

Better to use a join with the ALARMS table. I have [B]not[/B] checked that my syntax is correct... [CODE]SELECT s.Status as Error, NOW() - s.`TIMESTAMP` as `TIME Down`, s.`TIMESTAMP`, a.Reason from STATUS s join ALARMS a on s.error = a.Error_code where s.status = 5 AND s.timestamp > $lastTimeWeLooked[/CODE]Or something like …

Member Avatar for tesuji
0
157
Member Avatar for Wherany

Perhaps you should invest in a tinfoil hat? Or better yet, describe more precisely what you want. It would also be good to know what is your operating system and why you want such a thing.

Member Avatar for tryery
-1
74
Member Avatar for shiv0013

Is the leaf node a final state? If so, then it has [B]+[/B][I]verymuch[/I] if a win, [B]-[/B][I]verymuch[/I] if a loss and [I](whatever you deem appropriate)[/I] if it a draw. Look in the right column of this page, near the top. See all the related DaniWeb posts? Some of them may …

Member Avatar for fenerista
1
93

The End.