Re: [Tutor] Creating lists with definite (n) items without repetitions
On 10 September 2015 at 08:45, Francesco Loffredo via Tutorwrote: > > I wrote a small routine (below) to check when and if my code and the formula > do match. It easily shows that > they only match for len(pool) == (2 ** N) - 1, with N greater or equal to 2. That's interesting. I'm not sure exactly why that would happen. > My problem remains: WHY don't they match for every length? Your algorithm is not generally guaranteed to find a full solution. > How did you build your 12-triples set? I took it from this diagram: https://upload.wikimedia.org/wikipedia/commons/e/eb/Hesse_configuration.svg > What's wrong with my algorithm? And, most of all (and on topic, too): how can > you build a Python program that builds your triples list? Perhaps if we compare this problem to a different problem then we can see how your algorithm may not be optimal. Imagine solving a sudoku puzzle. Your algorithm loops through all triples and accepts any triple if it doesn't immediately conflict with any of the triples already accepted. If you were solving a sudoku puzzle then an analogous algorithm would take each empty square and fill it with any number that doesn't contradict any of the currently filled squares. If you try this on a real puzzle then you will reach a dead end and you won't fill the grid. The problem is that some of the squares you filled in could have had a number of possible values and you've just chosen them arbitrarily (and incorrectly). The solution for a sudoku solving algorithm would be to back-track. One of the previously filled squares was filled incorrectly so go back and change what you had before. As a recursive algorithm you would take an unfilled square, loop over the possible values that it can take and for each of those values attempt to fill the remainder of the sudoko grid. The analogous backtracking algorithm for this problem would mean deciding first to include a particular triple if it is compatible with the already accepted triples and then continuing with the remaining triples to see if it leads to a full set (you know how big a full set should be). If it does not lead to a full set then you were wrong to include one of your current triples so now decide not to include it and again loop through the remaining triples looking for a full set. I imagine that the complexity of this algorithm will grow rapidly as N increases. For N=9 you have thousands of triples, so the powerset of this has 2**N members meaning that this binary backtracking algorithm has a very large space to explore. The space is heavily pruned by the pairing constraint though so it may not work out as badly as I expect. Also there will be many possible solutions and you only really need to find one. Up to isomorphism there is 1 solution for N=9 but that means there will be 9! isomorphic solutions (the number of ways of relabelling the numbers 1 through 9). This means that you may not have to go far in the search before coming across a solution. -- Oscar ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Type Error
On Mon, Sep 14, 2015 at 9:29 AM, richard kapplerwrote: > everything works except the os.remove(file) which gives the following error: > > Traceback (most recent call last): > File "DataFeedBatch.py", line 104, in > os.remove(file) > TypeError: coercing to Unicode: need string or buffer, file found > > I don't understand the error os.remove() expects a filename, and you're passing it a 'file' object. -- Zach ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Type Error
On Mon, Sep 14, 2015 at 10:29 AM, richard kapplerwrote: > Still working on my data feed script, if you'll recall from previous > emails, it reads incoming data and creates a name for image files based on > the incoming data in a test environment. below is a snippet of that code > that copies the next image in the pool renaming it as it copies, sends to > another machine via ftp, the closes the file and *** should then delete the > file *** but does not. > > img = str(i) + '.jpg' > ID = device + '_' + timestamp + '_' + counter + '.jpg' > src = '/home/test/DataFeed/input/BOT/' + img > dst = '/home/test/DataFeed/output/BOT' + ID > shututil.copyfile(src, dst) > file = open(dst, 'rb') > sendBOT01.storbinary('STOR ' + ID, file) > file.close() > os.remove(file) > > > everything works except the os.remove(file) which gives the following error: > > Traceback (most recent call last): > File "DataFeedBatch.py", line 104, in > os.remove(file) > TypeError: coercing to Unicode: need string or buffer, file found > > I don't understand the error > -- > > All internal models of the world are approximate. ~ Sebastian Thrun > I'm not sure if you want to remove src or dst, but whichever one you want to remove, use the name, not the file object, eg: os.remove(src) ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor -- Joel Goldstick http://joelgoldstick.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Type Error
Still working on my data feed script, if you'll recall from previous emails, it reads incoming data and creates a name for image files based on the incoming data in a test environment. below is a snippet of that code that copies the next image in the pool renaming it as it copies, sends to another machine via ftp, the closes the file and *** should then delete the file *** but does not. img = str(i) + '.jpg' ID = device + '_' + timestamp + '_' + counter + '.jpg' src = '/home/test/DataFeed/input/BOT/' + img dst = '/home/test/DataFeed/output/BOT' + ID shututil.copyfile(src, dst) file = open(dst, 'rb') sendBOT01.storbinary('STOR ' + ID, file) file.close() os.remove(file) everything works except the os.remove(file) which gives the following error: Traceback (most recent call last): File "DataFeedBatch.py", line 104, in os.remove(file) TypeError: coercing to Unicode: need string or buffer, file found I don't understand the error -- All internal models of the world are approximate. ~ Sebastian Thrun ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Type Error
Correct, The filename should be passed as string value. Regards, -- Rohit Kumar | Technical Lead ZeOmega | Population Health Management Solutions Improving Population Health One Person at a Time Office: +91 80 4243 2000 (4067) | Mobile: +91 9342637703 -Original Message- From: Tutor [mailto:tutor-bounces+rohitraj007=gmail@python.org] On Behalf Of Zachary Ware Sent: 14 September 2015 20:11 To: tutor Subject: Re: [Tutor] Type Error On Mon, Sep 14, 2015 at 9:29 AM, richard kapplerwrote: > everything works except the os.remove(file) which gives the following error: > > Traceback (most recent call last): > File "DataFeedBatch.py", line 104, in > os.remove(file) > TypeError: coercing to Unicode: need string or buffer, file found > > I don't understand the error os.remove() expects a filename, and you're passing it a 'file' object. -- Zach ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor -- This e-mail message (including any attachments) may contain information that is confidential, protected by the attorney-client or other applicable privileges, or otherwise comprising non-public information. This message is intended to be conveyed only to the designated recipient(s). If you have any reason to believe you are not an intended recipient of this message, please notify the sender by replying to this message and then deleting it from your system. Any use, dissemination, distribution, or reproduction of this message by unintended recipients is not authorized and may be unlawful. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python 3.5 32-bit installer not creating standard registry key
Sorry, I've just realised that my previous message was wrong - please delete it. I now see that the key in question is actually a Python for Windows Extensions key. The problem appears to lie in the Python for Windows Extensions 32-bit installer not recognising any of the new Python 3.5 32-bit keys. I'll have to find some way of contacting the Python for Windows Extensions developers to ask them which key the installer is looking for, and then try to determine why I don't have it. Pete Subject: Python 3.5 32-bit installer not creating standard registry key Date: 2015-09-14 15:46 From: PeteTo: tutor@python.org Hi there, I am looking for the best place to post a problem I'm having with Python 3.5. The 64-bit installer works fine, creating among other 64-bit registry keys a generic one called HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\pywin32-py3.5. Installing Python for Windows Extensions afterwards works fine as its installer looks for this particular key on installation. However, the 32-bit Python 3.5 installer does not create a similar generic key in the 32-bit registry, meaning that I can't install Python for Windows Extensions 32-bit afterwards. This problem did not occur with Python 3.4 which correctly installed both keys (with 3.4 in the key name instead of 3.5). Pete ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python 3.5 32-bit installer not creating standard registry key
On 14/09/15 15:53, Pete wrote: Sorry, I've just realised that my previous message was wrong We don't seem to have that one. Are you sure you sent it to the tutor list? Python 3.5 32-bit keys. I'll have to find some way of contacting the Python for Windows Extensions developers to ask them which key the installer is looking for, and then try to determine why I don't have it. Try the Win32 mailing list/forum. https://mail.python.org/mailman/listinfo/python-win32 -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] ftp socket.error
Thanks for all the assistance, turned out it was a problem with the iptables not having an accept for eth1. Onward and upward! regards, Richard On Sat, Sep 12, 2015 at 12:24 PM, Martin A. Brownwrote: > > Hello and good morning > > I may be mistaken, but it looks like you are trying to open the socket on >> port 2021. Standard ftp uses 21. Is the server listening on 2021? >> > > Ooof! And, in fact, that is a great point! I overlooked that in the > original snippet! > > Everything I wrote still stands, except that you need to tell the > ip_conntrack_ftp (or nf_conntrack_ftp) kernel module to watch for a command > channel on TCP/2021. > > modprobe ip_conntrack_ftp ports=21,2021 > > That means that the ip_conntrack_ftp module will watch flows on both ports. > > I'm glad you observed that important detail, Robert! > > -Martin > > > Strictly speaking, it's no Python question, but... good ol' FTP. >>> >>> socket.error: [Errno 113] No route to host >>> >> > Your program is receiving an EHOSTUNREACH. >>> >>> >>> import errno >>> >>> errno.errorcode[113] >>> 'EHOSTUNREACH' >>> >>> This occurs at precisely the moment that your program is trying to >>> initiate a data transfer. Every firewall administrator in the world >>> loves >>> FTP for precisely this reason. (And, when I say "love", you can replace >>> this with a verb or of your choice.) >>> >>> Without packet captures, I will merely guess (based on experience). >>> >>> 1. The receiving machine is running the Python program, builds a >>> connection on port 21 (this is called the FTP command >>> channel), you log in and all is well. >>> 2. The moment you try to transfer any data, the FTP client (your >>> receiving machine) and the FTP server negotiate either FTP >>> passive mode or FTP active (retronym) mode. I'm guessing >>> that your FTP client is choosing passive mode. (Your FTP >>> client might produce logging of this negotiation.) >>> 3. Using the connection information, the client attempts to build >>> an FTP data channel. So, your machine running the Python >>> program initiates a connection to the FTP server. >>> 4. The FTP server is (probably) configured to allow connections >>> inbound to TCP/21 (FTP Command Channel), but doesn't know to >>> allow the connections to the ephemeral port(s) negotiated >>> during step 2 (above). So, the firewall on the FTP Server >>> sends an ICMP Type 3, Code 1 [0]. >>> >>> Figured it out. On the receiving machine I had to >>> > # modprobe ip_conntrack_ftp > > Right instinct! Try this same command on the FTP server side. Unless >>> your >>> Python FTP client is negotiating active mode, the server will be the >>> "problem" in this case. >>> >>> No, apparently I didn't figure it out. I thought I had as after the >>> modprobe I was getting a an EOFError, but now I'm getting the no route to host error again. I can ping it, and as you can see from the original post, I am able to establish a connection and log in, it's just when I try to send a file it goes bollocks up. Still need ideas. >>> Hopefully, my idea #1 helps. (If not, you'll need to do some packet >>> captures and probably crank up the logging on the FTP server, too.) >>> >>> I do have another idea, though. Have you ever wondered about the slow >>> demise of FTP? All of this command-channel, data-channel, PORT or PASV >>> nonsense goes away when you use a protocol that runs over a single TCP >>> port. Worked fine in the early days of the Internet before firewalls and >>> NAT. >>> >>> Anyway, short idea #2: >>> >>> If it's anonymous access, use HTTP. >>> If authenticated access, use ssh/scp/sftp. >>> >>> Good luck, >>> >>> -Martin >>> >>> [0] http://www.networksorcery.com/enp/protocol/icmp/msg3.htm >>> >>> -- >>> Martin A. Brown >>> http://linux-ip.net/ >>> ___ >>> Tutor maillist - Tutor@python.org >>> To unsubscribe or change subscription options: >>> https://mail.python.org/mailman/listinfo/tutor >>> >>> >> > -- > Martin A. Brown > http://linux-ip.net/ > -- All internal models of the world are approximate. ~ Sebastian Thrun ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python 3.5 32-bit installer not creating standard registry key
In a message of Mon, 14 Sep 2015 15:53:16 +0100, Pete writes: > > >Sorry, I've just realised that my previous message was wrong - please >delete it. I now see that the key in question is actually a Python for >Windows Extensions key. The problem appears to lie in the Python for >Windows Extensions 32-bit installer not recognising any of the new >Python 3.5 32-bit keys. I'll have to find some way of contacting the >Python for Windows Extensions developers to ask them which key the >installer is looking for, and then try to determine why I don't have it. > >Pete post a bug here: http://bugs.python.org/ Laura ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help with python
On 15/09/15 00:25, Laura Creighton wrote: The gmane.org reference is here: gmane.comp.python.testing.general I am not getting anything sensible out of this. Works for me, but admittedly I only see one post in September. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python 3.5 32-bit installer not creating standard registry key
In a message of Mon, 14 Sep 2015 18:19:47 +0100, Pete writes: > > >Thanks Laura. > >In the end I posted the bug to Python for Windows Extensions >(http://sourceforge.net/p/pywin32/bugs/702/) because I suspect that the >fault may well lie with the PWE installer. > >If I don't get any resolution there then I'll post to the Python bugs >link you kindly list. However, if you recommend that I post in both >places now then I'll do that. > >Pete I don't know what is best. I know that people with other installers are having problems getting 3.5.0 working on their machines, but whether their problems and your problems are related, I have no clue. Laura ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Invalid Syntax Message
On 9/14/2015 2:50 PM, Shannon Rodenbeck wrote: I have downloaded Python 3.4.3 on my Mac 10.10.4. When i try running my programs from IDLE to go on Shell i get the message that says "Invalid Syntax". I've tried my programs on a different windows computer and it runs and works perfectly. How do I fix this problem so the programs are able to run on my Mac. Start by providing a complete copy-n-paste of the screen when the error occurs. That normally provides enough detail to diagnose the issue. Emile ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help with python
In a message of Mon, 14 Sep 2015 19:48:01 +0100, Alan Gauld writes: >On 14/09/15 18:02, vijayram wrote: >> Hi, >> >> I need help with python nose tests and test-suite… can I request help >> with a tutor.. > >You can try asking basic questions here, but as nose is not >part of the standard library you might get more help on the >python testing list: > >The gmane.org reference is here: > >gmane.comp.python.testing.general I am not getting anything sensible out of this. But the testing list is over here: http://lists.idyll.org/pipermail/testing-in-python/ Though it has been unbelievably quiet this month ... Laura ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Invalid Syntax Message
I have downloaded Python 3.4.3 on my Mac 10.10.4. When i try running my programs from IDLE to go on Shell i get the message that says "Invalid Syntax". I've tried my programs on a different windows computer and it runs and works perfectly. How do I fix this problem so the programs are able to run on my Mac. Thank you, Shannon Rodenbeck srode...@saintmarys.edu ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help with python
On Mon, Sep 14, 2015 at 10:02:35AM -0700, vijayram wrote: > Hi, > > I need help with python nose tests and test-suite… can I request help with > a tutor.. Sure. Ask your questions on the mailing list, and somebody will answer. This is a group for *public* tutoring, so that everyone can learn from it, not private tutoring. -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] syntax error
Hi What's wrong with the following code? def main() lunch = int(input('How many hours did you eat?')) cost = float(input('Enter the hourly cost: ')) gross_cost = lunch * cost print('cost:$', format(cost, '.2f'), sep='') main() I get the error File "", line 6 Thanks, Sarah ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] syntax error
On Mon, Sep 14, 2015 at 01:20:55PM -0400, Sarah wrote: > Hi > What's wrong with the following code? > > def main() >lunch = int(input('How many hours did you eat?')) >cost = float(input('Enter the hourly cost: ')) >gross_cost = lunch * cost >print('cost:$', format(cost, '.2f'), sep='') > main() > > > I get the error File "", line 6 The above should be fine when saved and run from a .py file, but at the interactive interpreter, you need to leave a blank line after functions. Try leaving a blank after the print(...) line and before main(). -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python 3.5 32-bit installer not creating standard registry key
Thanks Laura. In the end I posted the bug to Python for Windows Extensions (http://sourceforge.net/p/pywin32/bugs/702/) because I suspect that the fault may well lie with the PWE installer. If I don't get any resolution there then I'll post to the Python bugs link you kindly list. However, if you recommend that I post in both places now then I'll do that. Pete On 2015-09-14 18:10, Laura Creighton wrote: In a message of Mon, 14 Sep 2015 15:53:16 +0100, Pete writes: Sorry, I've just realised that my previous message was wrong - please delete it. I now see that the key in question is actually a Python for Windows Extensions key. The problem appears to lie in the Python for Windows Extensions 32-bit installer not recognising any of the new Python 3.5 32-bit keys. I'll have to find some way of contacting the Python for Windows Extensions developers to ask them which key the installer is looking for, and then try to determine why I don't have it. Pete post a bug here: http://bugs.python.org/ Laura ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Need help with python
Hi, I need help with python nose tests and test-suite… can I request help with a tutor.. Thank you, vijay ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] syntax error
On Mon, Sep 14, 2015 at 1:20 PM, Sarahwrote: > Hi > What's wrong with the following code? > > def main() >lunch = int(input('How many hours did you eat?')) >cost = float(input('Enter the hourly cost: ')) >gross_cost = lunch * cost >print('cost:$', format(cost, '.2f'), sep='') > main() > > > I get the error File "", line 6 > > Thanks, Sarah > You forgot the : after def main(...): > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- Joel Goldstick http://joelgoldstick.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] syntax error
On 14/09/15 19:25, Joel Goldstick wrote: On Mon, Sep 14, 2015 at 1:20 PM, Sarahwrote: Hi What's wrong with the following code? def main() lunch = int(input('How many hours did you eat?')) cost = float(input('Enter the hourly cost: ')) gross_cost = lunch * cost print('cost:$', format(cost, '.2f'), sep='') main() I get the error File "", line 6 Thanks, Sarah You forgot the : after def main(...): Also your print line is, I suspect, wrong. I assume you want to print gross_cost not cost? You could also use the format method of the string which tends to be more flexible: print('cost: ${:.2f}'.format(gross_cost)) hth -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help with python
On 14/09/15 18:02, vijayram wrote: Hi, I need help with python nose tests and test-suite… can I request help with a tutor.. You can try asking basic questions here, but as nose is not part of the standard library you might get more help on the python testing list: The gmane.org reference is here: gmane.comp.python.testing.general -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor