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

8:00 PM
@ParitoshSingh ok I'll do that. I'm hoping everything works out
 
If you wrote a mod for a game, you should be able to get this. We have faith!
 
@Dave yep, but something better than hoping exists. finding out for sure
 
Thanks everyone
 
Honestly, imagine being able to choose what to forget
 
I get what you are saying now @AndrasDeak I just had to run it myself to figure it out. if a == True: is almost the same as if a: because path.exists makes a True/False, is what I think you are saying.
 
8:03 PM
I'd re-read a lot of my favourite books and re-watch some of my favourite movies just to experience them fresh
 
@ChristopherBrown yes. And using strings "True" or "true" are very wrong, even in an example posted in passing. It's easy to mislead innocent users here ;)
 
@ChristopherBrown well in that message, AD was specifically pointing out that, as you wrote it, 'True' is a string, which is not the same as True the boolean.
 
yeah... I tried 'true' and 'True' and was like... poop
'True' != True
 
@ParitoshSingh It's easy: you "just" make up your mind never to think of it again :P
 
... great, now im thinking of it. dang it :P
 
8:05 PM
What?
 
@ParitoshSingh did you just lose the game?
 
i think i did :(
 
What game?
 
The Game (and now you lost it too)
 
There are too dang many games named "The Game"
I get it, naming things is hard, but c'mon
 
8:16 PM
@Aran-Fey In this case the ambiguity is intentional.
 
How so?
 
Anyone seen this project yet? just found out about it, looks very interesting. cinder
 
If I said I just lost "NameOfGameThatIsVerySpecific" people would know to avoid it more readily. The ambiguity lends itself to make people who aren't aware to find out what it is.
 
But there are at least 3 more games with the same name that don't have that excuse :P
 
lame! I agree.
 
8:24 PM
@piRSquared hmm, I haven't thought about that. I wonder if that's intentional.
 
very small props to the designer of "The Game"'s sequel "The Game on Fire" for picking a slightly more creative name than "The Game 2"
 
@AndrasDeak I wasn't consulted during the development of this game so I can't say with certainty. It is just my guess.
 
@Aran-Fey "Also The Game"
 
    Does one know why the reading with argarse, and pandas gives me an invalid syntax after line1?
parser = argparse.ArgumentParser()
parser.add_argument('filename')
args = parser.parse_args()
df = pd.read_csv(args.filename, sep='\t')#
 
Pandas is not an interpreter, it can't throw a syntax error. So what error is it really throwing?
 
8:30 PM
Aran's crystal ball is crisp tonight
Wonder what "line1" is
I hope it's not that the csv parsing breaks on line 1
 
Let's see the exact error message
 
oh, ok. its a .tsv file, as error i get only SyntaxError: invalid syntax
 
nice
 
Ok, technically pandas can throw a SyntaxError, but I'm gonna go out on a limb and say even pandas isn't crazy enough to do that
This has been a very roundabout way of saying that we need a Minimal, Complete, and Verifiable Example
 
np, will try.
 
8:32 PM
The crystal ball is foggy after all. My next bet is a syntax error in code we weren't shown, preceding the argparse part.
 
also, either you're using a bad IDE, or you don't realise it yet, but the lines above just the error are also important. It's important to show the full traceback of error, because they actually can reveal the part that's interesting
 
@Aran-Fey ha
OK, that seems to be inside string queries
 
yeah i'd give them a pass there, that's perfectly fair to raise
 
My first thought was "Why?", then I saw pandas.eval, and now my question is "Why?!"
 
though if you want to question ..
yeah...that.
might be due to their .query interface perhaps? I am not sure, i never use it anyways :P
 
8:36 PM
I have one answer about pandas eval and it involves a bug in its implementation, so...
 
    # df_sp = pd.read_csv("C:/file.tsv",sep='\t')
    # df_sp.head()
    #
    #works fine, this to that:
    # print(df_sp.head())

    parser = argparse.ArgumentParser()
    parser.add_argument('filename')
    args = parser.parse_args()
    df = pd.read_csv(args.filename, sep='\t')# i just dont a real error output I see first line +           ^
SyntaxError: invalid syntax
 
intriguing
 
whelp.
 
#terminal: python3 numbers.tsv myprogram.py #not much
 
...You mean python3 myprogram.py numbers.tsv?
I'm gonna wait for an MCVE that isn't 90% made up
 
8:46 PM
no, if i write it in console #python3 myprogram.py numbers.tsv, I get: #import pandas as pd, No module named pandas
I have pandas, +otherwise full filepath, without argparse would give me an error as well,
 
Well, if you try to execute a tsv file with python then you can't be surprised about syntax errors...
 
@pythonabsir that would be an improvement: that's a python error. Are you using the right python executable to run the code?
 
If you're sure you have pandas, you must've installed it for a different python interpreter than the one you're using
 
I don't see import pandas as pd
 
*hands over a crystal ball*
 
8:51 PM
no, its for sure no interpreter problem,
 
@pythonabsir ah, thanks for clarifying
 
Traceback (most recent call last):
File "species.py", line 13, in <module>
 import pandas as pd
ModuleNotFoundError: No module named 'pandas'
 
Unfortunately there is no explanation for your error.
 
Well, then it must be a you-don't-have-pandas-installed problem
 
When python says no module named pandas, im quite sure it means that it doesn't have a module named pandas
 
8:52 PM
it's probably a python bug
 
wow, if i dont use argparse, and use my path, I read my file, but get the same error. Nono, thats the error with the full filepath, without argparse
 
wow indeed :)
 
i havent seen an error before, because I read my file with path, but at the end, there is the same error. ok, its nothing with arpgarse
 
Do you know what a virtualenv is?
If you do: check if you have the right one activated. If you don't: check what changed in how you're running the python script, look very closely at the python executable you're using.
If it used to work and now it doesn't, something changed.
 
I use pandas about as often as I upgrade Python, so import pandas has approximately a 50% success rate for me
 
9:04 PM
ok, sorry, I have a conflict with perl and python, pip
 
9:18 PM
Hmm
 
@pythonabsir I wore out a spot on the crystal ball but this is what I got. The initial run worked in a notebook or an IPython session. Second one, with argparse, requires to run on a command line. If you have anaconda, you need to activate your environment that your notebook/IPython session are running in before you run your command from the command line. OR, you can use the path to the environments python executable directly.
path/to/anaconda/envs/name_of_my_env/bin/python file_to_run.py myargument
 
@piRSquared thx, i think Can't locate pip.pm in @INC (you may need to install the pip module) (@INC contains: C:/Perl64/site/lib C:/Perl64/lib) at C:\Dwimperl\perl\bin/pip line 5. is the problem
 
@pythonabsir can you confirm if you are using anaconda? Yes or no?
 
@piRSquared not at the moment
 
that is still ambiguous. Do you have anaconda installed? Do you know what anaconda is?
 
9:29 PM
It's ok to not know what anaconda is. I don't know what anaconda is.
I live a full and rich life in spite of this
 
@piRSquared yes, i used it, its installed, but thats month ago, just reading on stackoverflow, about the perl issue with pip, #error: C:\Dwimperl\perl\bin/pip line 5.BEGIN failed
 
Are you aware you can run pip with python -m pip?
 
If you're saying you can't pip install pandas because your perl install also has an executable named pip, you could always specify the absolute path of the pip you do want to run.
 
your pip situation may prevent you from installing a module using pip but if you have anaconda installed, then you also have the conda command. And that is likely better.
 
I'm glad we're all in agreement that the perl problem is solved :-)
 
9:34 PM
You're using windows (like a boss) so you should be able to press the windows key and type "anaconda" and see the "Anaconda Powershell Prompt"
run that and pin it to your task bar
 
no I was not aware, python -m pip, gives me the same Can't locate pip.pm i
ok, there
 
then you from that anaconda powershell prompt, you should be able to run conda env list to see all of the virtual environments that conda is managing.
 
That gives the same error? O.o How do you even screw up your system so bad?
 
one of them likely has pandas installed. choose one to activate like this conda activate name_of_env_I_chose
If you're following what I'm saying, let me know when you've caught up.
 
@piRSquared there is pandas on miniconda3, yes, testrun on anaconda worked now
 
9:45 PM
anaconda manages python environments. I'm still not sure you've got it sorted.
 
@piRSquared wow, cool, I got an output with argparse
 
pi is credit to team
 
sometimes the shame of holding everyone back motivates me to try a little.
 
If that guess about anaconda from earlier turns out to have been correct after all, then going forward we'll ask you to bless our crystal balls once a week
let's pretend that typo never happened
 
[I immediately click message history]
 
10:02 PM
Shush! Don't teach people about that feature!
 
This regex result is a list of strings: ['$4,180.00', '$4,180.00', '$20,263.82', '$21,365.19'] correct?
I guess I could print(type())
 
Yes, it is a list of strings
Unless it is a custom type cunningly designed to look exactly like a list of strings when printed
 
Knowing my luck, someone changed the code in the matrix to mess with me and it is the latter.
 
Paranoia is a valuable tool when properly harnessed
 
@ChristopherBrown you can try explaining the X in this XY problem. Why did you have to ask?
 
10:13 PM
Because I want the largest amount from the the regex pull, and I was going to call .sort() on it but then I looked at my print statement again and was like, wait, those aren't ints, so I wasn't sure how Python would have sorted them, and I wanted a sanity check. Maybe there was some weird rule with dollar signs that made them floats. shrug
 
That all sounded reasonable until the last sentence. What is this about "made them floats"?
Python would sort strings lexicographically.
>>> sorted(['69', '420'])
['420', '69']
There's very little magic on the surface of python so if you notice you're thinking "maybe there's some weird rule with dollar signs" stop, step back, and question your thinking.
 
20,263.82, decimal point = float, I thought.
 
@ChristopherBrown yes if those weren't strings and didn't have any commas inside them they would be floats. But they are strings, and I'm not sure how the dollar signs come into play.
in fact the dollar signs are a dead giveaway that they can't be numerical types
I'm not trying to be hard on you, just trying to motivate you to prod these vague suspicions a bit :)
If you need a list of floats you can convert them. Or if you want to keep the list of strings you can still sort them as numbers with an appropriate key function.
To phrase it differently, python doesn't try to figure out the meaning of strings when you ask it to sort a list of strings.
Together with your == 'true' from earlier I wonder if you know javascript. If so, there's a lot of insanity you must unlearn for python.
 
nope, no Java. Some C# and some HTML but that is from High School, over a decade ago lol.
no need to apologize. I have thick skin.
 
normally it shouldn't come to the thickness of one's skin
 
10:38 PM
Today's candidates for "Error messages you've never seen before":
> TypeError: __dict__ slot disallowed: we already got one
> TypeError: __weakref__ slot disallowed: either we already got one, or __itemsize__ != 0
 
Chatty, aren't we?
 
11:03 PM
2
Q: Python argparse opening multiple files

WilleySlipperyi'm trying to access multiple .txt files with argparse and i've stumbled across a problem which i can't put my head around. parser = argparse.ArgumentParser() parser.add_argument('filename', nargs='+'. type=argparse.FileType('r')) args = parser.parse_args() with open(args.filenam...

import pandas as pd
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--tsv", help=".tsv files", action="store_true",type=argparse.FileType('r'), nargs='*')
args = parser.parse_args()
df_sp = pd.read_csv(args.tsv, sep='\t')
 
Yes?
Hint: for an MCVE you either need argparse or pandas, but not both
 
python fileprogram.py -t textfile.tsv
 
There's more, right?
 
@AndrasDeak why?, wouldnt it different if there is pandas + argparse, and i try to read 2 or 3 .files?
 
11:12 PM
nargs gathers all files into a list. I lack the understanding, how to call it.
 
"nargs gathers all files into a list" sounds correct to me
What is your question? We can only answer questions.
 
sorry, I stuck there; I tried to call it with -t, but my command is not correct, seems I dont quite understand how to call it.
 
It would be useful to include the actual Traceback or at the very least which line of code that failed on you. At a glance it looks like pd.read_csv might be complaining about the first argument being invalid, and if you read the linked documentation you might find that it only accepts a buffer...
 
@pythonabsir because you copied code from the question, not the answer. See also geek-and-poke.com/geekandpoke/2016/11/27/good-questions
 
but since args.tsv is probably a list due to the reference argument being set up with nargs='*', you might want to change how you call that function, or not use nargs='*'.
 
11:23 PM
@metatoaster too optimistic
TypeError: __init__() got an unexpected keyword argument 'type' :P
 
sorry, was reading, yes, know without nargs='*' there wouldnt be a problem,
 
okay
 
The type argument should be valid for add_argument, it is documented
 
@pythonabsir you really have to work on how you ask for help with problems. If you come here asking for help, have a proper MCVE. This includes 1. minimal self-contained code that reproduces your issue, 2. a clear explanation of what you expect, 3. a clear explanation of what happens instead, 4. full traceback if "what happens instead" includes an error.
If you keep asking the way you've been asking today we will soon tell you to stop.
 
@metatoaster #goal: commandline: python program.py file1 file2 for calling the list, I made the df_sp = pd.read_csv(args.tsv, sep='\t'), sure
 
11:35 PM
Let's see what the documentation has to say...
Help on function add_argument in module argparse:

add_argument(self, *args, **kwargs)
    add_argument(dest, ..., name=value, ...)
    add_argument(option_string, option_string, ..., name=value, ...)
ah yes, stdlib as usual
 
tried to ask with as minimal input as possible for the MCVE, will try to this is my error: parser.add_argument("-t", "--tsv", help=".tsv files", action="store_true",type=argparse.FileType('r'), nargs='*')
File "C:\Users\User\miniconda3\lib\argparse.py", line 1368, in add_argument
action = action_class(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'type'
 
So can you see which line of your code raises the error?
 
line 7, something with type=argparse.FileType('r')
 
I'd like to note that there's no line 7 in the traceback you quoted.
 
import pandas as pd
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--tsv", help=".tsv files", action="store_true",type=argparse.FileType('r'), nargs='*')
args = parser.parse_args()
df_sp = pd.read_csv(args.tsv, sep='\t')
print(df_sp.head())
df_me = pd.read_csv(args.tsv, sep='\t')#
print(df_me.head())
  File "spezia.py", line 7, in <module>
    parser.add_argument("-t", "--tsv", help=".tsv files", action="store_true",type=argparse.FileType('r'), nargs='*')
  File "C:\Users\User\miniconda3\lib\argparse.py", line 1368, in add_argument
    action = action_class(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'type'
sorry, its the first line
 
11:44 PM
Excellent. Can you find line 7 in your real file? Equivalently "something with type=argparse.FileType('r')"?
 
yes, its the parser.add_argument #here line 4
 
Very good. So do you see that all the code you have after that line is irrelevant, because the error happens earlier?
 
yes, was just looking:
 
How did you suddenly end up with a pandas traceback? I really can't keep doing this.
 
I erased the# action="store_true" from parser.add_argument
 
11:53 PM
Why that one?
And you also only posted a partial traceback.
let's not waste each other's time
 
01:00 - 20:0020:00 - 00:00

« first day (3855 days earlier)      last day (1078 days later) »