« first day (2907 days earlier)      last day (2044 days later) » 

2:54 AM
Nevermind... I found this answer: stackoverflow.com/questions/42559434/…
 
3:31 AM
yip yip yip yip yip yip yip...uh huh, uh huh, uh huh
 
4:14 AM
watch Sesame Street much lately?
 
 
1 hour later…
5:35 AM
yes, when I was 5
@jpp Congrats, just a few more questions more and you'll have answered more questions in 8 months than I have in over 3 years
 
 
2 hours later…
7:16 AM
cbg all
What happened to __mro__ in python3?
 
Nothing, I think?
 
Oh nevermind was missing the class in instance.__class__.__mro__
@Aran-Fey great! was worried for a minute there :S
 
7:41 AM
I wish people wouldn't call python dictionaries "hashtables"... even if they are the same thing. I wouldn't call a java array a "list".
 
morning cabbage has the most unstable taste...
 
@coldspeed It is a bit annoying, but at least it's not ambiguous, or confusing. But it does annoy me when people call them hashes; I think that's Perl jargon.
 
8:06 AM
Yup
Hash or associative array
 
"associative arrays" are from PHP if memory serves
 
@coldspeed java arrays are not extendable
also hash table is (mostly an) implementation detail
 
jpp
@coldspeed, Thanks, though I'm trying to be more discriminatory!
@coldspeed, Well, more technically Python dict uses hashtables, but they are much more than hashtables. So yeh I agree with these kind of terminology blunders.
 
8:29 AM
@jpp Do you agree with the blunders, or agree with the fact that they're blunders? (wasn't sure, just checking)
@AnttiHaapala Hmm, arraylists <=> lists? :)
 
jpp
agree they are blunders :)
 
@coldspeed java's arraylists are lists and python lists are arraylists :D
 
jpp
Some other ones I've come across recently: It's better to vectorise via apply + lambda than a manual loop; or use a list comprehension via list(....). The first is just wrong, the second terminology error happens often.
 
well a manual loop can never be vectorised, so what do you mean?
 
jpp
@AnttiHaapala, Oh that's a thing. Where NumPy arrays avoid Python-level loops.
 
8:40 AM
It was fine the first ten thousand times, but after that it became tiresome to keep correcting people
 
So I have a function that takes a file path as input. Now I want to write tests for that function. Should I a) Mock the builtin open function so that I don't have to actually create files for my tests, or b) write a 2nd function that takes a file object and a file path as input, and only test that function?
Basically I can decide between these two:
class DataStore1:
    def store(self, file_path):
        with open(file_path) as fileobj:
            ... # do something with the file and the file path

class DataStore2:
    def store(self, file_path):
        with open(file_path) as fileobj:
            self._store_fileobj(fileobj, file_path)

    def _store_fileobj(self, fileobj, file_path):
        ... # do something with the file and the file path
 
@Aran-Fey why do you use file names as the first class system?
that to me is a flaw by itself...
so the answer is "yes yes yes and some more"
 
@Aran-Fey I'd go with the first route
 
I use the file path as a sort of identifier. After storing a file, you can then call datastore.load(file_path) and it'll restore the file
I need the file path for various reasons
 
But I think I'd set up a temp folder for the tests. Won't that work?
 
8:53 AM
... nothing has been said that would make me change my mind :D
 
@Arne Well, I'd like to avoid creating real files just for the purpose of testing. I don't see a reason to take a detour over the file system when I could just use in-memory file-like objects instead. Do you think I should use real files instead of mocking open?
 
Pass a file object instead. You can then mock the file object in tests.
 
Does this thing store arbitrary files, or do they have a format that you need to test as well?
 
@jpp Do you mean when people put a gen exp inside list()? Yeah, that's a bit silly: it's slower than a list comp, and uses more RAM.
 
to generalise, pass any object that you can call obj.read() on to fetch data, and then mock that object as you please. Let obj abstract away file IO
 
8:57 AM
@coldspeed There is no "instead". I can either pass a file path and a file object, or just a file path.
@Arne arbitrary files
 
Then you're right, just mock open.
 
again I ask "why they're arbitrary files"?
 
I don't like that idea. It means you have to write tests keeping your function's implementation in mind
tests should always test the interface, not the implementation
 
your api is that you stash something into a filelike object and then can retrieve it
 
if wim was here, he'd tell you the same thing in a lot more words
 
8:59 AM
@coldspeed that sounds very idealistic
 
@coldspeed actually you're incorrect
tests can test everything
black box vs white box
 
Tests can test everything. But good tests don't require changes when the implementation changes, imo
 
@AnttiHaapala No, that's not right. I stash arbitrary data somewhere undefined, and let you retrieve stored data through the restore(data_identifier) method
Where data_identifier is a file path, in this case
 
Changing the implementation without changing the behaviour is also something that hardly ever works in my experience
 
well, perhaps you should have a storage layer...
 
9:02 AM
Isn't this my storage layer?
 
well, idk, is it?
 
I'll go ahead and say "yes"
 
btw tangentially related: I hate the fact that many python stuff require file names when they don't need it... then we cannot use something like zip modules etc, because "aint got no file name eh"?
 
jpp
@PM2Ring, Yep, exactly it's like a self-fulfilling thing. More people that do it as part of answers, more people use it in their Q / A.
 
@Aran-Fey but isn't this kind of funny, your datastorage layer is creating files, then you must test that, because that's what it is doing!
what if you make a mistake with your mock
if you insist that it does something else that is much more important to be tested, then...
 
9:05 AM
The data storage doesn't necessarily create files. All I know is that it opens files
 
... why does it still deal with named files only.
 
It's a backup program. It backs up your files. I don't really have a reason to support unnamed files, because nobody would want to back those up
 
good, that's the first thing that makes some sense
... but with backup program then of course you want to back up real files and restore those too...
... then what's the point in mocking that
 
carefully think about your use cases and then figure out what you need to test for. What file types? Just files or entire folders? Thread safety?
 
Well, I don't want to have hundreds of megabytes worth of files in my tests folder
 
9:08 AM
and who'd care about that?
 
of course, you create files in setUp() and recursivelyDelete in tearDown().
 
use tempdir in /dev/shm
 
So instead of mocking open, I should actually create real files on disk, and remove them when the tests are done?
 
if you have a place that calls open then inject that open into it, and then also test without mocking
program to an interface: you have
def store(filename); def restore(filename);
make a single class have only that...
 
@coldspeed I don't think I'm quite at that point yet. First I need to figure out how to even test a single file. I'll worry about file types and folders later...
 
9:11 AM
then inject an instance where needed
then one test will test your actual implementation
the other test will test with injected one where there is a dictionary of strings to BytesIOs
do not mock "open"
 
@AnttiHaapala Sorry, I don't follow. I understand I should test the storage layer separately from everything else (by mocking the storage layer if necessary), but I still don't get how I would test the storage layer without mocking open
 
because it is an alternative implementation
you will write another class that you can inject
and ofc the actual open impelementation would need to write files...
 
Say I have a DataStore class like this. How would you test this?
class DataStore:
    def __init__(self):
        self.files = {}

    def store(self, file_path):
        with open(file_path) as fileobj:
            self.files[file_path] = fileobj.read()

    def load(self, file_path):
        content = self.files[file_path]
        return io.StringIO(content)
 
I'd test with DataStore().store('/tmp/myfile').load('/tmp/myfile') contents match that of that I generated from os.urandom(16) to /tmp/myfile
(after that file has been truncated and unlinked ofc)
notice that it is just 1 test... since you know it is not going to change for 16 and 16G file... (except that perhaps it breaks with 2G, 4G, or out of ram)
if you insist you need gazillion test cases through this, then you're wrong
you need the boundary tests for this and some integration tests and...
then not a mock or a stub but a complete alternate in-memory copy of this
 
hey there.. is there any image recognition data scientist here? or who can use "wand" in python
 
9:24 AM
@AnttiHaapala What you're describing is an integration test already, though
 
What's the benefit of using real files though? Why is that better than implementing a def _store_fileobj(filepath, fileobj) method, and testing that?
 
Since calling open produces different results depending on the deployment environment
 
So if I implement that _store_fileobj method and I test it with both in-memory data as well as real files, there's no harm?
 
@Aran-Fey well, also maybe no gain
 
@Arne that's bs, there is nothing in this module besides that it uses some opens
 
9:26 AM
since there is no logic happening behind it, or is it?
 
@Tehseen What's your problem ?
 
@AnttiHaapala That's my point, I think I just draw a different conclusion
 
@Arne The store method would be reduced to with open(file_path) as fileobj: self._store_fileobj(fileobj, file_path), yes. Everything that needs to be tested would be in _store_fileobj
 
The file object abstraction Aran proposes sounds like the kind of thing you'd do to separate the business logic that you'd unit test from the environment dependent part of the implementation, which you can only test in integration.
 
@IMCoins i am using wand to calculate the average color baseline for image in python but i am new to wand so i really don't know how to use it. i have a code snippet for imagemagick package but i have some issues installing it so now i want to do that using wand
 
9:30 AM
But since there is no additional logic apart from opening files, the only meaningful test would be integration level, with actual files created and stuff.
I might be wrong, I have no certificate in testing or anything. That's just how it's done in our shop.
 
@IMCoins convert <input.jpg> -resize 1x1\! \
-format "%[fx:int(255*r+.5)],%[fx:int(255*g+.5)],%[fx:int(255*b+.5)]" info:-
@IMCoins i want to do this in python using wand
 
Maybe I'm trying too hard to avoid writing data to disk... but I really don't see a good reason to take the detour over the file system. Why slow down my tests writing 100MB of test data to disk when I could process it all in-memory?
 
@Aran-Fey it just depends what you want to test
If you want to test your code logic, you should do that mocking the storage in unit tests, and maybe some integration tests can also use mocked storage, but if you're storing stuff, at some point you want to end to end test that it all works before you go live
 
^
 
That should be as early as possible, to avoid lots of embarrassment if it doesn't work 2 weeks before go live and that's the first time you bothered testing the actual code
 
9:43 AM
Oh, I'll definitely have some end-to-end tests. But I don't think I have to use real files for all of my tests
The project is in early stages of development, so right now I'm writing more unit- than integration tests. I was planning to test my storage layer with in-memory file objects, and then use real files for the full system tests
 
9:58 AM
@Tehseen I invited you into a new room to talk about it. If you didn't have the notif, the room is here
 
@IMCoins thanks
 
If you can know the quadrant of point A (x,y) and can know the distance to any other point from point A. assume point A is the center of a circle and you know the radius but can't really know the x and y of point A. can you determine if the circle is in the quadrant?
 
10:19 AM
"know the distance to any other point from point A"
does that mean we know the distance from A to (x,0) and from A to (0,y)?
 
something weird I am facing...
when I am doing `msg = socket.recv(1024)`, then `len(msg)` is 1024. However, when I do `msg = socket.recv(10485760)`, then `len(msg)=8760`...why this can be?
 
> Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by bufsize.
You have to keep calling recv until you have all the data you need.
 
yup I know
I am talking about only one recv() call
is it like the input buffer is capable of holding 8760 bytes only. Hence when I do socket.recv(10485760), it is capable of feeding only 8760 bytes?
 
guyz little help here
 
You use faces as the template name for r_data faces=r_data but keep trying to access r_data in the template?
 
10:31 AM
@Mahesha999 It's undefined how much data a single recv call returns. All you know is that it won't be more than bufsize. Why it returns specifically 8760 bytes, I have no idea. But why does it matter?
 
@Chillie i i tried faces in the template but that too not working
 
was just curious, I was thinking to increase that size so that incoming messages will be read faster...
 
@Chillie no, assume you have method the is called distance(x,y) which returns the distance to point A and that's it.
you can plug in any point you want
 
@AkhilAlexander Please don't post such long pieces of code here. A dozen lines or so is ok, but for longer snippets please use an external site like dpaste or Github gist & link it here.
 
@PM2Ring next time!
 
10:45 AM
@Mahesha999 There's a limit to the packet size that a socket can handle.
 
@someone but given the radius of the circle and free use of that method we can get A's distance from (0,50), (0,-50), (50,0), (-50,0), right?
 
yes
 
Doesn't that effectively give us the position of A?
 
And knowing the position of A, telling if the circle is inside the quadrant is easy.
Even thee distances would be enough, no?
 
10:58 AM
I'm not sure I understand what you mean. How did you get to these points? you can get the distance between (0,50) and the center of the circle but how do you check if it's still in that quadrant?
 
@Chillie Correct. With 3 distances we can determine the coordinates of A. With 2 distances, there are generally 2 solutions.
 
@PM2Ring exactly I thought there must be some size limit put by network...but how can we be sure that MTU is that 8760 bytes limit?
 
still what does 50 mean do you mean the radius because that's the only thing that you can know
 
@someone 50 is the random number i picked for our "triangulation".
if we know the centre of the circle and its radius we can calculate whether its radius is longer that the shortest distances to the absciss and the ordinates axis (i.e. if the distance from the centre of the circle (with coordinates x,y) to either (0,y) or (0,x) is longer than the circle's radius.) If the radius is longer than either one of those distances, that means our circle is not contained within just one quadrant.
 
let's add another method. assume we have translate(x,y) so you can move point A (the center) to any where you want. you can also do (Point A).getQuadrant() which returns the quadrant number
 
11:11 AM
@Mahesha999 Is this over a LAN? That's probably your size limit. That Wikipedia article talks about MTU discovery. Big packets can improve transmission speed, but if packets are too big & get fragmented that slows things down. OTOH, smaller packets are much better for general network traffic, so if there's a lot of stuff on your network then small packets are good for general system performance.
 
@Chillie I did this and it seems to work but I still don't know exactly how :)
xTranslate = (quad == 1 || quad == 4) ? -r : r;
yTranslate = (quad == 1 || quad == 2) ? -r : r;

pointB = translate(xTranslate, yTranslate)

pointA.getQudrant == pointB.getQudrant
 
If stuff is going over Ethernet, then your limit is 1500 bytes, so there's no point using bigger packets since they'll get fragmented as soon as they hit the Ethernet interface.
 
I meant pointB = pointA.translate(.... etc
 
recbg
@Mahesha999 8760 sounds odd :P
 
yup this is over LAN. In fact both client and servers are running on same machine. Also now when do `msg=data_socket.recv(90000)` and then `print(len(message_chunks))` in loop, it prints

1460
1460
1460
1460
1460
1460
1460
5840
1460
2800
how there can be such change in read size? 1460->5840->1460->2800 ?
 
11:19 AM
@Mahesha999 From that output, I'd stick with 1460
 
@Mahesha999 1460 is the size of TCP payload in standard ethereum frame
you shouldn't care either way.
it does not block trying to receive more than 1 bytes...
>>> 5840 / 1460
4.0
the 2800 is the odd one out, I guess that was the end of the packet
so 4 ethereum frames were received and you did get them in one go - good for you
otherwise you'd have made 4 syscalls to read the same data that you could have received with just one.
 
ohhh so data_socket.recv(xyz) is not necessary to return data <= xyz bytes? It might be anything?
 
recv(xyz) if the socket is non-blocking,
will return 1 to xyz bytes, inclusive, if the socket wasn't closed
there is no particular reason for you to pick a small number for this...
nor a particularly large, because it means that you do need to reserve enough ram...
 
@someone I can't tell if I helped O_o What exactly are you saying?
 
@AnttiHaapala Doesn't it increase the chance of fragmentation if your request is too big?
 
11:26 AM
@PM2Ring for recv?!
for send it might make sense to find out what's the actual MTU... to some extent...
ofc there is the Nagle's algorithm etc...
 
I am not getting fully...
First shouldnt it mean strictly just between 1 to xyz bytes? But again it was multiple of xyz and also lesser anywhere...I mean there is no point...
 
@Mahesha999 multiple of xyz where?
msg=data_socket.recv(90000)
since when is 2800 multiple of 90000? :D
 
Admitedly, Mahesha999's server & client are on the same machine, so he should be safe using bigger packets. But I haven't thought about this stuff for years, and I'm a little rusty...
 
@PM2Ring clearly that still goes through ethernet buffers
9
Q: Is there an optimal byte size for sending data over a network?

intargcI assume 100 bytes is too small and can slow down larger file transfers with all of the writes, but something like 1MB seems like it may be too much. Does anyone have any suggestions for an optimal chunk of bytes per write for sending data over a network? To elaborate a bit more, I'm implementi...

 
Fair enough.
 
11:30 AM
my loopback has lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 :D
 
recbg
 
@PM2Ring the only thing where MTU really matters is...
> If you are using TCP/IP over Ethernet, the maximum packet size is about 1500 bytes. If you try to send more than that at once, the data will be split up into multiple packets before being sent out on the wire. If the data in your application is already packetized, then you might want to choose a packet size of just under 1500 so that when you send a full packet, the underlying stack doesn't have to break it up.
perhaps not even so for TCP/IP, but if you design a UDP realtime protocol, you'd be really stupid to not have adaptive packet size, and especially so if you default to something like 1501 byte payload in every datagram :D
 
@Chillie this is clarified a bit more pastebin.com/raw/tFdbswEK
 
12:02 PM
@someone so where do the values on the border belong to :D
 
I wrote a solution but I'm not sure why it works exactly :) Can you find an example where my solution fails? tpcg.io/pADNT4
The solution is the test method
be careful the test method modifies pointA :D
 
12:21 PM
print(test(1, Point(0,0), 100)) prints False but it should print True. A circle centered on the origin passes through all four quadrants.
Unless test is supposed to determine whether only the center of the circle lies within a particular quadrant? But then why would you need to do any math involving the radius...
 
it could be used to determine if the entire circle is in a quadrant
 
the Point(0,0) is not actually in any quadrant in itself so it should be false
i guess
because the circle would be in all of the quadrants
what Andras said is correct
 
Fine. So test should return true only when the circle is in the given quadrant, and not in any other quadrant.
 
yes
 
In that case, the existing implementation is satisfactory. You can conceptualize the algorithm like this: draw a square around the circle and identify the corner closest to the origin. i.e. pointA.translate(xTranslate, yTranslate). If that corner is within the same quadrant as the center, then the whole circle is in a single quadrant.
 
12:30 PM
or you know, just check x/y vs r ;)
 
The whole point is that we can't get r. Assume it's private but python doesn't have that :)
 
Yes, although reverse-engineering the coordinates of the center would require some triangulation, assuming we can't access those attributes directly
 
i mean x,y lol
 
It requires a little bit of trig so we may as well avoid it if we can find the solution with just arithmetic
 
For the record I think it's weird to have a circle without knowing its position, given that a circle is defined by its position and radius.
 
12:33 PM
Mm hmm, you wouldn't see this kind of problem in "real" code
 
it's an extra credit question so I wanted to solve it. This would probably never be needed in real life.
 
You wouldn't criticize the Zebra Puzzle by saying "simply knock on the door of each house and ask if they own a zebra"
 
it's more like taking the slip of paper that says "the zebra is in the fifth house" and putting it in your back pocket to be forgotten forever
 
Anyway knocking on the door doesn't work because the owner of the zebra is a dealer of illegal exotic pets, and he doesn't know whether you're a cop.
You can arrange a meeting with him via craigslist but the rendevous won't be at his house, obviously, and he'll be dressed like the guy on Neighborhood Watch signs, thus eliminating all distinguishing features
 
@AnttiHaapala that was 1460*6
 
12:46 PM
perhaps you can sniff out his tobacco of choice
 
That's exactly the kind of thing that Sherlock Holmes would try to pull
 
@AnttiHaapala sorry off to team break...
I meant 5840/1460 = 4
But then I was mistaking in considering 1460 in denominator. I started thinking the whole stuff as 1460 being effective parameter for `recv()`. But thats not the case. Its still 90000. Its just that sometimes it reads 1 frame of 1460 bytes, sometimes multiple of them, while still staying below 90000 bytes.
 
"Based on the red clay on your shoes, you must be a bricklayer..." orrrrr maybe I walked through a red puddle this morning
 
cbg
 
12:52 PM
@AndrasDeak yesterday someone was asking about how to run python code from within python for his shell ... Is this what they wanted?
`with open('E:\\Certificate\\my_file.txt', 'a') as my_file:
my_output = subprocess.run(['powershell', 'python -c \"print(eval(\'32+11\'))\"'], shell=True, stdout=my_file)
print(my_output.stdout) `
I have 43 in my file now
I'm not sure if I got where he was stuck correctly
 
probably not, they wanted an interactive python shell as far as I could tell
 
You've effectively got two layers of indirection there: running the code via powershell, and running the code via eval. Using just one or the other would be fine*
 
anyway it wasn't very clear, so...
 
(*insofar as it is fine to execute arbitrary user input, which is to say, not fine. But that's a problem with the question, not the answer)
 
hi friends
 
12:54 PM
Hi idjaw :-)
 
recbg
 
In any case, someone wanting to implement their own REPL should probably just use the modules at docs.python.org/3.7/library/custominterp.html, since that's what they're for
 
@Kevin yeah I just wanted to write one example and wasn't really sure what to write there :-p
 
(ok, in the case of writing a REPL it explicitly is fine to execute arbitrary user input, since that's what a REPL is for)
 
yey, I went through subprocess module anyway, didn't know it before so good for me :-D also this wasn't working with 'cmd' and with 'powershell' it works :-D which justifies this
 
1:01 PM
@AnttiHaapala I was thinking what is 1460 exactly? I know Ethernet MTU 1500B - 10B IP header - 10B TCP header = 1460B. Does this apply while doing socket programming in Python...?
 
@Mahesha999 hmm I meant 2800
 
Well, if you're saying "` subprocess.run(['cmd', 'python -c \"print(eval(\'32+11\'))\"'], shell=True, stdout=my_file) ` didn't work so I used powershell instead", that makes sense to me.
 
@Mahesha999 eth max frame size is 1518, less eth headers 1500,
ip+tcp header size is 40 bytes
 
cmd is used to open the command prompt, but I don't think you can tack additional commands onto the end of it.
 
and cbg
 
1:02 PM
Perhaps you could have done just subprocess.run(['python -c \"print(eval(\'32+11\'))\"'], shell=True, stdout=my_file) and skipped any mention of shells entirely. So really you have three layers of indirection.
 
hmmm thats quite a good learning for today
 
(not actually sure if that exact syntax would work because I can never remember how subprocess expects command line arguments to be supplied, but something like that would surely work)
 
@someone sorry, I had to get out for a bit. How does this solution look to you?
 
>>> import subprocess
>>> subprocess.check_output(['python', '-c', 'print(1+1)'])
b'2\r\n'
Just to reiterate, you would almost never need to do this in a serious project. Python does not need subprocess in order to run Python code
 
1:12 PM
that's pypy right there
 
Using subprocess to run powershell to run Python to run eval to run Python code is more like... Pypypypy.
 
make it 8 and call it octopy
 
There's another shell above powershell, since you set shell=True
 
shells all the way down
>>> s = '\'\\\'\\\\\\\'\\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'1+1\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'\\\\\\\\\\\\\\\'\\\\\\\'\\\'\''
>>> eval(eval(eval(eval(eval(eval(eval(eval(s))))))))
2
 
if you're going with that much eval, then put more eval. There isn't enough eval.
 
1:16 PM
@Kevin yup, and it was ['cmd','-c',..]
 
code golf: compose the shortest value of s, such that eval(eval(eval(eval(eval(eval(eval(eval(s)))))))) returns 2.
 
@Kevin this works for commands such as dir, but to run python I couldn't just set it directly and had to send it to either shell or cmd
@AnttiHaapala yeah tried `` :-P wrong one!
 
So you can't run python directly, like subprocess.check_output(['python', '-c', 'print(1+1)'])? That's unusual.
Might be a problem with the PATH... I dunno
 
@Kevin trying this now
 
@Kevin That reminds me of codegolf.stackexchange.com/a/68823/45297 (click "full code here")
 
1:22 PM
Hmm. Are there any strings where s == eval(s)?
 
@Kevin that'd be quine
 
A quine of sorts?
 
@Kevin This runs :-D why was I doing all that last night then :-D was 5 A.M and I was sleepy :-P
yey I read on subprocess now I go and answer all questions incorrectly and come back :-P
 
>>> x=2
>>> for i in range(10):x=repr(x)
too bad reduce misbehaves, otherwise that'd be my take
 
>>> a = "(lambda s:s.replace(chr(81),chr(39)).replace(chr(88),s))('(lambda s:s.replace(chr(81),chr(39)).replace(chr(88),s))(QXQ)')"
>>> a == eval(a)
True
Not the smallest possible evalquine, but it at least proves the concept
 
1:28 PM
@Kevin either the first line is too long or my memory_buffer is too small to be capturing all there is in that line of code! that is LONG!
 
>>> a = "(lambda s,q=chr(39):s+q+s+q+chr(41))('(lambda s,q=chr(39):s+q+s+q+chr(41))(')"
>>> a == eval(a)
True
 
\o cbg
 
did he really put his real token here?
cbg mooing
 
>>> s=(lambda r=repr:r(r(r(r(r(r(r("1+1"))))))))()
>>> print(eval(eval(eval(eval(eval(eval(eval(eval(s)))))))))
2
Guess I didn't really need a quine after all.
 
x = '''"{0}{0!r})".format('"{0}{0!r})".format(')'''
print(x == eval(x))
@Kevin ^here be an eval quine
can be shortened... perhaps
fstrings? :D
 
1:44 PM
@Kevin Am I missing something or can you replace "1+1" with "2"?
 
Any ideas how to show multiple jpeg in a subplot fashion way? tried with PIL but its show() method is very limited
 
"Without using the character '2'" was a condition of the problem that I didn't write, but I did whisper it to a passing sparrow in the hopes it would reach the contest entrants
 
ok let's up the ante.
find x so that x == eval(x), using just standard library but you must not use any string formatting operations, including repr
I just solved this ;)
 
Whenever I whisper to sparrows people just give me funny looks
 
@Kevin ^
 
1:50 PM
My s+q+s+q solution satisfies that criteria, I think
 
ah :D
then I need to tighten it
 
No true scotsman quine uses chr
 
ok... allowed characters are: '()._ and letters.
but then you'd use __add__ ... damn
 
Python is just too darn Turing complete
 
1:53 PM
I propose we add "no 2 consecutive underscores may occur in your solution" to the room 6 standard puzzle rules
 
@Aran-Fey it invalidates my (easy) solution, alas.
 
That's unfortunate :D
 
ok
find x so that x == eval(x), using just standard library but you yourself must not use any string concatenation operations including + , __add__, .format, f-strings, g-strings, superstrings, .encode, .decode, lists, tuples, sets, dictionaries or constructors.
 
Hmm
 
code = '<75 characters go in here, pep8>'
print(code == eval(code))
 

« first day (2907 days earlier)      last day (2044 days later) »