« first day (2492 days earlier)      last day (2472 days later) » 

1:42 AM
Had a quick question ... what exactly is the definition of embedded system?
 
did you try googling exactly that?
 
As far as I know it's a program that exclusively runs on a designated micro-controller which doesn't have to be a fully capable computer
no I have
my question is ... how do i put it ...
for example
at a school
lunch ladies might ring out kids who are buying food
they use "computers" which are locked to specific application intended solely to process payments for lunches etc etc
Yes they are computers sure enough but they are only running a particular program ... I'm not quite sure if it contains a complete OS that auto-starts an installed program which is then restricted only to use that program
or if there is a way to develop a compiled self-contained program without an OS that loads in
in any case ... how would someone go about developing that
I've looked into it but I'll I've found it stuff on Pi and MicroPython and really low level GPIO and LEDs
Is there something that pertains to fully featured standalone GUIs?
@AndrasDeak Does my question make sense?
 
I guess it does, but there's no guarantee you'll have more luck asking here than googling yourself first.
I only have a layman's impression and your guess is as good as mine, so I won't bore you with my own notion of the subject
rhubarb
 
 
4 hours later…
6:16 AM
Hi.. I am new to python. I am creating a restful API using python flask and the database I am using is SQL server connected with pyodbc. I have some problems with my code. Could anyone please help me out
 
Please read rule #2 under "asking a question": sopython.com/chatroom
Fair warning though: It's a saturday and early in the morning, so you're not likely to get help soon
 
Yeah. Hope to get a help soon. Thank you
 
user8392362
6:41 AM
Hi,
 
user8392362
can somebody help me put join on this? # Threads
for x in xrange(thread):

startSleep().start()
time.sleep(0.003)
print bcolors.BLUE + "Thread " + str(x) + " started!"


x=800

if x > 800:
# input of the treads
thread = input("Threads (2000): ")

startSleep().join()
time.sleep(0.003)
print bcolors.BLUE + "Thread " + str(x) + " started!"
 
user8392362
Hi, Rawing
 
I'm not sure what's going on in that code. x=800 and in the next line if x > 800:?
 
user8392362
I want a condition if it gets 800 I want it thread.join()
 
6:46 AM
Okay, let's back up and start from the beginning. You want to do what exactly? You want to start a certain number of threads, and join only the 800th thread?
 
user8392362
I want a thread of threads of threads
 
user8392362
if it gets 800 it will have a new t hreading
 
I don't understand. What's a thread of threads?
 
user8392362
Could it be possible to have a thread of threads?
 
user8392362
like start(800) if 800 start(800) something like
 
6:50 AM
You mean a thread that starts other threads?
 
user8392362
could that be possible?
 
user8392362
like list_of_threads.append(example)
example.start()
for thread in list_of_threads:
thread.join()
 
user8392362
I want it on the above code
 
Hi Rawing, I would be glad if you can solve my problem too. This is how I get all records from my database table.
I want to know how to get a specific record. Plz help!

server = 'localhost'
database = 'PSaaS'
username = 'sa'
password = 'sa@123'
connection = pypyodbc.connect('DRIVER={SQL Server};SERVER=' + server + ';DATABASE=' + database + ';UID=' + username + ';PWD=' + password)
cursor = connection.cursor()
SQLCommand = ("SELECT * FROM PartyOrders")
cursor.execute(SQLCommand)
results = cursor.fetchall()
 
user8392362
Angela, can you do
like list_of_threads.append(example)
example.start()
for thread in list_of_threads:
thread.join() on my above code???
 
6:56 AM
I still don't understand your goal, so I'm going to tune out of this conversation until you start answering the questions I ask and make an attempt to post a proper explanation
 
I am really sorry iann. This is my first ever python program and I am totally new to this language
 
@AngelaAmarapala Sorry, but I have no idea. I've don't have experience with Flask or databases
 
Thank you Rawing :)
 
7:26 AM
@AngelaAmarapalan Not familair with Flask,either. But generally to select a record from a database table, you need to append a WHERE condition. Change your SQLCommand to something like SELECT * FROM PartyOrders WHERE no_of_beers = 1
 
But I don't want the search values to be hardcoded.
 
I have no problem with getting data using SQL. But the problem is with flask and pyodbc. Anyway thank you very much for your suggestion
 
Good luck then.
 
 
3 hours later…
11:01 AM
this edit though...
 
11:45 AM
Cabbage
@wim lifo is a stack, filo is a kind of pastry.
 
12:09 PM
And LIGO is very cool
 
:)
LIGO is cool, although its (physicists + money + time) / results ratio is rather low.
 
12:31 PM
@Rawing Here's another way to get those keys that doesn't require an import:
all_keys = set.union(*map(set, foo))
 
that only depends on the price tag you assign to "staring mother nature in the yamming face"
 
True, and I guess they could've said some time & cash if they'd been able to spend more money in the first place, rather than having to upgrade it several times to get the required sensitivity. OTOH, I guess they've been able to benefit in improvements to technology that might not have been available when they first started.
But the physicists who've worked on LIGO have my sympathy. It must be scary to devote a major part of your career to an experiment that gave null results for so long.
 
cbg
 
:waves at the Canadian Lego™ man:
 
@PM2Ring That throws an error if foo is empty, so it's better to use set().union instead. And then there's no need to convert the arguments to sets anymore, so you're left with Alex Hall's set().union(*foo)
 
12:36 PM
I'm waiting for LISA to be honest
 
@Rawing Ah, right.
I didn't see Alex's code... Well, I guess I must've, but my brain blanked it out. :)
 
I have to admit, it's easy to miss. It's just too darned short and elegant :/
 
@AndrasDeak Yeah, if you want to detect gravitation waves you really need nice big path lengths to measure. And detectors that don't have to deal with a vibrating planet.
 
1:04 PM
I really need to take a look at Qt one of these days... Gtk makes me want to bash my head against a wall
 
I've never really looked at Qt, but I don't mind Gtk (it's certainly nicer than Tkinter, although it's obviously got a bigger learning curve), although I've hardly used it in the last few years, and I only know Gtk2+, not Gtk3.
 
It annoys me how everything resizes itself automatically, but once you add scrollbars to a widget it shrinks to a size where it's practically unusable
which you can "fix" by setting its minimum size, but that conflicts with Gtk's responsive layout/size allocation
and I never did understand how widgets are resized and placed. Half of the time you call widget.set_hexpand(True) or widget.set_halign(Gtk.Align.LEFT) it has no effect whatsoever
^ that was a lie by the way, there is no Gtk.Align.LEFT. There's only Gtk.Align.START and Gtk.Align.END, which correspond to either left or right depending on whether your language is read from left to right or from right to left.
 
1:22 PM
@Rawing Sorry, I can't offer much help there. I'm a bit too rusty, and I gather a lot of that stuff has changed between Gtk2 and Gtk3. But you might get better results using a Table for layout, rather than using the pack methods.
 
Tables are deprecated, Grid is what you're supposed to use nowadays. But don't get me started on those :p
 
1:45 PM
Oh, ok.
 
1:56 PM
What is this suppossed to mean?
state=1
state = state and func()

I don't see why the "and" was added, it doesn't seem to do anything. The state is always sat to whatever value happens to come after the and part.

- This is the snippet of a python code from the editorial on a task on hackerrank.
Link to the full code (26 lines of code) - pastiebin.com/#&togetherjs=fBEki0f6D7
 
I guess it's just for consistency with the following three lines
 
It's still weird
 
DSM
Preserving symmetry in code can often be more important than making trivial special-case exceptions. Among other reasons, it makes it much easier to see patterns.
 
2:12 PM
But don't you think the symmetry would be just as if you had omitted the "state and"
Making it look like this:

state = 1
state = call(x-1,y-2)
state = call(x+1,y-2)
state = call(x-2,y+1)
state = call(x-2,y-1)
 
now you've changed what the code does.
 
In what way? It would always asign the value of the function "call" to state anyway
 
DSM
...
 
state = state and call() is the same as state = call() if state else state and different from state = call()
 
Another way to write it is:
state = call(x-1,y-2) and call(x+1,y-2) and call(x-2,y+1) and call(x-2,y-1)
 
2:16 PM
"if state else state" does that mean, if state is false, it keeps being false?
 
now you've got it
 
@SebastianNielsen are you familiar with truth tables
 
ah so if the first call to the func call is true the state is updated to the value that it returns, if it's false it continues to see if any of the other ones are true?
Not really idjaw
 
it's a very simple concept, and worth taking a look at to understand these types of conditional statements
 
I mean I know how "and" "or" works, if that's what you are referring to
 
2:18 PM
yeah exactly
 
@SebastianNielsen Not quite. The and operator short-circuits, which means that the right-hand expression is only evaluated if the left-hand expression is truthy.
 
I think I get it now, there is just one thing not quite making sense, say we got this:
state = 1 and 2 and 3 and 4
 
So if any of those call() calls evalutes to False then no further calls will be made.
 
it would update state because all is true
 
>>> 0 and 0
0
>>> 0 and 1
0
>>> 1 and 0
0
>>> 1 and 1
1
 
2:20 PM
@SebastianNielsen Yes, so state would end up being set to 4.
 
Because it always assign the last value right?
if the statement is true
 
>>> d = 1 or 0
>>> d
1
>>> d = 1 and 0
>>> d
0
 
@SebastianNielsen Here's an answer I wrote last year that you may find helpful. Sorry it's in Python 2. stackoverflow.com/a/36551857/4014959
 
I get it now, thanks! :D
 
Hey, can anyone help me with openpyxl, i have a problem that all my cells data types are changed to TIME format after i import some data into the sheet. is there a property that i can edit to change it back to number?
 
2:29 PM
@Mike.G Looks like you're looking for cell.number_format
 
Dont think so, i mean if you open excel you hava dropdown to select frm Date,Number,Text,Custom,Currency... etc... im looking for that property
 
@Mike.G what is that called in excel? Is there a proper name for the thing you are looking for?
 
Pretty sure that's all handled by the number_format property. You can see in the example code that they're using it as a date format
 
Anyone using docker that can try logging into their service using docker login? I'm inputting the correct username and pw but cannot login. I wanna know if it's me or them.
 
@Rawing, thing is dont want it as a number :) i want it plain text
 
2:37 PM
Nvm I got it, apparently it's different logins for docker and dockerhub :)
 
@simeg This doesn't really have anything to do with Python.
 
@idjaw No I know, but people are usually very helpful here and I needed some help.
And I'm about to deploy a Python application to Heroku so it's related for me :D
 
DSM
Aww, I was preparing my 'countdown to "but this is where the light is"..' line, and the OP beat me to it. :-/
 
(using a Docker container)
 
@Mike.G Not sure how to do text, but you can try cell.number_format = 'General'
 
2:40 PM
@Rawing, will try.
 
There's a constant FORMAT_TEXT in openpyxl.styles.numbers
 
2:53 PM
@Rawing setting it to general did help to change the type from "TIME" to "General" , now i need to make this to a few columns.
 
What is a graceful way of quitting a Python application? Right now I raise an exception, log the cause and do a quit(). I'd like it to show in the console the exception + the reason
The equivalent in Java would be to throw an exception and add a message inside of it
 
what kind of application is it
 
wim
how do you quit if you just raised an unhandled exception?
 
if it is a service are you sure you want to outright kill the app?
 
Ok it's not really an application, it's a script that will run once every day. If the exception is thrown the script should terminate immediately.
 
wim
2:58 PM
but that's what happens anyway when an exception is thrown and not handled
(unless you've screwed with sys.excepthook)
 
Ok so that's how I should do it, got it. Thanks.
 
Funny. Looking up "python" in SO search returns the tag result. Looking up something else, like docker for example does not "tag" the result for me and I have to explicitly do [docker]
 
SO is biased for Python
 
@simeg raise SystemExit('Bye')
 
raise SystemExit('You messed up yo. Be better next time.')
 
3:06 PM
@PM2Ring I don't like that exception, it doesn't tell me anything :/
Working with Python feels really free after working with Java for a while, I really like it
but the data structures are confusing, list, dicts
 
confusing in what sense?
 
wim
Don't use SystemExit. It makes writing the tests slightly annoying.
 
if you are running things in a container I don't see why it just doesn't run as a service and logs failures but stays alive
on-demand inside a running container seems strange to me
 
Is it just me or does this question not make a whole lot of sense? Though part of it is because it's python 2.
 
@idjaw Yeah maybe a container is overkill, not sure. Haven't published a container to Heroku before so I'm seeing it as a learning opportunity too.
 
3:14 PM
Well. You can do whatever you want. I don't want to be that guy that shames you for doing things a certain way.
 
wim
yah. I'm that guy
 
haha
<3 wiiiim
 
wim
 
dramatization of a recent wim code review session
 
@idjaw I know I can do whatever I want :) But it's always nice to hear other people's opinions, and you certainly have a point. A script inside a docker container? It's weird.
 
3:18 PM
If you want to really have fun with docker. Turn that Python script in to a service and expose it to be hit by some endpoint
see how docker works at that level with how it ties things together
how the networking and security works
a simple application that you just hit and then mess around with the docker parts
 
Yeah that's an idea.. maybe I'll do that. That would be for the next iteration, step 1 is to get it up and running.
 
Is your example code Python 2 or Python 3? — wim 4 mins ago
wim pls...
 
@simeg good plan
 
@wim
for s in ['"A\u0026B"', '"A&B"']:
    print s, list(s)
#output
"A\u0026B" ['"', 'A', '\\', 'u', '0', '0', '2', '6', 'B', '"']
"A&B" ['"', 'A', '&', 'B', '"']
 
wim
missed the print statement
yech, python 2 :(
 
3:33 PM
I've posted a somewhat clunky answer, but I also advised the OP to migrate to Python 3.
 
wim
this question is highly suspicious
you can't "know" that '"A\\u0026B"' was encoded with unicode escape
it could just be the bytestring '"A\\u0026B"'
it's the common mistake of people assuming that the bytes themselves should be able to tell you what encoding they're encoded with
no, you have to know that in advance :)
 
Indeed. So there's no foolproof method.
 
wim
I'll edit my answer into shape to try and describe this
 
FWIW, I always thought it was a really dumb move for Python 2 to permit non ASCII in plain string literals. If you want non-ASCII literals use a yamming u string.
 
wim
you mean the # coding declaration thing?
 
3:42 PM
@wim No, you'd still need the # coding directive so the interpreter knows how to decode your source. I'm saying that s = 'Война́ и миръ' should be a syntax error in Python 2, just like s = b'Война́ и миръ' is in Python 3, and if you want Unicode literals you need to use an actual Unicode string s = u'Война́ и миръ'.
 
Why does return return None? I'm confused, could someone take a look at this snippet? dpaste.de/ZP7S
 
wim
@PM2Ring hmm, I'm not so convinced
I think it's more complicated than you're assuming
 
@simeg Because every Python function has to return some object. And if some return path doesn't return a specific object then None gets returned.
 
Hmmm... is there no unicode character with a code point between 0 and 9999 that's longer than 5 bytes if encoded with utf-8?
...I guess I could write ~3 lines of code and find out
Looks like there isn't. I guess that makes @PM2Ring's answer correct.
 
@simeg some languages differentiate between functions (which return values) and procedures or soubroutines (which don't). In FORTRAN-77, for example, a procedure call had to be a standalone statement. Python simplifies things: it allows any expression as a statement (as well as the keyword for, if and so on statements). It simply throws away the value of the expression (except in the interactive interpreter, when its repr() is printed and it's bound to the name _).
 
3:53 PM
@Rawing What's UTF-8 got to do with it? I'm comparing the number of bytes in the original string to the number of codepoints in the decoded version, and that will only be less than the original length if the unicode-literal decoding managed to decode a \u sequence. I think. :)
 
Alright. Downloaded all the things I needed. I'm getting off the internet today. $%*^ is crazy
rbrb
 
This allows you to use functions as procedures. If the return value of a function is never intended to be used, it's conventional to write ` return without a value, but to keep everything straight (all expressions must have values) the interpreter treats that as a request to return None.
 
wim
0
A: How to determine if a string is escaped unicode

wimYou can not. There is no way to tell if '"A\u0026B"' originally came from some text that was encoded, or if the data are just the bytes '"A\u0026B"', or if we arrived there from some other encoding. How do ... you know whether or not to run .decode("unicode-escape") You have to know if...

updated
 
@PM2Ring Well, AFAIK python 2 strings use utf-8 encoding. A unicode escape \u1234 has 6 characters. So if there was a unicode character that takes >5 bytes to encode with utf-8, then the decoded string wouldn't be shorter.
 
wim
@Rawing you might want to remove obsolete comment
 
3:57 PM
Gone.
 
If your function returning None is a part of its specification, it's good practice to explicitly write return None even though return is entirely equivalent.
 
@holdenweb Thanks for the detailed explanation
 
@Rawing Each item in a Python 2 Unicode string is a codepoint. Take a look:
def decoder(s):
    y = s.decode('unicode-escape')
    return y if len(y) < len(s) else s.decode('utf8')

for s in ['"A\u0026B"', '"Война́ и миръ"']:
    z = decoder(s)
    print s, z, len(s), len(z), [c for c in z]
#output
"A\u0026B" "A&B" 10 5 [u'"', u'A', u'&', u'B', u'"']
"Война и миръ" "Война и миръ" 26 15 [u'"', u'\u0412', u'\u043e', u'\u0439', u'\u043d', u'\u0430', u'\u0301', u' ', u'\u0438', u' ', u'\u043c', u'\u0438', u'\u0440', u'\u044a', u'"']
 
wim
> python 2 strings use utf-8 encoding
what do you mean?
the unicode implementation detail is UTF-16
and python 2 strings "use" whatever encoding you encoded them with
 
@idjaw \o
 
wim
4:04 PM
I think I can find a counter-example for PM 2Ring idea
 
So yes, the original "Война и миръ" string uses the coding specified in the # coding so its got UTF-8 bytes in it. But the decoded version has codepoints, which are represented by u'\uxxxx
 
@wim ...true. I forgot those -*- coding:garbage -*- headers were a thing.
 
s = u'"Война́ и миръ"'
a = list(s)
print a, len(s), len(a)
#output
[u'"', u'\u0412', u'\u043e', u'\u0439', u'\u043d', u'\u0430', u'\u0301', u' ', u'\u0438', u' ', u'\u043c', u'\u0438', u'\u0440', u'\u044a', u'"'] 15 15
 
@PM2Ring Ah, you're right. Guess there are no holes to be found in your answer.
Unless I find a way to prove that 1 >= 6
*ponders for a moment* Nope, can't do it.
 
@Rawing Oh, I wouldn't be surprised if there were holes. :) I did say it was clunky.
Weird. I just got a downvote on this: stackoverflow.com/a/45649755/4014959
 
4:10 PM
Wait, the guy who puts his import in his classes got 4 upvotes?
Maybe I should re-read that question
 
@Rawing His updated version is even worse: he moved the imports into his __init__ methods. :facepalm:
 
Fast-forward a few revisions into the future: He now imports the function every time he wants to call it :)
 
wim
haha, I used to do that when I was a complete n00b
 
@Rawing Even though he has some misguided ideas the question is still nicely written.
 
wim
cringe
 
4:18 PM
I don't care about losing a few points, but I do care that the negative score makes it look like my answer contains technical inaccuracies &/or is giving bad advice.
 
Reminds me of back when I couldn't grasp the difference between import a and from a import *. Good times.
 
Which reminds me... I hate how the example code in the standard docs (and many 3rd party module docs) is generally written to work with star imports. It makes it so much harder to convince newbies not to use star imports.
 
@simeg A genuine pleasure. That's what old farts are for. They hold on to what they can remember and pass it on so it doesn't die with them ;-)
 
wim
@PM2Ring maybe it is giving bad advice (TL;DR)
 
@holdenweb =)
 
4:25 PM
@PM2Ring it's convenient to be able to write complex examples without module-name prefixes, but I agree that importing the specific names used would be a much better example of good practice.
Starts to wonder whether he used from module import * in the Nutshell
 
And I guess repeating the module name all over the place would add clutter to the docs. OTOH, it would show people what the code looks like in a real program. On the 3rd hand, I often do stuff like from random import seed, randrange and from itertools import product, groupby if I'm only going to use a couple of names from a module, and those names are sufficiently distinct.
 
Speaking of which, I am now so keen to find Android developers (and if they aren't afraid of Python that's a bonus) I am offering a free copy of Python in a Nutshell, 3rd Ed for any introductions.
 
Thankyou, anonymous upvoter! :)
 
@PM2Ring How many hands do you have? :s
 
wim
I could not find counter-example
 
4:32 PM
@Rawing Actually, I have no hands, since I'm a sentient rhombic dodecahedron, as you can see from my avatar.
 
wim
but this is suspicious:
def decoder(s):
    y = s.decode('unicode-escape')
    return y if len(y) < len(s) else s.decode('utf8')
how do you know that the s.decode('utf8') part will work? (answer: you don't)
 
@wim It'll always work if s is a string literal in a script with the UTF-8 coding directive. If it's not a string literal, the the OP needs to clarify the question.
 
wim
LOL, come on. This is obviously not a string literal in a script, it's some data coming over a socket or out of a file
If it was a string literal in a script, they don't have the question in the first place (they just look at the literal and see if it has a unicode escape in it) :)
 
It may be obvious to you, it's not obvious to me.
 
wim
anyway, I think you are giving them a hack and a crutch that will not help them in the long run
@PM2Ring no
# -*- coding: utf-8 -*-
s = '\xff\xfe\xac '
s.decode('utf8')
 
4:41 PM
@wim Oh, ok. I see what you mean.
 
4:54 PM
Certainly for literals in the program it's best to specify an encoding, but it's not unknown to have to unscramble data where (_e.g.) different components have modified rows of a database table randomly in a specific column, so some values are encoded and some values aren't.
 
I am having networking issues. My application sends tcp data to a server as part of GUI clicks. However, I also schedule regular tcp data to be sent every 100ms. These frequent messages are mixing together with my user-clicked data on the server side. Can someone recommend me a way around this? Should I use a separate tcp/udp connection for the more frequent data? I'm using socket module on python side, winsock2 (c) on server side
 
5:20 PM
Yup, use two separate connections is the simplest way
Otherwise you have to design a protocol that allows the application to demultiplex the two streams.
 
5:38 PM
@vaultah: you do know we can't respond to comment flags, right?
We have three options: delete, edit and decline. Responding is not part of those options. I've edited the comment in question.
 
@MartijnPieters after reading this I assumed that you can. I've also got a few flags declined with custom reasons before, so...
 
@vaultah I fail to see how the post you linked has anything to do with flagging comments.
 
Okay. I expected my flag to be declined, and explanation to be written as the custom reason. I did not know that comment flags are handled differently from post flags.
Thanks
 
Like comments themselves, the functionality around flagging them is limited too.
Until recently, we couldn't even (officially) see who flagged a comment (there was an elaborate way to reveal that info anyway with a userscript).
 
5:58 PM
weekend cabbage!
 
random people (cc @PM2Ring), do you think generating points on a unit sphere using normalized normals (3 normal random variables per point) is competitive in terms of speed?
it's really straightforward but this part should be as fast as possible
 
@AndrasDeak Sounds ok, but if the distribution is important beware of en.wikipedia.org/wiki/Bertrand_paradox_%28probability%29
 
thanks for the tip, I'll look into that
It shouldn't be too important as long as it's almost uniform, I'm looking for ~ an energy minimum
 
Here's how to do it properly if you want a uniform distribution: math.stackexchange.com/questions/1585975/… and math.stackexchange.com/questions/114135/…
 
thanks, I'm aware of the arccos version, but that sounds like much more work
2 uniform randoms but inverse trigonometrics...
 
6:13 PM
Doing normalized normals isn't uniform since you're scaling vectors in a cube, so you get more points along the long diagonals and less points on the vectors approaching the centres of the faces.
 
nope, not for normals
that applies to using three uniforms, which are grossly non-uniform
there's no cube with normals, those are unbounded
 
@AndrasDeak Ah, got you.
 
actually, I'm starting to suspect that Bertrand doesn't apply either
so the question is speed vs the arccos thing
guess I should time it...
 
 
1 hour later…
7:27 PM
Is anybody here?
I have a problem:
In pygame:
: Code
The box in the code can move left , right with a , s.
How can I move it up and down?
Note: Use ping when answering me
 
@MuhammadNouman You should ask your question on the main site. There are many more people there than in this chat.
You are more likely to get an answer on the main SO site if you are patient enough.
 
8:05 PM
hey, gnat
 
hey @AndrasDeak just wanted to ask if Python folks have enough 20Kers to cleanup this mess in canonical Q&A
 
they definitely do, in case there's will too:)
I guess most of them think that -4 is enough for that not to do much harm
I'm <20k so I can only watch:)
quite a lot of regulars here are well above 20k
I'm not sure how many were around when that Q&A was last discussed here though
 
8:47 PM
Hello :) Is anyone here familiar with vowpal wabbit?
 
9:09 PM
@gnat Gone
 
 
2 hours later…
10:47 PM
AttributeError: recognitionClass instance has no attribute 'copy'
 
yup
 
class recognitionClass:

    def __init__(self): pass

#----------------------------------------------------------------------------------------

    def getRep(imgFrame, multiple=False):
        bgrImg = imgFrame.copy()
 
if you want that to be a staticmethod, use @staticmethod on it
 
I am able to do this (use the copy function on an image) in a normal script but not in my class apparently. the copy function is defined in cv2, which I already imported.
 
if you call it as my_obj = recognitionClass(); my_obj.getRep(...), the first argument passed will automatically be the object itself
just like __init__
 
10:48 PM
@AndrasDeak ok yes
 
if you don't need the instance, put @staticmethod before the definition, in that case my_obj.getRep(...) won't get the object as the first argument
either that, or put self in the method definition
depends on your use case
 
def @staticmethod getRep(imgFrame, multiple=False):
?
 
no
please read about decorators
just google "staticmethod python"
 
@AndrasDeak OK I ll do that
thanks :)
 
hint: there's a really good SO Q&A
 
10:55 PM
btw is it common practice when writing python to eg delimit every function in a class using
#--------------------
 
definitely not
that's verbose and distracting
 
I know in low level programming languages like assembly that is totally OK
 
the whole of python and its major third-party libraries are open source, so you can look around github for the style
 
but only using inenting in Python sometimes makes it difficult to have a proper overview imo
 
well that's your opinion, but common practice is not that
for an in-depth official view of code style, see PEP 8
 
10:57 PM
@AndrasDeak already read that ;)
 
well, the common practice is more or less PEP 8
 
@AndrasDeak by common practice you also mean in big companies?
 
I'm sure that depends on the company, and I've never worked at one.
 
@AndrasDeak student?
 
nope
 
10:59 PM
@AndrasDeak prof?
 
close
 
I see
@AndrasDeak do you happen to speak or understand Russian?
 
I happened to learn it for 4 years in high school, and I was in the top 10 of my year in the national Russian competition. Unfortunately I haven't used it in a long while and I understand very little.
 
I have no idea how close Hungarian is to Russian. I guess not close at all
 
yup, not close at all
we have a bunch of Slavic loan words, but the languages are nothing alike
 
11:21 PM
@AndrasDeak
Traceback (most recent call last):\n File \"<string>\", line 1, in <module>\n File \"/home/yalishanda/openface/demos/recognitionClass.py\", line 5, in <module>\n import alignDlib\nImportError: No module named alignDlib\n

I am able to load that module from my command line in the virtual environment but am unable to load it from my C++ code. Any idea's?
 
I guess you need to figure out how to load a python module from your C++ code.
it's also entirely needless to ping me with your essentially unrelated and underspecified new problem
 
@AndrasDeak well I am able to load all the modules except that one
it is related to some extent because all I am doing in my cpp code is passing a command (the same I write in my command line) to the python virtual environment
it does receive it (based on the structure of the error message)
 
perhaps there's a different path when you're using C++
I assume there is code involved and there's also a bug
the key is to find the bug, and the problem goes away
 
@AndrasDeak what makes you think the cause of this issue is a bug rather than something I may not know about python?
 
I'm making wild guesses based on the code you provided :P
 
11:33 PM
don't be so wild
 

« first day (2492 days earlier)      last day (2472 days later) »