« first day (3516 days earlier)      last day (1418 days later) » 
01:00 - 20:0020:00 - 00:00

1:02 AM
Anyone know how to install tensorflow's object identification API in pycharm?
 
 
1 hour later…
2:23 AM
Anyone know how complicated this is: ```import math

l = list(string.ascii_lowercase)

newl = []

for i in range(int(math.sqrt(int(len(l)**2)))):
newi = (math.sqrt(i ** 2) * 5)/5
newl.extend(l[int(newi)])


stringToReturn = (newl[7] + newl[4] + newl[11] + newl[11] + newl[14] + " " + newl[22] + newl[14] + newl[17] + newl[11] + newl[3])

print(stringToReturn) ```
 
2:57 AM
Hello or cbg :) haven't been much of an user here
Can I ask questions here regarding how I can design my python application?
 
@python_learner You can ask away. No guarantees on answers.
 
wow, I get an alert here, thought this chat was normal
I am planning to do two versions of my app in parallel. One will be using PyQt and other will be using flask.
I have not used an ORM so far, and I have done some research and understood that SQLAlchemy is mostly used and there is flask-sqlalchemy as well, my question is, if I wish to make the database common I both versions, can I do this with flask's version of sqlachemy
in*
 
3:14 AM
I can't answer that, looking at SQLAlchemy is something I'm planning on getting to in the next couple of months. From what I understand the Flask extension is a thin wrapper on SQLAlchemy, so ... Also I presume that as long as the schema are common etc, the connections and interactions with the database will be the same, as far as the database is concerned?
 
its the exact same app, its just being displayed as a gui and a web app, so all inputs and what I want to save will be the same
I find SQLAlchemy to be huge having done nothing with it so far, so it is possible to not reinvent my tables again if I have done so in normal SQLAlchemy
Also I find it hard to wrap my head around ORM, is it really better than writing your own queries? I find that to be less difficult.
 
3:29 AM
I am heading out for now, would greatly appreciate if anyone can add more suggestions to what I asked, have a nice day, rbrb :)
 
4:26 AM
@roganjosh Hmm, I don't think so: that one's not the usual simple case of "remove duplicates with identical values in two columns A,B" because the OP further wants to find the row with max value in column C, so we can skip using drop_duplicates and do a groupby() and then max(C).
Reasking: Needs more details, also no MCVE stackoverflow.com/questions/58390928/… @roganjosh, it badly needs closing, I don't see the point quibbling which of multiple viable close-reasons we should use.
@MisterMiyagi Deleted
 
user13004974
4:55 AM
If anyone help me in this issue:

https://stackoverflow.com/questions/62102358/how-to-run-a-python-scipt-and-create-a-string-xml-file-for-translation
 
5:16 AM
cbg folks! It's been a while
 
6:11 AM
@PranavBhatt please review the room rules; you are allowed to bring up a post here when it's eligible for a bounty (minimum age 48 hours)
also, if your question is "how do I avoid being blacklisted" or "where can I find another similar service", both are unrelated to programming and thus unsuitable for Stack Overflow (and the fact that I can't tell also makes your question unclear)
 
7:01 AM
Been trying this for last 5 mins...
Still can't figure out what's wrong
n1, n2 = map(float, input().split())
print(int(n1*n2))
 
Well, what error do you get?
 
Well, no error, the answer comes out wrong, which one sadly can't see
My code does pass the trial test cases
 
Okay. Do you have the input, perhaps?
 
Yes
0 < A < 10^12
0 < B < 10
A is n1
B is n2
 
that function expects two float numbers as input, not an expression
 
7:07 AM
 
works fine if I type
12.3 45.6
as the input
 
@tripleee Which function?
 
but obviously breaks if you type in something else than two floats (such as only one float, or three floats, or something else which isn't two whitepace-separated floats)
@d4rk4ng31 well, sorry, expression
 
That is how the input is going to be given
That's the input format
specified
 
how do you know the input part is failing? what output do you get?
 
7:11 AM
One can't see the output
Try submitting the question
*answer
Well?
 
your code gives the expected outputs for me
 
That's what
Their test cases cannot be viewed
 
I tried the examples on the page and they work
 
Yeah
I know
 
without any additional diagnostics I can't help, maybe somebody else in here is familiar with that site
or maybe you can show us exactly how to repro
 
7:14 AM
Will I be asking too much if I request you guys to try and submit the answer?
For diagnostics, you need to log in and submit
 
the top answer on the leaderboard is quite similar to yours atcoder.jp/contests/abc169/submissions/13917724
 
from decimal import *
a,b = map(Decimal,input().split(' '))
print(int(a*b))
 
the main difference is that they use Decimal instead of float - I'm guessing maybe some of the input requires arbitrary precision rather than regular float arithmetic
 
this you mean?
 
yup, that's what I linked to
 
7:17 AM
Oh!
OKay lemme try with Decimal
Yay!!
Thanks :)
 
user13004974
7:31 AM
@tripleee Ok
 
@d4rk4ng31 that is not what the problem description states.
 
7:58 AM
Okay <= sorry, My nad
*bad
 
8:45 AM
I wonder if there's a library (other than gast) that'd allow parsing both Py 2 & 3 to some common AST, that's not necessarily the official one.
If not, I'll have to start using subprocesses :(
 
You may want to checkout what backend black is using. They're Py2 and Py3.
 
Good pointer, thanks.
In [14]: ast27.parse("""
    ...: print "test"
    ...: """)
Out[14]: <typed_ast._ast27.Module at 0x7fb33c7fbba8>
This might work out...
 
 
1 hour later…
10:20 AM
Are iterators faster than lists? [I know they use less memory]
 
Depends. If you're looking for the length then no.
 
Are iterators faster than list iterators, you mean?
 
@AjayMishra As you might have learned by now, "A is [adjective] than B" needs very specific A and B to be answerable
 
yeah, I wanted to know this:
 
crystal ball: genex vs listcomp
 
10:23 AM
k = product(some lists)
for i in range(len(k)):	a = k.pop()
or
try:	while True:    a = next(k)
Where product = itertools.product
 
never the latter...
for a in k:
    ...
And why pop of all things?
Where did you pick these up?
 
I wanna use them without maintaining memory.(is that bad?)
 
You are knee deep in an XY problem. Tell us the X instead.
 
That's exactly the problem that iterators solve. Just loop over the product
 
@AndrasDeak I was solving a game
and I was timing out, I thought it would be better to try some micro-optimization than changing the algorithm.
 
10:28 AM
Yeah, no. Your problem is probably that you have 10**10**10 iterations or something like that. Making it marginally faster to loop won't help. (I didn't load the game though due to javascript)
@AjayMishra your two options would be for a in k in both cases. Just swap between a list k and an iterator k. The two lines of code you offered are both bad
 
:D(got it, I have to change the algorithm)
 
Hello
How can i get the tinker widget font size?
I try widget.cget("size")
with widget.cget("font") --> TkDefaultFont
 
try font['size']
 
AttributeError: 'Label' object has no attribute 'font'
 
attribute...?
 
10:36 AM
widget['font']['size']
 
self.now_playing['font'] is just a string
 
ok? What does that have to do with anything?
 
3 mins ago, by Chris P
with widget.cget("font") --> TkDefaultFont
that seems like a Font
 
Yes but inside TkDefaultFont there is no any property.
I suppose...
 
Property?
 
10:39 AM
Like font["size"]
or font.size
 
uh, OK
I remembered I had to do that thing
 
0
A: Getting the default font in Tkinter

Terry Jan Reedyidlelib/help.py has this line: normalfont = self.findfont(['TkDefaultFont', 'arial', 'helvetica']) where findfont is defined thusly: def findfont(self, names): "Return name of first font family derived from names." for name in names: if name.lower() in (x.lower() for x in ...

 
>>> Label()['font']
'TkDefaultFont'
wow
 
oh, that's the actual string
If only there was a way to say that in clear terms. Or if the interpreter said something informative in this case :(
maybe in python 4
 
Ok i will just set it to 9.
 
user12267139
10:45 AM
Im trying to implement this function
 
user12267139
listoflist = [[None, None, None, None, None, None, None]]

def loop_over():
        for i in listoflist:
            # if all elements are type flaot and in range of 12 <= i <= 20

            # return True

            # else return false

loop_over()
 
user12267139
how to loop over all elements and get a return ? so far I can only get an return one by one
 
Is this homework?
 
user12267139
nope trying impleemnt something
 
user12267139
implement
 
10:46 AM
Have you read a python tutorial yet?
 
take a look at the all function
 
user12267139
@Aran-Fey thanks
 
hey
 
Hello
 
10:49 AM
Is there any way to also get the coordinates of val here (magnitudes is a 2d numpy array)
   for val in magnitudes[magnitudes > snip] :
        print(val)
 
Welp, still no Py2 parsing, and plenty of possibilities for false positives and negatives, but here's a little list of questions (and their answers) that may contain SQL injection: saarni.kapsi.fi/sqli
 
I'd store magnitudes > snip and use that to index into coordinate arrays
Or use.nonzero on that bool array
@RandoHinn ^
 
user12267139
I used the all function
 
user12267139
listoflist = [[14,12,13,None]]

if all([element is type(float) and 12 <= element <= 20 for element in listoflist]):
print("true")
 
user12267139
how can I implement the range condition ?
 
10:56 AM
? you already have
your type check is broken, though
 
Wow... the django-rest-framework github is blowing up a bit with a recent choice made by the site managers...
 
in a good or bad way?
 
well, they've taken down the site and put a static page in solidarity with what's going on in the US at the moment... so - it's both I guess
 
user12267139
@Aran-Fey where is the error ?
 
it's... just... completely wrong. No idea where you got that from, but you should google how to do it correctly
 
11:09 AM
22 mins ago, by Andras Deak
Have you read a python tutorial yet?
Until then you are making the mistake of cargo culting
 
11:25 AM
Hello, I would just like to ask for your help. Is there a way to get the sum of a list in a nested list? For example, a = [[2,3],1,[3,4]] and have an output like this: [5, 1, 7]? Thank you!
 
@Acee yes. Define a function that returns the number of it gets a number and the sum of the list of it gets a list. Then apply that function to your list in one of multiple ways.
 
will this code work? fitness = []
for elem in sub_fit:
fitness.append(sum(elem)) if isinstance(elem, list) else fitness.append(elem)
print(fitness), what for the case of an array?
 
@Acee 1. please see our code formatting guide to chat and practice in the sandbox if necessary. 2. try and see what happens?
 
11:41 AM
Oh, sorry! Anyway, I got it! I use numpy to change the list into array. Thanks!
 
Hello, i need some help with converting a integer into datetime type.
dt = 20131210135959
and im trying to converting with
datestring = datetime.strptime(str(dt), "%y%m%d%H%M%S%f")
but for somereason this is the output:
2020-01-31 21:01:35.959000

the year gets messed up why?
i mean the whole date parts is messed up, only time part is correct
 
sorry, I misread
 
you probably want %Y I guess
 
oh god, yeah that fixed it :D
 
11:51 AM
thanks
 
12:37 PM
> You're receiving this email because your Stack Overflow activity triggered this tip or reminder.
what a bald-faced lie
 
Is there a function in datetime to "round" microseconds? say i want microseconds with 4 decimals instead of 6 that im getting now?

Or do i have to convert to string and [:3]?
 
>>> now = datetime.now()
>>> now
datetime.datetime(2020, 6, 1, 14, 48, 7, 906649)
>>> now.replace(microsecond=round(now.microsecond, -2))
datetime.datetime(2020, 6, 1, 14, 48, 7, 906600)
 
1:05 PM
doesnt remove the trailing zeros though, but works otherwise, thanks
 
"906600 microseconds" is 0.9066. "9066 microseconds" is 0.009066.
10^-4 doesn't even seem to have a proper SI prefix name
> Other obsolete double prefixes included "decimilli-" (10−4), which was contracted to "dimi-"[12] and standardized in France up to 1961.
so you want dimiseconds :P
 
cbg
@Nanoni what are you planning to do with those 4-digit "microseconds"?
 
1:28 PM
In short what im trying to do is compare 2 datetime values and calculate the difference within 4 milliseconds.

For example:
2015-12-23 23:59:59 - 8302 milliseconds = 2015-12-23 23:59:58.169800
but i want 2015-12-23 23:59:58.1698 to be the output.
 
so rather than "4 milliseconds" you want the difference within 0.0001 seconds, right?
Why not take the difference of datetimes (to get a timedelta) and massage that into a format that you like?
>>> backthen = datetime.now()
>>> now = datetime.now()
>>> delta = now - backthen
>>> delta
datetime.timedelta(seconds=4, microseconds=916154)
>>> delta.total_seconds()
4.916154
>>> round(delta.total_seconds(), 4)
4.9162
Actually, your example is not "compare 2 datetime values and calculate difference". It's "compute a datetime from a datetime and a delta"...
so I'm wondering if this is an XY problem
 
True, im doing this:
true_time = datestring - timedelta(seconds=ms)
 
And again "- 8302 milliseconds" is problematic for the aforementioned reasons
Why the 4 digits? Are you reading that as user input or something?
 
sec
 
looking at the datetime docs I can't see an obvious way to round your micros like that
And I hope you're only trying to do this manipulation for printing, not for an internal representation of your object.
if it's reasonable to subclass datetimes (I have no idea) you can implement a wrapper that hacks the stringification...
 
1:43 PM
Oh yes, the 4 digit round up is for priting only, kinda having a hard time really explaining what im trying to do here, since its kinda complicated, or not really just takes ages to explain properly :)
 
Sure thing. I just have a nagging feeling that we're trying to solve the wrong problem. But I'm out of ideas and I understand if it's too complicated to explain :)
Neither the python docs nor strftime.org mention anything other than %f for microseconds, which produces 6 digits.
 
Too bad it's four decimal places you want and not three, because the latter is supported by isoformat
 
I bet it's because of milliseconds
 
Yeah
 
I am reading a 32bit binary datafile that has a timestamp (8bits) before every dataframe.
Sometimes at the beginning of the file there might be few milliseconds worth of data before first timestamp but we cant access it since we dont know the exact starttime of the file.

So i we divide the first incomplete frame with full frame and we get the amount of milliseconds there is data before first timestamp and then we can calculate the truestart time of the data. ill give an example...
 
1:55 PM
Well, I've officially built a program that allows me to read a forum's thread without clicking "Next page"...
 
Nice 👍
 
We're just getting started ^.^
 
On more than one occasion I've worked around the user-hostile design of a web page with liberal application of requests and beautifulsoup
 
@JossieCalderon not the best choice for an example post, but good job
 
Yeah, sorry Andras. Realized that too late
 
@Kevin I used lxml this time
 
that reminds me I need to fix my JS automatic-next-page locator. I've been manually finding and clicking "next page" links/buttons like a savage
 
First_timestamp = 2015-12-23 23:59:59
Datapoints before first time_stamp = 127056
Full frame = 156250
127056/156250=0,8131584‬

2015-12-23 23:59:59 - 8134584 milliseconds = 2013-12-10 13:59:58.186900 < true starttime of the file
So thats what im trying to accomplish if that makes sense :D
 
@Nanoni still not "milliseconds"
right?
 
it is? no?
 
2:01 PM
8134584 milliseconds == 8134.584 seconds
milli- means "one thousandth"
 
0.8302 ms
 
0.8302 ms == 0.000832 seconds :D
 
Once you get the true starttime of the file, what do you intend to do with it? Convert it back into an 8 bit timestamp? I feel like that should be possible without having to do a round trip through strftime or whatever strategy you might use to chop three digits off the end of the time
 
Oh im not the one that has to do the conversion back, i just need to find the truetime's and print it to a file and someone else does the rest :D
 
Ah, good old departmental inefficiency. I know it well.
 
2:04 PM
i do just what im told ^^
 
Same.
 
Well i am getting the right end results now, so ill just convert the datetime to a string and take out the last 2 digits from the datetime and print it to .csv, seems easiest
 
>>> datetime.strptime('2015-12-23 23:59:59', '%Y-%m-%d %H:%M:%S') - timedelta(milliseconds=8134584)
datetime.datetime(2015, 12, 23, 21, 44, 24, 416000)
 
Yeah I'm inclined to say that there isn't going to be an easier solution than "convert to string and [:3]"
 
@Kevin [:-2]?
 
2:07 PM
This assumes you're fine with a string like ".499999" getting truncated to ".499" instead of being rounded to ".500". Can't get that with just slicing.
 
Considering the end result I mean.
 
@AndrasDeak I guess. I just copy-pasted the phrasing from the original question :3
 
@Kevin yeah, that's why I suggested a thin wrapper if that can be pulled off
 
im rounding before conversion with true_time.replace(microsecond=round(true_time.microsecond, -2))
 
datetime doesn't strike me as the friendliest stdlib package, alas
 
2:10 PM
Half of all newbies are confounded by datetime because import datetime; print(datetime.now()) doesn't do what they expect
 
def getDateTime():
	# datetime object containing current date and time
	now = datetime.now()

	# Time
	dt_string = now.strftime("%m/%d/%Y %I:%M %p")

	return dt_string
 
Python devs, please overload the AttributeError on the datetime module object so it prints module 'datetime' has no attribute 'now' (did you mean to do `from datetime import datetime`?)
 
@JossieCalderon you should switch to snake_case, camelcase looks terrible
 
Counterpoint: you should switch to snake_case because it is the pep8-approved idiomatic style despite not being objectively better or worse than camelCase
 
Pep8-approved for being better, surely :P
 
2:16 PM
(╯°□°)╯︵ ┻━┻
 
I do find snek easier to read, to be honest
 
Concept: an IDE that parses camelCase variable names and displays them as snake_case
Or let's split the difference and display both camelCase and snake_case as words separated by spaces
def get date time():
 
@Kevin I know the tab argument when I see it. Begone!
 
If you're thinking "there are about a dozen scenarios where this can go horribly wrong", the IDE will magically know about those scenarios and handle them properly.
I'll let the boys down in R&D know that we need more magic. Looks like it's another weekender for them.
 
2:30 PM
cbg and closed
 
3:21 PM
I've worked on codebases where you saw functions like get_Date_Time (once saw something like get_DATE_TIME was a dark day and the function didn't even return the date just time)
 
3:38 PM
@Kevin Sublime Text has a Case Conversion plugin that does just that.
 
hmm...I wonder if PyCharm has one - I know Intellij does (use it when dealing with databases) so it would make sense but I never looked.
 
thread with post number. is a dict or tuple better?
52
A: Tuple vs Dictionary differences

Midhun MPMajor difference: If you need to return multiple values from a method you can use tuple. Tuple won't need any key value pairs like Dictionary. A tuple can contain only the predefined number of values, in dictionary there is no such limitation. A tuple can contain different values with different...

 
3:53 PM
a dict is never really worse than a bunch of 2-tuples
...unless you have duplicate keys
 
A-ha
Midhun said "If you need to return multiple values from a method you can use tuple." but I'm pretty sure a dictionary can do the same thing
 
...or unless the dict only contains only one key: value pair
 
I just realized that's iOS lol
31
Q: When to use a dictionary vs tuple in Python

clbThe specific example in mind is a list of filenames and their sizes. I can't decide whether each item in the list should be of the form {"filename": "blabla", "size": 123}, or just ("blabla", 123). A dictionary seems more logical to me because to access the size, for example, file["size"] is more...

 
I typically go with "whichever is easiest to read or understand" then use a dictionary or class over a named tuple because of that (except sometimes when munging weird input)
 
snake_case_is_way_better thanThisCamelCaseUnreadablePhrase
 
3:57 PM
I assumed we were talking about 2-tuples like [(id, post), ...] vs a dict like {id: post, ...}, so let's pretend I never said anything
 
We were, Aran!
I went with a tuple
 
everything is better than everything else, also worse
 
@JossieCalderon if you want to be able to "give me post with id ID", go with a dict. O(1) rather than O(N) lookup.
same for testing membership ("is this post ID in there?")
 
I used to use a namedtuple with a class definition when cleaning data but now I find the dataclasses better for that
 
@LinkBerest well, sounds like the use case for that
 
4:09 PM
I was really happy when I found they were added in 3.6 :)
changing a cross validation class from tons of parameters in the init & a bunch of self. self. self. to a simple list of what is needed with type hints was magical
 
 
2 hours later…
6:08 PM
Heyall! I'm trying to access a file on a different machine on a local network. So I have the IP and the file location, just trying to read it. This network is not on the internet, so I just have local IP's established to all machines on it. Started going down this route, wasn't sure if it was the "best" way or if there is a better way. Just trying to read text file stackoverflow.com/questions/1596963/…
 
Hello, is there any way to get tkinter Text Label widget height not in text units but in pixels?
 
label.winfo_height(), I think
 
returns 1
because is one line
 
^^ after tk.update() (if not updated it returns the default value = 1)
 
I am searching something like grid_propagate(0) only for y axis
@LinkBerest i will try
tk.update() or root.update()?
 
6:17 PM
whicheverwidget.update() then, yes, it is winfo_height <- my always open when doing TK stuff reference page
 
they're all the same thing under the hood anyway
 
returns 1 also after update()
 
@ChrisP if its 1 line (meaning 1 pixel) it should return 1: is it suppose to be 1 pixel?
 
No it's bigger
 
gives me a height of 22, not sure what you're doing wrong
 
6:21 PM
Has anyone asked for an MCVE yet?
with ChrisP's history I'm surprised it needs asking, frankly
 
Ok now works
 
I've implied the need for an MCVE in my last message. I'm feeling optimistic today
 
Ha, implied MCVE requests. That's rich :P
 
shush :P
it worked, didn't it? :P
 
Zen of Python #2: Explicit is better than implicit.
 
6:25 PM
nah, but I was really answering Aran's "I think" part as I always have the winfo reference page open when working on Tk projects. Currently building a game right now in a "need my brain to turn off for a bit....stupid graphs" thing - on effbot cause tkinkter docs = .......*tumbleweed*......)
as always, building a TK app makes me go very thankful for the fact that I no longer have to work with Tk
 
@Aran-Fey heh
 
lol
@biggi_ The "best" way depends on a number of factors (I do this using sockets, calling/piping external Powershell scripts, piping external Linux tools, using SSH, etc...): research the operation you would like to use based on your OS then ask about your specific attempt if you run into questions
fyi, if its just a remote server file (truly on local network) you should be able to open it normally with remote_file=open(r'\\SERVER\share\file.ext', 'r')
 
6:54 PM
The system of springs and pulleys...
pulleys
0
How is that? I am running "if string in post" and yet I get 0?
			for post in postContent:
				print(post)
				print(value)
				if value in postContent:
					count += 1
				print("over")
				print(count)
It printed "over" after pulleys and before 0, by the way
Oh lord, it's if value in post
 
Hi peeps. I'm playing around with Python. I wanted to try contextily (python 3 package), which I installed using Pip. I get a invalid syntax syntaxerror on importing it (as a one line script). Any recommendations on how to approach this (I'm relatively new to Python, so not sure if I did something wrong). This is on Linux with python 3.5. Upon installing with pip I got an error on an outdate package (pyparsing), which I then upgraded, after which I reinstalled contextily.
 
you may want to upgrade your python version. 3.5 is ancient.
 
What was your import code? Have you used a hyphen instead of an underscore?
 
Oh shit, ok, I try that first. I was just using an Ubuntu 16.04 install because I got frustrated in Windows haha
 
@Bernhard Please edit your message to remove the expletive. You can do that by clicking the arrow on the left of your message for up to 2 minutes
 
7:04 PM
I import just with: import contextily, so nothing weird
 
please post the traceback
 
Traceback (most recent call last):
File "tmp2.py", line 1, in <module>
import contextily
File "/home/bernhard/.local/lib/python3.5/site-packages/contextily/__init__.py", line 5, in <module>
from . import tile_providers as sources
File "/home/bernhard/.local/lib/python3.5/site-packages/contextily/tile_providers.py", line 37
return globals()[f'_{name}']
 
yeah, you need 3.6 (or newer)
 
Ok, perfect! Didn't think in this direction. Can you maybe elaborate a little bit for my understanding?
 
the failing line is using an f-string, which were introduced in 3.6
see PEP 498 for details
 
7:10 PM
Thanks! I hoped I could ignore the string things in Python, but this is good to learn
 
@Bernhard You got one but missed the main one. Too late now but thanks for editing. In future, please be mindful of the rules. Also note the formatting guide for chat since it's somewhat... unusual. But I'll leave you be while you work on this problem
 
@Bernhard strings are... kinda important for many tasks. There is little chance you can ignore them.
 
@roganjosh Sorry for that. I am not sure if I can edit again.
My approach is to google the string things when I need them. Having a background in C++ some things are a bit unusual. But I am getting there :)
 
feel free to ask for clarification here. strings aren't complicated, but there are a lot of imprecisely worded guides out there.
 
Thanks. But normally with my big friend google it is easy to resolve issues, but in this case I had no clue where to look
I already got distracted and am reading about the walrus operator
 
7:23 PM
Go back to f-strings! Only pain and suffering lies with the walrus :P
surprisingly f-strings are documented at lexical analysis...
 
has it been 5 years since they added f-strings? I really thought that was more recent.
 
Can you summarize the big advantage of f-strings?
 
why is that surprising? its where all the literals are (and there's a link to it in .format I think)
 
@LinkBerest 3.6.0 in 2016 december. So bit more than 3 years in release.
@Bernhard in certain situations they let you write less boilerplate, and they can be faster than the equivalent str.format call. And most people don't like percent formatting.
Sometimes you can't use f-strings even if you want to, for instance if you want a template created ahead of time that gets filled later.
 
Ah, ok, I just learned about the percent formating
 
7:27 PM
that's usually seen as anachronistic
 
@Bernhard f-strings are generally the simplest way to format a template immediately. str.format is very verbose, %-formatting has some pitfalls, and $-formatting is... dunno why it even exists.
 
yeah, I remember a company I worked for upgraded to 3.6 just for f-strings (team leaders were a bunch of Perl programmers who came to Python so just loved how "readable" they were) - I wanted to upgrade for other reasons so was fine with me
 
@MisterMiyagi no need for the wacky brace dance?
 
What do you mean with template in a Python context? With my C++ background it's a bit confusing :)
 
@LinkBerest Most people won't care about their syntactical meaning, only about their functionality. Documentation for doing string formatting seems to be all over the place.
 
7:30 PM
@Bernhard template as in paint stencil
you fill in the gaps later
a string with placeholders that lets you build a final string later
 
Ok, that's what I assumed indeed, makes sense
 
@Bernhard a tempalte is a string with placeholders. e.g. "Hello %(name)s" or "Hello {name}".
 
At least not as complicated as C++ templates, which took me ages to understand
 
I learned this term with f-strings: "string interpolation"
 
Hi, anyone got any idea why np.fromfile not working on windows 10??
Works perfectly on Mac, exact same code

This is the error im getting:
>>>np.fromfile(path, dtype=np.uint8)
OSError: could not seek in file
*** Reference count error detected:
an attempt was made to deallocate 2 (B) ***

Google didnt help at all with this one...
 
7:34 PM
@Nanoni how did you open the file? The error is scary.
Might be a legit bug.
 
with open(path, 'rb') as f:
 
@Bernhard those would be "generics" (with duck typing) if your talking about those type of C++ templates (and way beyond "just starting with Python")
 
@Nanoni doesn't fromfile need a text file?
The dealloc error is bad either way
 
nope, like i said works perfectly on Mac laptop i have next to me, i just prefer coding on main PC :)
 
Then I suggest opening an issue with a minimal example complete with file, if it persists after restart
 
7:37 PM
yeah persistes with reboot, tried that couple time :(
 
How big is the file?
 
can you just open and print the file normally on Windows 10?
 
<curiosity potentially kills roganjosh here>
 
@LinkBerest Thanks, but not really a good idea to dive into that now. It's not like I used templates a lot in C++, other than some funny functions. I already use inheritance and mixing inheritance and template is like... asking for maintenance issues
 
Yeah i can..
with open(path, 'rb') as f:
bytes = f.read()

this does work, just thought numpy might be faster, since its a massive binary file :)
and i need to convert the array to numpy.array later for bitwise_and calculations
 
7:41 PM
Be back soon
 
Filesize is over 2-3GB so quite big
 
oh, yeah. That's what I meant by "way beyond" - going from C++ style inheritance (esp. abstract classes) to Python warped my mind once
@Nanoni Check your version, this was a known issue with Windows 10 and an older version of numpy (not that old)
 
Yeah, I'm looking at this question and was going to suggest running the code in the answer as a sanity check
 
hmm... i apparenlty have 32bit version of numpy apparently.. mayby thats the problem
 
Also, all the references I can find to this issue seem to point to Python 2.7?
 
7:51 PM
Python 3.7.1
 
The second answer to my link suggests you can't have 32bit numpy with 64 bit python but that was python 2.7 so have you checked your python installation? Is that 64bit?
 
yeah python is 32bit, need to change it, thanks
 
Ok, hopefully that'll work. I'll give my blind stabbing a rest :P I was half-expecting that you'd created some hybrid monster somehow :)
 
01:00 - 20:0020:00 - 00:00

« first day (3516 days earlier)      last day (1418 days later) »