Re: reading from sockets
AndrewTK wrote: > Hello, > > I'm trying to read data from a socket and I'm not seeing what I'm > expecting it seems to skip the first line of data. I am new to > Python and just trying to test what I can do with it... and it's not > looking pretty. > > > I have some Python code: > [-- > #! /usr/bin/python > > import socket > > s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) > s.connect( ("localhost",54321) ); > s.send("hello") > data = s.recv(1024) > while len(data) > 0: > print repr(data) # the first print of data always seems to "ignore" > the first line of data... > data = s.recv(1024) > --] I'm new to Python too, but I'd have to agree with Simon on this: There's probably something screwy in your java code. I'm assuming that your server waits to receive the word 'hello' before replying with the three strings (first, second, and third)? So once your script sends the word 'hello', there's nothing for it to do but wait for a response. And that's exactly what your script does. -- http://mail.python.org/mailman/listinfo/python-list
Re: Password authentication systems
[EMAIL PROTECTED] wrote: > This may only be tangentially related to Python, but since I am coding > a password authentication system in Python, I thought I would ask here. > > In Linux (and presumably other *NIX systems that support it), when > shadow passwords are enabled, the actual password is not stored. > Instead an encrypted version is stored. Then, to authenticate the > password, the system re-encrypts the user's input to see if it matches > the stored, encrypted version. > Correct me if I'm wrong, but I believe that all Linux passwords are encrypted whether you enable shadow passwords or not. I believe that when you enable shadow passwords, the encrypted passwords are stored in a file other than 'passwd'. Is this not correct? -- http://mail.python.org/mailman/listinfo/python-list
Re: Read a file with open command
jean-jeanot wrote: > Dear Sybrel, > > I am delighted to know that you have been enlighted through my > question. > I am aware of my stupidity and I would say of my ignorance.If all > Python users were not ignorant I suppose the Python group would be > superfluous. I would suggest that if if you think that a question is > supid please do not answer it.In French we say: "There is no stupid > question but answers can be stupid". For the citation of Zappa I am > convinced that when Zappa is speaking of world stupidity he is thinking > to stupidity and wickedness of mankind and not to ignorance. Ummm, he did not say that your question was stupid. The Zappa quote is included as part of what we refer to as a 'signature'. In the case of Sybren Stuvel's posts to this newsgroup, the Frank Zappa quote is included in every message that he posts. Not just messages that he posts to you. Secondly, I notice that when you quoted Sybren's message in your reply, your newsreader attributed the quoted text with: "Sybren Stuvel a écrit :" Likewise, when Sybren replied to your message, his newsreader attributed the quoted text with, "jean-jeanot enlightened us with:" Do you see what I mean? You didn't write "Sybren Stuvel a écrit" because Sybren was french, did you? Of course, not! Your mail/news application included that attribution by default. By the same token, Sybren's mail/news application defaulted to this attribution: 'jean-jeanot enlightened us with:" When reading people's responses to your queries, stick to the material that they actually "write" at the time of the response. Ignore the stuff that they entered while configuring their respective news/mail reader. Little items like message signatures and quote attributions are, at best, reflective of the personality and/or philosophy of the author, and say nothing of the person receiving the message. :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Make $1000's Monthly!
[EMAIL PROTECTED] wrote: > Make $1000's Monthly! > Over 600 work at home firms are in need of survey takers, product > assemblers, home mailers, mystery > shopping > Data entry and more! Report contains complete contact details for over > 650 companies now hiring! > For this complete report of over 600 firms please visit > http://www.typeinternational.com/idevaffiliate/idevaffiliate.php?id=6589_52_3_87 Just to bring this thread back on topic, you could also make thousands of dollars monthly by becoming a professional Python coder or consultant. ;-) -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Re: Read a file with open command
[EMAIL PROTECTED] wrote: > AlbaClause wrote: >> jean-jeanot wrote: >> > > >> Ummm, he did not say that your question was stupid. The Zappa quote is >> included as part of what we refer to as a 'signature'. In the case of >> Sybren Stuvel's posts to this newsgroup, the Frank Zappa quote is >> included >> in every message that he posts. Not just messages that he posts to you. > > First up, I *like* the Frank Zappa signature quote; it has a George > Carlin feel to it and takes a swipe at our overly-protective cultures > [side note: I bought an electric heating pad last night that came with > instructions not to use it in the bathtub! Well, duh!]. But, can you > see where the signature on a response to a tutor list -- where people > are already feeling a bit intimidated and/or inadequate and therefore > may feel a wee bit "stupid" -- might be taken the wrong way? > > I have spent many years teaching mathematics and physics in a classroom > setting and have come to realize that, as a teacher, just about > anything I say/do can be blown way out of proportion. So I don't use > sarcasm or "fun" little put-downs and I treat every question as if it > is the most important matter because, to the student, it is. Do I get > tired of answering the same thing over and over? Yes!! Many times I > will ask if the student has read the textbook and, if not, I will > request they give it a try (much in the same way we ask if they have > read any tutorials), but I take Homeric efforts not to offend them and, > to that end, modify my behavior in order to teach them mathematics. > > My point is that this is a wonderful service you tutors provide, but > the Zappa signature may not be the best choice for this setting. Most > people will read it and get a laugh (as did I), but how many have taken > it the way jean-jeanot did and walk away feeling insulted? How many > will not post a response expressing their feelings, never post a > question again or, worst case, decide Python is not for them? > > Again, I admire this list and those of you you maintain it. These are > just my thoughts. YMMV. > > --greg This is getting a little off-topic, but my feeling is that if you're unable to discern the difference between the substance of the message, and the "personal style" of the author (eg: quote attributions and/or signature lines) then you probably shouldn't be attempting to code in Python or any other structured language. A newsgroup post is quite structured -- just as a Python script is -- there is the header, which contains the subject, the sender, the recipient, and other protocol information; and the text body. The text body is also quite structured. The text body can contain a quote from a prior message, the added comments that make up the substance of the message, and a signature/tag line. If a person has great difficulty in differentiating the various parts of a newsgroup message, then perhaps structured programming languages are not for them. Perhaps we should begin a new message passing convention. One where the substance of the post is contained within braces -- like C/C++ code? Just kidding! LOL -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Re: Easy to use distributed system?
Jim Jones wrote: > I am looking for a system in Python that will easily allow me to > distribute > processes across multiple systems?So, if I have a function 'foo', I'd > like to be able to call something along the lines of > > distribute(foo(x)) > > And have the system figure out which node is available for process, and > then have the results returned in some sort of callback fashion. > > Any insight is greatly appreciated. > I did a little research on this subject not too long ago. From what I've seen, OpenMosix appears to be about the easiest one for Linux Operating Systems. Here's the url: http://openmosix.sourceforge.net/ -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for a simple way to load a program from another python program..
[EMAIL PROTECTED] wrote: > I was looking for a simple way to load a simple python program from > another python program. > > I tried > > os.system(cabel) > > The file name is cabel.py a csound instrument editor.. > > The error I am getting is > > Traceback (most recent call last): > File "C:\Python24\Lib\site-packages\boa-constructor\test of > snake\Frame1.py", line 212, in OnCabelItems0Menu > os.system(cabel) > NameError: global name 'cabel' is not defined > Localisation of messages is disabled, using default language. > time resolution is 279.365 ns > > This is with cabel in the current directory. I have managed to use > import to run it but it will only do it once. I may be able to use the > exec commands but I don't want to exit the program I am using only to > run other programs and then exit. I would also perfer that cabel is in > it's own directory. > > thanks in advance for any help > > http://www.stormpages.com/edexter/csound.html I am new to Python coding myself, but I've found that the easiest way to start another script from within a script, is to use the execfile('filename.py') command. There may be better ways of loading other Python scripts -- better ways that I'm not yet aware of -- but execfile() works for me. -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Re: Mega Newbie Questions: Probably FAQs
Zeph wrote: > 4) There are a lot of books and tutorials out there, but they are of the > proof-of-concept type. Specifically, a tutorial might teach me Hello > World, but not really care about the framework, because it's a very > simple item, and the point is simply to get me coding. I'd like to start > off with an established, tested and reputable system whose habits I can > ingrain from day one, rather than figure it out later. Can someone > recommend a good book, or your favourite tutorials? Perhaps even one > that assumes MVC as the framework? There is no "tutorial" that will teach you good coding habits. You pretty much have to develop them on your own. Looking at other people's source is a good way to learn "accepted" coding habits. Python, in and of itself, is a good language for learning good programming habits, as the interpreter forces you to use certain conventions that are widely regarded as good coding structure. One of the things that many Python detractors harp about, is that Python forces you to use a considerable amount of whitespace. i.e. consistent indentation of code blocks. However, good and consistent indentation is generally considered to assist in making the source more readable and thus, easier to debug. All in all, these conventions help you to develop some good habits by producing runtime errors when you fail to observe them. -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Re: yet another noob question
mike_wilson1333 wrote: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number and follow each combo with a newline. So i'm looking at > generating combinations such as: (12345) , (12235), (4) and so on. > What would be the best way to do this? So, basically i'm looking for a > list of all combinations of 1-5 in a 5 digit unique number. Also, when > I send the list to print there can't be any duplicates of the combos. > > > Thanks, > > Mike This is one of those questions that reminded me that I don't know Python. I launched my Python interpreter, and forgot how to even print a string. Duh! Oh well... -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Re: Mega Newbie Questions: Probably FAQs
Zeph wrote: > ajaksu wrote: > I do intend to start small and build up, but I want to front load my > learning curve, usually makes the other side of the curve more productive. Did you ever play on teeter-totters when you were a kid? I think that's what they're called. Those board like things that are balanced in the middle, one kid on each end, and as one kid goes up, the other kid goes down. Anyway, when I was a kid there was some teeter-totters in the yard at a nearby apartment complex, and there were some teeter-totters in the park behind my house. If you spend much time on these contraptions, you soon realize that simply going up and down is not very much fun. We'd often carry on in our activity as it was supposed to be, but, invariably, one of us would be sitting on the low end and looking up at our playmate. With an almost devilish grin, we'd hop off the teeter totter and send our good buddy crashing to the ground. Such wonderful childhood fun. Another activity that my brother and I took part in was shoplifting. We devised a clever way of hording candy from the checkout aisles at a local grocery store. What we'd do, is climb in under the conveyor belt cabinet and reach out and bring entire boxes of candy bars, etcetera in under the conveyor belt where we'd sit and eat away at our leisure. We never ever got caught, and we went through probably hundreds of dollars worth of candy. But we got greedy! Hope this helps rather than confuses you. -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Re: Permission Denied
hiaips wrote: > > Tom Strickland wrote: >> Hopefully this is a simple question. I've started to program in Python >> after an absence of about a year, so I'm very rusty. I wrote a short >> program and tried to run it using Python2.4 in Linux. I keep getting >> "permission denied" messages after entering the path to the program. I >> switched to the root directory and tried again, but got the same >> result.I ran a very similar program earlier and it ran fine. >> >> What am I doing wrong? The program is: >> >> >> #!/usr/bin/python2.4 >> i=1 >> while i<1: >> print 'step 1',i >> i+=1 >> raw_input() >> print 'step 2' >> >> >> Thank you. >> >> Tom > > > Is your script executable? That's the problem I had when I wrote my first Python script. I wrote it using vi, and vi doesn't save files with the executable flag set. A simple 'chmod 755 script.py' fixed that right up. Then, to execute the file from from the shell prompt, I had to create a 'bin' directory in my home folder, cuz I didn't want to litter my /usr/local/bin folder with useless Python scripts. (Useless because I wrote them to learn the language and for no other practical purpose.) Of course, I had to uncomment a line or two in my .bashrc file too. Hey, what do I know? I'm as new to this as virgins are to... Well, you get the idea. :-p -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Re: Permission Denied
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, AlbaClause wrote: > >> Then, to execute the file from from the shell prompt, I had to create a >> 'bin' directory in my home folder, cuz I didn't want to litter >> my /usr/local/bin folder with useless Python scripts. > > Executable files can be kept anywhere, you don't need a special directory > for them. Yes, I know, but if you want to just enter the filename at the shell prompt, the file has to be somewhere that it can be found. Otherwise you get the dreaded "command not found" error. Unless I'm doing something wrong? -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Learning Python - Have Question.
I'm just learning Python, and I have a question about os.path.join(dirpath, name) and its use. Simply put, I haven't figured out how to use it. I was looking through the Python reference material in the wee hours of the morning and checking out some of the modules. I was keenly interested in the os module, as it is necessary for me to learn this stuff in order to begin my first real Python project. I was looking at os.walk(top) when I read a little blurb about using os.path.join(dirpath, name) to get complete directory listings with path/filname. Unfortunately, I was unable to figure out how to use it. I kept getting an error with a message something like "b.startswith" or something like that. I was also unable to find any other information about this in the reference material. If someone could offer some insight into the use of os.path.join(dirpath, name), I would really appreciate it. Oh, I have one more question. So far everything that I've played with yields only the filename of file. I am aware that os.walk will place the pathnames and filenames in a tuple, but I'm wondering if there is a way to input a full path directory from within Python. Specifically, I want to be able to get directories like one would get by entering "ls -l" at a *nix shell prompt. Thanks. -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python - Have Question.
iapain wrote: >> I'm just learning Python, and I have a question about >> os.path.join(dirpath, >> name) and its use. Simply put, I haven't figured out how to use it. > > First thing you have to remember while using python is "everything is > an object". os.join.path concatenates one or more path for example > os.path.join("c:", "myfolder") represent a path relative to current dir > on c: drive. > Thank you. I was thinking about it all wrong. That helped a lot. I have it figured out now. :-) -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python - Have Question.
Tal Einat wrote: > iapain wrote: >> First thing you have to remember while using python is "everything is >> an object". os.join.path concatenates one or more path for example >> os.path.join("c:", "myfolder") represent a path relative to current dir >> on c: drive. >> > > Actually, os.path.join() is a simple function, there's nothing > Obejct-Oriented about it. "Everything is an object" simply means that > functions are objects, but that doesn't mean that the design of > everything is Object-Oriented. It turns out that I was using os.path.join() properly in the first place. And you're right, it is a very simple function. Apparently, I was using os.walk() improperly. More specifically, I was not fully understanding how os.walk() worked. I've played with it some more in the Python interpreter and I now have a very good understanding of how it works. For example: import os d=os.walk('/server1') for a, b, c in d: pass This will place the path '/server1' in 'a', all directories in 'a' in a list called 'b', and all files in a list called 'c'. On the next iteration of the loop, 'a' will contain the path '/server1' with the path of the first directory in '/server1' appended. So 'a' will be '/server1/directory1', all of the directories in 'a' will be stored in 'b', and all of the files in 'a' will be stored in 'c'. So on the first iteration, a, b, and c would be: a = server1 b = directory1, directory2, directory3 c = file1, file2, file3 On the second iteration of the loop, a, b, and c would be: a = server1/directory1 b = subdirectory1, subdirectory2 c = d1file1, d1file2, d1file3 On the third iteration of the loop, a, b, and c would be: a = server1/directory1/subdirectory1 b = [] # there are no directories in subdirectory1 so b is empty. c = sd1file1, sdfile2 >> you could easily do it with python. Its more than your expectation. The >> best would be to call os.system(shell cmd). > > Using the shell for this is the least cross-platform solution possible. > Python's libraries have very corss-platform implementations of such > operations you should use them! > > In this case, it seems you're looking for os.listdir(dir_name). Just > call it with the path of a directory and it will return a list of names > of all the files and directories therein. You can use os.path.isdir(), > os.path.isfile(), etc. to figure out what type of file system object > each item in the list is. You can check premissions for the current > user with os.access(). Finally, you can find out more data about any > file with the "stat" module, which is more low-level. Thank you for this. The most daunting task in learning Python, is learning all of the modules and functions that are available. And there's a tonne of them. :-) -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list
Re: python loops
Putty wrote: > In C and C++ and Java, the 'for' statement is a shortcut to make very > concise loops. In python, 'for' iterates over elements in a sequence. > Is there a way to do this in python that's more concise than 'while'? > > C: > for(i=0; i > > python: > while i < length: > i += 1 for i in range(length): print i -- -- There are several things that I will never be: * I will never be attracted to females. * I will never enjoy the company of others. Exactly how these realities bode for my enemy, is not of my concern. -- http://mail.python.org/mailman/listinfo/python-list